1
TEMPLATE STRINGS youcan also use line JAVASCRIPT Easily embedvariables expressions breaks within backticks to create multi line strings E S 6 No more in SYNTAX ARROWFUNCTIONS There are many HTheBigPicturekESG adds new A concise syntax for creating functions syntactic variations declarative syntax whichshiftsour 1 focus awayfrom imperative implementationdetails allows us return atb towrite higher levelmore 3 i Arrow functions donot bind their own interpretable code this rather they inherit one from their to declarevariables that will Parent lexical scoping SCOPING be used in a wider context i Just because you canuse shorthand contain this variable within doesn't mean you should Readability first the immediate functionscope let us Vanya to create a block scoped constant variable that cannot be re assigned To enforce block scoping ratherthan COLI signalintent this variable will not change relyingon stylistic conventions i this does not mean that the value of the variable is immutable contain this variable within this block scope i Must be initialized withavalue mm Giorgio c.is iiiEehsz Elisha.io 9ieiii iiniiePiiii.eiiioR variables only exist within their enclosing block denoted by 3 In an assignment context transforms an indefinite www.J list of arguments into a proper array fool aras isan array of all parameterspassed DESTRUCTURING into the function Extract data from arrays objects m 2,33 A Extract Istaznd it gathers the elements from rest ofthe myArr Otherwise i expands an iterable elements my obj Extract properties a b from myob fool args Pass the elements ofan array into a function This is just the tip ofthe iceberg when it comes to destructoring let succintarray b Coil 2,33 creation DEFAULT VALUES if no valve or is passed CONCISE PROPERTIES METHODS Eliminate duplicative code in objects Default value assigned in function head when the property namevaluename b t shorthand for methoddefinitions A default value can also be passed when destructuring

Dotnotes: JavaScript ES6 Syntax - Amy Peniston · 2020. 6. 11. · let shorthandformethoddefinitions a 42 b c ham Adefaultvaluecanalso bepassedwhendestructuring. Title: Dotnotes:

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

  • TEMPLATE STRINGS youcanalsouseline

    JAVASCRIPT Easilyembedvariables expressions breakswithinbacktickstocreatemultilinestrings

    E S 6 Thecactusisnamed name Nomore inSYNTAX

    ARROWFUNCTIONS TherearemanyHTheBigPicturekESGaddsnew Aconcisesyntaxforcreatingfunctions syntacticvariationsdeclarativesyntaxwhichshiftsour 1focusawayfromimperative letsum functionab letsum ab atbimplementationdetails allowsus returnatbtowritehigherlevelmore 3 i Arrowfunctionsdonotbindtheirowninterpretablecode this rathertheyinheritonefromtheir

    todeclarevariablesthatwill Parent lexicalscopingSCOPING beusedinawidercontext i Justbecauseyoucanuseshorthand

    containthisvariablewithin doesn'tmeanyoushouldReadabilityfirsttheimmediatefunctionscopelet us Vanya tocreateablockscopedconstant

    variablethatcannotbereassignedToenforceblockscoping ratherthan COLI signalintentthisvariablewillnotchangerelyingonstylisticconventions i thisdoesnotmeanthatthevalueofthevariableisimmutable

    containthisvariablewithinthisblockscope i Mustbeinitializedwithavalue

    mm

    Giorgioc.is iiiEehsz Elisha.io 9ieiiiiiniiePiiii.eiiioRvariablesonlyexistwithintheirenclosingblockdenotedby 3 Inanassignmentcontext transformsanindefinitewww.J listofargumentsintoaproperarray

    function fool args aras isanarrayofallparameterspassedDESTRUCTURING intothefunctionExtractdatafromarrays objects let s m i2,33 m 2,33AExtractIstaznd itgathersthelet first second myArr elementsfrom restofthe

    myArr Otherwise i expandsaniterable elements

    let a b myobj Extractpropertiesa b frommyob fool args Passtheelementsofanarrayintoafunction

    Thisisjustthetipoftheicebergwhenitcomestodestructoring leta 1.2.33 succintarrayb Coil2,33 creationletb 0 a

    DEFAULTVALUESif novalve or undefined ispassed CONCISEPROPERTIES METHODS

    varob Eliminateduplicativecodeinobjectsfunctionspam n l Defaultvalueassigned ainfunctionhead whenthepropertyname valuenameb t shorthandformethoddefinitionslet a 42 b c ham Adefaultvaluecanalsobepassedwhendestructuring