sample_es6.html 1000 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583
  1. <!doctype html>
  2. <html lang="en-GB">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ECMAScript Language Specification ECMA-262 6th Edition &ndash; DRAFT</title>
  6. <link href="es6-draft.css" rel="stylesheet">
  7. <script src="es6-draft-sections.js"></script>
  8. </head>
  9. <body>
  10. <div id="unofficial">
  11. <p><strong>This is <em>not</em> the official ECMAScript Language Specification.</strong></p>
  12. <p>This is a draft of the next edition of the standard. See also:</p>
  13. <ul>
  14. <li><a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">ECMAScript Language Specification,
  15. Edition 5.1 (PDF)</a>, the most recent official, final standard.</li>
  16. <li><a href="http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts">The ES specification drafts archive</a> for
  17. PDF and Word versions of this document, and older drafts.</li>
  18. <li><a href="https://github.com/jorendorff/es-spec-html">The script that produced this web page</a>, and especially the <a
  19. href="https://github.com/jorendorff/es-spec-html/issues?state=open">issue tracker &mdash; please file bugs when you find
  20. them</a>. Patches are welcome too.</li>
  21. </ul>
  22. <p>For copyright information, see Ecma International&rsquo;s legal disclaimer in the document itself.</p>
  23. </div>
  24. <hgroup>
  25. <h1>Draft</h1>
  26. <h1>ECMA-262</h1>
  27. <h1>6<sup>th</sup> Edition / Draft March 17, 2015</h1>
  28. <h1>Ecma/TC39/2015/0XX</h1>
  29. </hgroup>
  30. <hgroup>
  31. <h1>ECMAScript 2015</h1>
  32. <h1>Language Specification</h1>
  33. <p>Draft<br>Release Candidate #3</p>
  34. <p>Report Errors and Issues at: https://bugs.ecmascript.org</p>
  35. <p>Product: Draft for 6th Edition</p>
  36. <p>Component: choose an appropriate one</p>
  37. <p>Version: Rev 36, March 17, 2015 Draft</p>
  38. </hgroup>
  39. <section id="contents">
  40. <h1>Contents</h1>
  41. </section>
  42. <section>
  43. <h1>Introduction</h1>
  44. <p>This is the sixth edition of ECMAScript Language Specification. Since publication of the first edition in 1997, ECMAScript
  45. has grown to be one of the world&rsquo;s most widely used general purpose programming languages. It is best known as the
  46. language embedded in web browsers but has also been widely adopted for server and embedded applications. The sixth edition is
  47. the most extensive update to ECMAScript since the publication of the first edition in 1997.</p>
  48. <p>Goals for the sixth edition include providing better support for large applications, library creation, and for use of
  49. ECMAScript as a compilation target for other languages. Some of its major enhancements include modules, class declarations,
  50. lexical block scoping, iterators and generators, promises for asynchronous programming, destructuring patterns, and proper tail
  51. calls. The ECMAScript library of built-ins has been expanded to support additional data abstractions including maps, sets, and
  52. arrays of binary numeric values as well as additional support for Unicode supplemental characters in strings and regular
  53. expressions. The built-ins are now extensible via subclassing.</p>
  54. <p>Focused development of the sixth edition started in 2009, as the fifth edition was being prepared for publication. However,
  55. this was preceded by significant experimentation and language enhancement design efforts dating to the publication of the third
  56. edition in 1999. In a very real sense, the completion of the sixth edition is the culmination of a fifteen year effort. Dozens
  57. of individuals representing many organizations have made very significant contributions within TC39 to the development of this
  58. edition and to the prior editions. In addition, a vibrant informal community has emerged supporting TC39&rsquo;s ECMAScript
  59. efforts. This community has reviewed numerous drafts, filed thousands of bug reports, performed implementation experiments,
  60. contributed test suites, and educated the world-wide developer community about ECMAScript. Unfortunately, it is impossible to
  61. identify and acknowledge every person and organization who has contributed to this effort.</p>
  62. <p>New uses and requirements for ECMAScript continue to emerge. The sixth edition provides the foundation for regular,
  63. incremental language and library enhancements.</p>
  64. <p>Allen Wirfs-Brock<br>ECMA-262, 6<sup>th</sup> Edition Project Editor</p>
  65. <p>This Ecma Standard has been adopted by the General Assembly of &lt;month&gt; &lt;year&gt;.</p>
  66. <p><b>ECMA-262 Edition History</b></p>
  67. <p>This Ecma Standard is based on several originating technologies, the most well-known being JavaScript (Netscape) and JScript
  68. (Microsoft). The language was invented by Brendan Eich at Netscape and first appeared in that company&rsquo;s Navigator 2.0
  69. browser. It has appeared in all subsequent browsers from Netscape and in all browsers from Microsoft starting with Internet
  70. Explorer 3.0.</p>
  71. <p>The development of this Standard started in November 1996. The first edition of this Ecma Standard was adopted by the Ecma
  72. General Assembly of June 1997.</p>
  73. <p>That Ecma Standard was submitted to ISO/IEC JTC 1 for adoption under the fast-track procedure, and approved as international
  74. standard ISO/IEC 16262, in April 1998. The Ecma General Assembly of June 1998 approved the second edition of ECMA-262 to keep it
  75. fully aligned with ISO/IEC 16262. Changes between the first and the second edition are editorial in nature.</p>
  76. <p>The third edition of the Standard introduced powerful regular expressions, better string handling, new control statements,
  77. try/catch exception handling, tighter definition of errors, formatting for numeric output and minor changes in anticipation
  78. future language growth. The third edition of the ECMAScript standard was adopted by the Ecma General Assembly of December 1999
  79. and published as ISO/IEC 16262:2002 in June 2002.</p>
  80. <p>After publication of the third edition, ECMAScript achieved massive adoption in conjunction with the World Wide Web where it
  81. has become the programming language that is supported by essentially all web browsers. Significant work was done to develop a
  82. fourth edition of ECMAScript. However, that work was not completed and not published as the fourth edition of ECMAScript but
  83. some of it was incorporated into the development of the sixth edition.</p>
  84. <p>The fifth edition of ECMAScript (published as ECMA-262 5<sup>th</sup> edition) codified de facto interpretations of the
  85. language specification that have become common among browser implementations and added support for new features that had emerged
  86. since the publication of the third edition. Such features include accessor properties, reflective creation and inspection of
  87. objects, program control of property attributes, additional array manipulation functions, support for the JSON object encoding
  88. format, and a strict mode that provides enhanced error checking and program security. The Fifth Edition was adopted by the Ecma
  89. General Assembly of December 2009.</p>
  90. <p>The Fifth Edition was submitted to ISO/IEC JTC 1 for adoption under the fast-track procedure, and approved as international
  91. standard ISO/IEC 16262:2011. Edition 5.1 of the ECMAScript Standard incorporated minor corrections and is the same text as
  92. ISO/IEC 16262:2011. The 5.1 Edition was adopted by the Ecma General Assembly of June 2011.</p>
  93. <p><i>"DISCLAIMER</i></p>
  94. <p><i>This draft document may be copied and furnished to others, and derivative works that comment on or otherwise explain it or
  95. assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of
  96. any kind, provided that the above copyright notice and this section are included on all such copies and derivative works.
  97. However, this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma
  98. International, except as needed for the purpose of developing any document or deliverable produced by Ecma
  99. International.</i></p>
  100. <p><i>This disclaimer is valid only prior to final version of this document. After approval all rights on the standard are
  101. reserved by Ecma International.</i></p>
  102. <p><i>The limited permissions are granted through the standardization phase and will not be revoked by Ecma International or its
  103. successors or assigns during this time.</i></p>
  104. <p><i>This document and the information contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL DISCLAIMS ALL
  105. WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT
  106. INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE."</i></p>
  107. </section>
  108. <div class="inner-title">ECMAScript 2015 Language Specification</div>
  109. <section id="sec-scope">
  110. <h1><span class="secnum" id="sec-1"><a href="#sec-scope" title="link to this section">1</a></span> Scope</h1>
  111. <p>This Standard defines the ECMAScript 2015 general purpose programming language.</p>
  112. </section>
  113. <section id="sec-conformance">
  114. <h1><span class="secnum" id="sec-2"><a href="#sec-conformance" title="link to this section">2</a></span> Conformance</h1>
  115. <p>A conforming implementation of ECMAScript must provide and support all the types, values, objects, properties, functions, and
  116. program syntax and semantics described in this specification.</p>
  117. <p>A conforming implementation of ECMAScript must interpret source text input in conformance with the Unicode Standard, Version
  118. 5.1.0 or later and ISO/IEC 10646. If the adopted ISO/IEC 10646-1 subset is not otherwise specified, it is presumed to be the
  119. Unicode set, collection 10646.</p>
  120. <p>A conforming implementation of ECMAScript that provides an application programming interface that supports programs that need
  121. to adapt to the linguistic and cultural conventions used by different human languages and countries must implement the interface
  122. defined by the most recent edition of ECMA-402 that is compatible with this specification.</p>
  123. <p>A conforming implementation of ECMAScript may provide additional types, values, objects, properties, and functions beyond
  124. those described in this specification. In particular, a conforming implementation of ECMAScript may provide properties not
  125. described in this specification, and values for those properties, for objects that are described in this specification.</p>
  126. <p>A conforming implementation of ECMAScript may support program and regular expression syntax not described in this
  127. specification. In particular, a conforming implementation of ECMAScript may support program syntax that makes use of the
  128. &ldquo;future reserved words&rdquo; listed in <a href="#sec-future-reserved-words">subclause 11.6.2.2</a> of this
  129. specification.</p>
  130. <p>A conforming implementation of ECMAScript must not implement any extension that is listed as a Forbidden Extension in <a
  131. href="#sec-forbidden-extensions">subclause 16.1</a>.</p>
  132. </section>
  133. <section id="sec-normative-references">
  134. <h1><span class="secnum" id="sec-3"><a href="#sec-normative-references" title="link to this section">3</a></span> Normative
  135. references</h1>
  136. <p>The following referenced documents are indispensable for the application of this document. For dated references, only the
  137. edition cited applies. For undated references, the latest edition of the referenced document (including any amendments)
  138. applies.</p>
  139. <p class="formal-reference">IEEE Std 754-2008: <i>IEEE Standard for Floating-Point Arithmetic</i>. Institute of Electrical and
  140. Electronic Engineers, New York (2008)</p>
  141. <p class="formal-reference">ISO/IEC 10646:2003: <i>Information Technology &ndash; Universal Multiple-Octet Coded Character Set
  142. (UCS) plus Amendment 1:2005, Amendment 2:2006, Amendment 3:2008, and Amendment 4:2008</i>, plus additional amendments and
  143. corrigenda, or successor</p>
  144. <p class="formal-reference"><i>The Unicode Standard, Version 5.0</i>, as amended by Unicode 5.1.0, or successor.<br><a
  145. href="http://www.unicode.org/versions/latest">http://www.unicode.org/versions/latest</a></p>
  146. <p class="formal-reference"><i>Unicode Standard Annex #15, Unicode Normalization Forms, version Unicode 5.1.0</i>, or
  147. successor.<br><a href="http://www.unicode.org/reports/tr15/">http://www.unicode.org/reports/tr15/</a></p>
  148. <p class="formal-reference"><i>Unicode Standard Annex #31, Unicode Identifiers and Pattern Syntax, version Unicode 5.1.0</i>, or
  149. successor. <a href="http://www.unicode.org/reports/tr31/">http://www.unicode.org/reports/tr31/</a></p>
  150. <p>ECMA-402, <i>ECMAScript 2015 Internationalization API Specification</i>.<br><a
  151. href="http://www.ecma-international.org/publications/standards/Ecma-402.htm">http://www.ecma-international.org/publications/standards/Ecma-402.htm</a></p>
  152. <p>ECMA-404, <i>The JSON Data Interchange Format</i>.<br><a
  153. href="http://www.ecma-international.org/publications/standards/Ecma-404.htm">http://www.ecma-international.org/publications/standards/Ecma-404.htm</a></p>
  154. </section>
  155. <section id="sec-overview">
  156. <div class="front">
  157. <h1><span class="secnum" id="sec-4"><a href="#sec-overview" title="link to this section">4</a></span> Overview</h1>
  158. <p>This section contains a non-normative overview of the ECMAScript language.</p>
  159. <p>ECMAScript is an object-oriented programming language for performing computations and manipulating computational objects
  160. within a host environment. ECMAScript as defined here is not intended to be computationally self-sufficient; indeed, there are
  161. no provisions in this specification for input of external data or output of computed results. Instead, it is expected that the
  162. computational environment of an ECMAScript program will provide not only the objects and other facilities described in this
  163. specification but also certain environment-specific objects, whose description and behaviour are beyond the scope of this
  164. specification except to indicate that they may provide certain properties that can be accessed and certain functions that can
  165. be called from an ECMAScript program.</p>
  166. <p>ECMAScript was originally designed to be used as a scripting language, but has become widely used as a general purpose
  167. programming language. A <b><i>scripting language</i></b> is a programming language that is used to manipulate, customize, and
  168. automate the facilities of an existing system. In such systems, useful functionality is already available through a user
  169. interface, and the scripting language is a mechanism for exposing that functionality to program control. In this way, the
  170. existing system is said to provide a host environment of objects and facilities, which completes the capabilities of the
  171. scripting language. A scripting language is intended for use by both professional and non-professional programmers.</p>
  172. <p>ECMAScript was originally designed to be a <b><i>Web scripting language</i></b>, providing a mechanism to enliven Web pages
  173. in browsers and to perform server computation as part of a Web-based client-server architecture. ECMAScript is now used to
  174. provide core scripting capabilities for a variety of host environments. Therefore the core language is specified in this
  175. document apart from any particular host environment.</p>
  176. <p>ECMAScript usage has moved beyond simple scripting and it is now used for the full spectrum of programming tasks in many
  177. different environments and scales. As the usage of ECMAScript has expanded, so has the features and facilities it provides.
  178. ECMAScript is now a fully featured general propose programming language.</p>
  179. <p>Some of the facilities of ECMAScript are similar to those used in other programming languages; in particular C,
  180. Java&trade;, Self, and Scheme as described in:</p>
  181. <p>ISO/IEC&nbsp;9899:1996, Programming Languages &ndash; C.</p>
  182. <p class="formal-reference">Gosling, James, Bill Joy and Guy Steele. <span class="book-title">The Java&trade; Language
  183. Specification</span>. Addison Wesley Publishing Co., 1996.</p>
  184. <p class="formal-reference">Ungar, David, and Smith, Randall B. <span class="book-title">Self: The Power of Simplicity</span>.
  185. OOPSLA '87 Conference Proceedings, pp. 227&ndash;241, Orlando, FL, October 1987.</p>
  186. <p class="formal-reference"><span class="book-title">IEEE Standard for the Scheme Programming Language</span>. IEEE Std
  187. 1178-1990.</p>
  188. </div>
  189. <section id="sec-web-scripting">
  190. <h1><span class="secnum" id="sec-4.1"><a href="#sec-web-scripting" title="link to this section">4.1</a></span> Web
  191. Scripting</h1>
  192. <p>A web browser provides an ECMAScript host environment for client-side computation including, for instance, objects that
  193. represent windows, menus, pop-ups, dialog boxes, text areas, anchors, frames, history, cookies, and input/output. Further, the
  194. host environment provides a means to attach scripting code to events such as change of focus, page and image loading,
  195. unloading, error and abort, selection, form submission, and mouse actions. Scripting code appears within the HTML and the
  196. displayed page is a combination of user interface elements and fixed and computed text and images. The scripting code is
  197. reactive to user interaction and there is no need for a main program.</p>
  198. <p>A web server provides a different host environment for server-side computation including objects representing requests,
  199. clients, and files; and mechanisms to lock and share data. By using browser-side and server-side scripting together, it is
  200. possible to distribute computation between the client and server while providing a customized user interface for a Web-based
  201. application.</p>
  202. <p>Each Web browser and server that supports ECMAScript supplies its own host environment, completing the ECMAScript execution
  203. environment.</p>
  204. </section>
  205. <section id="sec-ecmascript-overview">
  206. <div class="front">
  207. <h1><span class="secnum" id="sec-4.2"><a href="#sec-ecmascript-overview" title="link to this section">4.2</a></span>
  208. ECMAScript Overview</h1>
  209. <p>The following is an informal overview of ECMAScript&mdash;not all parts of the language are described. This overview is
  210. not part of the standard proper.</p>
  211. <p>ECMAScript is object-based: basic language and host facilities are provided by objects, and an ECMAScript program is a
  212. cluster of communicating objects. In ECMAScript, an <b><i>object</i></b> is a collection of zero or more
  213. <b><i>properties</i></b> each with <b><i>attributes</i></b> that determine how each property can be used&mdash;for example,
  214. when the Writable attribute for a property is set to <b>false</b>, any attempt by executed ECMAScript code to assign a
  215. different value to the property fails. Properties are containers that hold other objects, <b><i>primitive values</i></b>, or
  216. <b><i>functions</i></b>. A primitive value is a member of one of the following built-in types: <b>Undefined</b>,
  217. <b>Null</b>, <b>Boolean</b>, <b>Number</b>, <b>String,</b> and <b>Symbol;</b> an object is a member of the built-in type
  218. <b>Object</b>; and a function is a callable object. A function that is associated with an object via a property is called a
  219. <b><i>method</i></b>.</p>
  220. <p>ECMAScript defines a collection of <b><i>built-in objects</i></b> that round out the definition of ECMAScript entities.
  221. These built-in objects include the global object; objects that are fundamental to the runtime semantics of the language
  222. including <b>Object</b>, <b>Function</b>, <b>Boolean</b>, <b>Symbol</b>, and various <b>Error</b> objects; objects that
  223. represent and manipulate numeric values including <b>Math</b>, <b>Number</b>, and <b>Date</b>; the text processing objects
  224. <b>String</b> and <b>RegExp</b>; objects that are indexed collections of values including <b>Array</b> and nine different
  225. kinds of Typed Arrays whose elements all have a specific numeric data representation; keyed collections including <b>Map</b>
  226. and <b>Set</b> objects; objects supporting structured data including the <b>JSON</b> object, <b>ArrayBuffer</b>, and
  227. <b>DataView</b>; objects supporting control abstractions including generator functions and <b>Promise</b> objects;
  228. and<b>,</b> reflection objects including <b>Proxy</b> and <b>Reflect</b>.</p>
  229. <p>ECMAScript also defines a set of built-in <b><i>operators</i></b>. ECMAScript operators include various unary operations,
  230. multiplicative operators, additive operators, bitwise shift operators, relational operators, equality operators, binary
  231. bitwise operators, binary logical operators, assignment operators, and the comma operator.</p>
  232. <p>Large ECMAScript programs are supported by <b><i>modules</i></b> which allow a program to be divided into multiple
  233. sequences of statements and declarations. Each module explicitly identifies declarations it uses that need to be provided by
  234. other modules and which of its declarations are available for use by other modules.</p>
  235. <p>ECMAScript syntax intentionally resembles Java syntax. ECMAScript syntax is relaxed to enable it to serve as an
  236. easy-to-use scripting language. For example, a variable is not required to have its type declared nor are types associated
  237. with properties, and defined functions are not required to have their declarations appear textually before calls to
  238. them.</p>
  239. </div>
  240. <section id="sec-objects">
  241. <h1><span class="secnum" id="sec-4.2.1"><a href="#sec-objects" title="link to this section">4.2.1</a></span> Objects</h1>
  242. <p>Even though ECMAScript includes syntax for class definitions, ECMAScript objects are not fundamentally class-based such
  243. as those in C++, Smalltalk, or Java. Instead objects may be created in various ways including via a literal notation or via
  244. <b><i>constructors</i></b> which create objects and then execute code that initializes all or part of them by assigning
  245. initial values to their properties. Each constructor is a function that has a property named <code>"prototype"</code> that
  246. is used to implement <b><i>prototype-based inheritance</i></b> and <b><i>shared properties</i></b>. Objects are created by
  247. using constructors in <b>new</b> expressions; for example, <code>new Date(2009,11)</code> creates a new Date object.
  248. Invoking a constructor without using <b>new</b> has consequences that depend on the constructor. For example,
  249. <code>Date()</code> produces a string representation of the current date and time rather than an object.</p>
  250. <p>Every object created by a constructor has an implicit reference (called the object&rsquo;s <i>prototype</i>) to the value
  251. of its constructor&rsquo;s <code>"prototype"</code> property. Furthermore, a prototype may have a non-null implicit
  252. reference to its prototype, and so on; this is called the <i>prototype chain</i>. When a reference is made to a property in
  253. an object, that reference is to the property of that name in the first object in the prototype chain that contains a
  254. property of that name. In other words, first the object mentioned directly is examined for such a property; if that object
  255. contains the named property, that is the property to which the reference refers; if that object does not contain the named
  256. property, the prototype for that object is examined next; and so on.</p>
  257. <figure>
  258. <object data="figure-1.svg" height="354" type="image/svg+xml" width="719">
  259. <img alt="An image of lots of boxes and arrows." height="354" src="figure-1.png" width="719">
  260. </object>
  261. <figcaption>Figure 1 &mdash; Object/Prototype Relationships</figcaption>
  262. </figure>
  263. <p>In a class-based object-oriented language, in general, state is carried by instances, methods are carried by classes, and
  264. inheritance is only of structure and behaviour. In ECMAScript, the state and methods are carried by objects, while
  265. structure, behaviour, and state are all inherited.</p>
  266. <p>All objects that do not directly contain a particular property that their prototype contains share that property and its
  267. value. Figure 1 illustrates this:</p>
  268. <p><b>CF</b> is a constructor (and also an object). Five objects have been created by using <code>new</code> expressions:
  269. <b>cf<sub>1</sub></b>, <b>cf<sub>2</sub></b>, <b>cf<sub>3</sub></b>, <b>cf<sub>4</sub></b>, and <b>cf<sub>5</sub></b>. Each
  270. of these objects contains properties named <code>q1</code> and <code>q2</code>. The dashed lines represent the implicit
  271. prototype relationship; so, for example, <b>cf<sub>3</sub></b>&rsquo;s prototype is <b>CF<sub>p</sub></b>. The constructor,
  272. <b>CF</b>, has two properties itself, named <code>P1</code> and <code>P2</code>, which are not visible to
  273. <b>CF<sub>p</sub></b>, <b>cf<sub>1</sub></b>, <b>cf<sub>2</sub></b>, <b>cf<sub>3</sub></b>, <b>cf<sub>4</sub></b>, or
  274. <b>cf<sub>5</sub></b>. The property named <code>CFP1</code> in <b>CF<sub>p</sub></b> is shared by <b>cf<sub>1</sub></b>,
  275. <b>cf<sub>2</sub></b>, <b>cf<sub>3</sub></b>, <b>cf<sub>4</sub></b>, and <b>cf<sub>5</sub></b> (but not by <b>CF</b>), as
  276. are any properties found in <b>CF<sub>p</sub></b>&rsquo;s implicit prototype chain that are not named <code>q1</code>,
  277. <code>q2</code>, or <code>CFP1</code>. Notice that there is no implicit prototype link between <b>CF</b> and
  278. <b>CF<sub>p</sub></b>.</p>
  279. <p>Unlike most class-based object languages, properties can be added to objects dynamically by assigning values to them.
  280. That is, constructors are not required to name or assign values to all or any of the constructed object&rsquo;s properties.
  281. In the above diagram, one could add a new shared property for <b>cf<sub>1</sub></b>, <b>cf<sub>2</sub></b>,
  282. <b>cf<sub>3</sub></b>, <b>cf<sub>4</sub></b>, and <b>cf<sub>5</sub></b> by assigning a new value to the property in
  283. <b>CF<sub>p</sub></b>.</p>
  284. <p>Although ECMAScript objects are not inherently class-based, it is often convenient to define class-like abstractions
  285. based upon a common pattern of constructor functions, prototype objects, and methods. The ECMAScript built-in objects
  286. themselves follow such a class-like pattern. Beginning with the sixth edition, the ECMAScript language includes syntactic
  287. class definitions that permit programmers to concisely define objects that conform to the same class-like abstraction
  288. pattern used by the built-in objects.</p>
  289. </section>
  290. <section id="sec-strict-variant-of-ecmascript">
  291. <h1><span class="secnum" id="sec-4.2.2"><a href="#sec-strict-variant-of-ecmascript"
  292. title="link to this section">4.2.2</a></span> The Strict Variant of ECMAScript</h1>
  293. <p>The ECMAScript Language recognizes the possibility that some users of the language may wish to restrict their usage of
  294. some features available in the language. They might do so in the interests of security, to avoid what they consider to be
  295. error-prone features, to get enhanced error checking, or for other reasons of their choosing. In support of this
  296. possibility, ECMAScript defines a strict variant of the language. The strict variant of the language excludes some specific
  297. syntactic and semantic features of the regular ECMAScript language and modifies the detailed semantics of some features. The
  298. strict variant also specifies additional error conditions that must be reported by throwing error exceptions in situations
  299. that are not specified as errors by the non-strict form of the language.</p>
  300. <p>The strict variant of ECMAScript is commonly referred to as the <i>strict mode</i> of the language. Strict mode selection
  301. and use of the strict mode syntax and semantics of ECMAScript is explicitly made at the level of individual ECMAScript
  302. source text units. Because strict mode is selected at the level of a syntactic source text unit, strict mode only imposes
  303. restrictions that have local effect within such a source text unit. Strict mode does not restrict or modify any aspect of
  304. the ECMAScript semantics that must operate consistently across multiple source text units. A complete ECMAScript program may
  305. be composed of both strict mode and non-strict mode ECMAScript source text units. In this case, strict mode only applies
  306. when actually executing code that is defined within a strict mode source text unit.</p>
  307. <p>In order to conform to this specification, an ECMAScript implementation must implement both the full unrestricted
  308. ECMAScript language and the strict variant of the ECMAScript language as defined by this specification. In addition, an
  309. implementation must support the combination of unrestricted and strict mode source text units into a single composite
  310. program.</p>
  311. </section>
  312. </section>
  313. <section id="sec-terms-and-definitions">
  314. <div class="front">
  315. <h1><span class="secnum" id="sec-4.3"><a href="#sec-terms-and-definitions" title="link to this section">4.3</a></span> Terms
  316. and definitions</h1>
  317. <p>For the purposes of this document, the following terms and definitions apply.</p>
  318. </div>
  319. <section id="sec-type">
  320. <h1><span class="secnum" id="sec-4.3.1"><a href="#sec-type" title="link to this section">4.3.1</a></span> type</h1>
  321. <p>set of data values as defined in <a href="#sec-ecmascript-data-types-and-values">clause 6</a> of this specification</p>
  322. </section>
  323. <section id="sec-primitive-value">
  324. <h1><span class="secnum" id="sec-4.3.2"><a href="#sec-primitive-value" title="link to this section">4.3.2</a></span>
  325. primitive value</h1>
  326. <p>member of one of the types Undefined, Null, Boolean, Number, Symbol, or String as defined in <a
  327. href="#sec-ecmascript-data-types-and-values">clause 6</a></p>
  328. <div class="note">
  329. <p><span class="nh">NOTE</span> A primitive value is a datum that is represented directly at the lowest level of the
  330. language implementation.</p>
  331. </div>
  332. </section>
  333. <section id="sec-terms-and-definitions-object">
  334. <h1><span class="secnum" id="sec-4.3.3"><a href="#sec-terms-and-definitions-object"
  335. title="link to this section">4.3.3</a></span> object</h1>
  336. <p>member of the type Object</p>
  337. <div class="note">
  338. <p><span class="nh">NOTE</span> An object is a collection of properties and has a single prototype object. The prototype
  339. may be the null value.</p>
  340. </div>
  341. </section>
  342. <section id="sec-constructor">
  343. <h1><span class="secnum" id="sec-4.3.4"><a href="#sec-constructor" title="link to this section">4.3.4</a></span>
  344. constructor</h1>
  345. <p>function object that creates and initializes objects</p>
  346. <div class="note">
  347. <p><span class="nh">NOTE</span> The value of a constructor&rsquo;s <code>prototype</code> property is a prototype object
  348. that is used to implement inheritance and shared properties.</p>
  349. </div>
  350. </section>
  351. <section id="sec-terms-and-definitions-prototype">
  352. <h1><span class="secnum" id="sec-4.3.5"><a href="#sec-terms-and-definitions-prototype"
  353. title="link to this section">4.3.5</a></span> prototype</h1>
  354. <p>object that provides shared properties for other objects</p>
  355. <div class="note">
  356. <p><span class="nh">NOTE</span> When a constructor creates an object, that object implicitly references the
  357. constructor&rsquo;s <code>prototype</code> property for the purpose of resolving property references. The
  358. constructor&rsquo;s <code>prototype</code> property can be referenced by the program expression
  359. <code><i>constructor</i><b>.prototype</b></code>, and properties added to an object&rsquo;s prototype are shared, through
  360. inheritance, by all objects sharing the prototype. Alternatively, a new object may be created with an explicitly specified
  361. prototype by using the <code><a href="#sec-object.create">Object.create</a></code> built-in function.</p>
  362. </div>
  363. </section>
  364. <section id="sec-ordinary-object">
  365. <h1><span class="secnum" id="sec-4.3.6"><a href="#sec-ordinary-object" title="link to this section">4.3.6</a></span>
  366. ordinary object</h1>
  367. <p>object that has the default behaviour for the essential internal methods that must be supported by all objects.</p>
  368. </section>
  369. <section id="sec-exotic-object">
  370. <h1><span class="secnum" id="sec-4.3.7"><a href="#sec-exotic-object" title="link to this section">4.3.7</a></span> exotic
  371. object</h1>
  372. <p>object that does not have the default behaviour for one or more of the essential internal methods that must be supported
  373. by all objects.</p>
  374. <div class="note">
  375. <p><span class="nh">NOTE</span> Any object that is not an ordinary object is an exotic object.</p>
  376. </div>
  377. </section>
  378. <section id="sec-standard-object">
  379. <h1><span class="secnum" id="sec-4.3.8"><a href="#sec-standard-object" title="link to this section">4.3.8</a></span>
  380. standard object</h1>
  381. <p>object whose semantics are defined by this specification</p>
  382. </section>
  383. <section id="sec-built-in-object">
  384. <h1><span class="secnum" id="sec-4.3.9"><a href="#sec-built-in-object" title="link to this section">4.3.9</a></span>
  385. built-in object</h1>
  386. <p>object specified and supplied by an ECMAScript implementation</p>
  387. <div class="note">
  388. <p><span class="nh">NOTE</span> Standard built-in objects are defined in this specification. An ECMAScript implementation
  389. may specify and supply additional kinds of built-in objects. A <i>built-in constructor</i> is a built-in object that is
  390. also a constructor.</p>
  391. </div>
  392. </section>
  393. <section id="sec-undefined-value">
  394. <h1><span class="secnum" id="sec-4.3.10"><a href="#sec-undefined-value" title="link to this section">4.3.10</a></span>
  395. undefined value</h1>
  396. <p>primitive value used when a variable has not been assigned a value</p>
  397. </section>
  398. <section id="sec-terms-and-definitions-undefined-type">
  399. <h1><span class="secnum" id="sec-4.3.11"><a href="#sec-terms-and-definitions-undefined-type"
  400. title="link to this section">4.3.11</a></span> Undefined type</h1>
  401. <p>type whose sole value is the <b>undefined</b> value</p>
  402. </section>
  403. <section id="sec-null-value">
  404. <h1><span class="secnum" id="sec-4.3.12"><a href="#sec-null-value" title="link to this section">4.3.12</a></span> null
  405. value</h1>
  406. <p>primitive value that represents the intentional absence of any object value</p>
  407. </section>
  408. <section id="sec-terms-and-definitions-null-type">
  409. <h1><span class="secnum" id="sec-4.3.13"><a href="#sec-terms-and-definitions-null-type"
  410. title="link to this section">4.3.13</a></span> Null type</h1>
  411. <p>type whose sole value is the null value</p>
  412. </section>
  413. <section id="sec-terms-and-definitions-boolean-value">
  414. <h1><span class="secnum" id="sec-4.3.14"><a href="#sec-terms-and-definitions-boolean-value"
  415. title="link to this section">4.3.14</a></span> Boolean value</h1>
  416. <p>member of the Boolean type</p>
  417. <div class="note">
  418. <p><span class="nh">NOTE</span> There are only two Boolean values, <b>true</b> and <b>false</b></p>
  419. </div>
  420. </section>
  421. <section id="sec-terms-and-definitions-boolean-type">
  422. <h1><span class="secnum" id="sec-4.3.15"><a href="#sec-terms-and-definitions-boolean-type"
  423. title="link to this section">4.3.15</a></span> Boolean type</h1>
  424. <p>type consisting of the primitive values <b>true</b> and <b>false</b></p>
  425. </section>
  426. <section id="sec-boolean-object">
  427. <h1><span class="secnum" id="sec-4.3.16"><a href="#sec-boolean-object" title="link to this section">4.3.16</a></span>
  428. Boolean object</h1>
  429. <p>member of the Object type that is an instance of the standard built-in <code>Boolean</code> constructor</p>
  430. <div class="note">
  431. <p><span class="nh">NOTE</span> A Boolean object is created by using the <code>Boolean</code> constructor in a
  432. <code>new</code> expression, supplying a Boolean value as an argument. The resulting object has an <a
  433. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the Boolean value. A Boolean
  434. object can be coerced to a Boolean value.</p>
  435. </div>
  436. </section>
  437. <section id="sec-terms-and-definitions-string-value">
  438. <h1><span class="secnum" id="sec-4.3.17"><a href="#sec-terms-and-definitions-string-value"
  439. title="link to this section">4.3.17</a></span> String value</h1>
  440. <p>primitive value that is a finite ordered sequence of zero or more 16-bit unsigned integer</p>
  441. <div class="note">
  442. <p><span class="nh">NOTE</span> A String value is a member of the String type. Each integer value in the sequence usually
  443. represents a single 16-bit unit of UTF-16 text. However, ECMAScript does not place any restrictions or requirements on the
  444. values except that they must be 16-bit unsigned integers.</p>
  445. </div>
  446. </section>
  447. <section id="sec-terms-and-definitions-string-type">
  448. <h1><span class="secnum" id="sec-4.3.18"><a href="#sec-terms-and-definitions-string-type"
  449. title="link to this section">4.3.18</a></span> String type</h1>
  450. <p>set of all possible String values</p>
  451. </section>
  452. <section id="sec-string-object">
  453. <h1><span class="secnum" id="sec-4.3.19"><a href="#sec-string-object" title="link to this section">4.3.19</a></span> String
  454. object</h1>
  455. <p>member of the Object type that is an instance of the standard built-in <code>String</code> constructor</p>
  456. <div class="note">
  457. <p><span class="nh">NOTE</span> A String object is created by using the <code>String</code> constructor in a
  458. <code>new</code> expression, supplying a String value as an argument. The resulting object has an <a
  459. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the String value. A String object
  460. can be coerced to a String value by calling the <code>String</code> constructor as a function (<a
  461. href="#sec-string-constructor-string-value">21.1.1.1</a>).</p>
  462. </div>
  463. </section>
  464. <section id="sec-terms-and-definitions-number-value">
  465. <h1><span class="secnum" id="sec-4.3.20"><a href="#sec-terms-and-definitions-number-value"
  466. title="link to this section">4.3.20</a></span> Number value</h1>
  467. <p>primitive value corresponding to a double-precision 64-bit binary format IEEE 754 value</p>
  468. <div class="note">
  469. <p><span class="nh">NOTE</span> A Number value is a member of the Number type and is a direct representation of a
  470. number.</p>
  471. </div>
  472. </section>
  473. <section id="sec-terms-and-definitions-number-type">
  474. <h1><span class="secnum" id="sec-4.3.21"><a href="#sec-terms-and-definitions-number-type"
  475. title="link to this section">4.3.21</a></span> Number type</h1>
  476. <p>set of all possible Number values including the special &ldquo;Not-a-Number&rdquo; (NaN) value, positive infinity, and
  477. negative infinity</p>
  478. </section>
  479. <section id="sec-number-object">
  480. <h1><span class="secnum" id="sec-4.3.22"><a href="#sec-number-object" title="link to this section">4.3.22</a></span> Number
  481. object</h1>
  482. <p>member of the Object type that is an instance of the standard built-in <code>Number</code> constructor</p>
  483. <div class="note">
  484. <p><span class="nh">NOTE</span> A Number object is created by using the <code>Number</code> constructor in a
  485. <code>new</code> expression, supplying a Number value as an argument. The resulting object has an <a
  486. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the Number value. A Number object
  487. can be coerced to a Number value by calling the <code>Number</code> constructor as a function (<a
  488. href="#sec-number-constructor-number-value">20.1.1.1</a>).</p>
  489. </div>
  490. </section>
  491. <section id="sec-terms-and-definitions-infinity">
  492. <h1><span class="secnum" id="sec-4.3.23"><a href="#sec-terms-and-definitions-infinity"
  493. title="link to this section">4.3.23</a></span> Infinity</h1>
  494. <p>number value that is the positive infinite Number value</p>
  495. </section>
  496. <section id="sec-terms-and-definitions-nan">
  497. <h1><span class="secnum" id="sec-4.3.24"><a href="#sec-terms-and-definitions-nan"
  498. title="link to this section">4.3.24</a></span> NaN</h1>
  499. <p>number value that is an IEEE 754 &ldquo;Not-a-Number&rdquo; value</p>
  500. </section>
  501. <section id="sec-symbol-value">
  502. <h1><span class="secnum" id="sec-4.3.25"><a href="#sec-symbol-value" title="link to this section">4.3.25</a></span> Symbol
  503. value</h1>
  504. <p>primitive value that represents a unique, non-String Object <a href="#sec-object-type">property key</a></p>
  505. </section>
  506. <section id="sec-terms-and-definitions-symbol-type">
  507. <h1><span class="secnum" id="sec-4.3.26"><a href="#sec-terms-and-definitions-symbol-type"
  508. title="link to this section">4.3.26</a></span> Symbol type</h1>
  509. <p>set of all possible Symbol values</p>
  510. </section>
  511. <section id="sec-symbol-object">
  512. <h1><span class="secnum" id="sec-4.3.27"><a href="#sec-symbol-object" title="link to this section">4.3.27</a></span> Symbol
  513. object</h1>
  514. <p>member of the Object type that is an instance of the standard built-in <code>Symbol</code> constructor</p>
  515. </section>
  516. <section id="sec-terms-and-definitions-function">
  517. <h1><span class="secnum" id="sec-4.3.28"><a href="#sec-terms-and-definitions-function"
  518. title="link to this section">4.3.28</a></span> function</h1>
  519. <p>member of the Object type that may be invoked as a subroutine</p>
  520. <div class="note">
  521. <p><span class="nh">NOTE</span> In addition to its properties, a function contains executable code and state that
  522. determine how it behaves when invoked. A function&rsquo;s code may or may not be written in ECMAScript.</p>
  523. </div>
  524. </section>
  525. <section id="sec-built-in-function">
  526. <h1><span class="secnum" id="sec-4.3.29"><a href="#sec-built-in-function" title="link to this section">4.3.29</a></span>
  527. built-in function</h1>
  528. <p>built-in object that is a function</p>
  529. <div class="note">
  530. <p><span class="nh">NOTE</span> Examples of built-in functions include <code>parseInt</code> and <code><a
  531. href="#sec-math.exp">Math.exp</a></code>. An implementation may provide implementation-dependent built-in functions that
  532. are not described in this specification.</p>
  533. </div>
  534. </section>
  535. <section id="sec-property">
  536. <h1><span class="secnum" id="sec-4.3.30"><a href="#sec-property" title="link to this section">4.3.30</a></span>
  537. property</h1>
  538. <p>part of an object that associates a key (either a String value or a Symbol value) and a value.</p>
  539. <div class="note">
  540. <p><span class="nh">NOTE</span> Depending upon the form of the property the value may be represented either directly as a
  541. data value (a primitive value, an object, or a function object) or indirectly by a pair of accessor functions.</p>
  542. </div>
  543. </section>
  544. <section id="sec-method">
  545. <h1><span class="secnum" id="sec-4.3.31"><a href="#sec-method" title="link to this section">4.3.31</a></span> method</h1>
  546. <p>function that is the value of a property</p>
  547. <div class="note">
  548. <p><span class="nh">NOTE</span> When a function is called as a method of an object, the object is passed to the function
  549. as its <b>this</b> value.</p>
  550. </div>
  551. </section>
  552. <section id="sec-built-in-method">
  553. <h1><span class="secnum" id="sec-4.3.32"><a href="#sec-built-in-method" title="link to this section">4.3.32</a></span>
  554. built-in method</h1>
  555. <p>method that is a built-in function</p>
  556. <div class="note">
  557. <p><span class="nh">NOTE</span> Standard built-in methods are defined in this specification, and an ECMAScript
  558. implementation may specify and provide other additional built-in methods.</p>
  559. </div>
  560. </section>
  561. <section id="sec-attribute">
  562. <h1><span class="secnum" id="sec-4.3.33"><a href="#sec-attribute" title="link to this section">4.3.33</a></span>
  563. attribute</h1>
  564. <p>internal value that defines some characteristic of a property</p>
  565. </section>
  566. <section id="sec-own-property">
  567. <h1><span class="secnum" id="sec-4.3.34"><a href="#sec-own-property" title="link to this section">4.3.34</a></span> own
  568. property</h1>
  569. <p>property that is directly contained by its object</p>
  570. </section>
  571. <section id="sec-inherited-property">
  572. <h1><span class="secnum" id="sec-4.3.35"><a href="#sec-inherited-property" title="link to this section">4.3.35</a></span>
  573. inherited property</h1>
  574. <p>property of an object that is not an own property but is a property (either own or inherited) of the object&rsquo;s
  575. prototype</p>
  576. </section>
  577. </section>
  578. <section id="sec-organization-of-this-specification">
  579. <h1><span class="secnum" id="sec-4.4"><a href="#sec-organization-of-this-specification"
  580. title="link to this section">4.4</a></span> Organization of This Specification</h1>
  581. <p>The remainder of this specification is organized as follows:</p>
  582. <p>Clause 5 defines the notational conventions used throughout the specification.</p>
  583. <p>Clauses 6&minus;9 define the execution environment within which ECMAScript programs operate.</p>
  584. <p>Clauses 10&minus;16 define the actual ECMAScript programming language including its syntactic encoding and the execution
  585. semantics of all language features.</p>
  586. <p>Clauses 17&minus;26 define the ECMAScript standard library. It includes the definitions of all of the standard objects that
  587. are available for use by ECMAScript programs as they execute.</p>
  588. </section>
  589. </section>
  590. <section id="sec-notational-conventions">
  591. <div class="front">
  592. <h1><span class="secnum" id="sec-5"><a href="#sec-notational-conventions" title="link to this section">5</a></span> Notational
  593. Conventions</h1>
  594. </div>
  595. <section id="sec-syntactic-and-lexical-grammars">
  596. <div class="front">
  597. <h1><span class="secnum" id="sec-5.1"><a href="#sec-syntactic-and-lexical-grammars"
  598. title="link to this section">5.1</a></span> Syntactic and Lexical Grammars</h1>
  599. </div>
  600. <section id="sec-context-free-grammars">
  601. <h1><span class="secnum" id="sec-5.1.1"><a href="#sec-context-free-grammars" title="link to this section">5.1.1</a></span>
  602. Context-Free Grammars</h1>
  603. <p>A <i>context-free grammar</i> consists of a number of <i>productions</i>. Each production has an abstract symbol called a
  604. <i>nonterminal</i> as its <i>left-hand side</i>, and a sequence of zero or more nonterminal and <i>terminal</i> symbols as
  605. its <i>right-hand side</i>. For each grammar, the terminal symbols are drawn from a specified alphabet.</p>
  606. <p>A <i>chain production</i> is a production that has exactly one nonterminal symbol on its right-hand side along with zero
  607. or more terminal symbols.</p>
  608. <p>Starting from a sentence consisting of a single distinguished nonterminal, called the <i>goal symbol</i>, a given
  609. context-free grammar specifies a <i>language</i>, namely, the (perhaps infinite) set of possible sequences of terminal
  610. symbols that can result from repeatedly replacing any nonterminal in the sequence with a right-hand side of a production for
  611. which the nonterminal is the left-hand side.</p>
  612. </section>
  613. <section id="sec-lexical-and-regexp-grammars">
  614. <h1><span class="secnum" id="sec-5.1.2"><a href="#sec-lexical-and-regexp-grammars"
  615. title="link to this section">5.1.2</a></span> The Lexical and RegExp Grammars</h1>
  616. <p>A <i>lexical grammar</i> for ECMAScript is given in <a href="#sec-ecmascript-language-lexical-grammar">clause 11</a>.
  617. This grammar has as its terminal symbols Unicode code points that conform to the rules for <span
  618. class="nt">SourceCharacter</span> defined in <a href="#sec-source-text">10.1</a>. It defines a set of productions, starting
  619. from the goal symbol <var>InputElementDiv,</var> <var>InputElementTemplateTail,</var> or <span
  620. class="nt">InputElementRegExp</span>, or <var>InputElementRegExpOrTemplateTail,</var> that describe how sequences of such
  621. code points are translated into a sequence of input elements.</p>
  622. <p>Input elements other than white space and comments form the terminal symbols for the syntactic grammar for ECMAScript and
  623. are called ECMAScript <i>tokens</i>. These tokens are the reserved words, identifiers, literals, and punctuators of the
  624. ECMAScript language. Moreover, line terminators, although not considered to be tokens, also become part of the stream of
  625. input elements and guide the process of <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a
  626. href="#sec-automatic-semicolon-insertion">11.9</a>). Simple white space and single-line comments are discarded and do not
  627. appear in the stream of input elements for the syntactic grammar. A <span class="nt">MultiLineComment</span> (that is, a
  628. comment of the form <code>/*</code>&hellip;<code>*/</code> regardless of whether it spans more than one line) is likewise
  629. simply discarded if it contains no line terminator; but if a <span class="nt">MultiLineComment</span> contains one or more
  630. line terminators, then it is replaced by a single line terminator, which becomes part of the stream of input elements for
  631. the syntactic grammar.</p>
  632. <p>A <i>RegExp grammar</i> for ECMAScript is given in <a href="#sec-patterns">21.2.1</a>. This grammar also has as its
  633. terminal symbols the code points as defined by <span class="nt">SourceCharacter</span>. It defines a set of productions,
  634. starting from the goal symbol <span class="nt">Pattern</span>, that describe how sequences of code points are translated
  635. into regular expression patterns.</p>
  636. <p>Productions of the lexical and RegExp grammars are distinguished by having two colons &ldquo;<b>::</b>&rdquo; as
  637. separating punctuation. The lexical and RegExp grammars share some productions.</p>
  638. </section>
  639. <section id="sec-numeric-string-grammar">
  640. <h1><span class="secnum" id="sec-5.1.3"><a href="#sec-numeric-string-grammar" title="link to this section">5.1.3</a></span>
  641. The Numeric String Grammar</h1>
  642. <p>Another grammar is used for translating Strings into numeric values. This grammar is similar to the part of the lexical
  643. grammar having to do with numeric literals and has as its terminal symbols <span class="nt">SourceCharacter</span>. This
  644. grammar appears in <a href="#sec-tonumber-applied-to-the-string-type">7.1.3.1</a>.</p>
  645. <p>Productions of the numeric string grammar are distinguished by having three colons &ldquo;<b>:::</b>&rdquo; as
  646. punctuation.</p>
  647. </section>
  648. <section id="sec-syntactic-grammar">
  649. <h1><span class="secnum" id="sec-5.1.4"><a href="#sec-syntactic-grammar" title="link to this section">5.1.4</a></span> The
  650. Syntactic Grammar</h1>
  651. <p>The <i>syntactic grammar</i> for ECMAScript is given in clauses 11, 12, 13, 14, and 15. This grammar has ECMAScript
  652. tokens defined by the lexical grammar as its terminal symbols (<a href="#sec-lexical-and-regexp-grammars">5.1.2</a>). It
  653. defines a set of productions, starting from two alternative goal symbols <span class="nt">Script</span> and <span
  654. class="nt">Module</span>, that describe how sequences of tokens form syntactically correct independent components of
  655. ECMAScript programs.</p>
  656. <p>When a stream of code points is to be parsed as an ECMAScript <span class="nt">Script</span> or <span
  657. class="nt">Module</span>, it is first converted to a stream of input elements by repeated application of the lexical
  658. grammar; this stream of input elements is then parsed by a single application of the syntactic grammar. The input stream is
  659. syntactically in error if the tokens in the stream of input elements cannot be parsed as a single instance of the goal
  660. nonterminal (<span class="nt">Script</span> or <span class="nt">Module</span>), with no tokens left over.</p>
  661. <p>Productions of the syntactic grammar are distinguished by having just one colon &ldquo;<b>:</b>&rdquo; as
  662. punctuation.</p>
  663. <p>The syntactic grammar as presented in clauses 12, 13, 14 and 15 is not a complete account of which token sequences are
  664. accepted as a correct ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span>. Certain additional token
  665. sequences are also accepted, namely, those that would be described by the grammar if only semicolons were added to the
  666. sequence in certain places (such as before line terminator characters). Furthermore, certain token sequences that are
  667. described by the grammar are not considered acceptable if a line terminator character appears in certain
  668. &ldquo;awkward&rdquo; places.</p>
  669. <p>In certain cases in order to avoid ambiguities the syntactic grammar uses generalized productions that permit token
  670. sequences that do not form a valid ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span>. For example,
  671. this technique is used for object literals and object destructuring patterns. In such cases a more restrictive
  672. <i>supplemental grammar</i> is provided that further restricts the acceptable token sequences. In certain contexts, when
  673. explicitly specified, the input elements corresponding to such a production are parsed again using a goal symbol of a
  674. supplemental grammar. The input stream is syntactically in error if the tokens in the stream of input elements parsed by a
  675. cover grammar cannot be parsed as a single instance of the corresponding supplemental goal symbol, with no tokens left
  676. over.</p>
  677. </section>
  678. <section id="sec-grammar-notation">
  679. <h1><span class="secnum" id="sec-5.1.5"><a href="#sec-grammar-notation" title="link to this section">5.1.5</a></span>
  680. Grammar Notation</h1>
  681. <p>Terminal symbols of the lexical, RegExp, and numeric string grammars are shown in <code>fixed width</code> font, both in
  682. the productions of the grammars and throughout this specification whenever the text directly refers to such a terminal
  683. symbol. These are to appear in a script exactly as written. All terminal symbol code points specified in this way are to be
  684. understood as the appropriate Unicode code points from the Basic Latin range, as opposed to any similar-looking code points
  685. from other Unicode ranges.</p>
  686. <p>Nonterminal symbols are shown in <var>italic</var> type. The definition of a nonterminal (also called a
  687. &ldquo;production&rdquo;) is introduced by the name of the nonterminal being defined followed by one or more colons. (The
  688. number of colons indicates to which grammar the production belongs.) One or more alternative right-hand sides for the
  689. nonterminal then follow on succeeding lines. For example, the syntactic definition:</p>
  690. <div class="gp">
  691. <div class="lhs"><span class="nt">WhileStatement</span> <span class="geq">:</span></div>
  692. <div class="rhs"><code class="t">while</code> <code class="t">(</code> <span class="nt">Expression</span> <code class="t">)</code> <span class="nt">Statement</span></div>
  693. </div>
  694. <p>states that the nonterminal <span class="nt">WhileStatement</span> represents the token <code>while</code>, followed by a
  695. left parenthesis token, followed by an <span class="nt">Expression</span>, followed by a right parenthesis token, followed
  696. by a <span class="nt">Statement</span>. The occurrences of <span class="nt">Expression</span> and <span
  697. class="nt">Statement</span> are themselves nonterminals. As another example, the syntactic definition:</p>
  698. <div class="gp">
  699. <div class="lhs"><span class="nt">ArgumentList</span> <span class="geq">:</span></div>
  700. <div class="rhs"><span class="nt">AssignmentExpression</span></div>
  701. <div class="rhs"><span class="nt">ArgumentList</span> <code class="t">,</code> <span class="nt">AssignmentExpression</span></div>
  702. </div>
  703. <p>states that an <span class="nt">ArgumentList</span> may represent either a single <span
  704. class="nt">AssignmentExpression</span> or an <span class="nt">ArgumentList</span>, followed by a comma, followed by an <span
  705. class="nt">AssignmentExpression</span>. This definition of <span class="nt">ArgumentList</span> is recursive, that is, it is
  706. defined in terms of itself. The result is that an <span class="nt">ArgumentList</span> may contain any positive number of
  707. arguments, separated by commas, where each argument expression is an <span class="nt">AssignmentExpression</span>. Such
  708. recursive definitions of nonterminals are common.</p>
  709. <p>The subscripted suffix &ldquo;<sub>opt</sub>&rdquo;, which may appear after a terminal or nonterminal, indicates an
  710. optional symbol. The alternative containing the optional symbol actually specifies two right-hand sides, one that omits the
  711. optional element and one that includes it. This means that:</p>
  712. <div class="gp">
  713. <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
  714. <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span><sub class="g-opt">opt</sub></div>
  715. </div>
  716. <p>is a convenient abbreviation for:</p>
  717. <div class="gp">
  718. <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
  719. <div class="rhs"><span class="nt">BindingIdentifier</span></div>
  720. <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span></div>
  721. </div>
  722. <p>and that:</p>
  723. <div class="gp">
  724. <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
  725. <div class="rhs"><code class="t">for</code> <code class="t">(</code> <span class="nt">LexicalDeclaration</span> <span class="nt">Expression</span><sub class="g-opt">opt</sub> <code class="t">;</code> <span class="nt">Expression</span><sub class="g-opt">opt</sub> <code class="t">)</code> <span class="nt">Statement</span></div>
  726. </div>
  727. <p>is a convenient abbreviation for:</p>
  728. <div class="gp">
  729. <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
  730. <div class="rhs"><code class="t">for</code> <code class="t">(</code> <span class="nt">LexicalDeclaration</span> <code class="t">;</code> <span class="nt">Expression</span><sub class="g-opt">opt</sub> <code class="t">)</code> <span class="nt">Statement</span></div>
  731. <div class="rhs"><code class="t">for</code> <code class="t">(</code> <span class="nt">LexicalDeclaration</span> <span class="nt">Expression</span> <code class="t">;</code> <span class="nt">Expression</span><sub class="g-opt">opt</sub> <code class="t">)</code> <span class="nt">Statement</span></div>
  732. </div>
  733. <p>which in turn is an abbreviation for:</p>
  734. <div class="gp">
  735. <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
  736. <div class="rhs"><code class="t">for</code> <code class="t">(</code> <span class="nt">LexicalDeclaration</span> <code class="t">;</code> <code class="t">)</code> <span class="nt">Statement</span></div>
  737. <div class="rhs"><code class="t">for</code> <code class="t">(</code> <span class="nt">LexicalDeclaration</span> <code class="t">;</code> <span class="nt">Expression</span> <code class="t">)</code> <span class="nt">Statement</span></div>
  738. <div class="rhs"><code class="t">for</code> <code class="t">(</code> <span class="nt">LexicalDeclaration</span> <span class="nt">Expression</span> <code class="t">;</code> <code class="t">)</code> <span class="nt">Statement</span></div>
  739. <div class="rhs"><code class="t">for</code> <code class="t">(</code> <span class="nt">LexicalDeclaration</span> <span class="nt">Expression</span> <code class="t">;</code> <span class="nt">Expression</span> <code class="t">)</code> <span class="nt">Statement</span></div>
  740. </div>
  741. <p>so, in this example, the nonterminal <span class="nt">IterationStatement</span> actually has four alternative right-hand
  742. sides.</p>
  743. <p>A production may be parameterized by a subscripted annotation of the form &ldquo;<sub>[parameters]</sub>&rdquo;, which
  744. may appear as a suffix to the nonterminal symbol defined by the production. &ldquo;<sub>parameters</sub>&rdquo; may be
  745. either a single name or a comma separated list of names. A parameterized production is shorthand for a set of productions
  746. defining all combinations of the parameter names, preceded by an underscore, appended to the parameterized nonterminal
  747. symbol. This means that:</p>
  748. <div class="gp">
  749. <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
  750. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  751. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  752. </div>
  753. <p>is a convenient abbreviation for:</p>
  754. <div class="gp">
  755. <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
  756. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  757. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  758. </div>
  759. <div class="gp">
  760. <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
  761. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  762. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  763. </div>
  764. <p>and that:</p>
  765. <div class="gp">
  766. <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return, In]</sub> <span class="geq">:</span></div>
  767. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  768. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  769. </div>
  770. <p>is an abbreviation for:</p>
  771. <div class="gp">
  772. <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
  773. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  774. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  775. </div>
  776. <div class="gp">
  777. <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
  778. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  779. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  780. </div>
  781. <div class="gp">
  782. <div class="lhs"><span class="nt">StatementList_In</span> <span class="geq">:</span></div>
  783. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  784. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  785. </div>
  786. <div class="gp">
  787. <div class="lhs"><span class="nt">StatementList_Return_In</span> <span class="geq">:</span></div>
  788. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  789. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  790. </div>
  791. <p>Multiple parameters produce a combinatory number of productions, not all of which are necessarily referenced in a
  792. complete grammar.</p>
  793. <p>References to nonterminals on the right-hand side of a production can also be parameterized. For example:</p>
  794. <div class="gp">
  795. <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
  796. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  797. <div class="rhs"><span class="nt">ExpressionStatement</span><sub class="g-params">[In]</sub></div>
  798. </div>
  799. <p>is equivalent to saying:</p>
  800. <div class="gp">
  801. <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
  802. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  803. <div class="rhs"><span class="nt">ExpressionStatement_In</span></div>
  804. </div>
  805. <p>A nonterminal reference may have both a parameter list and an &ldquo;<sub>opt</sub>&rdquo; suffix. For example:</p>
  806. <div class="gp">
  807. <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
  808. <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span><sub class="g-params">[In]</sub><sub class="g-opt">opt</sub></div>
  809. </div>
  810. <p>is an abbreviation for:</p>
  811. <div class="gp">
  812. <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
  813. <div class="rhs"><span class="nt">BindingIdentifier</span></div>
  814. <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer_In</span></div>
  815. </div>
  816. <p>Prefixing a parameter name with &ldquo;<sub>?</sub>&rdquo; on a right-hand side nonterminal reference makes that
  817. parameter value dependent upon the occurrence of the parameter name on the reference to the current production&rsquo;s
  818. left-hand side symbol. For example:</p>
  819. <div class="gp">
  820. <div class="lhs"><span class="nt">VariableDeclaration</span><sub class="g-params">[In]</sub> <span class="geq">:</span></div>
  821. <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span><sub class="g-params">[?In]</sub></div>
  822. </div>
  823. <p>is an abbreviation for:</p>
  824. <div class="gp">
  825. <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
  826. <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span></div>
  827. </div>
  828. <div class="gp">
  829. <div class="lhs"><span class="nt">VariableDeclaration_In</span> <span class="geq">:</span></div>
  830. <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer_In</span></div>
  831. </div>
  832. <p>If a right-hand side alternative is prefixed with &ldquo;[+parameter]&rdquo; that alternative is only available if the
  833. named parameter was used in referencing the production&rsquo;s nonterminal symbol. If a right-hand side alternative is
  834. prefixed with &ldquo;[~parameter]&rdquo; that alternative is only available if the named parameter was <i>not</i> used in
  835. referencing the production&rsquo;s nonterminal symbol. This means that:</p>
  836. <div class="gp">
  837. <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
  838. <div class="rhs"><span class="grhsannot">[+Return]</span> <span class="nt">ReturnStatement</span></div>
  839. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  840. </div>
  841. <p>is an abbreviation for:</p>
  842. <div class="gp">
  843. <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
  844. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  845. </div>
  846. <div class="gp">
  847. <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
  848. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  849. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  850. </div>
  851. <p>and that</p>
  852. <div class="gp">
  853. <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
  854. <div class="rhs"><span class="grhsannot">[~Return]</span> <span class="nt">ReturnStatement</span></div>
  855. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  856. </div>
  857. <p>is an abbreviation for:</p>
  858. <div class="gp">
  859. <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
  860. <div class="rhs"><span class="nt">ReturnStatement</span></div>
  861. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  862. </div>
  863. <div class="gp">
  864. <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
  865. <div class="rhs"><span class="nt">ExpressionStatement</span></div>
  866. </div>
  867. <p>When the words &ldquo;<b>one of</b>&rdquo; follow the colon(s) in a grammar definition, they signify that each of the
  868. terminal symbols on the following line or lines is an alternative definition. For example, the lexical grammar for
  869. ECMAScript contains the production:</p>
  870. <div class="gp">
  871. <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  872. <div class="rhs"><code class="t">1</code> <code class="t">2</code> <code class="t">3</code> <code class="t">4</code> <code class="t">5</code> <code class="t">6</code> <code class="t">7</code> <code class="t">8</code> <code class="t">9</code></div>
  873. </div>
  874. <p>which is merely a convenient abbreviation for:</p>
  875. <div class="gp">
  876. <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span></div>
  877. <div class="rhs"><code class="t">1</code></div>
  878. <div class="rhs"><code class="t">2</code></div>
  879. <div class="rhs"><code class="t">3</code></div>
  880. <div class="rhs"><code class="t">4</code></div>
  881. <div class="rhs"><code class="t">5</code></div>
  882. <div class="rhs"><code class="t">6</code></div>
  883. <div class="rhs"><code class="t">7</code></div>
  884. <div class="rhs"><code class="t">8</code></div>
  885. <div class="rhs"><code class="t">9</code></div>
  886. </div>
  887. <p>If the phrase &ldquo;[empty]&rdquo; appears as the right-hand side of a production, it indicates that the production's
  888. right-hand side contains no terminals or nonterminals.</p>
  889. <p>If the phrase &ldquo;[lookahead &notin; <var>set</var>]&rdquo; appears in the right-hand side of a production, it
  890. indicates that the production may not be used if the immediately following input token is a member of the given
  891. <var>set</var>. The <var>set</var> can be written as a list of terminals enclosed in curly brackets. For convenience, the
  892. set can also be written as a nonterminal, in which case it represents the set of all terminals to which that nonterminal
  893. could expand. If the <var>set</var> consists of a single terminal the phrase &ldquo;[lookahead &ne;
  894. <var>terminal</var>]&rdquo; may be used.</p>
  895. <p>For example, given the definitions</p>
  896. <div class="gp">
  897. <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  898. <div class="rhs"><code class="t">0</code> <code class="t">1</code> <code class="t">2</code> <code class="t">3</code> <code class="t">4</code> <code class="t">5</code> <code class="t">6</code> <code class="t">7</code> <code class="t">8</code> <code class="t">9</code></div>
  899. </div>
  900. <div class="gp">
  901. <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">::</span></div>
  902. <div class="rhs"><span class="nt">DecimalDigit</span></div>
  903. <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
  904. </div>
  905. <p>the definition</p>
  906. <div class="gp">
  907. <div class="lhs"><span class="nt">LookaheadExample</span> <span class="geq">::</span></div>
  908. <div class="rhs"><code class="t">n</code> <span class="grhsannot">[lookahead &notin; {<code class="t">1</code>, <code class="t">3</code>, <code class="t">5</code>, <code class="t">7</code>, <code class="t">9</code>}]</span> <span class="nt">DecimalDigits</span></div>
  909. <div class="rhs"><span class="nt">DecimalDigit</span> <span class="grhsannot">[lookahead &notin; <span class="nt">DecimalDigit</span>]</span></div>
  910. </div>
  911. <p>matches either the letter <code>n</code> followed by one or more decimal digits the first of which is even, or a decimal
  912. digit not followed by another decimal digit.</p>
  913. <p>If the phrase &ldquo;[no <span class="nt">LineTerminator</span> here]&rdquo; appears in the right-hand side of a
  914. production of the syntactic grammar, it indicates that the production is <i>a restricted production</i>: it may not be used
  915. if a <span class="nt">LineTerminator</span> occurs in the input stream at the indicated position. For example, the
  916. production:</p>
  917. <div class="gp">
  918. <div class="lhs"><span class="nt">ThrowStatement</span> <span class="geq">:</span></div>
  919. <div class="rhs"><code class="t">throw</code> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <span class="nt">Expression</span> <code class="t">;</code></div>
  920. </div>
  921. <p>indicates that the production may not be used if a <span class="nt">LineTerminator</span> occurs in the script between
  922. the <code>throw</code> token and the <span class="nt">Expression</span>.</p>
  923. <p>Unless the presence of a <span class="nt">LineTerminator</span> is forbidden by a restricted production, any number of
  924. occurrences of <span class="nt">LineTerminator</span> may appear between any two consecutive tokens in the stream of input
  925. elements without affecting the syntactic acceptability of the script.</p>
  926. <p>When an alternative in a production of the lexical grammar or the numeric string grammar appears to be a multi-code point
  927. token, it represents the sequence of code points that would make up such a token.</p>
  928. <p>The right-hand side of a production may specify that certain expansions are not permitted by using the phrase
  929. &ldquo;<b>but not</b>&rdquo; and then indicating the expansions to be excluded. For example, the production:</p>
  930. <div class="gp">
  931. <div class="lhs"><span class="nt">Identifier</span> <span class="geq">::</span></div>
  932. <div class="rhs"><span class="nt">IdentifierName</span> <span class="grhsmod">but not</span> <span class="nt">ReservedWord</span></div>
  933. </div>
  934. <p>means that the nonterminal <span class="nt">Identifier</span> may be replaced by any sequence of code points that could
  935. replace <span class="nt">IdentifierName</span> provided that the same sequence of code points could not replace <span
  936. class="nt">ReservedWord</span>.</p>
  937. <p>Finally, a few nonterminal symbols are described by a descriptive phrase in sans-serif type in cases where it would be
  938. impractical to list all the alternatives:</p>
  939. <div class="gp">
  940. <div class="lhs"><span class="nt">SourceCharacter</span> <span class="geq">::</span></div>
  941. <div class="rhs"><span class="gprose">any Unicode code point</span></div>
  942. </div>
  943. </section>
  944. </section>
  945. <section id="sec-algorithm-conventions">
  946. <h1><span class="secnum" id="sec-5.2"><a href="#sec-algorithm-conventions" title="link to this section">5.2</a></span>
  947. Algorithm Conventions</h1>
  948. <p>The specification often uses a numbered list to specify steps in an algorithm. These algorithms are used to precisely
  949. specify the required semantics of ECMAScript language constructs. The algorithms are not intended to imply the use of any
  950. specific implementation technique. In practice, there may be more efficient algorithms available to implement a given
  951. feature.</p>
  952. <p>Algorithms may be explicitly parameterized, in which case the names and usage of the parameters must be provided as part of
  953. the algorithm&rsquo;s definition. In order to facilitate their use in multiple parts of this specification, some algorithms,
  954. called <i>abstract</i> <i>operations</i>, are named and written in parameterized functional form so that they may be
  955. referenced by name from within other algorithms. Abstract operations are typically referenced using a functional application
  956. style such as <span style="font-family: Times New Roman">operationName(<i>arg1</i>, <i>arg2</i>)</span>. Some abstract
  957. operations are treated as polymorphically dispatched methods of class-like specification abstractions. Such method-like
  958. abstract operations are typically referenced using a method application style such as <span style="font-family: Times New
  959. Roman"><i>someValue</i>.operationName(<i>arg1</i>, <i>arg2</i>)</span>.</p>
  960. <p>Algorithms may be associated with productions of one of the ECMAScript grammars. A production that has multiple alternative
  961. definitions will typically have a distinct algorithm for each alternative. When an algorithm is associated with a grammar
  962. production, it may reference the terminal and nonterminal symbols of the production alternative as if they were parameters of
  963. the algorithm. When used in this manner, nonterminal symbols refer to the actual alternative definition that is matched when
  964. parsing the source text.</p>
  965. <p>When an algorithm is associated with a production alternative, the alternative is typically shown without any &ldquo;[
  966. ]&rdquo; grammar annotations. Such annotations should only affect the syntactic recognition of the alternative and have no
  967. effect on the associated semantics for the alternative.</p>
  968. <p>Unless explicitly specified otherwise, all <a href="#sec-context-free-grammars">chain productions</a> have an implicit
  969. definition for every algorithm that might be applied to that production&rsquo;s left-hand side nonterminal. The implicit
  970. definition simply reapplies the same algorithm name with the same parameters, if any, to the <a
  971. href="#sec-context-free-grammars">chain production</a>&rsquo;s sole right-hand side nonterminal and then returns the result.
  972. For example, assume there is a production:</p>
  973. <div class="gp">
  974. <div class="lhs"><span class="nt">Block</span> <span class="geq">:</span></div>
  975. <div class="rhs"><code class="t">{</code> <span class="nt">StatementList</span> <code class="t">}</code></div>
  976. </div>
  977. <p>but there is no corresponding Evaluation algorithm that is explicitly specified for that production. If in some algorithm
  978. there is a statement of the form: &ldquo;<span style="font-family: Times New Roman">Return the result of evaluating
  979. <i>Block</i></span>&rdquo; it is implicit that an Evaluation algorithm exists of the form:</p>
  980. <p><b>Runtime Semantics: Evaluation</b></p>
  981. <div class="gp prod"><span class="nt">Block</span> <span class="geq">:</span> <code class="t">{</code> <span class="nt">StatementList</span> <code class="t">}</code></div>
  982. <ol class="proc">
  983. <li>Return the result of evaluating <i>StatementList</i>.</li>
  984. </ol>
  985. <p>For clarity of expression, algorithm steps may be subdivided into sequential substeps. Substeps are indented and may
  986. themselves be further divided into indented substeps. Outline numbering conventions are used to identify substeps with the
  987. first level of substeps labelled with lower case alphabetic characters and the second level of substeps labelled with lower
  988. case roman numerals. If more than three levels are required these rules repeat with the fourth level using numeric labels. For
  989. example:</p>
  990. <ol class="proc">
  991. <li>Top-level step
  992. <ol class="block">
  993. <li>Substep.</li>
  994. <li>Substep.
  995. <ol class="block">
  996. <li>Subsubstep.
  997. <ol class="block">
  998. <li>Subsubsubstep
  999. <ol class="block">
  1000. <li>Subsubsubsubstep
  1001. <ol class="block">
  1002. <li>Subsubsubsubsubstep</li>
  1003. </ol>
  1004. </li>
  1005. </ol>
  1006. </li>
  1007. </ol>
  1008. </li>
  1009. </ol>
  1010. </li>
  1011. </ol>
  1012. </li>
  1013. </ol>
  1014. <p>A step or substep may be written as an &ldquo;if&rdquo; predicate that conditions its substeps. In this case, the substeps
  1015. are only applied if the predicate is true. If a step or substep begins with the word &ldquo;else&rdquo;, it is a predicate
  1016. that is the negation of the preceding &ldquo;if&rdquo; predicate step at the same level.</p>
  1017. <p>A step may specify the iterative application of its substeps.</p>
  1018. <p>A step that begins with &ldquo;Assert:&rdquo; asserts an invariant condition of its algorithm. Such assertions are used to
  1019. make explicit algorithmic invariants that would otherwise be implicit. Such assertions add no additional semantic requirements
  1020. and hence need not be checked by an implementation. They are used simply to clarify algorithms.</p>
  1021. <p>Mathematical operations such as addition, subtraction, negation, multiplication, division, and the mathematical functions
  1022. defined later in this clause should always be understood as computing exact mathematical results on mathematical real numbers,
  1023. which unless otherwise noted do not include infinities and do not include a negative zero that is distinguished from positive
  1024. zero. Algorithms in this standard that model floating-point arithmetic include explicit steps, where necessary, to handle
  1025. infinities and signed zero and to perform rounding. If a mathematical operation or function is applied to a floating-point
  1026. number, it should be understood as being applied to the exact mathematical value represented by that floating-point number;
  1027. such a floating-point number must be finite, and if it is <span class="value">+0</span> or <span class="value">&minus;0</span>
  1028. then the corresponding mathematical value is simply <span class="value">0</span>.</p>
  1029. <p>The mathematical function <span style="font-family: Times New Roman">abs(<i>x</i>)</span> produces the absolute value of
  1030. <var>x</var>, which is <span style="font-family: Times New Roman">&minus;<i>x</i></span> if <var>x</var> is negative (less
  1031. than zero) and otherwise is <var>x</var> itself.</p>
  1032. <p>The mathematical function <span style="font-family: Times New Roman">sign(<i>x</i>)</span> produces <span
  1033. style="font-family: Times New Roman">1</span> if <var>x</var> is positive and <span style="font-family: Times New
  1034. Roman">&minus;1</span> if <var>x</var> is negative. The sign function is not used in this standard for cases when <var>x</var>
  1035. is zero.</p>
  1036. <p>The mathematical function <span style="font-family: Times New Roman">min(<i>x</i><sub>1</sub>,</span> <span
  1037. style="font-family: Times New Roman"><i>x</i><sub>2</sub>, ..., <i>x</i><sub>n</sub>)</span> produces the mathematically
  1038. smallest of <span style="font-family: Times New Roman"><i>x</i><sub>1</sub></span> through <span style="font-family: Times New
  1039. Roman"><i>x</i><sub>n</sub></span>. The mathematical function <span style="font-family: Times New
  1040. Roman">max(<i>x</i><sub>1</sub>,</span> <span style="font-family: Times New Roman"><i>x</i><sub>2</sub>, ...,
  1041. <i>x</i><sub>n</sub>)</span> produces the mathematically largest of <span style="font-family: Times New
  1042. Roman"><i>x</i><sub>1</sub></span> through <span style="font-family: Times New Roman"><i>x</i><sub>n</sub></span>. The domain
  1043. and range of these mathematical functions include +<b>&infin;</b> and <b>&minus;&infin;</b>.</p>
  1044. <p>The notation &ldquo;<span style="font-family: Times New Roman"><i>x</i> modulo <i>y</i></span>&rdquo; (<var>y</var> must be
  1045. finite and nonzero) computes a value <var>k</var> of the same sign as <var>y</var> (or zero) such that <span
  1046. style="font-family: Times New Roman">abs(<i>k</i>) &lt; abs(<i>y</i>) and <i>x</i>&minus;<i>k</i> = <i>q</i></span> <span
  1047. style="font-family: Times New Roman">&times;</span> <var>y</var> for some integer <var>q</var>.</p>
  1048. <p>The mathematical function <span style="font-family: Times New Roman">floor(<i>x</i>)</span> produces the largest integer
  1049. (closest to positive infinity) that is not larger than <var>x</var>.</p>
  1050. <div class="note">
  1051. <p><span class="nh">NOTE</span> floor(<i>x</i>) = <i>x</i>&minus;(<i>x</i> modulo 1).</p>
  1052. </div>
  1053. </section>
  1054. <section id="sec-static-semantic-rules">
  1055. <h1><span class="secnum" id="sec-5.3"><a href="#sec-static-semantic-rules" title="link to this section">5.3</a></span> Static
  1056. Semantic Rules</h1>
  1057. <p>Context-free grammars are not sufficiently powerful to express all the rules that define whether a stream of input elements
  1058. form a valid ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span> that may be evaluated. In some
  1059. situations additional rules are needed that may be expressed using either ECMAScript algorithm conventions or prose
  1060. requirements. Such rules are always associated with a production of a grammar and are called the <i>static semantics</i> of
  1061. the production.</p>
  1062. <p>Static Semantic Rules have names and typically are defined using an algorithm. Named Static Semantic Rules are associated
  1063. with grammar productions and a production that has multiple alternative definitions will typically have for each alternative a
  1064. distinct algorithm for each applicable named static semantic rule.</p>
  1065. <p>Unless otherwise specified every grammar production alternative in this specification implicitly has a definition for a
  1066. static semantic rule named <span style="font-family: Times New Roman">Contains</span> which takes an argument named
  1067. <var>symbol</var> whose value is a terminal or nonterminal of the grammar that includes the associated production. The default
  1068. definition of <span style="font-family: Times New Roman">Contains</span> is:</p>
  1069. <ol class="proc">
  1070. <li>For each terminal and nonterminal grammar symbol, <i>sym</i>, in the definition of this production do
  1071. <ol class="block">
  1072. <li>If <i>sym</i> is the same grammar symbol as <i>symbol</i>, return <b>true</b>.</li>
  1073. <li>If <i>sym</i> is a nonterminal, then
  1074. <ol class="block">
  1075. <li>Let <i>contained</i> be the result of <i>sym</i> Contains <i>symbol</i>.</li>
  1076. <li>If <i>contained</i> is <b>true</b>, return <b>true</b>.</li>
  1077. </ol>
  1078. </li>
  1079. </ol>
  1080. </li>
  1081. <li>Return <b>false</b>.</li>
  1082. </ol>
  1083. <p>The above definition is explicitly over-ridden for specific productions.</p>
  1084. <p>A special kind of static semantic rule is an Early Error Rule. Early error rules define early error conditions (see <a
  1085. href="#sec-error-handling-and-language-extensions">clause 16</a>) that are associated with specific grammar productions.
  1086. Evaluation of most early error rules are not explicitly invoked within the algorithms of this specification. A conforming
  1087. implementation must, prior to the first evaluation of a <span class="nt">Script</span>, validate all of the early error rules
  1088. of the productions used to parse that <span class="nt">Script</span>. If any of the early error rules are violated the <span
  1089. class="nt">Script</span> is invalid and cannot be evaluated.</p>
  1090. </section>
  1091. </section>
  1092. <section id="sec-ecmascript-data-types-and-values">
  1093. <div class="front">
  1094. <h1><span class="secnum" id="sec-6"><a href="#sec-ecmascript-data-types-and-values" title="link to this section">6</a></span>
  1095. ECMAScript Data Types and Values</h1>
  1096. <p>Algorithms within this specification manipulate values each of which has an associated type. The possible value types are
  1097. exactly those defined in this clause. Types are further subclassified into ECMAScript language types and specification
  1098. types.</p>
  1099. <p>Within this specification, the notation &ldquo;<span style="font-family: Times New Roman">Type(<i>x</i>)</span>&rdquo; is
  1100. used as shorthand for &ldquo;<span style="font-family: Times New Roman">the type of <i>x</i></span>&rdquo; where &ldquo;<span
  1101. style="font-family: Times New Roman">type</span>&rdquo; refers to the ECMAScript language and specification types defined in
  1102. this clause. When the term &ldquo;empty&rdquo; is used as if it was naming a value, it is equivalent to saying &ldquo;no value
  1103. of any type&rdquo;.</p>
  1104. </div>
  1105. <section id="sec-ecmascript-language-types">
  1106. <div class="front">
  1107. <h1><span class="secnum" id="sec-6.1"><a href="#sec-ecmascript-language-types" title="link to this section">6.1</a></span>
  1108. ECMAScript Language Types</h1>
  1109. <p>An ECMAScript language type corresponds to values that are directly manipulated by an ECMAScript programmer using the
  1110. ECMAScript language. The ECMAScript language types are Undefined, Null, Boolean, String, Symbol, Number, and Object. An
  1111. ECMAScript language value is a value that is characterized by an ECMAScript language type.</p>
  1112. </div>
  1113. <section id="sec-ecmascript-language-types-undefined-type">
  1114. <h1><span class="secnum" id="sec-6.1.1"><a href="#sec-ecmascript-language-types-undefined-type"
  1115. title="link to this section">6.1.1</a></span> The Undefined Type</h1>
  1116. <p>The Undefined type has exactly one value, called <b>undefined</b>. Any variable that has not been assigned a value has
  1117. the value <b>undefined</b>.</p>
  1118. </section>
  1119. <section id="sec-ecmascript-language-types-null-type">
  1120. <h1><span class="secnum" id="sec-6.1.2"><a href="#sec-ecmascript-language-types-null-type"
  1121. title="link to this section">6.1.2</a></span> The Null Type</h1>
  1122. <p>The Null type has exactly one value, called <b>null</b>.</p>
  1123. </section>
  1124. <section id="sec-ecmascript-language-types-boolean-type">
  1125. <h1><span class="secnum" id="sec-6.1.3"><a href="#sec-ecmascript-language-types-boolean-type"
  1126. title="link to this section">6.1.3</a></span> The Boolean Type</h1>
  1127. <p>The Boolean type represents a logical entity having two values, called <b>true</b> and <b>false</b>.</p>
  1128. </section>
  1129. <section id="sec-ecmascript-language-types-string-type">
  1130. <h1><span class="secnum" id="sec-6.1.4"><a href="#sec-ecmascript-language-types-string-type"
  1131. title="link to this section">6.1.4</a></span> The String Type</h1>
  1132. <p>The String type is the set of all finite ordered sequences of zero or more 16-bit unsigned integer values
  1133. (&ldquo;elements&rdquo;). The String type is generally used to represent textual data in a running ECMAScript program, in
  1134. which case each element in the String is treated as a UTF-16 code unit value. Each element is regarded as occupying a
  1135. position within the sequence. These positions are indexed with nonnegative integers. The first element (if any) is at index
  1136. 0, the next element (if any) at index 1, and so on. The length of a String is the number of elements (i.e., 16-bit values)
  1137. within it. The empty String has length zero and therefore contains no elements.</p>
  1138. <p>Where ECMAScript operations interpret String values, each element is interpreted as a single UTF-16 code unit. However,
  1139. ECMAScript does not place any restrictions or requirements on the sequence of code units in a String value, so they may be
  1140. ill-formed when interpreted as UTF-16 code unit sequences. Operations that do not interpret String contents treat them as
  1141. sequences of undifferentiated 16-bit unsigned integers. The function <code><a
  1142. href="#sec-string.prototype.normalize">String.prototype.normalize</a></code> (<a href="#sec-string.prototype.normalize">see
  1143. 21.1.3.12</a>) can be used to explicitly normalize a string value. <code><a
  1144. href="#sec-string.prototype.localecompare">String.prototype.localeCompare</a></code> (<a
  1145. href="#sec-string.prototype.localecompare">see 21.1.3.10</a>) internally normalizes strings values, but no other operations
  1146. implicitly normalize the strings upon which they operate. Only operations that are explicitly specified to be language or
  1147. locale sensitive produce language-sensitive results.</p>
  1148. <div class="note">
  1149. <p><span class="nh">NOTE</span> The rationale behind this design was to keep the implementation of Strings as simple and
  1150. high-performing as possible. If ECMAScript source text is in Normalized Form C, string literals are guaranteed to also be
  1151. normalized, as long as they do not contain any Unicode escape sequences.</p>
  1152. </div>
  1153. <p>Some operations interpret String contents as UTF-16 encoded Unicode code points. In that case the interpretation is:</p>
  1154. <ul>
  1155. <li>
  1156. <p>A code unit in the range <span style="font-family: Times New Roman">0</span> to <span style="font-family: Times New
  1157. Roman">0xD7FF</span> or in the range <span style="font-family: Times New Roman">0xE000</span> to <span
  1158. style="font-family: Times New Roman">0xFFFF</span> is interpreted as a code point with the same value.</p>
  1159. </li>
  1160. <li>
  1161. <p>A sequence of two code units, where the first code unit <var>c1</var> is in the range <span style="font-family: Times
  1162. New Roman">0xD800</span> to <span style="font-family: Times New Roman">0xDBFF</span> and the second code unit
  1163. <var>c2</var> is in the range <span style="font-family: Times New Roman">0xDC00</span> to <span style="font-family:
  1164. Times New Roman">0xDFFF</span>, is a surrogate pair and is interpreted as a code point with the value (<var>c1</var> -
  1165. <span style="font-family: Times New Roman">0xD800</span>) &times; <span style="font-family: Times New
  1166. Roman">0x400</span> + (<var>c2</var> &ndash; <span style="font-family: Times New Roman">0xDC00</span>) + <span
  1167. style="font-family: Times New Roman">0x10000</span>. (See <a href="#sec-utf16decode">10.1.2</a>)</p>
  1168. </li>
  1169. <li>
  1170. <p>A code unit that is in the range <span style="font-family: Times New Roman">0xD800</span> to <span
  1171. style="font-family: Times New Roman">0xDFFF</span>, but is not part of a surrogate pair, is interpreted as a code point
  1172. with the same value.</p>
  1173. </li>
  1174. </ul>
  1175. </section>
  1176. <section id="sec-ecmascript-language-types-symbol-type">
  1177. <div class="front">
  1178. <h1><span class="secnum" id="sec-6.1.5"><a href="#sec-ecmascript-language-types-symbol-type"
  1179. title="link to this section">6.1.5</a></span> The Symbol Type</h1>
  1180. <p>The Symbol type is the set of all non-String values that may be used as the key of an Object property (<a
  1181. href="#sec-object-type">6.1.7</a>).</p>
  1182. <p>Each possible Symbol value is unique and immutable.</p>
  1183. <p>Each Symbol value immutably holds an associated value called [[Description]] that is either <span
  1184. class="value">undefined</span> or a String value.</p>
  1185. </div>
  1186. <section id="sec-well-known-symbols">
  1187. <h1><span class="secnum" id="sec-6.1.5.1"><a href="#sec-well-known-symbols"
  1188. title="link to this section">6.1.5.1</a></span> Well-Known Symbols</h1>
  1189. <p>Well-known symbols are built-in Symbol values that are explicitly referenced by algorithms of this specification. They
  1190. are typically used as the keys of properties whose values serve as extension points of a specification algorithm. Unless
  1191. otherwise specified, well-known symbols values are shared by all Code Realms (<a href="#sec-code-realms">8.2</a>).</p>
  1192. <p>Within this specification a well-known symbol is referred to by using a notation of the form @@name, where
  1193. &ldquo;name&rdquo; is one of the values listed in <a href="#table-1">Table 1</a>.</p>
  1194. <figure>
  1195. <figcaption><span id="table-1">Table 1</span>&mdash; Well-known Symbols</figcaption>
  1196. <table class="real-table">
  1197. <tr>
  1198. <th>Specification Name</th>
  1199. <th>[[Description]]</th>
  1200. <th>Value and Purpose</th>
  1201. </tr>
  1202. <tr>
  1203. <td>@@hasInstance</td>
  1204. <td><code>"Symbol.hasInstance"</code></td>
  1205. <td>A method that determines if a constructor object recognizes an object as one of the constructor&rsquo;s instances. Called by the semantics of the <code>instanceof</code> operator.</td>
  1206. </tr>
  1207. <tr>
  1208. <td>@@isConcatSpreadable</td>
  1209. <td><code>"Symbol.isConcatSpreadable"</code></td>
  1210. <td>A Boolean valued property that if true indicates that an object should be flattened to its array elements by <code><a href="#sec-array.prototype.concat">Array.prototype.concat</a></code>.</td>
  1211. </tr>
  1212. <tr>
  1213. <td>@@iterator</td>
  1214. <td><code>"Symbol.iterator"</code></td>
  1215. <td>A method that returns the default Iterator for an object. Called by the semantics of the for-of statement.</td>
  1216. </tr>
  1217. <tr>
  1218. <td>@@match</td>
  1219. <td><code>"Symbol.match"</code></td>
  1220. <td>A regular expression method that matches the regular expression against a string. Called by the <code><a href="#sec-string.prototype.match">String.prototype.match</a></code> method.</td>
  1221. </tr>
  1222. <tr>
  1223. <td>@@replace</td>
  1224. <td><code>"Symbol.replace"</code></td>
  1225. <td>A regular expression method that replaces matched substrings of a string. Called by the <code><a href="#sec-string.prototype.replace">String.prototype.replace</a></code> method.</td>
  1226. </tr>
  1227. <tr>
  1228. <td>@@search</td>
  1229. <td><code>"Symbol.search"</code></td>
  1230. <td>A regular expression method that returns the index within a string that matches the regular expression. Called by the <code><a href="#sec-string.prototype.search">String.prototype.search</a></code> method.</td>
  1231. </tr>
  1232. <tr>
  1233. <td>@@species</td>
  1234. <td><code>"Symbol.species"</code></td>
  1235. <td>A function valued property that is the constructor function that is used to create derived objects.</td>
  1236. </tr>
  1237. <tr>
  1238. <td>@@split</td>
  1239. <td><code>"Symbol.split"</code></td>
  1240. <td>A regular expression method that splits a string at the indices that match the regular expression. Called by the <code><a href="#sec-string.prototype.split">String.prototype.split</a></code> method.</td>
  1241. </tr>
  1242. <tr>
  1243. <td>@@toPrimitive</td>
  1244. <td><code>"Symbol.toPrimitive"</code></td>
  1245. <td>A method that converts an object to a corresponding primitive value. Called by the <a href="#sec-toprimitive">ToPrimitive</a> abstract operation.</td>
  1246. </tr>
  1247. <tr>
  1248. <td>@@toStringTag</td>
  1249. <td><code>"Symbol.toStringTag"</code></td>
  1250. <td>A String valued property that is used in the creation of the default string description of an object. Accessed by the built-in method <code><a href="#sec-object.prototype.tostring">Object.prototype.toString</a></code>.</td>
  1251. </tr>
  1252. <tr>
  1253. <td>@@unscopables</td>
  1254. <td><code>"Symbol.unscopables"</code></td>
  1255. <td>An object valued property whose own property names are property names that are excluded from the <code>with</code> environment bindings of the associated object.</td>
  1256. </tr>
  1257. </table>
  1258. </figure>
  1259. </section>
  1260. </section>
  1261. <section id="sec-ecmascript-language-types-number-type">
  1262. <h1><span class="secnum" id="sec-6.1.6"><a href="#sec-ecmascript-language-types-number-type"
  1263. title="link to this section">6.1.6</a></span> The Number Type</h1>
  1264. <p>The Number type has exactly <span style="font-family: Times New Roman">18437736874454810627</span> (that is, <span
  1265. style="font-family: Times New Roman">2<sup>64</sup>&minus;2<sup>53</sup>+3</span>) values, representing the double-precision
  1266. 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic, except that the <span
  1267. style="font-family: Times New Roman">9007199254740990</span> (that is, <span style="font-family: Times New
  1268. Roman">2<sup>53</sup>&minus;2</span>) distinct &ldquo;Not-a-Number&rdquo; values of the IEEE Standard are represented in
  1269. ECMAScript as a single special <b>NaN</b> value. (Note that the <b>NaN</b> value is produced by the program expression
  1270. <code>NaN</code>.) In some implementations, external code might be able to detect a difference between various Not-a-Number
  1271. values, but such behaviour is implementation-dependent; to ECMAScript code, all NaN values are indistinguishable from each
  1272. other.</p>
  1273. <div class="note">
  1274. <p><span class="nh">NOTE</span> The bit pattern that might be observed in an ArrayBuffer (<a
  1275. href="#sec-arraybuffer-objects">see 24.1</a>) after a Number value has been stored into it is not necessarily the same as
  1276. the internal representation of that Number value used by the ECMAScript implementation.</p>
  1277. </div>
  1278. <p>There are two other special values, called <b>positive Infinity</b> and <b>negative Infinity</b>. For brevity, these
  1279. values are also referred to for expository purposes by the symbols <span class="value">+&infin;</span> and <span
  1280. class="value">&minus;&infin;</span>, respectively. (Note that these two infinite Number values are produced by the program
  1281. expressions <code>+Infinity</code> (or simply <code>Infinity</code>) and <code>-Infinity</code>.)</p>
  1282. <p>The other <span style="font-family: Times New Roman">18437736874454810624</span> (that is, <span style="font-family:
  1283. Times New Roman">2<sup>64</sup>&minus;2<sup>53</sup></span>) values are called the finite numbers. Half of these are
  1284. positive numbers and half are negative numbers; for every finite positive Number value there is a corresponding negative
  1285. value having the same magnitude.</p>
  1286. <p>Note that there is both a <b>positive zero</b> and a <b>negative zero</b>. For brevity, these values are also referred to
  1287. for expository purposes by the symbols <span class="value">+0</span> and <span class="value">&minus;0</span>, respectively.
  1288. (Note that these two different zero Number values are produced by the program expressions <code>+0</code> (or simply
  1289. <code>0</code>) and <code>-0</code>.)</p>
  1290. <p>The <span style="font-family: Times New Roman">18437736874454810622</span> (that is, <span style="font-family: Times New
  1291. Roman">2<sup>64</sup>&minus;2<sup>53</sup>&minus;2</span>) finite nonzero values are of two kinds:</p>
  1292. <p><span style="font-family: Times New Roman">18428729675200069632</span> (that is, <span style="font-family: Times New
  1293. Roman">2<sup>64</sup>&minus;2<sup>54</sup></span>) of them are normalized, having the form</p>
  1294. <div class="math-display"><i>s</i> &times; <i>m</i> &times; 2<sup><i>e</i></sup></div>
  1295. <p>where <var>s</var> is <span style="font-family: Times New Roman">+1</span> or <span style="font-family: Times New
  1296. Roman">&minus;1</span>, <var>m</var> is a positive integer less than <span style="font-family: Times New
  1297. Roman">2<sup>53</sup></span> but not less than <span style="font-family: Times New Roman">2<sup>52</sup></span>, and
  1298. <var>e</var> is an integer ranging from <span style="font-family: Times New Roman">&minus;1074</span> to <span
  1299. style="font-family: Times New Roman">971</span>, inclusive.</p>
  1300. <p>The remaining <span style="font-family: Times New Roman">9007199254740990</span> (that is, <span style="font-family:
  1301. Times New Roman">2<sup>53</sup>&minus;2</span>) values are denormalized, having the form</p>
  1302. <div class="math-display"><i>s</i> &times; <i>m</i> &times; 2<sup><i>e</i></sup></div>
  1303. <p>where <var>s</var> is <span style="font-family: Times New Roman">+1</span> or <span style="font-family: Times New
  1304. Roman">&minus;1</span>, <var>m</var> is a positive integer less than <span style="font-family: Times New
  1305. Roman">2<sup>52</sup></span>, and <var>e</var> is <span style="font-family: Times New Roman">&minus;1074</span>.</p>
  1306. <p>Note that all the positive and negative integers whose magnitude is no greater than <span style="font-family: Times New
  1307. Roman">2<sup>53</sup></span> are representable in the Number type (indeed, the integer <span style="font-family: Times New
  1308. Roman">0</span> has two representations, <code>+0</code> and <code>-0</code>).</p>
  1309. <p>A finite number has an <i>odd significand</i> if it is nonzero and the integer <var>m</var> used to express it (in one of
  1310. the two forms shown above) is odd. Otherwise, it has an <i>even significand</i>.</p>
  1311. <p>In this specification, the phrase &ldquo;<span style="font-family: Times New Roman">the Number value for
  1312. <i>x</i></span>&rdquo; where <var>x</var> represents an exact nonzero real mathematical quantity (which might even be an
  1313. irrational number such as <span style="font-family: Times New Roman">&pi;</span>) means a Number value chosen in the
  1314. following manner. Consider the set of all finite values of the Number type, with <span class="value">&minus;0</span> removed
  1315. and with two additional values added to it that are not representable in the Number type, namely <span style="font-family:
  1316. Times New Roman">2<sup>1024</sup></span> (which is <span style="font-family: Times New Roman">+1 &times;
  1317. 2<sup>53</sup></span> <span style="font-family: Times New Roman">&times; 2<sup>971</sup></span>) and <span
  1318. style="font-family: Times New Roman">&minus;2<sup>1024</sup></span> (which is <span style="font-family: Times New
  1319. Roman">&minus;1 &times; 2<sup>53</sup></span> <span style="font-family: Times New Roman">&times; 2<sup>971</sup></span>).
  1320. Choose the member of this set that is closest in value to <var>x</var>. If two values of the set are equally close, then the
  1321. one with an even significand is chosen; for this purpose, the two extra values <span style="font-family: Times New
  1322. Roman">2<sup>1024</sup></span> and <span style="font-family: Times New Roman">&minus;2<sup>1024</sup></span> are considered
  1323. to have even significands. Finally, if <span style="font-family: Times New Roman">2<sup>1024</sup></span> was chosen,
  1324. replace it with <span class="value">+&infin;</span>; if <span style="font-family: Times New
  1325. Roman">&minus;2<sup>1024</sup></span> was chosen, replace it with <span class="value">&minus;&infin;</span>; if <span
  1326. class="value">+0</span> was chosen, replace it with <span class="value">&minus;0</span> if and only if <var>x</var> is less
  1327. than zero; any other chosen value is used unchanged. The result is the Number value for <var>x</var>. (This procedure
  1328. corresponds exactly to the behaviour of the IEEE 754 &ldquo;round to nearest, ties to even&rdquo; mode.)</p>
  1329. <p>Some ECMAScript operators deal only with integers in specific ranges such as <span style="font-family: Times New
  1330. Roman">&minus;2<sup>31</sup></span> through <span style="font-family: Times New Roman">2<sup>31</sup>&minus;1</span>,
  1331. inclusive, or in the range <span style="font-family: Times New Roman">0</span> through <span style="font-family: Times New
  1332. Roman">2<sup>16</sup>&minus;1</span>, inclusive. These operators accept any value of the Number type but first convert each
  1333. such value to an integer value in the expected range. See the descriptions of the numeric conversion operations in <a
  1334. href="#sec-type-conversion">7.1</a>.</p>
  1335. </section>
  1336. <section id="sec-object-type">
  1337. <div class="front">
  1338. <h1><span class="secnum" id="sec-6.1.7"><a href="#sec-object-type" title="link to this section">6.1.7</a></span> The
  1339. Object Type</h1>
  1340. <p>An Object is logically a collection of properties. Each property is either a data property, or an accessor
  1341. property:</p>
  1342. <ul>
  1343. <li>
  1344. <p>A <i>data property</i> associates a key value with an <a href="#sec-ecmascript-language-types">ECMAScript language
  1345. value</a> and a set of Boolean attributes.</p>
  1346. </li>
  1347. <li>
  1348. <p>An <i>accessor property</i> associates a key value with one or two accessor functions, and a set of Boolean
  1349. attributes. The accessor functions are used to store or retrieve an <a
  1350. href="#sec-ecmascript-language-types">ECMAScript language value</a> that is associated with the property.</p>
  1351. </li>
  1352. </ul>
  1353. <p>Properties are identified using key values. A property key value is either an ECMAScript String value or a Symbol
  1354. value. All String and Symbol values, including the empty string, are valid as property keys. A <i>property name</i> is a
  1355. property key that is a String value.</p>
  1356. <p>An <i>integer index</i> is a String-valued property key that is a canonical numeric String (<a
  1357. href="#sec-canonicalnumericindexstring">see 7.1.16</a>) and whose numeric value is either <span style="font-family: Times
  1358. New Roman">+0</span> or a positive integer &le; 2<sup>53</sup>&minus;1. An <i>array index</i> is an integer index whose
  1359. numeric value <var>i</var> is in the range <span style="font-family: Times New Roman">+0 &le; <i>i</i></span> <span
  1360. style="font-family: Times New Roman">&lt; 2<sup>32</sup>&minus;1.</span></p>
  1361. <p>Property keys are used to access properties and their values. There are two kinds of access for properties: <i>get</i>
  1362. and <i>set</i>, corresponding to value retrieval and assignment, respectively. The properties accessible via get and set
  1363. access includes both <i>own properties</i> that are a direct part of an object and <i>inherited properties</i> which are
  1364. provided by another associated object via a property inheritance relationship. Inherited properties may be either own or
  1365. inherited properties of the associated object. Each own property of an object must each have a key value that is distinct
  1366. from the key values of the other own properties of that object.</p>
  1367. <p>All objects are logically collections of properties, but there are multiple forms of objects that differ in their
  1368. semantics for accessing and manipulating their properties. O<i>rdinary objects</i> are the most common form of objects and
  1369. have the default object semantics. An <i>exotic object</i> is any form of object whose property semantics differ in any
  1370. way from the default semantics.</p>
  1371. </div>
  1372. <section id="sec-property-attributes">
  1373. <h1><span class="secnum" id="sec-6.1.7.1"><a href="#sec-property-attributes"
  1374. title="link to this section">6.1.7.1</a></span> Property Attributes</h1>
  1375. <p>Attributes are used in this specification to define and explain the state of Object properties. A data property
  1376. associates a key value with the attributes listed in <a href="#table-2">Table 2</a>.</p>
  1377. <figure>
  1378. <figcaption><span id="table-2">Table 2</span> &mdash; Attributes of a Data Property</figcaption>
  1379. <table class="real-table">
  1380. <tr>
  1381. <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Attribute Name</th>
  1382. <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Value Domain</th>
  1383. <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Description</th>
  1384. </tr>
  1385. <tr>
  1386. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Value]]</td>
  1387. <td style="border-bottom: 1px solid black; border-right: 1px solid black">Any <a href="#sec-ecmascript-language-types">ECMAScript language type</a></td>
  1388. <td style="border-bottom: 1px solid black; border-right: 1px solid black">The value retrieved by a get access of the property.</td>
  1389. </tr>
  1390. <tr>
  1391. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Writable]]</td>
  1392. <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
  1393. <td style="border-bottom: 1px solid black; border-right: 1px solid black">If <b>false</b>, attempts by ECMAScript code to change the property&rsquo;s [[Value]] attribute using [[Set]] will not succeed.</td>
  1394. </tr>
  1395. <tr>
  1396. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Enumerable]]</td>
  1397. <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
  1398. <td style="border-bottom: 1px solid black; border-right: 1px solid black">If <b>true</b>, the property will be enumerated by a for-in enumeration (<a href="#sec-for-in-and-for-of-statements">see 13.6.4</a>). Otherwise, the property is said to be non-enumerable.</td>
  1399. </tr>
  1400. <tr>
  1401. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Configurable]]</td>
  1402. <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
  1403. <td style="border-bottom: 1px solid black; border-right: 1px solid black">If <b>false</b>, attempts to delete the property, change the property to be an accessor property, or change its attributes (other than [[Value]], or changing [[Writable]] to <b>false</b>) will fail.</td>
  1404. </tr>
  1405. </table>
  1406. </figure>
  1407. <p>An accessor property associates a key value with the attributes listed in <a href="#table-3">Table 3</a>.</p>
  1408. <figure>
  1409. <figcaption><span id="table-3">Table 3</span> &mdash; Attributes of an Accessor Property</figcaption>
  1410. <table class="real-table">
  1411. <tr>
  1412. <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Attribute Name</th>
  1413. <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Value Domain</th>
  1414. <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Description</th>
  1415. </tr>
  1416. <tr>
  1417. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000">[[Get]]</td>
  1418. <td style="border-bottom: 1px solid black; border-right: 1px solid black">Object <i>or</i> Undefined</td>
  1419. <td style="border-bottom: 1px solid black; border-right: 1px solid black">If the value is an Object it must be a function Object. The function&rsquo;s [[Call]] internal method (<a href="#table-6">Table 6</a>) is called with an empty arguments list to retrieve the property value each time a get access of the property is performed.</td>
  1420. </tr>
  1421. <tr>
  1422. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Set]]</td>
  1423. <td style="border-bottom: 1px solid black; border-right: 1px solid black">Object <i>or</i> Undefined</td>
  1424. <td style="border-bottom: 1px solid black; border-right: 1px solid black">If the value is an Object it must be a function Object. The function&rsquo;s [[Call]] internal method (<a href="#table-6">Table 6</a>) is called with an arguments list containing the assigned value as its sole argument each time a set access of the property is performed. The effect of a property's [[Set]] internal method may, but is not required to, have an effect on the value returned by subsequent calls to the property's [[Get]] internal method.</td>
  1425. </tr>
  1426. <tr>
  1427. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Enumerable]]</td>
  1428. <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
  1429. <td style="border-bottom: 1px solid black; border-right: 1px solid black">If <b>true</b>, the property is to be enumerated by a for-in enumeration (<a href="#sec-for-in-and-for-of-statements">see 13.6.4</a>). Otherwise, the property is said to be non-enumerable.</td>
  1430. </tr>
  1431. <tr>
  1432. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Configurable]]</td>
  1433. <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
  1434. <td style="border-bottom: 1px solid black; border-right: 1px solid black">If <b>false</b>, attempts to delete the property, change the property to be a data property, or change its attributes will fail.</td>
  1435. </tr>
  1436. </table>
  1437. </figure>
  1438. <p>If the initial values of a property&rsquo;s attributes are not explicitly specified by this specification, the default
  1439. value defined in <a href="#table-4">Table 4</a> is used.</p>
  1440. <figure>
  1441. <figcaption><span id="table-4">Table 4</span> &mdash; Default Attribute Values</figcaption>
  1442. <table class="real-table">
  1443. <tr>
  1444. <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Attribute Name</th>
  1445. <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Default Value</th>
  1446. </tr>
  1447. <tr>
  1448. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Value]]</td>
  1449. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black"><b>undefined</b></td>
  1450. </tr>
  1451. <tr>
  1452. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000">[[Get]]</td>
  1453. <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>undefined</b></td>
  1454. </tr>
  1455. <tr>
  1456. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Set]]</td>
  1457. <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>undefined</b></td>
  1458. </tr>
  1459. <tr>
  1460. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Writable]]</td>
  1461. <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
  1462. </tr>
  1463. <tr>
  1464. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Enumerable]]</td>
  1465. <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
  1466. </tr>
  1467. <tr>
  1468. <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Configurable]]</td>
  1469. <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
  1470. </tr>
  1471. </table>
  1472. </figure>
  1473. </section>
  1474. <section id="sec-object-internal-methods-and-internal-slots">
  1475. <h1><span class="secnum" id="sec-6.1.7.2"><a href="#sec-object-internal-methods-and-internal-slots"
  1476. title="link to this section">6.1.7.2</a></span> Object Internal Methods and Internal Slots</h1>
  1477. <p>The actual semantics of objects, in ECMAScript, are specified via algorithms called <i>internal methods</i>. Each
  1478. object in an ECMAScript engine is associated with a set of internal methods that defines its runtime behaviour. These
  1479. internal methods are not part of the ECMAScript language. They are defined by this specification purely for expository
  1480. purposes. However, each object within an implementation of ECMAScript must behave as specified by the internal methods
  1481. associated with it. The exact manner in which this is accomplished is determined by the implementation.</p>
  1482. <p>Internal method names are polymorphic. This means that different object values may perform different algorithms when a
  1483. common internal method name is invoked upon them. That actual object upon which an internal method is invoked is the
  1484. &ldquo;target&rdquo; of the invocation. If, at runtime, the implementation of an algorithm attempts to use an internal
  1485. method of an object that the object does not support, a <b>TypeError</b> exception is thrown.</p>
  1486. <p>Internal slots correspond to internal state that is associated with objects and used by various ECMAScript
  1487. specification algorithms. Internal slots are not object properties and they are not inherited. Depending upon the specific
  1488. internal slot specification, such state may consist of values of any <a href="#sec-ecmascript-language-types">ECMAScript
  1489. language type</a> or of specific ECMAScript specification type values. Unless explicitly specified otherwise, internal
  1490. slots are allocated as part of the process of creating an object and may not be dynamically added to an object. Unless
  1491. specified otherwise, the initial value of an internal slot is the value <span class="value">undefined</span>. Various
  1492. algorithms within this specification create objects that have internal slots. However, the ECMAScript language provides no
  1493. direct way to associate internal slots with an object.</p>
  1494. <p>Internal methods and internal slots are identified within this specification using names enclosed in double square
  1495. brackets [[ ]].</p>
  1496. <p><a href="#table-5">Table 5</a> summarizes the <i>essential internal methods</i> used by this specification that are
  1497. applicable to all objects created or manipulated by ECMAScript code. Every object must have algorithms for all of the
  1498. essential internal methods. However, all objects do not necessarily use the same algorithms for those methods.</p>
  1499. <p>The &ldquo;Signature&rdquo; column of <a href="#table-5">Table 5</a> and other similar tables describes the invocation
  1500. pattern for each internal method. The invocation pattern always includes a parenthesized list of descriptive parameter
  1501. names. If a parameter name is the same as an ECMAScript type name then the name describes the required type of the
  1502. parameter value. If an internal method explicitly returns a value, its parameter list is followed by the symbol
  1503. &ldquo;&rarr;&rdquo; and the type name of the returned value. The type names used in signatures refer to the types defined
  1504. in <a href="#sec-ecmascript-data-types-and-values">clause 6</a> augmented by the following additional names.
  1505. &ldquo;<i>any</i>&rdquo; means the value may be any <a href="#sec-ecmascript-language-types">ECMAScript language type</a>.
  1506. An internal method implicitly returns a <a href="#sec-completion-record-specification-type">Completion Record</a> as
  1507. described in <a href="#sec-completion-record-specification-type">6.2.2</a>. In addition to its parameters, an internal
  1508. method always has access to the object that is the target of the method invocation.</p>
  1509. <figure>
  1510. <figcaption><span id="table-5">Table 5</span> &mdash; Essential Internal Methods</figcaption>
  1511. <table class="real-table">
  1512. <tr>
  1513. <th>Internal Method</th>
  1514. <th>Signature</th>
  1515. <th>Description</th>
  1516. </tr>
  1517. <tr>
  1518. <td>[[GetPrototypeOf]]</td>
  1519. <td>() <b><i>&rarr;</i></b> Object or Null</td>
  1520. <td>Determine the object that provides inherited properties for this object. A <b>null</b> value indicates that there are no inherited properties.</td>
  1521. </tr>
  1522. <tr>
  1523. <td>[[SetPrototypeOf]]</td>
  1524. <td>(<i>Object</i> or Null) <b><i>&rarr;</i></b> Boolean</td>
  1525. <td>Associate with this object another object that provides inherited properties. Passing <b>null</b> indicates that there are no inherited properties. Returns <b>true</b> indicating that the operation was completed successfully or <b>false</b> indicating that the operation was not successful.</td>
  1526. </tr>
  1527. <tr>
  1528. <td>[[IsExtensible]]</td>
  1529. <td>( ) <b><i>&rarr;</i></b> Boolean</td>
  1530. <td>Determine whether it is permitted to add additional properties to this object.</td>
  1531. </tr>
  1532. <tr>
  1533. <td>[[PreventExtensions]]</td>
  1534. <td>( ) <b><i>&rarr;</i></b> Boolean</td>
  1535. <td>Control whether new properties may be added to this object. Returns <b>true</b> if the operation was successful or <b>false</b> if the operation was unsuccessful.</td>
  1536. </tr>
  1537. <tr>
  1538. <td>[[GetOwnProperty]]</td>
  1539. <td>(<i>propertyKey</i>) &rarr; Undefined or <a href="#sec-property-descriptor-specification-type">Property Descriptor</a></td>
  1540. <td>Return a <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> for the own property of this object whose key is <i>propertyKey</i>, or <b>undefined</b> if no such property exists.</td>
  1541. </tr>
  1542. <tr>
  1543. <td>[[HasProperty]]</td>
  1544. <td>(<i>propertyKey</i>) <b><i>&rarr;</i></b> Boolean</td>
  1545. <td>Return a Boolean value indicating whether this object already has either an own or inherited property whose key is <i>propertyKey</i>.</td>
  1546. </tr>
  1547. <tr>
  1548. <td>[[Get]]</td>
  1549. <td>(<i>propertyKey</i>, <i>Receiver</i>) <i><b>&rarr;</b> any</i></td>
  1550. <td>Return the value of the property whose key is <i>propertyKey</i> from this object. If any ECMAScript code must be executed to retrieve the property value, <i>Receiver</i> is used as the <b>this</b> value when evaluating the code.</td>
  1551. </tr>
  1552. <tr>
  1553. <td>[[Set]]</td>
  1554. <td>(<i>propertyKey</i>,<i>value</i>, <i>Receiver</i>) <br><i><b>&rarr;</b> Boolean</i></td>
  1555. <td>Set the value of this object property whose key is <i>propertyKey</i> to <i>value</i>. If any ECMAScript code must be executed to set the property value, <i>Receiver</i> is used as the <b>this</b> value when evaluating the code. Returns <b>true</b> if that the property value was set or <b>false</b> if that it could not be set.</td>
  1556. </tr>
  1557. <tr>
  1558. <td>[[Delete]]</td>
  1559. <td>(<i>propertyKey</i>) <b><i>&rarr;</i></b> Boolean</td>
  1560. <td>Remove the own property whose key is <i>propertyKey</i> from this object . Return <span class="value">false</span> if the property was not deleted and is still present. Return <span class="value">true</span> if the property was deleted or is not present.</td>
  1561. </tr>
  1562. <tr>
  1563. <td>[[DefineOwnProperty]]</td>
  1564. <td>(<i>propertyKey,PropertyDescriptor</i>)<b><i><br>&rarr;</i></b> Boolean</td>
  1565. <td>Create or alter the own property, whose key is <i>propertyKey</i>, to have the state described by <i>PropertyDescriptor</i>. Return <span class="value">true</span> if that the property was successfully created/updated or <span class="value">false</span> if the property could not be created or updated.</td>
  1566. </tr>
  1567. <tr>
  1568. <td>[[Enumerate]]</td>
  1569. <td>()<b><i>&rarr;</i></b>Object</td>
  1570. <td>Return an iterator object that produces the keys of the string-keyed enumerable properties of the object.</td>
  1571. </tr>
  1572. <tr>
  1573. <td>[[OwnPropertyKeys]]</td>
  1574. <td>()<b><i>&rarr;</i></b><a href="#sec-list-and-record-specification-type">List</a> of propertyKey</td>
  1575. <td>Return a <a href="#sec-list-and-record-specification-type">List</a> whose elements are all of the own property keys for the object.</td>
  1576. </tr>
  1577. </table>
  1578. </figure>
  1579. <p><a href="#table-6">Table 6</a> summarizes additional essential internal methods that are supported by objects that may
  1580. be called as functions. A <i>function object</i> is an object that supports the [[Call]] internal methods. A
  1581. <i>constructor</i> (also referred to as a <i>constructor function</i>) is a function object that supports the
  1582. [[Construct]] internal method.</p>
  1583. <figure>
  1584. <figcaption><span id="table-6">Table 6</span> &mdash; Additional Essential Internal Methods of Function Objects</figcaption>
  1585. <table class="real-table">
  1586. <tr>
  1587. <th>Internal Method</th>
  1588. <th>Signature</th>
  1589. <th>Description</th>
  1590. </tr>
  1591. <tr>
  1592. <td>[[Call]]</td>
  1593. <td>(<i>any</i>, a <a href="#sec-list-and-record-specification-type">List</a> of <i>any</i>)<br><span style="font-family: Times New Roman"><b><i>&rarr;</i></b></span> <i>any</i></td>
  1594. <td>Executes code associated with this object. Invoked via a function call expression. The arguments to the internal method are a <b>this</b> value and a list containing the arguments passed to the function by a call expression. Objects that implement this internal method are <i>callable</i>.</td>
  1595. </tr>
  1596. <tr>
  1597. <td>[[Construct]]</td>
  1598. <td>(a <a href="#sec-list-and-record-specification-type">List</a> of <i>any</i>, Object)<br><span style="font-family: Times New Roman"><b><i>&rarr;</i></b></span> Object</td>
  1599. <td>Creates an object. Invoked via the <code>new</code> or <code>super</code> operators. The first arguments to the internal method is a list containing the arguments of the operator. The second argument is the object to which the <code>new</code> operator was initially applied. Objects that implement this internal method are called <i>constructors</i>. A Function object is not necessarily a constructor and such non-constructor Function objects do not have a [[Construct]] internal method.</td>
  1600. </tr>
  1601. </table>
  1602. </figure>
  1603. <p>The semantics of the essential internal methods for ordinary objects and standard exotic objects are specified in <a
  1604. href="#sec-ordinary-and-exotic-objects-behaviours">clause 9</a>. If any specified use of an internal method of an exotic
  1605. object is not supported by an implementation, that usage must throw a <b>TypeError</b> exception when attempted.</p>
  1606. </section>
  1607. <section id="sec-invariants-of-the-essential-internal-methods">
  1608. <h1><span class="secnum" id="sec-6.1.7.3"><a href="#sec-invariants-of-the-essential-internal-methods"
  1609. title="link to this section">6.1.7.3</a></span> Invariants of the Essential Internal Methods</h1>
  1610. <p>The Internal Methods of Objects of an ECMAScript engine must conform to the list of invariants specified below.
  1611. Ordinary ECMAScript Objects as well as all standard exotic objects in this specification maintain these invariants.
  1612. ECMAScript Proxy objects maintain these invariants by means of runtime checks on the result of traps invoked on the
  1613. [[ProxyHandler]] object.</p>
  1614. <p>Any implementation provided exotic objects must also maintain these invariants for those objects. Violation of these
  1615. invariants may cause ECMAScript code to have unpredictable behaviour and create security issues. However, violation of
  1616. these invariants must never compromise the memory safety of an implementation.</p>
  1617. <p>An implementation must not allow these invariants to be circumvented in any manner such as by providing alternative
  1618. interfaces that implement the functionality of the essential internal methods without enforcing their invariants.</p>
  1619. <p>Definitions:</p>
  1620. <p>&#x25cf;&emsp;The <i>target</i> of an internal method is the object upon which the internal method is called.</p>
  1621. <p>&#x25cf;&emsp;A target is <i>non-extensible</i> if it has been observed to return false from its [[IsExtensible]]
  1622. internal method, or true from its [[PreventExtensions]] internal method.</p>
  1623. <p>&#x25cf;&emsp;A <i>non-existent</i> property is a property that does not exist as an own property on a non-extensible
  1624. target.</p>
  1625. <p>&#x25cf;&emsp;All references to <i><a href="#sec-samevalue">SameValue</a></i> are according to the definition of <a
  1626. href="#sec-samevalue">SameValue</a> algorithm specified in <a href="#sec-samevalue">7.2.9</a>.</p>
  1627. <p><b>[[GetPrototypeOf]] ( )</b></p>
  1628. <p>&#x25cf;&emsp;The Type of the return value must be either Object or Null.</p>
  1629. <p>&#x25cf;&emsp;If target is non-extensible, and [[GetPrototypeOf]] returns a value v, then any future calls to
  1630. [[GetPrototypeOf]] should return the <a href="#sec-samevalue">SameValue</a> as v.</p>
  1631. <div class="note">
  1632. <p><span class="nh">NOTE</span> An object&rsquo;s prototype chain should have finite length (that is, starting from any
  1633. object, recursively applying the [[GetPrototypeOf]] internal method to its result should eventually lead to the value
  1634. null). However, this requirement is not enforceable as an object level invariant if the prototype chain includes any
  1635. exotic objects that do not use the ordinary object definition of [[GetPrototypeOf]]. Such a circular prototype chain may
  1636. result in infinite loops when accessing object properties.</p>
  1637. </div>
  1638. <p><b>[[SetPrototypeOf]] (V)</b></p>
  1639. <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
  1640. <p>&#x25cf;&emsp;If target is non-extensible, [[SetPrototypeOf]] must return false, unless V is the <a
  1641. href="#sec-samevalue">SameValue</a> as the target&rsquo;s observed [[GetPrototypeOf]] value.</p>
  1642. <p><b>[[PreventExtensions]] ( )</b></p>
  1643. <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
  1644. <p>&#x25cf;&emsp;If [[PreventExtensions]] returns true, all future calls to [[IsExtensible]] on the target must return
  1645. false and the target is now considered non-extensible.</p>
  1646. <p><b>[[GetOwnProperty]] (P)</b></p>
  1647. <p>&#x25cf;&emsp;The Type of the return value must be either <a
  1648. href="#sec-property-descriptor-specification-type">Property Descriptor</a> or Undefined.</p>
  1649. <p>&#x25cf;&emsp;If the Type of the return value is <a href="#sec-property-descriptor-specification-type">Property
  1650. Descriptor</a>, the return value must be a complete property descriptor (<a href="#sec-completepropertydescriptor">see
  1651. 6.2.4.6</a>).</p>
  1652. <p>&#x25cf;&emsp;If a property P is described as a data property with Desc.[[Value]] equal to v and Desc.[[Writable]] and
  1653. Desc.[[Configurable]] are both false, then the <a href="#sec-samevalue">SameValue</a> must be returned for the
  1654. Desc.[[Value]] attribute of the property on all future calls to [[GetOwnProperty]] ( P ).</p>
  1655. <p>&#x25cf;&emsp;If P&rsquo;s attributes other than [[Writable]] may change over time or if the property might disappear,
  1656. then P&rsquo;s [[Configurable]] attribute must be true.</p>
  1657. <p>&#x25cf;&emsp;If the [[Writable]] attribute may change from false to true, then the [[Configurable]] attribute must be
  1658. true.</p>
  1659. <p>&#x25cf;&emsp;If the target is non-extensible and P is non-existent, then all future calls to [[GetOwnProperty]] (P)
  1660. on the target must describe P as non-existent (i.e. [[GetOwnProperty]] (P) must return undefined).</p>
  1661. <div class="note">
  1662. <p><span class="nh">NOTE</span> As a consequence of the third invariant, if a property is described as a data property
  1663. and it may return different values over time, then either or both of the Desc.[[Writable]] and Desc.[[Configurable]]
  1664. attributes must be true even if no mechanism to change the value is exposed via the other internal methods.</p>
  1665. </div>
  1666. <p><b>[[DefineOwnProperty]] (P, Desc)</b></p>
  1667. <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
  1668. <p>&#x25cf;&emsp;[[DefineOwnProperty]] must return false if P has previously been observed as a non-configurable own
  1669. property of the target, unless either:</p>
  1670. <p>1.&#x9;P is a non-configurable writable own data property. A non-configurable writable data property can be changed
  1671. into a non-configurable non-writable data property.</p>
  1672. <p>2.&#x9;All attributes in Desc are the <a href="#sec-samevalue">SameValue</a> as P&rsquo;s attributes.</p>
  1673. <p>&#x25cf;&emsp;[[DefineOwnProperty]] (P, Desc) must return false if target is non-extensible and P is a non-existent own
  1674. property. That is, a non-extensible target object cannot be extended with new properties.</p>
  1675. <p><b>[[HasProperty]] ( P )</b></p>
  1676. <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
  1677. <p>&#x25cf;&emsp;If P was previously observed as a non-configurable data or accessor own property of the target,
  1678. [[HasProperty]] must return true.</p>
  1679. <p><b>[[Get]] (P, Receiver)</b></p>
  1680. <p>&#x25cf;&emsp;If P was previously observed as a non-configurable, non-writable own data property of the target with
  1681. value v, then [[Get]] must return the <a href="#sec-samevalue">SameValue</a>.</p>
  1682. <p>&#x25cf;&emsp;If P was previously observed as a non-configurable own accessor property of the target whose [[Get]]
  1683. attribute is undefined, the [[Get]] operation must return undefined.</p>
  1684. <p><b>[[Set]] ( P, V, Receiver)</b></p>
  1685. <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
  1686. <p>&#x25cf;&emsp;If P was previously observed as a non-configurable, non-writable own data property of the target, then
  1687. [[Set]] must return false unless V is the <a href="#sec-samevalue">SameValue</a> as P&rsquo;s [[Value]] attribute.</p>
  1688. <p>&#x25cf;&emsp;If P was previously observed as a non-configurable own accessor property of the target whose [[Set]]
  1689. attribute is undefined, the [[Set]] operation must return false.</p>
  1690. <p><b>[[Delete]] ( P )</b></p>
  1691. <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
  1692. <p>&#x25cf;&emsp;If P was previously observed to be a non-configurable own data or accessor property of the target,
  1693. [[Delete]] must return false.</p>
  1694. <p><b>[[Enumerate]] ( )</b></p>
  1695. <p>&#x25cf;&emsp;The Type of the return value must be Object.</p>
  1696. <p><b>[[OwnPropertyKeys]] ( )</b></p>
  1697. <p>&#x25cf;&emsp;The return value must be a <a href="#sec-list-and-record-specification-type">List</a>.</p>
  1698. <p>&#x25cf;&emsp; The Type of each element of the returned <a href="#sec-list-and-record-specification-type">List</a> is
  1699. either String or Symbol.</p>
  1700. <p>&#x25cf;&emsp;The returned <a href="#sec-list-and-record-specification-type">List</a> must contain at least the keys of
  1701. all non-configurable own properties that have previously been observed.</p>
  1702. <p>&#x25cf;&emsp;If the object is non-extensible, the returned <a href="#sec-list-and-record-specification-type">List</a>
  1703. must contain only the keys of all own properties of the object that are observable using [[GetOwnProperty]].</p>
  1704. <p><b>[[Construct]] ( )</b></p>
  1705. <p>&#x25cf;&emsp;The Type of the return value must be Object.</p>
  1706. </section>
  1707. <section id="sec-well-known-intrinsic-objects">
  1708. <h1><span class="secnum" id="sec-6.1.7.4"><a href="#sec-well-known-intrinsic-objects"
  1709. title="link to this section">6.1.7.4</a></span> Well-Known Intrinsic Objects</h1>
  1710. <p>Well-known intrinsics are built-in objects that are explicitly referenced by the algorithms of this specification and
  1711. which usually have <a href="#sec-code-realms">Realm</a> specific identities. Unless otherwise specified each intrinsic
  1712. object actually corresponds to a set of similar objects, one per <a href="#sec-code-realms">Realm</a>.</p>
  1713. <p>Within this specification a reference such as %name% means the intrinsic object, associated with <a
  1714. href="#sec-execution-contexts">the current Realm</a>, corresponding to the name. Determination of <a
  1715. href="#sec-execution-contexts">the current Realm</a> and its intrinsics is described in <a
  1716. href="#sec-newglobalenvironment">8.1.2.5</a>. The well-known intrinsics are listed in <a href="#table-7">Table 7</a>.</p>
  1717. <figure>
  1718. <figcaption><span id="table-7">Table 7</span> &mdash; Well-known Intrinsic Objects</figcaption>
  1719. <table class="real-table">
  1720. <tr>
  1721. <th>Intrinsic Name</th>
  1722. <th>Global Name</th>
  1723. <th>ECMAScript Language Association</th>
  1724. </tr>
  1725. <tr>
  1726. <td>%Array%</td>
  1727. <td><code>Array</code></td>
  1728. <td>The <code>Array</code> constructor (<a href="#sec-array-constructor">22.1.1</a>)</td>
  1729. </tr>
  1730. <tr>
  1731. <td>%ArrayBuffer%</td>
  1732. <td><code>ArrayBuffer</code></td>
  1733. <td>The <code>ArrayBuffer</code> constructor (<a href="#sec-arraybuffer-constructor">24.1.2</a>)</td>
  1734. </tr>
  1735. <tr>
  1736. <td>%ArrayBufferPrototype%</td>
  1737. <td><code><a href="#sec-arraybuffer.prototype">ArrayBuffer.prototype</a></code></td>
  1738. <td>The initial value of the <code>prototype</code> data property of %ArrayBuffer%.</td>
  1739. </tr>
  1740. <tr>
  1741. <td>%ArrayIteratorPrototype%</td>
  1742. <td></td>
  1743. <td>The prototype of Array iterator objects (<a href="#sec-array-iterator-objects">22.1.5</a>)</td>
  1744. </tr>
  1745. <tr>
  1746. <td>%ArrayPrototype%</td>
  1747. <td><code>Array.prototype</code></td>
  1748. <td>The initial value of the <code>prototype</code> data property of %Array% (<a href="#sec-properties-of-the-array-prototype-object">22.1.3</a>)</td>
  1749. </tr>
  1750. <tr>
  1751. <td>%ArrayProto_values%</td>
  1752. <td><code><a href="#sec-array.prototype.values">Array.prototype.values</a></code></td>
  1753. <td>The initial value of the <code>values</code> data property of %ArrayPrototype% (<a href="#sec-array.prototype.values">22.1.3.29</a>)</td>
  1754. </tr>
  1755. <tr>
  1756. <td>%Boolean%</td>
  1757. <td><code>Boolean</code></td>
  1758. <td>The <code>Boolean</code> constructor (<a href="#sec-boolean-constructor">19.3.1</a>)</td>
  1759. </tr>
  1760. <tr>
  1761. <td>%BooleanPrototype%</td>
  1762. <td><code>Boolean.prototype</code></td>
  1763. <td>The initial value of the <code>prototype</code> data property of %Boolean% (<a href="#sec-properties-of-the-boolean-prototype-object">19.3.3</a>)</td>
  1764. </tr>
  1765. <tr>
  1766. <td>%DataView%</td>
  1767. <td><code>DataView</code></td>
  1768. <td>The <code>DataView</code> constructor (<a href="#sec-dataview-constructor">24.2.2</a>)</td>
  1769. </tr>
  1770. <tr>
  1771. <td>%DataViewPrototype%</td>
  1772. <td><code><a href="#sec-dataview.prototype">DataView.prototype</a></code></td>
  1773. <td>The initial value of the <code>prototype</code> data property of %DataView%</td>
  1774. </tr>
  1775. <tr>
  1776. <td>%Date%</td>
  1777. <td><code>Date</code></td>
  1778. <td>The <code>Date</code> constructor (<a href="#sec-date-constructor">20.3.2</a>)</td>
  1779. </tr>
  1780. <tr>
  1781. <td>%DatePrototype%</td>
  1782. <td><code>Date.prototype</code></td>
  1783. <td>The initial value of the <code>prototype</code> data property of %Date%.</td>
  1784. </tr>
  1785. <tr>
  1786. <td>%decodeURI%</td>
  1787. <td><code>decodeURI</code></td>
  1788. <td>The <code>decodeURI</code> function (<a href="#sec-decodeuri-encodeduri">18.2.6.2</a>)</td>
  1789. </tr>
  1790. <tr>
  1791. <td>%decodeURIComponent%</td>
  1792. <td><code>decodeURIComponent</code></td>
  1793. <td>The <code>decodeURIComponent</code> function (<a href="#sec-decodeuricomponent-encodeduricomponent">18.2.6.3</a>)</td>
  1794. </tr>
  1795. <tr>
  1796. <td>%encodeURI%</td>
  1797. <td><code>encodeURI</code></td>
  1798. <td>The <code>encodeURI</code> function (<a href="#sec-encodeuri-uri">18.2.6.4</a>)</td>
  1799. </tr>
  1800. <tr>
  1801. <td>%encodeURIComponent%</td>
  1802. <td><code>encodeURIComponent</code></td>
  1803. <td>The <code>encodeURIComponent</code> function (<a href="#sec-encodeuricomponent-uricomponent">18.2.6.5</a>)</td>
  1804. </tr>
  1805. <tr>
  1806. <td>%Error%</td>
  1807. <td><code>Error</code></td>
  1808. <td>The <code>Error</code> constructor (<a href="#sec-error-constructor">19.5.1</a>)</td>
  1809. </tr>
  1810. <tr>
  1811. <td>%ErrorPrototype%</td>
  1812. <td><code>Error.prototype</code></td>
  1813. <td>The initial value of the <code>prototype</code> data property of %Error%</td>
  1814. </tr>
  1815. <tr>
  1816. <td>%eval%</td>
  1817. <td><code>eval</code></td>
  1818. <td>The <code>eval</code> function (<a href="#sec-eval-x">18.2.1</a>)</td>
  1819. </tr>
  1820. <tr>
  1821. <td>%EvalError%</td>
  1822. <td><code>EvalError</code></td>
  1823. <td>The <code>EvalError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-evalerror">19.5.5.1</a>)</td>
  1824. </tr>
  1825. <tr>
  1826. <td>%EvalErrorPrototype%</td>
  1827. <td><code>EvalError.prototype</code></td>
  1828. <td>The initial value of the <code>prototype</code> property of %EvalError%</td>
  1829. </tr>
  1830. <tr>
  1831. <td>%Float32Array%</td>
  1832. <td><code><a href="#sec-float32array">Float32Array</a></code></td>
  1833. <td>The <code><a href="#sec-float32array">Float32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  1834. </tr>
  1835. <tr>
  1836. <td>%Float32ArrayPrototype%</td>
  1837. <td><code>Float32Array.prototype</code></td>
  1838. <td>The initial value of the <code>prototype</code> data property of %Float32Array%.</td>
  1839. </tr>
  1840. <tr>
  1841. <td>%Float64Array%</td>
  1842. <td><code><a href="#sec-float64array">Float64Array</a></code></td>
  1843. <td>The <code><a href="#sec-float64array">Float64Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  1844. </tr>
  1845. <tr>
  1846. <td>%Float64ArrayPrototype%</td>
  1847. <td><code>Float64Array.prototype</code></td>
  1848. <td>The initial value of the <code>prototype</code> data property of %Float64Array%</td>
  1849. </tr>
  1850. <tr>
  1851. <td>%Function%</td>
  1852. <td><code>Function</code></td>
  1853. <td>The <code>Function</code> constructor (<a href="#sec-function-constructor">19.2.1</a>)</td>
  1854. </tr>
  1855. <tr>
  1856. <td>%FunctionPrototype%</td>
  1857. <td><code>Function.prototype</code></td>
  1858. <td>The initial value of the <code>prototype</code> data property of %Function%</td>
  1859. </tr>
  1860. <tr>
  1861. <td>%Generator%</td>
  1862. <td></td>
  1863. <td>The initial value of the <code>prototype</code> property of %GeneratorFunction%</td>
  1864. </tr>
  1865. <tr>
  1866. <td>%GeneratorFunction%</td>
  1867. <td></td>
  1868. <td>The constructor of generator objects (<a href="#sec-generatorfunction-constructor">25.2.1</a>)</td>
  1869. </tr>
  1870. <tr>
  1871. <td>%GeneratorPrototype%</td>
  1872. <td></td>
  1873. <td>The initial value of the <code>prototype</code> property of %Generator%</td>
  1874. </tr>
  1875. <tr>
  1876. <td>%Int8Array%</td>
  1877. <td><code><a href="#sec-int8array">Int8Array</a></code></td>
  1878. <td>The <code><a href="#sec-int8array">Int8Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  1879. </tr>
  1880. <tr>
  1881. <td>%Int8ArrayPrototype%</td>
  1882. <td><code>Int8Array.prototype</code></td>
  1883. <td>The initial value of the <code>prototype</code> data property of %Int8Array%</td>
  1884. </tr>
  1885. <tr>
  1886. <td>%Int16Array%</td>
  1887. <td><code><a href="#sec-int16array">Int16Array</a></code></td>
  1888. <td>The <code><a href="#sec-int16array">Int16Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  1889. </tr>
  1890. <tr>
  1891. <td>%Int16ArrayPrototype%</td>
  1892. <td><code>Int16Array.prototype</code></td>
  1893. <td>The initial value of the <code>prototype</code> data property of %Int16Array%</td>
  1894. </tr>
  1895. <tr>
  1896. <td>%Int32Array%</td>
  1897. <td><code><a href="#sec-int32array">Int32Array</a></code></td>
  1898. <td>The <code><a href="#sec-int32array">Int32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  1899. </tr>
  1900. <tr>
  1901. <td>%Int32ArrayPrototype%</td>
  1902. <td><code>Int32Array.prototype</code></td>
  1903. <td>The initial value of the <code>prototype</code> data property of %Int32Array%</td>
  1904. </tr>
  1905. <tr>
  1906. <td>%isFinite%</td>
  1907. <td><code>isFinite</code></td>
  1908. <td>The <code>isFinite</code> function (<a href="#sec-isfinite-number">18.2.2</a>)</td>
  1909. </tr>
  1910. <tr>
  1911. <td>%isNaN%</td>
  1912. <td><code>isNaN</code></td>
  1913. <td>The <code>isNaN</code> function (<a href="#sec-isnan-number">18.2.3</a>)</td>
  1914. </tr>
  1915. <tr>
  1916. <td>%IteratorPrototype%</td>
  1917. <td></td>
  1918. <td>An object that all standard built-in iterator objects indirectly inherit from</td>
  1919. </tr>
  1920. <tr>
  1921. <td>%JSON%</td>
  1922. <td><code>JSON</code></td>
  1923. <td>The <code>JSON</code> object (<a href="#sec-json-object">24.3</a>)</td>
  1924. </tr>
  1925. <tr>
  1926. <td>%Map%</td>
  1927. <td><code>Map</code></td>
  1928. <td>The <code>Map</code> constructor (<a href="#sec-map-constructor">23.1.1</a>)</td>
  1929. </tr>
  1930. <tr>
  1931. <td>%MapIteratorPrototype%</td>
  1932. <td></td>
  1933. <td>The prototype of Map iterator objects (<a href="#sec-map-iterator-objects">23.1.5</a>)</td>
  1934. </tr>
  1935. <tr>
  1936. <td>%MapPrototype%</td>
  1937. <td><code>Map.prototype</code></td>
  1938. <td>The initial value of the <code>prototype</code> data property of %Map%</td>
  1939. </tr>
  1940. <tr>
  1941. <td>%Math%</td>
  1942. <td><code>Math</code></td>
  1943. <td>The <code>Math</code> object (<a href="#sec-math-object">20.2</a>)</td>
  1944. </tr>
  1945. <tr>
  1946. <td>%Number%</td>
  1947. <td><code>Number</code></td>
  1948. <td>The <code>Number</code> constructor (<a href="#sec-number-constructor">20.1.1</a>)</td>
  1949. </tr>
  1950. <tr>
  1951. <td>%NumberPrototype%</td>
  1952. <td><code>Number.prototype</code></td>
  1953. <td>The initial value of the <code>prototype</code> property of %Number%</td>
  1954. </tr>
  1955. <tr>
  1956. <td>%Object%</td>
  1957. <td><code>Object</code></td>
  1958. <td>The <code>Object</code> constructor (<a href="#sec-object-constructor">19.1.1</a>)</td>
  1959. </tr>
  1960. <tr>
  1961. <td>%ObjectPrototype%</td>
  1962. <td><code>Object.prototype</code></td>
  1963. <td>The initial value of the <code>prototype</code> data property of %Object%. (<a href="#sec-properties-of-the-object-prototype-object">19.1.3</a>)</td>
  1964. </tr>
  1965. <tr>
  1966. <td>%ObjProto_toString%</td>
  1967. <td><code>Object.prototype.<br>toString</code></td>
  1968. <td>The initial value of the <code>toString</code> data property of %ObjectPrototype% (<a href="#sec-object.prototype.tostring">19.1.3.6</a>)</td>
  1969. </tr>
  1970. <tr>
  1971. <td>%parseFloat%</td>
  1972. <td><code>parseFloat</code></td>
  1973. <td>The <code>parseFloat</code> function (<a href="#sec-parsefloat-string">18.2.4</a>)</td>
  1974. </tr>
  1975. <tr>
  1976. <td>%parseInt%</td>
  1977. <td><code>parseInt</code></td>
  1978. <td>The <code>parseInt</code> function (<a href="#sec-parseint-string-radix">18.2.5</a>)</td>
  1979. </tr>
  1980. <tr>
  1981. <td>%Promise%</td>
  1982. <td><code>Promise</code></td>
  1983. <td>The <code>Promise</code> constructor (<a href="#sec-promise-constructor">25.4.3</a>)</td>
  1984. </tr>
  1985. <tr>
  1986. <td>%PromisePrototype%</td>
  1987. <td><code>Promise.prototype</code></td>
  1988. <td>The initial value of the <code>prototype</code> data property of %Promise%</td>
  1989. </tr>
  1990. <tr>
  1991. <td>%Proxy%</td>
  1992. <td><code>Proxy</code></td>
  1993. <td>The <code>Proxy</code> constructor (<a href="#sec-proxy-constructor">26.2.1</a>)</td>
  1994. </tr>
  1995. <tr>
  1996. <td>%RangeError%</td>
  1997. <td><code>RangeError</code></td>
  1998. <td>The <code>RangeError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-rangeerror">19.5.5.2</a>)</td>
  1999. </tr>
  2000. <tr>
  2001. <td>%RangeErrorPrototype%</td>
  2002. <td><code>RangeError.prototype</code></td>
  2003. <td>The initial value of the <code>prototype</code> property of %RangeError%</td>
  2004. </tr>
  2005. <tr>
  2006. <td>%ReferenceError%</td>
  2007. <td><code>ReferenceError</code></td>
  2008. <td>The <code>ReferenceError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-referenceerror">19.5.5.3</a>)</td>
  2009. </tr>
  2010. <tr>
  2011. <td>%ReferenceErrorPrototype%</td>
  2012. <td><code>ReferenceError.<br>prototype</code></td>
  2013. <td>The initial value of the <code>prototype</code> property of %ReferenceError%</td>
  2014. </tr>
  2015. <tr>
  2016. <td>%Reflect%</td>
  2017. <td><code>Reflect</code></td>
  2018. <td>The <code>Reflect</code> object (<a href="#sec-reflect-object">26.1</a>)</td>
  2019. </tr>
  2020. <tr>
  2021. <td>%RegExp%</td>
  2022. <td><code>RegExp</code></td>
  2023. <td>The <code>RegExp</code> constructor (<a href="#sec-regexp-constructor">21.2.3</a>)</td>
  2024. </tr>
  2025. <tr>
  2026. <td>%RegExpPrototype%</td>
  2027. <td><code><a href="#sec-regexp.prototype">RegExp.prototype</a></code></td>
  2028. <td>The initial value of the <code>prototype</code> data property of %RegExp%</td>
  2029. </tr>
  2030. <tr>
  2031. <td>%Set%</td>
  2032. <td><code>Set</code></td>
  2033. <td>The <code>Set</code> constructor (<a href="#sec-set-constructor">23.2.1</a>)</td>
  2034. </tr>
  2035. <tr>
  2036. <td>%SetIteratorPrototype%</td>
  2037. <td></td>
  2038. <td>The prototype of Set iterator objects (<a href="#sec-set-iterator-objects">23.2.5</a>)</td>
  2039. </tr>
  2040. <tr>
  2041. <td>%SetPrototype%</td>
  2042. <td><code>Set.prototype</code></td>
  2043. <td>The initial value of the <code>prototype</code> data property of %Set%</td>
  2044. </tr>
  2045. <tr>
  2046. <td>%String%</td>
  2047. <td><code>String</code></td>
  2048. <td>The <code>String</code> constructor (<a href="#sec-string-constructor">21.1.1</a>)</td>
  2049. </tr>
  2050. <tr>
  2051. <td>%StringIteratorPrototype%</td>
  2052. <td></td>
  2053. <td>The prototype of String iterator objects (<a href="#sec-string-iterator-objects">21.1.5</a>)</td>
  2054. </tr>
  2055. <tr>
  2056. <td>%StringPrototype%</td>
  2057. <td><code>String.prototype</code></td>
  2058. <td>The initial value of the <code>prototype</code> data property of %String%</td>
  2059. </tr>
  2060. <tr>
  2061. <td>%Symbol%</td>
  2062. <td><code>Symbol</code></td>
  2063. <td>The <code>Symbol</code> constructor (<a href="#sec-symbol-constructor">19.4.1</a>)</td>
  2064. </tr>
  2065. <tr>
  2066. <td>%SymbolPrototype%</td>
  2067. <td><code>Symbol.prototype</code></td>
  2068. <td>The initial value of the <code>prototype</code> data property of %Symbol%. (<a href="#sec-properties-of-the-symbol-prototype-object">19.4.3</a>)</td>
  2069. </tr>
  2070. <tr>
  2071. <td>%SyntaxError%</td>
  2072. <td><code>SyntaxError</code></td>
  2073. <td>The <code>SyntaxError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-syntaxerror">19.5.5.4</a>)</td>
  2074. </tr>
  2075. <tr>
  2076. <td>%SyntaxErrorPrototype%</td>
  2077. <td><code>SyntaxError.prototype</code></td>
  2078. <td>The initial value of the <code>prototype</code> property of %SyntaxError%</td>
  2079. </tr>
  2080. <tr>
  2081. <td><a href="#sec-%throwtypeerror%">%ThrowTypeError%</a></td>
  2082. <td></td>
  2083. <td>A function object that unconditionally throws a new instance of %TypeError%</td>
  2084. </tr>
  2085. <tr>
  2086. <td>%TypedArray%</td>
  2087. <td></td>
  2088. <td>The super class of all typed Array constructors (<a href="#sec-%typedarray%-intrinsic-object">22.2.1</a>)</td>
  2089. </tr>
  2090. <tr>
  2091. <td>%TypedArrayPrototype%</td>
  2092. <td></td>
  2093. <td>The initial value of the <code>prototype</code> property of %TypedArray%</td>
  2094. </tr>
  2095. <tr>
  2096. <td>%TypeError%</td>
  2097. <td><code>TypeError</code></td>
  2098. <td>The <code>TypeError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-typeerror">19.5.5.5</a>)</td>
  2099. </tr>
  2100. <tr>
  2101. <td>%TypeErrorPrototype%</td>
  2102. <td><code>TypeError.prototype</code></td>
  2103. <td>The initial value of the <code>prototype</code> property of %TypeError%</td>
  2104. </tr>
  2105. <tr>
  2106. <td>%Uint8Array%</td>
  2107. <td><code><a href="#sec-uint8array">Uint8Array</a></code></td>
  2108. <td>The <code><a href="#sec-uint8array">Uint8Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  2109. </tr>
  2110. <tr>
  2111. <td>%Uint8ArrayPrototype%</td>
  2112. <td><code>Uint8Array.prototype</code></td>
  2113. <td>The initial value of the <code>prototype</code> data property of %Uint8Array%</td>
  2114. </tr>
  2115. <tr>
  2116. <td>%Uint8ClampedArray%</td>
  2117. <td><code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a></code></td>
  2118. <td>The <code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  2119. </tr>
  2120. <tr>
  2121. <td>%Uint8ClampedArrayPrototype%</td>
  2122. <td><code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a>.<br>prototype</code></td>
  2123. <td>The initial value of the <code>prototype</code> data property of %Uint8ClampedArray%</td>
  2124. </tr>
  2125. <tr>
  2126. <td>%Uint16Array%</td>
  2127. <td><code><a href="#sec-uint16array">Uint16Array</a></code></td>
  2128. <td>The <code><a href="#sec-uint16array">Uint16Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  2129. </tr>
  2130. <tr>
  2131. <td>%Uint16ArrayPrototype%</td>
  2132. <td><code>Uint16Array.prototype</code></td>
  2133. <td>The initial value of the <code>prototype</code> data property of %Uint16Array%</td>
  2134. </tr>
  2135. <tr>
  2136. <td>%Uint32Array%</td>
  2137. <td><code><a href="#sec-uint32array">Uint32Array</a></code></td>
  2138. <td>The <code><a href="#sec-uint32array">Uint32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
  2139. </tr>
  2140. <tr>
  2141. <td>%Uint32ArrayPrototype%</td>
  2142. <td><code>Uint32Array.prototype</code></td>
  2143. <td>The initial value of the <code>prototype</code> data property of %Uint32Array%</td>
  2144. </tr>
  2145. <tr>
  2146. <td>%URIError%</td>
  2147. <td><code><a href="#sec-constructor-properties-of-the-global-object-urierror">URIError</a></code></td>
  2148. <td>The <code><a href="#sec-constructor-properties-of-the-global-object-urierror">URIError</a></code> constructor (<a href="#sec-native-error-types-used-in-this-standard-urierror">19.5.5.6</a>)</td>
  2149. </tr>
  2150. <tr>
  2151. <td>%URIErrorPrototype%</td>
  2152. <td><code>URIError.prototype</code></td>
  2153. <td>The initial value of the <code>prototype</code> property of %URIError%</td>
  2154. </tr>
  2155. <tr>
  2156. <td>%WeakMap%</td>
  2157. <td><code>WeakMap</code></td>
  2158. <td>The <code>WeakMap</code> constructor (<a href="#sec-weakmap-constructor">23.3.1</a>)</td>
  2159. </tr>
  2160. <tr>
  2161. <td>%WeakMapPrototype%</td>
  2162. <td><code><a href="#sec-weakmap.prototype">WeakMap.prototype</a></code></td>
  2163. <td>The initial value of the <code>prototype</code> data property of %WeakMap%</td>
  2164. </tr>
  2165. <tr>
  2166. <td>%WeakSet%</td>
  2167. <td><code>WeakSet</code></td>
  2168. <td>The <code>WeakSet</code> constructor (<a href="#sec-weakset-constructor">23.4.1</a>)</td>
  2169. </tr>
  2170. <tr>
  2171. <td>%WeakSetPrototype%</td>
  2172. <td><code><a href="#sec-weakset.prototype">WeakSet.prototype</a></code></td>
  2173. <td>The initial value of the <code>prototype</code> data property of %WeakSet%</td>
  2174. </tr>
  2175. </table>
  2176. </figure>
  2177. </section>
  2178. </section>
  2179. </section>
  2180. <section id="sec-ecmascript-specification-types">
  2181. <div class="front">
  2182. <h1><span class="secnum" id="sec-6.2"><a href="#sec-ecmascript-specification-types"
  2183. title="link to this section">6.2</a></span> ECMAScript Specification Types</h1>
  2184. <p>A specification type corresponds to meta-values that are used within algorithms to describe the semantics of ECMAScript
  2185. language constructs and ECMAScript language types. The specification types are <a
  2186. href="#sec-reference-specification-type">Reference</a>, <a href="#sec-list-and-record-specification-type">List</a>, <a
  2187. href="#sec-completion-record-specification-type">Completion</a>, <a
  2188. href="#sec-property-descriptor-specification-type">Property Descriptor</a>, <a href="#sec-lexical-environments">Lexical
  2189. Environment</a>, <a href="#sec-environment-records">Environment Record</a>, and <a href="#sec-data-blocks">Data Block</a>.
  2190. Specification type values are specification artefacts that do not necessarily correspond to any specific entity within an
  2191. ECMAScript implementation. Specification type values may be used to describe intermediate results of ECMAScript expression
  2192. evaluation but such values cannot be stored as properties of objects or values of ECMAScript language variables.</p>
  2193. </div>
  2194. <section id="sec-list-and-record-specification-type">
  2195. <h1><span class="secnum" id="sec-6.2.1"><a href="#sec-list-and-record-specification-type"
  2196. title="link to this section">6.2.1</a></span> The List and Record Specification Type</h1>
  2197. <p>The List type is used to explain the evaluation of argument lists (<a href="#sec-argument-lists">see 12.3.6</a>) in
  2198. <code>new</code> expressions, in function calls, and in other algorithms where a simple ordered list of values is needed.
  2199. Values of the List type are simply ordered sequences of list elements containing the individual values. These sequences may
  2200. be of any length. The elements of a list may be randomly accessed using 0-origin indices. For notational convenience an
  2201. array-like syntax can be used to access List elements. For example, <i>arguments</i>[2] is shorthand for saying the
  2202. 3<sup>rd</sup> element of the List <i>arguments</i>.</p>
  2203. <p>For notational convenience within this specification, a literal syntax can be used to express a new List value. For
  2204. example, &laquo;1, 2&raquo; defines a List value that has two elements each of which is initialized to a specific value. A
  2205. new empty List can be expressed as &laquo;&raquo;.</p>
  2206. <p>The Record type is used to describe data aggregations within the algorithms of this specification. A Record type value
  2207. consists of one or more named fields. The value of each field is either an ECMAScript value or an abstract value represented
  2208. by a name associated with the Record type. Field names are always enclosed in double brackets, for example [[value]].</p>
  2209. <p>For notational convenience within this specification, an object literal-like syntax can be used to express a Record
  2210. value. For example, {[[field1]]: 42, [[field2]]: <b>false</b>, [[field3]]: <b>empty</b>} defines a Record value that has
  2211. three fields, each of which is initialized to a specific value. Field name order is not significant. Any fields that are not
  2212. explicitly listed are considered to be absent.</p>
  2213. <p>In specification text and algorithms, dot notation may be used to refer to a specific field of a Record value. For
  2214. example, if R is the record shown in the previous paragraph then R.[[field2]] is shorthand for &ldquo;the field of R named
  2215. [[field2]]&rdquo;.</p>
  2216. <p>Schema for commonly used Record field combinations may be named, and that name may be used as a prefix to a literal
  2217. Record value to identify the specific kind of aggregations that is being described. For example:
  2218. PropertyDescriptor{[[Value]]: 42, [[Writable]]: <b>false</b>, [[Configurable]]: <b>true</b>}.</p>
  2219. </section>
  2220. <section id="sec-completion-record-specification-type">
  2221. <div class="front">
  2222. <h1><span class="secnum" id="sec-6.2.2"><a href="#sec-completion-record-specification-type"
  2223. title="link to this section">6.2.2</a></span> The Completion Record Specification Type</h1>
  2224. <p>The Completion type is a Record used to explain the runtime propagation of values and control flow such as the
  2225. behaviour of statements (<code>break</code>, <code>continue</code>, <code>return</code> and <code>throw</code>) that
  2226. perform nonlocal transfers of control.</p>
  2227. <p>Values of the Completion type are Record values whose fields are defined as by <a href="#table-8">Table 8</a>.</p>
  2228. <figure>
  2229. <figcaption><span id="table-8">Table 8</span> &mdash; Completion Record Fields</figcaption>
  2230. <table class="real-table">
  2231. <tr>
  2232. <th>Field</th>
  2233. <th>Value</th>
  2234. <th>Meaning</th>
  2235. </tr>
  2236. <tr>
  2237. <td>[[type]]</td>
  2238. <td>One of <b>normal</b>, <b>break</b>, <b>continue</b>, <b>return</b>, or <b>throw</b></td>
  2239. <td>The type of completion that occurred.</td>
  2240. </tr>
  2241. <tr>
  2242. <td>[[value]]</td>
  2243. <td>any <a href="#sec-ecmascript-language-types">ECMAScript language value</a> or <b>empty</b></td>
  2244. <td>The value that was produced.</td>
  2245. </tr>
  2246. <tr>
  2247. <td>[[target]]</td>
  2248. <td>any ECMAScript string or <b>empty</b></td>
  2249. <td>The target label for directed control transfers.</td>
  2250. </tr>
  2251. </table>
  2252. </figure>
  2253. <p>The term &ldquo;abrupt completion&rdquo; refers to any completion with a <span style="font-family: Times New
  2254. Roman">[[type]]</span> value other than <b>normal</b>.</p>
  2255. </div>
  2256. <section id="sec-normalcompletion">
  2257. <h1><span class="secnum" id="sec-6.2.2.1"><a href="#sec-normalcompletion" title="link to this section">6.2.2.1</a></span>
  2258. NormalCompletion</h1>
  2259. <p>The abstract operation NormalCompletion with a single <i>argument</i>, such as:</p>
  2260. <ol class="proc">
  2261. <li>Return NormalCompletion(<i>argument</i>).</li>
  2262. </ol>
  2263. <p>Is a shorthand that is defined as follows:</p>
  2264. <ol class="proc">
  2265. <li>Return <a href="#sec-completion-record-specification-type">Completion</a>{[[type]]: <span style="font-family:
  2266. sans-serif">normal</span>, [[value]]: <i>argument</i>, [[target]]:<span style="font-family:
  2267. sans-serif">empty</span>}.</li>
  2268. </ol>
  2269. </section>
  2270. <section id="sec-implicit-completion-values">
  2271. <h1><span class="secnum" id="sec-6.2.2.2"><a href="#sec-implicit-completion-values"
  2272. title="link to this section">6.2.2.2</a></span> Implicit Completion Values</h1>
  2273. <p>The algorithms of this specification often implicitly return <a
  2274. href="#sec-completion-record-specification-type">Completion</a> Records whose [[type]] is <b>normal</b>. Unless it is
  2275. otherwise obvious from the context, an algorithm statement that returns a value that is not a <a
  2276. href="#sec-completion-record-specification-type">Completion Record</a>, such as:</p>
  2277. <ol class="proc">
  2278. <li>Return <code>"Infinity"</code>.</li>
  2279. </ol>
  2280. <p>means the same thing as:</p>
  2281. <ol class="proc">
  2282. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<code>"Infinity"</code>).</li>
  2283. </ol>
  2284. <p>However, if the value expression of a &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement
  2285. is a <a href="#sec-completion-record-specification-type">Completion Record</a> construction literal, the resulting <a
  2286. href="#sec-completion-record-specification-type">Completion Record</a> is returned. If the value expression is a call to
  2287. an abstract operation, the &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement simply returns
  2288. the <a href="#sec-completion-record-specification-type">Completion Record</a> produced by the abstract operation.</p>
  2289. <p>The abstract operation <span style="font-family: Times New Roman"><a
  2290. href="#sec-completion-record-specification-type">Completion</a>(<i>completionRecord</i>)</span> is used to emphasize that
  2291. a previously computed <a href="#sec-completion-record-specification-type">Completion Record</a> is being returned. The <a
  2292. href="#sec-completion-record-specification-type">Completion</a> abstract operation takes a single argument,
  2293. <var>completionRecord</var>, and performs the following steps: such as</p>
  2294. <ol class="proc">
  2295. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>completionRecord</i> is a <a
  2296. href="#sec-completion-record-specification-type">Completion Record</a>.</li>
  2297. <li>Return <i>completionRecord</i> as the <a href="#sec-completion-record-specification-type">Completion Record</a> of
  2298. this abstract operation.</li>
  2299. </ol>
  2300. <p>A &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement without a value in an algorithm step
  2301. means the same thing as:</p>
  2302. <ol class="proc">
  2303. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  2304. </ol>
  2305. <p>Any reference to a <a href="#sec-completion-record-specification-type">Completion Record</a> value that is in a context
  2306. that does not explicitly require a complete <a href="#sec-completion-record-specification-type">Completion Record</a>
  2307. value is equivalent to an explicit reference to the [[value]] field of the <a
  2308. href="#sec-completion-record-specification-type">Completion Record</a> value unless the <a
  2309. href="#sec-completion-record-specification-type">Completion Record</a> is an <a
  2310. href="#sec-completion-record-specification-type">abrupt completion</a>.</p>
  2311. </section>
  2312. <section id="sec-throw-an-exception">
  2313. <h1><span class="secnum" id="sec-6.2.2.3"><a href="#sec-throw-an-exception"
  2314. title="link to this section">6.2.2.3</a></span> Throw an Exception</h1>
  2315. <p>Algorithms steps that say to throw an exception, such as</p>
  2316. <ol class="proc">
  2317. <li>Throw a <b>TypeError</b> exception.</li>
  2318. </ol>
  2319. <p>mean the same things as:</p>
  2320. <ol class="proc">
  2321. <li>Return <a href="#sec-completion-record-specification-type">Completion</a>{[[type]]: <span style="font-family:
  2322. sans-serif">throw</span>, [[value]]: a newly created <b>TypeError</b> object, [[target]]:<span style="font-family:
  2323. sans-serif">empty</span>}.</li>
  2324. </ol>
  2325. </section>
  2326. <section id="sec-returnifabrupt">
  2327. <h1><span class="secnum" id="sec-6.2.2.4"><a href="#sec-returnifabrupt" title="link to this section">6.2.2.4</a></span>
  2328. ReturnIfAbrupt</h1>
  2329. <p>Algorithms steps that say</p>
  2330. <ol class="proc">
  2331. <li>ReturnIfAbrupt(<i>argument</i>).</li>
  2332. </ol>
  2333. <p>mean the same thing as:</p>
  2334. <ol class="proc">
  2335. <li>If <i>argument</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return
  2336. <i>argument</i>.</li>
  2337. <li>Else if <i>argument</i> is a <a href="#sec-completion-record-specification-type">Completion Record</a>, let
  2338. <i>argument</i> be <i>argument</i>.[[value]].</li>
  2339. </ol>
  2340. </section>
  2341. </section>
  2342. <section id="sec-reference-specification-type">
  2343. <div class="front">
  2344. <h1><span class="secnum" id="sec-6.2.3"><a href="#sec-reference-specification-type"
  2345. title="link to this section">6.2.3</a></span> The Reference Specification Type</h1>
  2346. <div class="note">
  2347. <p><span class="nh">NOTE</span> The Reference type is used to explain the behaviour of such operators as
  2348. <code>delete</code>, <code>typeof</code>, the assignment operators, the <code>super</code> keyword and other language
  2349. features. For example, the left-hand operand of an assignment is expected to produce a reference.</p>
  2350. </div>
  2351. <p>A <b>Reference</b> is a resolved name or property binding. A Reference consists of three components, the
  2352. <var>base</var> value, the <var>referenced name</var> and the Boolean valued <var>strict reference</var> flag. The
  2353. <var>base</var> value is either <b>undefined</b>, an Object, a Boolean, a String, a Symbol, a Number, or an <a
  2354. href="#sec-environment-records">Environment Record</a> (<a href="#sec-environment-records">8.1.1</a>). A <var>base</var>
  2355. value of <b>undefined</b> indicates that the Reference could not be resolved to a binding. The <var>referenced name</var>
  2356. is a String or Symbol value.</p>
  2357. <p>A Super Reference is a Reference that is used to represents a name binding that was expressed using the super keyword.
  2358. A Super Reference has an additional <var>thisValue</var> component and its <var>base</var> value will never be an <a
  2359. href="#sec-environment-records">Environment Record</a>.</p>
  2360. <p>The following abstract operations are used in this specification to access the components of references:</p>
  2361. <ul>
  2362. <li>
  2363. <p>GetBase(V). Returns the <i>base</i> value component of the reference V.</p>
  2364. </li>
  2365. <li>
  2366. <p>GetReferencedName(V). Returns the <i>referenced name</i> component of the reference V.</p>
  2367. </li>
  2368. <li>
  2369. <p>IsStrictReference(V). Returns the <i>strict reference</i> flag component of the reference V.</p>
  2370. </li>
  2371. <li>
  2372. <p>HasPrimitiveBase(V). Returns <b>true</b> if <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>base</i>)
  2373. is Boolean, String, Symbol, or Number.</p>
  2374. </li>
  2375. <li>
  2376. <p>IsPropertyReference(V). Returns <b>true</b> if either the <i>base</i> value is an object or HasPrimitiveBase(V) is
  2377. <b>true</b>; otherwise returns <b>false</b>.</p>
  2378. </li>
  2379. <li>
  2380. <p>IsUnresolvableReference(V). Returns <b>true</b> if the <i>base</i> value is <b>undefined</b> and <b>false</b>
  2381. otherwise.</p>
  2382. </li>
  2383. <li>
  2384. <p>IsSuperReference(V). Returns <b>true</b> if this reference has a <i>thisValue</i> component.</p>
  2385. </li>
  2386. </ul>
  2387. <p>The following abstract operations are used in this specification to operate on references:</p>
  2388. </div>
  2389. <section id="sec-getvalue">
  2390. <h1><span class="secnum" id="sec-6.2.3.1"><a href="#sec-getvalue" title="link to this section">6.2.3.1</a></span> GetValue
  2391. (V)</h1>
  2392. <ol class="proc">
  2393. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
  2394. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is not <a
  2395. href="#sec-reference-specification-type">Reference</a>, return <i>V</i>.</li>
  2396. <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
  2397. <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>), throw a <b>ReferenceError</b>
  2398. exception.</li>
  2399. <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>), then
  2400. <ol class="block">
  2401. <li>If <a href="#sec-reference-specification-type">HasPrimitiveBase</a>(<i>V</i>) is <b>true</b>, then
  2402. <ol class="block">
  2403. <li><a href="#sec-algorithm-conventions">Assert</a>: In this case, <i>base</i> will never be <b>null</b> or
  2404. <b>undefined</b>.</li>
  2405. <li>Let <i>base</i> be <a href="#sec-toobject">ToObject</a>(<i>base</i>).</li>
  2406. </ol>
  2407. </li>
  2408. <li>Return <i>base.</i>[[Get]](<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <a
  2409. href="#sec-getthisvalue">GetThisValue</a>(<i>V</i>)).</li>
  2410. </ol>
  2411. </li>
  2412. <li>Else <i>base</i> must be an <a href="#sec-environment-records">Environment Record</a>,
  2413. <ol class="block">
  2414. <li>Return <i>base.</i>GetBindingValue(<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>),
  2415. <a href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>)) (<a
  2416. href="#sec-environment-records">see 8.1.1</a>).</li>
  2417. </ol>
  2418. </li>
  2419. </ol>
  2420. <div class="note">
  2421. <p><span class="nh">NOTE</span> The object that may be created in step 5.a.ii is not accessible outside of the above
  2422. abstract operation and the ordinary object [[Get]] internal method. An implementation might choose to avoid the actual
  2423. creation of the object.</p>
  2424. </div>
  2425. </section>
  2426. <section id="sec-putvalue">
  2427. <h1><span class="secnum" id="sec-6.2.3.2"><a href="#sec-putvalue" title="link to this section">6.2.3.2</a></span> PutValue
  2428. (V, W)</h1>
  2429. <ol class="proc">
  2430. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
  2431. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>W</i>).</li>
  2432. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is not <a
  2433. href="#sec-reference-specification-type">Reference</a>, throw a <b>ReferenceError</b> exception.</li>
  2434. <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
  2435. <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>), then
  2436. <ol class="block">
  2437. <li>If <a href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>) is <b>true</b>, then
  2438. <ol class="block">
  2439. <li>Throw <b>ReferenceError</b> exception.</li>
  2440. </ol>
  2441. </li>
  2442. <li>Let <i>globalObj</i> be <a href="#sec-getglobalobject">GetGlobalObject</a>().</li>
  2443. <li>Return <a href="#sec-set-o-p-v-throw">Set</a>(<i>globalObj</i>,<a
  2444. href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <b>false</b>).</li>
  2445. </ol>
  2446. </li>
  2447. <li>Else if <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>), then
  2448. <ol class="block">
  2449. <li>If <a href="#sec-reference-specification-type">HasPrimitiveBase</a>(<i>V</i>) is <b>true</b>, then
  2450. <ol class="block">
  2451. <li><a href="#sec-algorithm-conventions">Assert</a>: In this case, <i>base</i> will never be <b>null</b> or
  2452. <b>undefined</b>.</li>
  2453. <li>Set <i>base</i> to <a href="#sec-toobject">ToObject</a>(<i>base</i>).</li>
  2454. </ol>
  2455. </li>
  2456. <li>Let <i>succeeded</i> be <i>base.</i>[[Set]](<a
  2457. href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <a
  2458. href="#sec-getthisvalue">GetThisValue</a>(<i>V</i>)).</li>
  2459. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>succeeded</i>).</li>
  2460. <li>If <i>succeeded</i> is <b>false</b> and <a
  2461. href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>) is <b>true</b>, throw a
  2462. <b>TypeError</b> exception.</li>
  2463. <li>Return.</li>
  2464. </ol>
  2465. </li>
  2466. <li>Else <i>base</i> must be an <a href="#sec-environment-records">Environment Record</a>.
  2467. <ol class="block">
  2468. <li>Return <i>base.</i>SetMutableBinding(<a
  2469. href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <a
  2470. href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>)) (<a
  2471. href="#sec-environment-records">see 8.1.1</a>).</li>
  2472. </ol>
  2473. </li>
  2474. </ol>
  2475. <div class="note">
  2476. <p><span class="nh">NOTE</span> The object that may be created in step 6.a.ii is not accessible outside of the above
  2477. algorithm and the ordinary object [[Set]] internal method. An implementation might choose to avoid the actual creation
  2478. of that object.</p>
  2479. </div>
  2480. </section>
  2481. <section id="sec-getthisvalue">
  2482. <h1><span class="secnum" id="sec-6.2.3.3"><a href="#sec-getthisvalue" title="link to this section">6.2.3.3</a></span>
  2483. GetThisValue (V)</h1>
  2484. <ol class="proc">
  2485. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  2486. href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>) is <b>true</b>.</li>
  2487. <li>If <a href="#sec-reference-specification-type">IsSuperReference</a>(<i>V</i>), then
  2488. <ol class="block">
  2489. <li>Return the value of the <i>thisValue</i> component of the reference <i>V</i>.</li>
  2490. </ol>
  2491. </li>
  2492. <li>Return <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
  2493. </ol>
  2494. </section>
  2495. <section id="sec-initializereferencedbinding">
  2496. <h1><span class="secnum" id="sec-6.2.3.4"><a href="#sec-initializereferencedbinding"
  2497. title="link to this section">6.2.3.4</a></span> InitializeReferencedBinding (V, W)</h1>
  2498. <ol class="proc">
  2499. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
  2500. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>W</i>).</li>
  2501. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>)
  2502. is <a href="#sec-reference-specification-type">Reference</a>.</li>
  2503. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  2504. href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>) is <b>false</b>.</li>
  2505. <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
  2506. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>base</i> is an <a href="#sec-environment-records">Environment
  2507. Record</a>.</li>
  2508. <li>Return <i>base.</i>InitializeBinding(<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>),
  2509. <i>W</i>).</li>
  2510. </ol>
  2511. </section>
  2512. </section>
  2513. <section id="sec-property-descriptor-specification-type">
  2514. <div class="front">
  2515. <h1><span class="secnum" id="sec-6.2.4"><a href="#sec-property-descriptor-specification-type"
  2516. title="link to this section">6.2.4</a></span> The Property Descriptor Specification Type</h1>
  2517. <p>The Property Descriptor type is used to explain the manipulation and reification of Object property attributes. Values
  2518. of the Property Descriptor type are Records. Each field&rsquo;s name is an attribute name and its value is a corresponding
  2519. attribute value as specified in <a href="#sec-property-attributes">6.1.7.1</a>. In addition, any field may be present or
  2520. absent. The schema name used within this specification to tag literal descriptions of Property Descriptor records is
  2521. &ldquo;PropertyDescriptor&rdquo;.</p>
  2522. <p>Property Descriptor values may be further classified as data Property Descriptors and accessor Property Descriptors
  2523. based upon the existence or use of certain fields. A data Property Descriptor is one that includes any fields named either
  2524. [[Value]] or [[Writable]]. An accessor Property Descriptor is one that includes any fields named either [[Get]] or
  2525. [[Set]]. Any Property Descriptor may have fields named [[Enumerable]] and [[Configurable]]. A Property Descriptor value
  2526. may not be both a data Property Descriptor and an accessor Property Descriptor; however, it may be neither. A generic
  2527. Property Descriptor is a Property Descriptor value that is neither a data Property Descriptor nor an accessor Property
  2528. Descriptor. A fully populated Property Descriptor is one that is either an accessor Property Descriptor or a data Property
  2529. Descriptor and that has all of the fields that correspond to the property attributes defined in either <a
  2530. href="#table-2">Table 2</a> or <a href="#table-3">Table 3</a>.</p>
  2531. <p>The following abstract operations are used in this specification to operate upon Property Descriptor values:</p>
  2532. </div>
  2533. <section id="sec-isaccessordescriptor">
  2534. <h1><span class="secnum" id="sec-6.2.4.1"><a href="#sec-isaccessordescriptor"
  2535. title="link to this section">6.2.4.1</a></span> IsAccessorDescriptor ( Desc )</h1>
  2536. <p>When the abstract operation IsAccessorDescriptor is called with <a
  2537. href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
  2538. steps are taken:</p>
  2539. <ol class="proc">
  2540. <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
  2541. <li>If both <i>Desc</i>.[[Get]] and <i>Desc</i>.[[Set]] are absent, return <b>false</b>.</li>
  2542. <li>Return <b>true</b>.</li>
  2543. </ol>
  2544. </section>
  2545. <section id="sec-isdatadescriptor">
  2546. <h1><span class="secnum" id="sec-6.2.4.2"><a href="#sec-isdatadescriptor" title="link to this section">6.2.4.2</a></span>
  2547. IsDataDescriptor ( Desc )</h1>
  2548. <p>When the abstract operation IsDataDescriptor is called with <a
  2549. href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
  2550. steps are taken:</p>
  2551. <ol class="proc">
  2552. <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
  2553. <li>If both <i>Desc</i>.[[Value]] and <i>Desc</i>.[[Writable]] are absent, return <b>false</b>.</li>
  2554. <li>Return <b>true</b>.</li>
  2555. </ol>
  2556. </section>
  2557. <section id="sec-isgenericdescriptor">
  2558. <h1><span class="secnum" id="sec-6.2.4.3"><a href="#sec-isgenericdescriptor"
  2559. title="link to this section">6.2.4.3</a></span> IsGenericDescriptor ( Desc )</h1>
  2560. <p>When the abstract operation IsGenericDescriptor is called with <a
  2561. href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
  2562. steps are taken:</p>
  2563. <ol class="proc">
  2564. <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
  2565. <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) and <a
  2566. href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) are both <b>false</b>, return <b>true</b>.</li>
  2567. <li>Return <b>false</b>.</li>
  2568. </ol>
  2569. </section>
  2570. <section id="sec-frompropertydescriptor">
  2571. <h1><span class="secnum" id="sec-6.2.4.4"><a href="#sec-frompropertydescriptor"
  2572. title="link to this section">6.2.4.4</a></span> FromPropertyDescriptor ( Desc )</h1>
  2573. <p>When the abstract operation FromPropertyDescriptor is called with <a
  2574. href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
  2575. steps are taken:</p>
  2576. <ol class="proc">
  2577. <li>If <i>Desc</i> is <b>undefined</b>, return <b>undefined</b>.</li>
  2578. <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
  2579. sans-serif">%ObjectPrototype%</span>).</li>
  2580. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>obj</i> is an extensible ordinary object with no own
  2581. properties.</li>
  2582. <li>If <i>Desc</i> has a [[Value]] field, then
  2583. <ol class="block">
  2584. <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
  2585. <code>"value"</code>, <i>Desc</i>.[[Value]]).</li>
  2586. </ol>
  2587. </li>
  2588. <li>If <i>Desc</i> has a [[Writable]] field, then
  2589. <ol class="block">
  2590. <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
  2591. <code>"writable"</code>, <i>Desc</i>.[[Writable]]).</li>
  2592. </ol>
  2593. </li>
  2594. <li>If <i>Desc</i> has a [[Get]] field, then
  2595. <ol class="block">
  2596. <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
  2597. <code>"get",</code> <i>Desc</i>.[[Get]]).</li>
  2598. </ol>
  2599. </li>
  2600. <li>If <i>Desc</i> has a [[Set]] field, then
  2601. <ol class="block">
  2602. <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
  2603. <code>"set"</code>, <i>Desc</i>.[[Set]])</li>
  2604. </ol>
  2605. </li>
  2606. <li>If <i>Desc</i> has an [[Enumerable]] field, then
  2607. <ol class="block">
  2608. <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
  2609. <code>"enumerable"</code>, <i>Desc</i>.[[Enumerable]]).</li>
  2610. </ol>
  2611. </li>
  2612. <li>If <i>Desc</i> has a [[Configurable]] field, then
  2613. <ol class="block">
  2614. <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i> ,
  2615. <code>"configurable"</code>, <i>Desc</i>.[[Configurable]]).</li>
  2616. </ol>
  2617. </li>
  2618. <li><a href="#sec-algorithm-conventions">Assert</a>: all of the above <a
  2619. href="#sec-createdataproperty">CreateDataProperty</a> operations return <b>true</b>.</li>
  2620. <li>Return <i>obj</i>.</li>
  2621. </ol>
  2622. </section>
  2623. <section id="sec-topropertydescriptor">
  2624. <h1><span class="secnum" id="sec-6.2.4.5"><a href="#sec-topropertydescriptor"
  2625. title="link to this section">6.2.4.5</a></span> ToPropertyDescriptor ( Obj )</h1>
  2626. <p>When the abstract operation ToPropertyDescriptor is called with object <span class="nt">Obj</span>, the following steps
  2627. are taken:</p>
  2628. <ol class="proc">
  2629. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>Obj</i>).</li>
  2630. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Obj</i>) is not Object throw a <b>TypeError</b>
  2631. exception.</li>
  2632. <li>Let <i>desc</i> be a new <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> that
  2633. initially has no fields.</li>
  2634. <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"enumerable"</code>) is <b>true</b>, then
  2635. <ol class="block">
  2636. <li>Let <i>enum</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
  2637. <code>"enumerable"</code>)).</li>
  2638. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>enum</i>).</li>
  2639. <li>Set the [[Enumerable]] field of <i>desc</i> to <i>enum</i>.</li>
  2640. </ol>
  2641. </li>
  2642. <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"configurable"</code>) is <b>true</b>, then
  2643. <ol class="block">
  2644. <li>Let <i>conf</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
  2645. <code>"configurable"</code>)).</li>
  2646. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>conf</i>).</li>
  2647. <li>Set the [[Configurable]] field of <i>desc</i> to <i>conf</i>.</li>
  2648. </ol>
  2649. </li>
  2650. <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"value"</code>) is <b>true</b>, then
  2651. <ol class="block">
  2652. <li>Let <i>value</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"value"</code>).</li>
  2653. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
  2654. <li>Set the [[Value]] field of <i>desc</i> to <i>value</i>.</li>
  2655. </ol>
  2656. </li>
  2657. <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"writable"</code>) is <b>true</b>, then
  2658. <ol class="block">
  2659. <li>Let <i>writable</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
  2660. <code>"writable"</code>)).</li>
  2661. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>writable</i>).</li>
  2662. <li>Set the [[Writable]] field of <i>desc</i> to <i>writable</i>.</li>
  2663. </ol>
  2664. </li>
  2665. <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"get"</code>) is <b>true</b>, then
  2666. <ol class="block">
  2667. <li>Let <i>getter</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"get"</code>).</li>
  2668. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>getter</i>).</li>
  2669. <li>If <a href="#sec-iscallable">IsCallable</a>(<i>getter</i>) is <b>false</b> and <i>getter</i> is not
  2670. <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
  2671. <li>Set the [[Get]] field of <i>desc</i> to <i>getter</i>.</li>
  2672. </ol>
  2673. </li>
  2674. <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"set"</code>) is <b>true</b>, then
  2675. <ol class="block">
  2676. <li>Let <i>setter</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"set"</code>).</li>
  2677. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>setter</i>).</li>
  2678. <li>If <a href="#sec-iscallable">IsCallable</a>(<i>setter</i>) is <b>false</b> and <i>setter</i> is not
  2679. <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
  2680. <li>Set the [[Set]] field of <i>desc</i> to <i>setter</i>.</li>
  2681. </ol>
  2682. </li>
  2683. <li>If either <i>desc</i>.[[Get]] or <i>desc</i>.[[Set]] are present, then
  2684. <ol class="block">
  2685. <li>If either <i>desc</i>.[[Value]] or <i>desc</i>.[[Writable]] are present, throw a <b>TypeError</b>
  2686. exception.</li>
  2687. </ol>
  2688. </li>
  2689. <li>Return <i>desc</i>.</li>
  2690. </ol>
  2691. </section>
  2692. <section id="sec-completepropertydescriptor">
  2693. <h1><span class="secnum" id="sec-6.2.4.6"><a href="#sec-completepropertydescriptor"
  2694. title="link to this section">6.2.4.6</a></span> CompletePropertyDescriptor ( Desc )</h1>
  2695. <p>When the abstract operation CompletePropertyDescriptor is called with <a
  2696. href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
  2697. steps are taken:</p>
  2698. <ol class="proc">
  2699. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>Desc</i>).</li>
  2700. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>Desc</i> is a <a
  2701. href="#sec-property-descriptor-specification-type">Property Descriptor</a></li>
  2702. <li>Let <i>like</i> be Record{[[Value]]: <b>undefined</b>, [[Writable]]: <b>false</b>, [[Get]]: <b>undefined</b>,
  2703. [[Set]]: <b>undefined</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b>}.</li>
  2704. <li>If either <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) or <a
  2705. href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
  2706. <ol class="block">
  2707. <li>If <i>Desc</i> does not have a [[Value]] field, set <i>Desc</i>.[[Value]] to <i>like</i>.[[Value]].</li>
  2708. <li>If <i>Desc</i> does not have a [[Writable]] field, set <i>Desc</i>.[[Writable]] to
  2709. <i>like</i>.[[Writable]].</li>
  2710. </ol>
  2711. </li>
  2712. <li>Else,
  2713. <ol class="block">
  2714. <li>If <i>Desc</i> does not have a [[Get]] field, set <i>Desc</i>.[[Get]] to <i>like</i>.[[Get]].</li>
  2715. <li>If <i>Desc</i> does not have a [[Set]] field, set <i>Desc</i>.[[Set]] to <i>like</i>.[[Set]].</li>
  2716. </ol>
  2717. </li>
  2718. <li>If <i>Desc</i> does not have an [[Enumerable]] field, set <i>Desc</i>.[[Enumerable]] to
  2719. <i>like</i>.[[Enumerable]].</li>
  2720. <li>If <i>Desc</i> does not have a [[Configurable]] field, set <i>Desc</i>.[[Configurable]] to
  2721. <i>like</i>.[[Configurable]].</li>
  2722. <li>Return <i>Desc</i>.</li>
  2723. </ol>
  2724. </section>
  2725. </section>
  2726. <section id="sec-lexical-environment-and-environment-record-specification-types">
  2727. <h1><span class="secnum" id="sec-6.2.5"><a href="#sec-lexical-environment-and-environment-record-specification-types"
  2728. title="link to this section">6.2.5</a></span> The Lexical Environment and Environment Record Specification Types</h1>
  2729. <p>The <a href="#sec-lexical-environments">Lexical Environment</a> and <a href="#sec-environment-records">Environment
  2730. Record</a> types are used to explain the behaviour of name resolution in nested functions and blocks. These types and the
  2731. operations upon them are defined in <a href="#sec-lexical-environments">8.1</a>.</p>
  2732. </section>
  2733. <section id="sec-data-blocks">
  2734. <div class="front">
  2735. <h1><span class="secnum" id="sec-6.2.6"><a href="#sec-data-blocks" title="link to this section">6.2.6</a></span> Data
  2736. Blocks</h1>
  2737. <p>The Data Block specification type is used to describe a distinct and mutable sequence of byte-sized (8 bit) numeric
  2738. values. A Data Block value is created with a fixed number of bytes that each have the initial value 0.</p>
  2739. <p>For notational convenience within this specification, an array-like syntax can be used to express to the individual
  2740. bytes of a Data Block value. This notation presents a Data Block value as a 0-origined integer indexed sequence of bytes.
  2741. For example, if <var>db</var> is a 5 byte Data Block value then <var>db</var>[2] can be used to express access to its
  2742. 3<sup>rd</sup> byte.</p>
  2743. <p>The following abstract operations are used in this specification to operate upon Data Block values:</p>
  2744. </div>
  2745. <section id="sec-createbytedatablock">
  2746. <h1><span class="secnum" id="sec-6.2.6.1"><a href="#sec-createbytedatablock"
  2747. title="link to this section">6.2.6.1</a></span> CreateByteDataBlock(size)</h1>
  2748. <p>When the abstract operation CreateByteDataBlock is called with integer argument <var>size</var>, the following steps
  2749. are taken:</p>
  2750. <ol class="proc">
  2751. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>size</i>&ge;0.</li>
  2752. <li>Let <i>db</i> be a new <a href="#sec-data-blocks">Data Block</a> value consisting of <i>size</i> bytes. If it is
  2753. impossible to create such a <a href="#sec-data-blocks">Data Block</a>, throw a <b>RangeError</b> exception.</li>
  2754. <li>Set all of the bytes of <i>db</i> to 0.</li>
  2755. <li>Return <i>db</i>.</li>
  2756. </ol>
  2757. </section>
  2758. <section id="sec-copydatablockbytes">
  2759. <h1><span class="secnum" id="sec-6.2.6.2"><a href="#sec-copydatablockbytes"
  2760. title="link to this section">6.2.6.2</a></span> CopyDataBlockBytes(toBlock, toIndex, fromBlock, fromIndex, count)</h1>
  2761. <p>When the abstract operation CopyDataBlockBytes is called the following steps are taken:</p>
  2762. <ol class="proc">
  2763. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromBlock</i> and <i>toBlock</i> are distinct <a
  2764. href="#sec-data-blocks">Data Block</a> values.</li>
  2765. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromIndex</i>, <i>toIndex</i>, and <i>count</i> are positive
  2766. integer values.</li>
  2767. <li>Let <i>fromSize</i> be the number of bytes in <i>fromBlock</i>.</li>
  2768. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromIndex</i>+<i>count</i> &le; <i>fromSize</i>.</li>
  2769. <li>Let <i>toSize</i> be the number of bytes in <i>toBlock</i>.</li>
  2770. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>toIndex</i>+<i>count</i> &le; <i>toSize</i>.</li>
  2771. <li>Repeat, while <i>count</i>&gt;0
  2772. <ol class="block">
  2773. <li>Set <i>toBlock</i>[<i>toIndex</i>] to the value of <i>fromBlock</i>[<i>fromIndex</i>].</li>
  2774. <li>Increment <i>toIndex</i> and <i>fromIndex</i> each by 1.</li>
  2775. <li>Decrement <i>count</i> by 1.</li>
  2776. </ol>
  2777. </li>
  2778. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>)</li>
  2779. </ol>
  2780. </section>
  2781. </section>
  2782. </section>
  2783. </section>
  2784. <section id="sec-abstract-operations">
  2785. <div class="front">
  2786. <h1><span class="secnum" id="sec-7"><a href="#sec-abstract-operations" title="link to this section">7</a></span> Abstract
  2787. Operations</h1>
  2788. <p>These operations are not a part of the ECMAScript language; they are defined here to solely to aid the specification of the
  2789. semantics of the ECMAScript language. Other, more specialized abstract operations are defined throughout this
  2790. specification.</p>
  2791. </div>
  2792. <section id="sec-type-conversion">
  2793. <div class="front">
  2794. <h1><span class="secnum" id="sec-7.1"><a href="#sec-type-conversion" title="link to this section">7.1</a></span> Type
  2795. Conversion</h1>
  2796. <p>The ECMAScript language implicitly performs automatic type conversion as needed. To clarify the semantics of certain
  2797. constructs it is useful to define a set of conversion abstract operations. The conversion abstract operations are
  2798. polymorphic; they can accept a value of any <a href="#sec-ecmascript-language-types">ECMAScript language type</a> or of a <a
  2799. href="#sec-completion-record-specification-type">Completion Record</a> value. But no other specification types are used with
  2800. these operations.</p>
  2801. </div>
  2802. <section id="sec-toprimitive">
  2803. <h1><span class="secnum" id="sec-7.1.1"><a href="#sec-toprimitive" title="link to this section">7.1.1</a></span> ToPrimitive
  2804. ( input [, PreferredType] )</h1>
  2805. <p>The abstract operation ToPrimitive takes an <var>input</var> argument and an optional argument <span
  2806. class="nt">PreferredType</span>. The abstract operation ToPrimitive converts its <var>input</var> argument to a non-Object
  2807. type. If an object is capable of converting to more than one primitive type, it may use the optional hint <span
  2808. class="nt">PreferredType</span> to favour that type. Conversion occurs according to <a href="#table-9">Table 9</a>:</p>
  2809. <figure>
  2810. <figcaption><span id="table-9">Table 9</span> &mdash; ToPrimitive Conversions</figcaption>
  2811. <table class="real-table">
  2812. <tr>
  2813. <th>Input Type</th>
  2814. <th>Result</th>
  2815. </tr>
  2816. <tr>
  2817. <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
  2818. <td>If <var>input</var> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return <var>input</var>. Otherwise return ToPrimitive(<var>input</var>.[[value]]) also passing the optional hint <span class="nt">PreferredType</span>.</td>
  2819. </tr>
  2820. <tr>
  2821. <td>Undefined</td>
  2822. <td>Return <var>input</var>.</td>
  2823. </tr>
  2824. <tr>
  2825. <td>Null</td>
  2826. <td>Return <var>input</var>.</td>
  2827. </tr>
  2828. <tr>
  2829. <td>Boolean</td>
  2830. <td>Return <var>input</var>.</td>
  2831. </tr>
  2832. <tr>
  2833. <td>Number</td>
  2834. <td>Return <var>input</var>.</td>
  2835. </tr>
  2836. <tr>
  2837. <td>String</td>
  2838. <td>Return <var>input</var>.</td>
  2839. </tr>
  2840. <tr>
  2841. <td>Symbol</td>
  2842. <td>Return <var>input</var>.</td>
  2843. </tr>
  2844. <tr>
  2845. <td>Object</td>
  2846. <td>Perform the steps following this table.</td>
  2847. </tr>
  2848. </table>
  2849. </figure>
  2850. <p>When <span style="font-family: Times New Roman"><a
  2851. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>input</i>)</span> is Object, the following steps are taken:</p>
  2852. <ol class="proc">
  2853. <li>If <i>PreferredType</i> was not passed, let <i>hint</i> be <code>"default"</code>.</li>
  2854. <li>Else if <i>PreferredType</i> is hint String, let <i>hint</i> be <code>"string"</code>.</li>
  2855. <li>Else <i>PreferredType</i> is hint Number, let <i>hint</i> be <code>"number"</code>.</li>
  2856. <li>Let <i>exoticToPrim</i> be <a href="#sec-getmethod">GetMethod</a>(<i>input</i>, @@toPrimitive).</li>
  2857. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exoticToPrim</i>).</li>
  2858. <li>If <i>exoticToPrim</i> is not <b>undefined</b>, then
  2859. <ol class="block">
  2860. <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>exoticToPrim</i>, <i>input,</i>
  2861. &laquo;<i>hint</i>&raquo;).</li>
  2862. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
  2863. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, return
  2864. <i>result</i>.</li>
  2865. <li>Throw a <b>TypeError</b> exception.</li>
  2866. </ol>
  2867. </li>
  2868. <li>If <i>hint</i> is <code>"default"</code>, let <i>hint</i> be <code>"number"</code>.</li>
  2869. <li>Return OrdinaryToPrimitive(<i>input,hint</i>).</li>
  2870. </ol>
  2871. <p>When the abstract operation OrdinaryToPrimitive is called with arguments <var>O</var> and <var>hint</var>, the following
  2872. steps are taken:</p>
  2873. <ol class="proc">
  2874. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  2875. Object</li>
  2876. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>hint</i>)
  2877. is String and its value is either <code>"string"</code> or <code>"number"</code>.</li>
  2878. <li>If <i>hint</i> is <code>"string"</code>, then
  2879. <ol class="block">
  2880. <li>Let <i>methodNames</i> be &laquo;<code>"toString"</code>, <code>"valueOf"</code>&raquo;.</li>
  2881. </ol>
  2882. </li>
  2883. <li>Else,
  2884. <ol class="block">
  2885. <li>Let <i>methodNames</i> be &laquo;<code>"valueOf"</code>, <code>"toString"</code>&raquo;.</li>
  2886. </ol>
  2887. </li>
  2888. <li>For each <i>name</i> in <i>methodNames</i> in <a href="#sec-list-and-record-specification-type">List</a> order, do
  2889. <ol class="block">
  2890. <li>Let <i>method</i> be <a href="#sec-get-o-p">Get</a>(<i>O</i>, <i>name</i>).</li>
  2891. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>method</i>).</li>
  2892. <li>If <a href="#sec-iscallable">IsCallable</a>(<i>method</i>) is <b>true</b>, then
  2893. <ol class="block">
  2894. <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>method</i>, <i>O</i>).</li>
  2895. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
  2896. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, return
  2897. <i>result</i>.</li>
  2898. </ol>
  2899. </li>
  2900. </ol>
  2901. </li>
  2902. <li>Throw a <b>TypeError</b> exception.</li>
  2903. </ol>
  2904. <div class="note">
  2905. <p><span class="nh">NOTE</span> When ToPrimitive is called with no hint, then it generally behaves as if the hint were
  2906. Number. However, objects may over-ride this behaviour by defining a @@toPrimitive method. Of the objects defined in this
  2907. specification only Date objects (<a href="#sec-date.prototype-@@toprimitive">see 20.3.4.45</a>) and Symbol objects (<a
  2908. href="#sec-symbol.prototype-@@toprimitive">see 19.4.3.4</a>) over-ride the default ToPrimitive behaviour. Date objects
  2909. treat no hint as if the hint were String.</p>
  2910. </div>
  2911. </section>
  2912. <section id="sec-toboolean">
  2913. <h1><span class="secnum" id="sec-7.1.2"><a href="#sec-toboolean" title="link to this section">7.1.2</a></span> ToBoolean (
  2914. argument )</h1>
  2915. <p>The abstract operation ToBoolean converts <var>argument</var> to a value of type Boolean according to <a
  2916. href="#table-10">Table 10</a>:</p>
  2917. <figure>
  2918. <figcaption><span id="table-10">Table 10</span> &mdash; ToBoolean Conversions</figcaption>
  2919. <table class="real-table">
  2920. <tr>
  2921. <th>Argument Type</th>
  2922. <th>Result</th>
  2923. </tr>
  2924. <tr>
  2925. <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
  2926. <td>If <var>argument</var> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return <var>argument</var>. Otherwise return ToBoolean(<var>argument</var>.[[value]]).</td>
  2927. </tr>
  2928. <tr>
  2929. <td>Undefined</td>
  2930. <td>Return <b>false</b>.</td>
  2931. </tr>
  2932. <tr>
  2933. <td>Null</td>
  2934. <td>Return <b>false</b>.</td>
  2935. </tr>
  2936. <tr>
  2937. <td>Boolean</td>
  2938. <td>Return <var>argument</var>.</td>
  2939. </tr>
  2940. <tr>
  2941. <td>Number</td>
  2942. <td>Return <b>false</b> if <var>argument</var> is <b>+0</b>, <b>&minus;0</b>, or <b>NaN</b>; otherwise return <b>true</b>.</td>
  2943. </tr>
  2944. <tr>
  2945. <td>String</td>
  2946. <td>Return <b>false</b> if <var>argument</var> is the empty String (its length is zero); otherwise return <b>true</b>.</td>
  2947. </tr>
  2948. <tr>
  2949. <td>Symbol</td>
  2950. <td>Return <b>true</b>.</td>
  2951. </tr>
  2952. <tr>
  2953. <td>Object</td>
  2954. <td>Return <b>true</b>.</td>
  2955. </tr>
  2956. </table>
  2957. </figure>
  2958. </section>
  2959. <section id="sec-tonumber">
  2960. <div class="front">
  2961. <h1><span class="secnum" id="sec-7.1.3"><a href="#sec-tonumber" title="link to this section">7.1.3</a></span> ToNumber (
  2962. argument )</h1>
  2963. <p>The abstract operation ToNumber converts <var>argument</var> to a value of type Number according to <a
  2964. href="#table-11">Table 11</a>:</p>
  2965. <figure>
  2966. <figcaption><span id="table-11">Table 11</span> &mdash; ToNumber Conversions</figcaption>
  2967. <table class="real-table">
  2968. <tr>
  2969. <th>Argument Type</th>
  2970. <th>Result</th>
  2971. </tr>
  2972. <tr>
  2973. <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
  2974. <td>If <var>argument</var> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return <var>argument</var>. Otherwise return ToNumber(<var>argument</var>.[[value]]).</td>
  2975. </tr>
  2976. <tr>
  2977. <td>Undefined</td>
  2978. <td>Return <b>NaN</b>.</td>
  2979. </tr>
  2980. <tr>
  2981. <td>Null</td>
  2982. <td>Return <b>+0</b>.</td>
  2983. </tr>
  2984. <tr>
  2985. <td>Boolean</td>
  2986. <td>Return <b>1</b> if <var>argument</var> is <b>true</b>. Return <b>+0</b> if <var>argument</var> is <b>false</b>.</td>
  2987. </tr>
  2988. <tr>
  2989. <td>Number</td>
  2990. <td>Return <var>argument</var> (no conversion).</td>
  2991. </tr>
  2992. <tr>
  2993. <td>String</td>
  2994. <td>See grammar and conversion algorithm below.</td>
  2995. </tr>
  2996. <tr>
  2997. <td>Symbol</td>
  2998. <td>Throw a <b>TypeError</b> exception.</td>
  2999. </tr>
  3000. <tr>
  3001. <td>Object</td>
  3002. <td>
  3003. <p>Apply the following steps:</p>
  3004. <ol class="proc">
  3005. <li>Let <i>primValue</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint Number).</li>
  3006. <li>Return ToNumber(<i>primValue</i>).</li>
  3007. </ol>
  3008. </td>
  3009. </tr>
  3010. </table>
  3011. </figure>
  3012. </div>
  3013. <section id="sec-tonumber-applied-to-the-string-type">
  3014. <div class="front">
  3015. <h1><span class="secnum" id="sec-7.1.3.1"><a href="#sec-tonumber-applied-to-the-string-type"
  3016. title="link to this section">7.1.3.1</a></span> ToNumber Applied to the String Type</h1>
  3017. <p><a href="#sec-tonumber">ToNumber</a> applied to Strings applies the following grammar to the input String interpreted
  3018. as a sequence of UTF-16 encoded code points (<a href="#sec-ecmascript-language-types-string-type">6.1.4</a>). If the
  3019. grammar cannot interpret the String as an expansion of <span class="nt">StringNumericLiteral</span>, then the result of
  3020. <a href="#sec-tonumber">ToNumber</a> is <b>NaN</b>.</p>
  3021. <div class="note">
  3022. <p><span class="nh">NOTE</span> The terminal symbols of this grammar are all composed of Unicode BMP code points so
  3023. the result will be <b>NaN</b> if the string contains the UTF-16 encoding of any supplementary code points or any
  3024. unpaired surrogate code points</p>
  3025. </div>
  3026. <h2>Syntax</h2>
  3027. <div class="gp">
  3028. <div class="lhs"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span></div>
  3029. <div class="rhs"><span class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></div>
  3030. <div class="rhs"><span class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub> <span class="nt">StrNumericLiteral</span> <span class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></div>
  3031. </div>
  3032. <div class="gp">
  3033. <div class="lhs"><span class="nt">StrWhiteSpace</span> <span class="geq">:::</span></div>
  3034. <div class="rhs"><span class="nt">StrWhiteSpaceChar</span> <span class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></div>
  3035. </div>
  3036. <div class="gp">
  3037. <div class="lhs"><span class="nt">StrWhiteSpaceChar</span> <span class="geq">:::</span></div>
  3038. <div class="rhs"><span class="nt">WhiteSpace</span></div>
  3039. <div class="rhs"><span class="nt">LineTerminator</span></div>
  3040. </div>
  3041. <div class="gp">
  3042. <div class="lhs"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span></div>
  3043. <div class="rhs"><span class="nt">StrDecimalLiteral</span></div>
  3044. <div class="rhs"><span class="nt">BinaryIntegerLiteral</span></div>
  3045. <div class="rhs"><span class="nt">OctalIntegerLiteral</span></div>
  3046. <div class="rhs"><span class="nt">HexIntegerLiteral</span></div>
  3047. </div>
  3048. <div class="gp">
  3049. <div class="lhs"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span></div>
  3050. <div class="rhs"><span class="nt">StrUnsignedDecimalLiteral</span></div>
  3051. <div class="rhs"><code class="t">+</code> <span class="nt">StrUnsignedDecimalLiteral</span></div>
  3052. <div class="rhs"><code class="t">-</code> <span class="nt">StrUnsignedDecimalLiteral</span></div>
  3053. </div>
  3054. <div class="gp">
  3055. <div class="lhs"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span></div>
  3056. <div class="rhs"><span class="nt">Infinity</span></div>
  3057. <div class="rhs"><span class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">DecimalDigits</span><sub class="g-opt">opt</sub> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
  3058. <div class="rhs"><code class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
  3059. <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
  3060. </div>
  3061. <div class="gp">
  3062. <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">:::</span></div>
  3063. <div class="rhs"><span class="nt">DecimalDigit</span></div>
  3064. <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
  3065. </div>
  3066. <div class="gp">
  3067. <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">:::</span> <span class="grhsmod">one of</span></div>
  3068. <div class="rhs"><code class="t">0</code> <code class="t">1</code> <code class="t">2</code> <code class="t">3</code> <code class="t">4</code> <code class="t">5</code> <code class="t">6</code> <code class="t">7</code> <code class="t">8</code> <code class="t">9</code></div>
  3069. </div>
  3070. <div class="gp">
  3071. <div class="lhs"><span class="nt">ExponentPart</span> <span class="geq">:::</span></div>
  3072. <div class="rhs"><span class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></div>
  3073. </div>
  3074. <div class="gp">
  3075. <div class="lhs"><span class="nt">ExponentIndicator</span> <span class="geq">:::</span> <span class="grhsmod">one of</span></div>
  3076. <div class="rhs"><code class="t">e</code> <code class="t">E</code></div>
  3077. </div>
  3078. <div class="gp">
  3079. <div class="lhs"><span class="nt">SignedInteger</span> <span class="geq">:::</span></div>
  3080. <div class="rhs"><span class="nt">DecimalDigits</span></div>
  3081. <div class="rhs"><code class="t">+</code> <span class="nt">DecimalDigits</span></div>
  3082. <div class="rhs"><code class="t">-</code> <span class="nt">DecimalDigits</span></div>
  3083. </div>
  3084. <p>All grammar symbols not explicitly defined above have the definitions used in the Lexical Grammar for numeric
  3085. literals (<a href="#sec-literals-numeric-literals">11.8.3</a>)</p>
  3086. <div class="note">
  3087. <p><span class="nh">NOTE</span> Some differences should be noted between the syntax of a <i>StringNumericLiteral</i>
  3088. and a <i>NumericLiteral</i> (<a href="#sec-literals-numeric-literals">see 11.8.3</a>):</p>
  3089. <ul>
  3090. <li>
  3091. <p>A <i>StringNumericLiteral</i> may include leading and/or trailing white space and/or line terminators.</p>
  3092. </li>
  3093. <li>
  3094. <p>A <i>StringNumericLiteral</i> that is decimal may have any number of leading <code>0</code> digits.</p>
  3095. </li>
  3096. <li>
  3097. <p>A <i>StringNumericLiteral</i> that is decimal may include a <code>+</code> or <code>-</code> to indicate its
  3098. sign.</p>
  3099. </li>
  3100. <li>
  3101. <p>A <i>StringNumericLiteral</i> that is empty or contains only white space is converted to <b>+0</b>.</p>
  3102. </li>
  3103. <li>
  3104. <p><code>Infinity</code> <code>and &ndash;Infinity</code> are recognized as a <i>StringNumericLiteral</i> but not
  3105. as a <i>NumericLiteral</i>.</p>
  3106. </li>
  3107. </ul>
  3108. </div>
  3109. </div>
  3110. <section id="sec-runtime-semantics-mv-s">
  3111. <h1><span class="secnum" id="sec-7.1.3.1.1"><a href="#sec-runtime-semantics-mv-s"
  3112. title="link to this section">7.1.3.1.1</a></span> Runtime Semantics: MV&rsquo;s</h1>
  3113. <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a
  3114. numeric literal (<a href="#sec-literals-numeric-literals">see 11.8.3</a>), but some of the details are different, so the
  3115. process for converting a String numeric literal to a value of Number type is given here. This value is determined in two
  3116. steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is
  3117. rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <a
  3118. href="#sec-static-semantics-mv-s">11.8.3.1</a>.</p>
  3119. <ul>
  3120. <li>
  3121. <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <span
  3122. class="grhsannot">[empty]</span></span> is 0.</p>
  3123. </li>
  3124. <li>
  3125. <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <span
  3126. class="nt">StrWhiteSpace</span></span> is 0.</p>
  3127. </li>
  3128. <li>
  3129. <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <span
  3130. class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub> <span class="nt">StrNumericLiteral</span> <span
  3131. class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></span> is the MV of <span
  3132. class="nt">StrNumericLiteral</span>, no matter whether white space is present or not.</p>
  3133. </li>
  3134. <li>
  3135. <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
  3136. class="nt">StrDecimalLiteral</span></span> is the MV of <span class="nt">StrDecimalLiteral</span>.</p>
  3137. </li>
  3138. <li>
  3139. <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
  3140. class="nt">BinaryIntegerLiteral</span></span> is the MV of <span class="nt">BinaryIntegerLiteral</span>.</p>
  3141. </li>
  3142. <li>
  3143. <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
  3144. class="nt">OctalIntegerLiteral</span></span> is the MV of <span class="nt">OctalIntegerLiteral</span>.</p>
  3145. </li>
  3146. <li>
  3147. <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
  3148. class="nt">HexIntegerLiteral</span></span> is the MV of <span class="nt">HexIntegerLiteral</span>.</p>
  3149. </li>
  3150. <li>
  3151. <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <span
  3152. class="nt">StrUnsignedDecimalLiteral</span></span> is the MV of <span
  3153. class="nt">StrUnsignedDecimalLiteral</span>.</p>
  3154. </li>
  3155. <li>
  3156. <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <code
  3157. class="t">+</code> <span class="nt">StrUnsignedDecimalLiteral</span></span> is the MV of <span
  3158. class="nt">StrUnsignedDecimalLiteral</span>.</p>
  3159. </li>
  3160. <li>
  3161. <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <code
  3162. class="t">-</code> <span class="nt">StrUnsignedDecimalLiteral</span></span> is the negative of the MV of <span
  3163. class="nt">StrUnsignedDecimalLiteral</span>. (Note that if the MV of <span
  3164. class="nt">StrUnsignedDecimalLiteral</span> is 0, the negative of this MV is also 0. The rounding rule described
  3165. below handles the conversion of this signless mathematical zero to a floating-point <b>+0</b> or <b>&minus;0</b> as
  3166. appropriate.)</p>
  3167. </li>
  3168. <li>
  3169. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
  3170. class="nt">Infinity</span></span> is <span style="font-family: Times New Roman">10<sup>10000</sup></span> (a value
  3171. so large that it will round to <b>+&infin;</b>).</p>
  3172. </li>
  3173. <li>
  3174. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
  3175. class="nt">DecimalDigits</span> <code class="t">.</code></span> is the MV of <span
  3176. class="nt">DecimalDigits</span>.</p>
  3177. </li>
  3178. <li>
  3179. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
  3180. class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of
  3181. the first <span class="nt">DecimalDigits</span> plus (the MV of the second <span class="nt">DecimalDigits</span>
  3182. times <span style="font-family: Times New Roman">10<sup>&minus;<i>n</i></sup></span>), where <var>n</var> is the
  3183. number of code points in the second <span class="nt">DecimalDigits</span>.</p>
  3184. </li>
  3185. <li>
  3186. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
  3187. class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">ExponentPart</span></span> is the MV of
  3188. <i>DecimalDigits</i> times 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
  3189. </li>
  3190. <li>
  3191. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
  3192. class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">DecimalDigits</span> <span
  3193. class="nt">ExponentPart</span></span> is (the MV of the first <i>DecimalDigits</i> plus (the MV of the second
  3194. <i>DecimalDigits</i> times 10<sup>&minus;<i>n</i></sup>)) times 10<sup><i>e</i></sup>, where <i>n</i> is the number
  3195. of code points in the second <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
  3196. </li>
  3197. <li>
  3198. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <code
  3199. class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i> times
  3200. 10<sup>&minus;<i>n</i></sup>, where <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
  3201. </li>
  3202. <li>
  3203. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <code
  3204. class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of
  3205. <i>DecimalDigits</i> times 10<sup><i>e</i>&minus;<i>n</i></sup>, where <i>n</i> is the number of code points in
  3206. <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
  3207. </li>
  3208. <li>
  3209. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
  3210. class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
  3211. </li>
  3212. <li>
  3213. <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
  3214. class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of <i>DecimalDigits</i> times
  3215. 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
  3216. </li>
  3217. </ul>
  3218. <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type.
  3219. If the MV is 0, then the rounded value is +0 unless the first non white space code point in the String numeric literal
  3220. is &lsquo;<code>-</code>&rsquo;, in which case the rounded value is &minus;0. Otherwise, the rounded value must be the
  3221. Number value for the MV (in the sense defined in <a href="#sec-ecmascript-language-types-number-type">6.1.6</a>), unless
  3222. the literal includes a <span class="nt">StrUnsignedDecimalLiteral</span> and the literal has more than 20 significant
  3223. digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each
  3224. significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each
  3225. significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is
  3226. significant if it is not part of an <span class="nt">ExponentPart</span> and</p>
  3227. <ul>
  3228. <li>it is not <code>0</code>; or</li>
  3229. <li>there is a nonzero digit to its left and there is a nonzero digit, not in the <span
  3230. class="nt">ExponentPart</span>, to its right.</li>
  3231. </ul>
  3232. </section>
  3233. </section>
  3234. </section>
  3235. <section id="sec-tointeger">
  3236. <h1><span class="secnum" id="sec-7.1.4"><a href="#sec-tointeger" title="link to this section">7.1.4</a></span> ToInteger (
  3237. argument )</h1>
  3238. <p>The abstract operation ToInteger converts <var>argument</var> to an integral numeric value. This abstract operation
  3239. functions as follows:</p>
  3240. <ol class="proc">
  3241. <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3242. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
  3243. <li>If <i>number</i> is <b>NaN</b>, return <b>+0</b>.</li>
  3244. <li>If <i>number</i> is <b>+0</b>, <b>&minus;0</b>, <b>+&infin;,</b> or <b>&minus;&infin;</b>, return <i>number</i>.</li>
  3245. <li>Return the number value that is the same sign as <i>number</i> and whose magnitude is <a
  3246. href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
  3247. </ol>
  3248. </section>
  3249. <section id="sec-toint32">
  3250. <h1><span class="secnum" id="sec-7.1.5"><a href="#sec-toint32" title="link to this section">7.1.5</a></span> ToInt32 (
  3251. argument )</h1>
  3252. <p>The abstract operation ToInt32 converts <var>argument</var> to one of <span style="font-family: Times New
  3253. Roman">2<sup>32</sup></span> integer values in the range <span style="font-family: Times New
  3254. Roman">&minus;2<sup>31</sup></span> through <span style="font-family: Times New Roman">2<sup>31</sup>&minus;1</span>,
  3255. inclusive. This abstract operation functions as follows:</p>
  3256. <ol class="proc">
  3257. <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3258. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
  3259. <li>If <i>number</i> is <b>NaN</b>, <b>+0</b>, <b>&minus;0</b>, <b>+&infin;</b>, or <b>&minus;&infin;</b>, return
  3260. <b>+0</b>.</li>
  3261. <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
  3262. href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
  3263. <li>Let <i>int32bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>32</sup>.</li>
  3264. <li>If <i>int32bit</i> &ge; 2<sup>31</sup>, return <i>int32bit</i> &minus; 2<sup>32</sup>, otherwise return
  3265. <i>int32bit</i>.</li>
  3266. </ol>
  3267. <div class="note">
  3268. <p><span class="nh">NOTE</span> Given the above definition of ToInt32:</p>
  3269. <ul>
  3270. <li>
  3271. <p>The ToInt32 abstract operation is idempotent: if applied to a result that it produced, the second application
  3272. leaves that value unchanged.</p>
  3273. </li>
  3274. <li>
  3275. <p><i>ToInt32(<a href="#sec-touint32">ToUint32</a>(x))</i> is equal to ToInt32(<i>x</i>) for all values of <i>x</i>.
  3276. (It is to preserve this latter property that +<b>&infin;</b> and &minus;<b>&infin;</b> are mapped to <b>+0</b>.)</p>
  3277. </li>
  3278. <li>
  3279. <p>ToInt32 maps <b>&minus;0</b> to <b>+0</b>.</p>
  3280. </li>
  3281. </ul>
  3282. </div>
  3283. </section>
  3284. <section id="sec-touint32">
  3285. <h1><span class="secnum" id="sec-7.1.6"><a href="#sec-touint32" title="link to this section">7.1.6</a></span> ToUint32 (
  3286. argument )</h1>
  3287. <p>The abstract operation ToUint32 converts <var>argument</var> to one of <span style="font-family: Times New
  3288. Roman">2<sup>32</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
  3289. style="font-family: Times New Roman">2<sup>32</sup>&minus;1</span>, inclusive. This abstract operation functions as
  3290. follows:</p>
  3291. <ol class="proc">
  3292. <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3293. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
  3294. <li>If <i>number</i> is <b>NaN</b>, <b>+0</b>, <b>&minus;0</b>, <b>+&infin;</b>, or <b>&minus;&infin;</b>, return
  3295. <b>+0</b>.</li>
  3296. <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
  3297. href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
  3298. <li>Let <i>int32bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>32</sup>.</li>
  3299. <li>Return <i>int32bit</i>.</li>
  3300. </ol>
  3301. <div class="note">
  3302. <p><span class="nh">NOTE</span> Given the above definition of ToUint32:</p>
  3303. <ul>
  3304. <li>
  3305. <p>Step 6 is the only difference between ToUint32 and <a href="#sec-toint32">ToInt32</a>.</p>
  3306. </li>
  3307. <li>
  3308. <p>The ToUint32 abstract operation is idempotent: if applied to a result that it produced, the second application
  3309. leaves that value unchanged.</p>
  3310. </li>
  3311. <li>
  3312. <p>ToUint32(<a href="#sec-toint32">ToInt32</a>(<i>x</i>)) is equal to ToUint32(<i>x</i>) for all values of <i>x</i>.
  3313. (It is to preserve this latter property that <b>+&infin;</b> and <b>&minus;&infin;</b> are mapped to <b>+0</b>.)</p>
  3314. </li>
  3315. <li>
  3316. <p>ToUint32 maps <b>&minus;0</b> to <b>+0</b>.</p>
  3317. </li>
  3318. </ul>
  3319. </div>
  3320. </section>
  3321. <section id="sec-toint16">
  3322. <h1><span class="secnum" id="sec-7.1.7"><a href="#sec-toint16" title="link to this section">7.1.7</a></span> ToInt16 (
  3323. argument )</h1>
  3324. <p>The abstract operation ToInt16 converts <var>argument</var> to one of <span style="font-family: Times New
  3325. Roman">2<sup>16</sup></span> integer values in the range <span style="font-family: Times New Roman">&minus;32768</span>
  3326. through <span style="font-family: Times New Roman">32767</span>, inclusive. This abstract operation functions as
  3327. follows:</p>
  3328. <ol class="proc">
  3329. <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3330. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
  3331. <li>If <i>number</i> is <b>NaN</b>, <b>+0</b>, <b>&minus;0</b>, <b>+&infin;</b>, or <b>&minus;&infin;</b>, return
  3332. <b>+0</b>.</li>
  3333. <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
  3334. href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
  3335. <li>Let <i>int16bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>16</sup>.</li>
  3336. <li>If <i>int16bit</i> &ge; 2<sup>15</sup>, return <i>int16bit</i> &minus; 2<sup>16</sup>, otherwise return
  3337. <i>int16bit</i>.</li>
  3338. </ol>
  3339. </section>
  3340. <section id="sec-touint16">
  3341. <h1><span class="secnum" id="sec-7.1.8"><a href="#sec-touint16" title="link to this section">7.1.8</a></span> ToUint16 (
  3342. argument )</h1>
  3343. <p>The abstract operation ToUint16 converts <var>argument</var> to one of <span style="font-family: Times New
  3344. Roman">2<sup>16</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
  3345. style="font-family: Times New Roman">2<sup>16</sup>&minus;1</span>, inclusive. This abstract operation functions as
  3346. follows:</p>
  3347. <ol class="proc">
  3348. <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3349. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
  3350. <li>If <i>number</i> is <b>NaN</b>, <b>+0</b>, <b>&minus;0</b>, <b>+&infin;</b>, or <b>&minus;&infin;</b>, return
  3351. <b>+0</b>.</li>
  3352. <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
  3353. href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
  3354. <li>Let <i>int16bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>16</sup>.</li>
  3355. <li>Return <i>int16bit</i>.</li>
  3356. </ol>
  3357. <div class="note">
  3358. <p><span class="nh">NOTE</span> Given the above definition of ToUint16:</p>
  3359. <ul>
  3360. <li>The substitution of 2<sup>16</sup> for 2<sup>32</sup> in step 5 is the only difference between <a
  3361. href="#sec-touint32">ToUint32</a> and ToUint16.</li>
  3362. <li>ToUint16 maps <b>&minus;0</b> to <span style="font-family: sans-serif"><b>+0</b></span>.</li>
  3363. </ul>
  3364. </div>
  3365. </section>
  3366. <section id="sec-toint8">
  3367. <h1><span class="secnum" id="sec-7.1.9"><a href="#sec-toint8" title="link to this section">7.1.9</a></span> ToInt8 (
  3368. argument )</h1>
  3369. <p>The abstract operation ToInt8 converts <var>argument</var> to one of <span style="font-family: Times New
  3370. Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">&minus;128</span> through
  3371. <span style="font-family: Times New Roman">127</span>, inclusive. This abstract operation functions as follows:</p>
  3372. <ol class="proc">
  3373. <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3374. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
  3375. <li>If <i>number</i> is <b>NaN</b>, <b>+0</b>, <b>&minus;0</b>, <b>+&infin;</b>, or <b>&minus;&infin;</b>, return
  3376. <b>+0</b>.</li>
  3377. <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
  3378. href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
  3379. <li>Let <i>int8bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>8</sup>.</li>
  3380. <li>If <i>int8bit</i> &ge; 2<sup>7</sup>, return <i>int8bit</i> &minus; 2<sup>8</sup>, otherwise return
  3381. <i>int8bit</i>.</li>
  3382. </ol>
  3383. </section>
  3384. <section id="sec-touint8">
  3385. <h1><span class="secnum" id="sec-7.1.10"><a href="#sec-touint8" title="link to this section">7.1.10</a></span> ToUint8 (
  3386. argument )</h1>
  3387. <p>The abstract operation ToUint8 converts <var>argument</var> to one of <span style="font-family: Times New
  3388. Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
  3389. style="font-family: Times New Roman">255</span>, inclusive. This abstract operation functions as follows:</p>
  3390. <ol class="proc">
  3391. <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3392. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
  3393. <li>If <i>number</i> is <b>NaN</b>, <b>+0</b>, <b>&minus;0</b>, <b>+&ininfin;</b>, or <b>&minus;&infin;</b>, return
  3394. <b>+0</b>.</li>
  3395. <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
  3396. href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
  3397. <li>Let <i>int8bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>8</sup>.</li>
  3398. <li>Return <i>int8bit</i>.</li>
  3399. </ol>
  3400. </section>
  3401. <section id="sec-touint8clamp">
  3402. <h1><span class="secnum" id="sec-7.1.11"><a href="#sec-touint8clamp" title="link to this section">7.1.11</a></span>
  3403. ToUint8Clamp ( argument )</h1>
  3404. <p>The abstract operation ToUint8Clamp converts <var>argument</var> to one of <span style="font-family: Times New
  3405. Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
  3406. style="font-family: Times New Roman">255</span>, inclusive. This abstract operation functions as follows:</p>
  3407. <ol class="proc">
  3408. <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3409. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
  3410. <li>If <i>number</i> is <b>NaN</b>, return <b>+0</b>.</li>
  3411. <li>If <i>number</i> &le; 0, return <b>+0</b>.</li>
  3412. <li>If <i>number</i> &ge; 255, return 255.</li>
  3413. <li>Let <i>f</i> be <a href="#sec-algorithm-conventions">floor</a>(<i>number</i>).</li>
  3414. <li>If <i>f</i> <i>+</i> 0.5 &lt; <i>number</i>, return <i>f</i> + 1.</li>
  3415. <li>If <i>number</i> &lt; <i>f +</i> 0.5, return <i>f</i>.</li>
  3416. <li>If <i>f</i> is odd, return <i>f</i> + 1.</li>
  3417. <li>Return <i>f</i>.</li>
  3418. </ol>
  3419. <div class="note">
  3420. <p><span class="nh">NOTE</span> Note that unlike the other ECMAScript integer conversion abstract operation, ToUint8Clamp
  3421. rounds rather than truncates non-integer values and does not convert +<b>&infin;</b> to 0. ToUint8Clamp does &ldquo;round
  3422. half to even&rdquo; tie-breaking. This differs from <code><a href="#sec-math.round">Math.round</a></code> which does
  3423. &ldquo;round half up&rdquo; tie-breaking.</p>
  3424. </div>
  3425. </section>
  3426. <section id="sec-tostring">
  3427. <div class="front">
  3428. <h1><span class="secnum" id="sec-7.1.12"><a href="#sec-tostring" title="link to this section">7.1.12</a></span> ToString (
  3429. argument )</h1>
  3430. <p>The abstract operation ToString converts <var>argument</var> to a value of type String according to <a
  3431. href="#table-12">Table 12</a>:</p>
  3432. <figure>
  3433. <figcaption><span id="table-12">Table 12</span> &mdash; ToString Conversions</figcaption>
  3434. <table class="real-table">
  3435. <tr>
  3436. <th>Argument Type</th>
  3437. <th>Result</th>
  3438. </tr>
  3439. <tr>
  3440. <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
  3441. <td>If <var>argument</var> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return <var>argument</var>. Otherwise return ToString(<var>argument</var>.[[value]]).</td>
  3442. </tr>
  3443. <tr>
  3444. <td>Undefined</td>
  3445. <td>Return <code>"undefined"</code>.</td>
  3446. </tr>
  3447. <tr>
  3448. <td>Null</td>
  3449. <td>Return <code>"null"</code>.</td>
  3450. </tr>
  3451. <tr>
  3452. <td>Boolean</td>
  3453. <td>
  3454. <p>If <var>argument</var> is <b>true</b>, return <code>"true"</code>.</p>
  3455. <p>If <var>argument</var> is <b>false</b>, return <b><code>"false"</code>.</b></p>
  3456. </td>
  3457. </tr>
  3458. <tr>
  3459. <td>Number</td>
  3460. <td>See <a href="#sec-tostring-applied-to-the-number-type">7.1.12.1</a>.</td>
  3461. </tr>
  3462. <tr>
  3463. <td>String</td>
  3464. <td>Return <var>argument</var>.</td>
  3465. </tr>
  3466. <tr>
  3467. <td>Symbol</td>
  3468. <td>Throw a <b>TypeError</b> exception.</td>
  3469. </tr>
  3470. <tr>
  3471. <td>Object</td>
  3472. <td>
  3473. <p>Apply the following steps:</p>
  3474. <p>1. Let <i>primValue</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint String).</p>
  3475. <p>2. Return ToString(<i>primValue</i>).</p>
  3476. </td>
  3477. </tr>
  3478. </table>
  3479. </figure>
  3480. </div>
  3481. <section id="sec-tostring-applied-to-the-number-type">
  3482. <h1><span class="secnum" id="sec-7.1.12.1"><a href="#sec-tostring-applied-to-the-number-type"
  3483. title="link to this section">7.1.12.1</a></span> ToString Applied to the Number Type</h1>
  3484. <p>The abstract operation <a href="#sec-tostring">ToString</a> converts a Number <var>m</var> to String format as
  3485. follows:</p>
  3486. <ol class="proc">
  3487. <li>If <i>m</i> is <b>NaN</b>, return the String <code>"NaN"</code>.</li>
  3488. <li>If <i>m</i> is <b>+0</b> or <b>&minus;0</b>, return the String <code>"0"</code>.</li>
  3489. <li>If <i>m</i> is less than zero, return the String concatenation of the String <code>"-"</code> and <a
  3490. href="#sec-tostring">ToString</a>(&minus;<i>m</i>).</li>
  3491. <li>If <i>m</i> is +&infin;, return the String <code>"Infinity"</code>.</li>
  3492. <li>Otherwise, let <i>n</i>, <i>k</i>, and <i>s</i> be integers such that <i>k</i> &ge; 1, 10<sup><i>k</i>&minus;1</sup>
  3493. &le; <i>s</i> &lt; 10<sup><i>k</i></sup>, the Number value for <i>s</i> &times; 10<sup><i>n&minus;k</i></sup> is
  3494. <i>m</i>, and <i>k</i> is as small as possible. Note that <i>k</i> is the number of digits in the decimal
  3495. representation of <i>s</i>, that <i>s</i> is not divisible by 10, and that the least significant digit of <i>s</i>
  3496. is not necessarily uniquely determined by these criteria.</li>
  3497. <li>If <i>k</i> &le; <i>n</i> &le; 21, return the String consisting of the code units of the <i>k</i> digits of the
  3498. decimal representation of <i>s</i> (in order, with no leading zeroes), followed by <i>n&minus;k</i> occurrences of
  3499. the code unit 0x0030 (DIGIT ZERO).</li>
  3500. <li>If 0 &lt; <i>n</i> &le; 21, return the String consisting of the code units of the most significant <i>n</i> digits
  3501. of the decimal representation of <i>s</i>, followed by the code unit 0x002E (FULL STOP), followed by the code units
  3502. of the remaining <i>k&minus;n</i> digits of the decimal representation of <i>s</i>.</li>
  3503. <li>If &minus;6 &lt; <i>n</i> &le; 0, return the String consisting of the code unit 0x0030 (DIGIT ZERO), followed by the
  3504. code unit 0x002E (FULL STOP), followed by &minus;<i>n</i> occurrences of the code unit 0x0030 (DIGIT ZERO), followed
  3505. by the code units of the <i>k</i> digits of the decimal representation of <i>s</i>.</li>
  3506. <li>Otherwise, if <i>k</i> = 1, return the String consisting of the code unit of the single digit of <i>s</i>, followed
  3507. by code unit 0x0065 (LATIN SMALL LETTER E), followed by the code unit 0x002B (PLUS SIGN) or the code unit 0x002D
  3508. (HYPHEN-MINUS) according to whether <i>n</i>&minus;1 is positive or negative, followed by the code units of the
  3509. decimal representation of the integer <a href="#sec-algorithm-conventions">abs</a>(<i>n</i>&minus;1) (with no
  3510. leading zeroes).</li>
  3511. <li>Return the String consisting of the code units of the most significant digit of the decimal representation of
  3512. <i>s</i>, followed by code unit 0x002E (FULL STOP), followed by the code units of the remaining <i>k</i>&minus;1
  3513. digits of the decimal representation of <i>s</i>, followed by code unit 0x0065 (LATIN SMALL LETTER E), followed by
  3514. code unit 0x002B (PLUS SIGN) or the code unit 0x002D (HYPHEN-MINUS) according to whether <i>n</i>&minus;1 is
  3515. positive or negative, followed by the code units of the decimal representation of the integer <a
  3516. href="#sec-algorithm-conventions">abs</a>(<i>n</i>&minus;1) (with no leading zeroes).</li>
  3517. </ol>
  3518. <div class="note">
  3519. <p><span class="nh">NOTE 1</span> The following observations may be useful as guidelines for implementations, but are
  3520. not part of the normative requirements of this Standard:</p>
  3521. <ul>
  3522. <li>
  3523. <p>If x is any Number value other than <b>&minus;0</b>, then <a href="#sec-tonumber">ToNumber</a>(<a
  3524. href="#sec-tostring">ToString</a>(x)) is exactly the same Number value as x.</p>
  3525. </li>
  3526. <li>
  3527. <p>The least significant digit of s is not always uniquely determined by the requirements listed in step 5.</p>
  3528. </li>
  3529. </ul>
  3530. </div>
  3531. <div class="note">
  3532. <p><span class="nh">NOTE 2</span> For implementations that provide more accurate conversions than required by the rules
  3533. above, it is recommended that the following alternative version of step 5 be used as a guideline:</p>
  3534. <p>Otherwise, let <i>n</i>, <i>k</i>, and <i>s</i> be integers such that <i>k</i> &ge; 1, 10<sup><i>k</i>&minus;1</sup>
  3535. &le; <i>s</i> &lt; 10<sup><i>k</i></sup>, the Number value for <i>s</i> &times; 10<sup><i>n</i>&minus;<i>k</i></sup> is
  3536. <i>m</i>, and <i>k</i> is as small as possible. If there are multiple possibilities for <i>s</i>, choose the value of
  3537. <i>s</i> for which <i>s</i> &times; 10<sup><i>n</i>&minus;<i>k</i></sup> is closest in value to <i>m</i>. If there are
  3538. two such possible values of <i>s</i>, choose the one that is even. Note that <i>k</i> is the number of digits in the
  3539. decimal representation of <i>s</i> and that <i>s</i> is not divisible by 10.</p>
  3540. </div>
  3541. <div class="note">
  3542. <p><span class="nh">NOTE 3</span> Implementers of ECMAScript may find useful the paper and code written by David M. Gay
  3543. for binary-to-decimal conversion of floating-point numbers:</p>
  3544. <p>Gay, David M. Correctly Rounded Binary-Decimal and Decimal-Binary Conversions. Numerical Analysis, Manuscript 90-10.
  3545. AT&amp;T Bell Laboratories (Murray Hill, New Jersey). November 30, 1990. Available as<br><span style="font-family:
  3546. sans-serif"><a
  3547. href="http://cm.bell-labs.com/cm/cs/doc/90/4-10.ps.gz">http://cm.bell-labs.com/cm/cs/doc/90/4-10.ps.gz</a></span>.
  3548. Associated code available as<br><span style="font-family: sans-serif"><a
  3549. href="http://netlib.sandia.gov/fp/dtoa.c">http://netlib.sandia.gov/fp/dtoa.c</a></span>&nbsp;and&nbsp;as<br><span
  3550. style="font-family: sans-serif"><a
  3551. href="http://netlib.sandia.gov/fp/g_fmt.c">http://netlib.sandia.gov/fp/g_fmt.c</a></span> and may also be found at the
  3552. various <code>netlib</code> mirror sites.</p>
  3553. </div>
  3554. </section>
  3555. </section>
  3556. <section id="sec-toobject">
  3557. <h1><span class="secnum" id="sec-7.1.13"><a href="#sec-toobject" title="link to this section">7.1.13</a></span> ToObject (
  3558. argument )</h1>
  3559. <p>The abstract operation ToObject converts <var>argument</var> to a value of type Object according to <a
  3560. href="#table-13">Table 13</a>:</p>
  3561. <figure>
  3562. <figcaption><span id="table-13">Table 13</span> &mdash; ToObject Conversions</figcaption>
  3563. <table class="real-table">
  3564. <tr>
  3565. <th>Argument Type</th>
  3566. <th>Result</th>
  3567. </tr>
  3568. <tr>
  3569. <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
  3570. <td>If <i>argument</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return <i>argument</i>. Otherwise return ToObject(<i>argument</i>.[[value]]).</td>
  3571. </tr>
  3572. <tr>
  3573. <td>Undefined</td>
  3574. <td>Throw a <b>TypeError</b> exception.</td>
  3575. </tr>
  3576. <tr>
  3577. <td>Null</td>
  3578. <td>Throw a <b>TypeError</b> exception.</td>
  3579. </tr>
  3580. <tr>
  3581. <td>Boolean</td>
  3582. <td>Return a new Boolean object whose [[BooleanData]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is set to the value of <i>argument</i>. See <a href="#sec-boolean-objects">19.3</a> for a description of Boolean objects.</td>
  3583. </tr>
  3584. <tr>
  3585. <td>Number</td>
  3586. <td>Return a new Number object whose [[NumberData]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is set to the value of <i>argument</i>. See <a href="#sec-number-objects">20.1</a> for a description of Number objects.</td>
  3587. </tr>
  3588. <tr>
  3589. <td>String</td>
  3590. <td>Return a new String object whose [[StringData]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is set to the value of <i>argument</i>. See <a href="#sec-string-objects">21.1</a> for a description of String objects.</td>
  3591. </tr>
  3592. <tr>
  3593. <td>Symbol</td>
  3594. <td>Return a new Symbol object whose [[SymbolData]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is set to the value of <i>argument</i>. See <a href="#sec-symbol-objects">19.4</a> for a description of Symbol objects.</td>
  3595. </tr>
  3596. <tr>
  3597. <td>Object</td>
  3598. <td>Return <i>argument</i>.</td>
  3599. </tr>
  3600. </table>
  3601. </figure>
  3602. </section>
  3603. <section id="sec-topropertykey">
  3604. <h1><span class="secnum" id="sec-7.1.14"><a href="#sec-topropertykey" title="link to this section">7.1.14</a></span>
  3605. ToPropertyKey ( argument )</h1>
  3606. <p>The abstract operation ToPropertyKey converts <var>argument</var> to a value that can be used as a <a
  3607. href="#sec-object-type">property key</a> by performing the following steps:</p>
  3608. <ol class="proc">
  3609. <li>Let <i>key</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint String).</li>
  3610. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>key</i>).</li>
  3611. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>key</i>) is Symbol, then
  3612. <ol class="block">
  3613. <li>Return <i>key</i>.</li>
  3614. </ol>
  3615. </li>
  3616. <li>Return <a href="#sec-tostring">ToString</a>(<i>key</i>).</li>
  3617. </ol>
  3618. </section>
  3619. <section id="sec-tolength">
  3620. <h1><span class="secnum" id="sec-7.1.15"><a href="#sec-tolength" title="link to this section">7.1.15</a></span> ToLength (
  3621. argument )</h1>
  3622. <p>The abstract operation ToLength converts <var>argument</var> to an integer suitable for use as the length of an
  3623. array-like object. It performs the following steps:</p>
  3624. <ol class="proc">
  3625. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
  3626. <li>Let <i>len</i> be <a href="#sec-tointeger">ToInteger</a>(<i>argument</i>).</li>
  3627. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
  3628. <li>If <i>len</i> &le; +0, return +0.</li>
  3629. <li>If <i>len</i> is <b>+&infin;</b>, return 2<sup>53</sup>-1.</li>
  3630. <li>Return min(<i>len</i>, 2<sup>53</sup>-1).</li>
  3631. </ol>
  3632. </section>
  3633. <section id="sec-canonicalnumericindexstring">
  3634. <h1><span class="secnum" id="sec-7.1.16"><a href="#sec-canonicalnumericindexstring"
  3635. title="link to this section">7.1.16</a></span> CanonicalNumericIndexString ( argument )</h1>
  3636. <p>The abstract operation CanonicalNumericIndexString returns <var>argument</var> converted to a numeric value if it is a
  3637. String representation of a Number that would be produced by <a href="#sec-tostring">ToString</a>, or the string
  3638. <code>"-0"</code>. Otherwise, it returns <span class="value">undefined.</span> This abstract operation functions as
  3639. follows:</p>
  3640. <ol class="proc">
  3641. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  3642. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is String.</li>
  3643. <li>If <i>argument</i> is <code>"-0"</code>, return &minus;0.</li>
  3644. <li>Let <i>n</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
  3645. <li>If <a href="#sec-samevalue">SameValue</a>(<a href="#sec-tostring">ToString</a>(<i>n</i>), <i>argument</i>) is
  3646. <b>false</b>, return <b>undefined</b>.</li>
  3647. <li>Return <i>n</i>.</li>
  3648. </ol>
  3649. <p>A <i>canonical numeric string</i> is any String value for which the CanonicalNumericIndexString abstract operation does
  3650. not return <span class="value">undefined</span>.</p>
  3651. </section>
  3652. </section>
  3653. <section id="sec-testing-and-comparison-operations">
  3654. <div class="front">
  3655. <h1><span class="secnum" id="sec-7.2"><a href="#sec-testing-and-comparison-operations"
  3656. title="link to this section">7.2</a></span> Testing and Comparison Operations</h1>
  3657. </div>
  3658. <section id="sec-requireobjectcoercible">
  3659. <h1><span class="secnum" id="sec-7.2.1"><a href="#sec-requireobjectcoercible" title="link to this section">7.2.1</a></span>
  3660. RequireObjectCoercible ( argument )</h1>
  3661. <p>The abstract operation RequireObjectCoercible throws an error if <var>argument</var> is a value that cannot be converted
  3662. to an Object using <a href="#sec-toobject">ToObject</a>. It is defined by <a href="#table-14">Table 14</a>:</p>
  3663. <figure>
  3664. <figcaption><span id="table-14">Table 14</span>&nbsp;&mdash; RequireObjectCoercible Results</figcaption>
  3665. <table class="real-table">
  3666. <tr>
  3667. <th>Argument Type</th>
  3668. <th>Result</th>
  3669. </tr>
  3670. <tr>
  3671. <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
  3672. <td>If <var>argument</var> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return <var>argument</var>. Otherwise return RequireObjectCoercible(<var>argument</var>.[[value]]).</td>
  3673. </tr>
  3674. <tr>
  3675. <td>Undefined</td>
  3676. <td>Throw a <b>TypeError</b> exception.</td>
  3677. </tr>
  3678. <tr>
  3679. <td>Null</td>
  3680. <td>Throw a <b>TypeError</b> exception.</td>
  3681. </tr>
  3682. <tr>
  3683. <td>Boolean</td>
  3684. <td>Return <var>argument</var>.</td>
  3685. </tr>
  3686. <tr>
  3687. <td>Number</td>
  3688. <td>Return <var>argument</var>.</td>
  3689. </tr>
  3690. <tr>
  3691. <td>String</td>
  3692. <td>Return <var>argument</var>.</td>
  3693. </tr>
  3694. <tr>
  3695. <td>Symbol</td>
  3696. <td>Return <var>argument</var>.</td>
  3697. </tr>
  3698. <tr>
  3699. <td>Object</td>
  3700. <td>Return <var>argument</var>.</td>
  3701. </tr>
  3702. </table>
  3703. </figure>
  3704. </section>
  3705. <section id="sec-isarray">
  3706. <h1><span class="secnum" id="sec-7.2.2"><a href="#sec-isarray" title="link to this section">7.2.2</a></span> IsArray (
  3707. argument )</h1>
  3708. <p>The abstract operation IsArray takes one argument <var>argument</var>, and performs the following steps:</p>
  3709. <ol class="proc">
  3710. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
  3711. <li>If <i>argument</i> is an <a href="#sec-array-exotic-objects">Array exotic object</a>, return <b>true</b>.</li>
  3712. <li>If <i>argument</i> is a Proxy exotic object, then
  3713. <ol class="block">
  3714. <li>If the value of the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
  3715. of <i>argument</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  3716. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  3717. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>argument</i>.</li>
  3718. <li>Return IsArray(<i>target</i>).</li>
  3719. </ol>
  3720. </li>
  3721. <li>Return <b>false</b>.</li>
  3722. </ol>
  3723. </section>
  3724. <section id="sec-iscallable">
  3725. <h1><span class="secnum" id="sec-7.2.3"><a href="#sec-iscallable" title="link to this section">7.2.3</a></span> IsCallable (
  3726. argument )</h1>
  3727. <p>The abstract operation IsCallable determines if <var>argument</var>, which must be an <a
  3728. href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
  3729. href="#sec-completion-record-specification-type">Completion Record</a>, is a callable function with a [[Call]] internal
  3730. method.</p>
  3731. <ol class="proc">
  3732. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
  3733. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
  3734. <li>If <i>argument</i> has a [[Call]] internal method, return <b>true</b>.</li>
  3735. <li>Return <b>false</b>.</li>
  3736. </ol>
  3737. </section>
  3738. <section id="sec-isconstructor">
  3739. <h1><span class="secnum" id="sec-7.2.4"><a href="#sec-isconstructor" title="link to this section">7.2.4</a></span>
  3740. IsConstructor ( argument )</h1>
  3741. <p>The abstract operation IsConstructor determines if <var>argument</var>, which must be an <a
  3742. href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
  3743. href="#sec-completion-record-specification-type">Completion Record</a>, is a function object with a [[Construct]] internal
  3744. method.</p>
  3745. <ol class="proc">
  3746. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
  3747. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
  3748. <li>If <i>argument</i> has a [[Construct]] internal method, return <b>true</b>.</li>
  3749. <li>Return <b>false</b>.</li>
  3750. </ol>
  3751. </section>
  3752. <section id="sec-isextensible-o">
  3753. <h1><span class="secnum" id="sec-7.2.5"><a href="#sec-isextensible-o" title="link to this section">7.2.5</a></span>
  3754. IsExtensible (O)</h1>
  3755. <p>The abstract operation <span style="font-family: Times New Roman">IsExtensible</span> is used to determine whether
  3756. additional properties can be added to the object that is <var>O</var>. A Boolean value is returned. This abstract operation
  3757. performs the following steps:</p>
  3758. <ol class="proc">
  3759. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  3760. Object.</li>
  3761. <li>Return <i>O</i>.[[IsExtensible]]().</li>
  3762. </ol>
  3763. </section>
  3764. <section id="sec-isinteger">
  3765. <h1><span class="secnum" id="sec-7.2.6"><a href="#sec-isinteger" title="link to this section">7.2.6</a></span> IsInteger (
  3766. argument )</h1>
  3767. <p>The abstract operation IsInteger determines if <var>argument</var> is a finite integer numeric value.</p>
  3768. <ol class="proc">
  3769. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
  3770. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Number, return <b>false</b>.</li>
  3771. <li>If <i>argument</i> is <b>NaN</b>, <b>+&infin;</b>, or <b>&minus;&infin;</b>, return <b>false</b>.</li>
  3772. <li>If <a href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>argument</i>)) &ne;
  3773. <a href="#sec-algorithm-conventions">abs</a>(<i>argument</i>), return <b>false</b>.</li>
  3774. <li>Return <b>true</b>.</li>
  3775. </ol>
  3776. </section>
  3777. <section id="sec-ispropertykey">
  3778. <h1><span class="secnum" id="sec-7.2.7"><a href="#sec-ispropertykey" title="link to this section">7.2.7</a></span>
  3779. IsPropertyKey ( argument )</h1>
  3780. <p>The abstract operation IsPropertyKey determines if <var>argument</var>, which must be an <a
  3781. href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
  3782. href="#sec-completion-record-specification-type">Completion Record</a>, is a value that may be used as a <a
  3783. href="#sec-object-type">property key</a>.</p>
  3784. <ol class="proc">
  3785. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
  3786. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is String, return <b>true</b>.</li>
  3787. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is Symbol, return <b>true</b>.</li>
  3788. <li>Return <b>false</b>.</li>
  3789. </ol>
  3790. </section>
  3791. <section id="sec-isregexp">
  3792. <h1><span class="secnum" id="sec-7.2.8"><a href="#sec-isregexp" title="link to this section">7.2.8</a></span> IsRegExp (
  3793. argument )</h1>
  3794. <p>The abstract operation IsRegExp with argument <var>argument</var> performs the following steps:</p>
  3795. <ol class="proc">
  3796. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
  3797. <li>Let <i>isRegExp</i> be <a href="#sec-get-o-p">Get</a>(<i>argument</i>, @@match).</li>
  3798. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>isRegExp</i>).</li>
  3799. <li>If <i>isRegExp</i> is not <b>undefined</b>, return <a href="#sec-toboolean">ToBoolean</a>(<i>isRegExp</i>).</li>
  3800. <li>If <i>argument</i> has a [[RegExpMatcher]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  3801. slot</a>, return <b>true</b>.</li>
  3802. <li>Return <b>false</b>.</li>
  3803. </ol>
  3804. </section>
  3805. <section id="sec-samevalue">
  3806. <h1><span class="secnum" id="sec-7.2.9"><a href="#sec-samevalue" title="link to this section">7.2.9</a></span> SameValue(x,
  3807. y)</h1>
  3808. <p>The internal comparison abstract operation SameValue(<var>x</var>, <var>y</var>), where <var>x</var> and <var>y</var> are
  3809. <a href="#sec-ecmascript-language-types">ECMAScript language values</a>, produces <b>true</b> or <b>false</b>. Such a
  3810. comparison is performed as follows:</p>
  3811. <ol class="proc">
  3812. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
  3813. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
  3814. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
  3815. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
  3816. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
  3817. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
  3818. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
  3819. <ol class="block">
  3820. <li>If <i>x</i> is NaN and <i>y</i> is NaN, return <b>true</b>.</li>
  3821. <li>If <i>x</i> is +0 and <i>y</i> is -0, return <b>false</b>.</li>
  3822. <li>If <i>x</i> is -0 and <i>y</i> is +0, return <b>false</b>.</li>
  3823. <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
  3824. <li>Return <b>false</b>.</li>
  3825. </ol>
  3826. </li>
  3827. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
  3828. <ol class="block">
  3829. <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
  3830. corresponding indices) return <b>true</b>; otherwise, return <b>false</b>.</li>
  3831. </ol>
  3832. </li>
  3833. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
  3834. <ol class="block">
  3835. <li>If <i>x</i> and <i>y</i> are both <b>true</b> or both <b>false</b>, return <b>true</b>; otherwise, return
  3836. <b>false</b>.</li>
  3837. </ol>
  3838. </li>
  3839. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Symbol, then
  3840. <ol class="block">
  3841. <li>If <i>x</i> and <i>y</i> are both the same Symbol value, return <b>true</b>; otherwise, return <b>false</b>.</li>
  3842. </ol>
  3843. </li>
  3844. <li>Return <b>true</b> if <i>x</i> and <i>y</i> are the same Object value. Otherwise, return <b>false</b>.</li>
  3845. </ol>
  3846. </section>
  3847. <section id="sec-samevaluezero">
  3848. <h1><span class="secnum" id="sec-7.2.10"><a href="#sec-samevaluezero" title="link to this section">7.2.10</a></span>
  3849. SameValueZero(x, y)</h1>
  3850. <p>The internal comparison abstract operation SameValueZero(<var>x</var>, <var>y</var>), where <var>x</var> and <var>y</var>
  3851. are <a href="#sec-ecmascript-language-types">ECMAScript language values</a>, produces <b>true</b> or <b>false</b>. Such a
  3852. comparison is performed as follows:</p>
  3853. <ol class="proc">
  3854. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
  3855. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
  3856. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
  3857. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
  3858. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
  3859. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
  3860. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
  3861. <ol class="block">
  3862. <li>If <i>x</i> is NaN and <i>y</i> is NaN, return <b>true</b>.</li>
  3863. <li>If <i>x</i> is +0 and <i>y</i> is -0, return <b>true</b>.</li>
  3864. <li>If <i>x</i> is -0 and <i>y</i> is +0, return <b>true</b>.</li>
  3865. <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
  3866. <li>Return <b>false</b>.</li>
  3867. </ol>
  3868. </li>
  3869. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
  3870. <ol class="block">
  3871. <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
  3872. corresponding indices) return <b>true</b>; otherwise, return <b>false</b>.</li>
  3873. </ol>
  3874. </li>
  3875. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
  3876. <ol class="block">
  3877. <li>If <i>x</i> and <i>y</i> are both <b>true</b> or both <b>false</b>, return <b>true</b>; otherwise, return
  3878. <b>false</b>.</li>
  3879. </ol>
  3880. </li>
  3881. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Symbol, then
  3882. <ol class="block">
  3883. <li>If <i>x</i> and <i>y</i> are both the same Symbol value, return <b>true</b>; otherwise, return <b>false</b>.</li>
  3884. </ol>
  3885. </li>
  3886. <li>Return <b>true</b> if <i>x</i> and <i>y</i> are the same Object value. Otherwise, return <b>false</b>.</li>
  3887. </ol>
  3888. <div class="note">
  3889. <p><span class="nh">NOTE</span> SameValueZero differs from SameValue only in its treatment of +0 and -0.</p>
  3890. </div>
  3891. </section>
  3892. <section id="sec-abstract-relational-comparison">
  3893. <h1><span class="secnum" id="sec-7.2.11"><a href="#sec-abstract-relational-comparison"
  3894. title="link to this section">7.2.11</a></span> Abstract Relational Comparison</h1>
  3895. <p>The comparison <var>x</var> &lt; <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b>,
  3896. <b>false</b>, or <b>undefined</b> (which indicates that at least one operand is <b>NaN</b>). In addition to <var>x</var> and
  3897. <var>y</var> the algorithm takes a Boolean flag named <span class="nt">LeftFirst</span> as a parameter. The flag is used to
  3898. control the order in which operations with potentially visible side-effects are performed upon <var>x</var> and
  3899. <var>y</var>. It is necessary because ECMAScript specifies left to right evaluation of expressions. The default value of
  3900. <span class="nt">LeftFirst</span> is <b>true</b> and indicates that the <var>x</var> parameter corresponds to an expression
  3901. that occurs to the left of the <var>y</var> parameter&rsquo;s corresponding expression. If <span class="nt">LeftFirst</span>
  3902. is <b>false</b>, the reverse is the case and operations must be performed upon <var>y</var> before <var>x</var>. Such a
  3903. comparison is performed as follows:</p>
  3904. <ol class="proc">
  3905. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
  3906. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
  3907. <li>If the <i>LeftFirst</i> flag is <b>true</b>, then
  3908. <ol class="block">
  3909. <li>Let <i>px</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>, hint Number).</li>
  3910. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>px</i>).</li>
  3911. <li>Let <i>py</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>, hint Number).</li>
  3912. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>py</i>).</li>
  3913. </ol>
  3914. </li>
  3915. <li>Else the order of evaluation needs to be reversed to preserve left to right evaluation
  3916. <ol class="block">
  3917. <li>Let <i>py</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>, hint Number).</li>
  3918. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>py</i>).</li>
  3919. <li>Let <i>px</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>, hint Number).</li>
  3920. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>px</i>).</li>
  3921. </ol>
  3922. </li>
  3923. <li>If both <i>px</i> and <i>py</i> are Strings, then
  3924. <ol class="block">
  3925. <li>If <i>py</i> is a prefix of <i>px</i>, return <b>false</b>. (A String value <i>p</i> is a prefix of String value
  3926. <i>q</i> if <i>q</i> can be the result of concatenating <i>p</i> and some other String <i>r</i>. Note that any
  3927. String is a prefix of itself, because <i>r</i> may be the empty String.)</li>
  3928. <li>If <i>px</i> is a prefix of <i>py</i>, return <b>true</b>.</li>
  3929. <li>Let <i>k</i> be the smallest nonnegative integer such that the code unit at index <i>k</i> within <i>px</i> is
  3930. different from the code unit at index <i>k</i> within <i>py</i>. (There must be such a <i>k</i>, for neither
  3931. String is a prefix of the other.)</li>
  3932. <li>Let <i>m</i> be the integer that is the code unit value at index <i>k</i> within <i>px</i>.</li>
  3933. <li>Let <i>n</i> be the integer that is the code unit value at index <i>k</i> within <i>py</i>.</li>
  3934. <li>If <i>m</i> &lt; <i>n</i>, return <b>true</b>. Otherwise, return <b>false</b>.</li>
  3935. </ol>
  3936. </li>
  3937. <li>Else,
  3938. <ol class="block">
  3939. <li>Let <i>nx</i> be <a href="#sec-tonumber">ToNumber</a>(<i>px</i>). Because <i>px</i> and <i>py</i> are primitive
  3940. values evaluation order is not important.</li>
  3941. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nx</i>).</li>
  3942. <li>Let <i>ny</i> be <a href="#sec-tonumber">ToNumber</a>(<i>py</i>).</li>
  3943. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ny</i>).</li>
  3944. <li>If <i>nx</i> is <b>NaN</b>, return <b>undefined</b>.</li>
  3945. <li>If <i>ny</i> is <b>NaN</b>, return <b>undefined</b>.</li>
  3946. <li>If <i>nx</i> and <i>ny</i> are the same Number value, return <b>false</b>.</li>
  3947. <li>If <i>nx</i> is <b>+0</b> and <i>ny</i> is <b>&minus;0</b>, return <b>false</b>.</li>
  3948. <li>If <i>nx</i> is <b>&minus;0</b> and <i>ny</i> is <b>+0</b>, return <b>false</b>.</li>
  3949. <li>If <i>nx</i> is <b>+&infin;</b>, return <b>false</b>.</li>
  3950. <li>If <i>ny</i> is <b>+&infin;</b>, return <b>true</b>.</li>
  3951. <li>If <i>ny</i> is <b>&minus;&infin;</b>, return <b>false</b>.</li>
  3952. <li>If <i>nx</i> is <b>&minus;&infin;</b>, return <b>true</b>.</li>
  3953. <li>If the mathematical value of <i>nx</i> is less than the mathematical value of <i>ny</i> &mdash;note that these
  3954. mathematical values are both finite and not both zero&mdash;return <b>true</b>. Otherwise, return
  3955. <b>false</b>.</li>
  3956. </ol>
  3957. </li>
  3958. </ol>
  3959. <div class="note">
  3960. <p><span class="nh">NOTE 1</span> Step 5 differs from step 11 in the algorithm for the addition operator <code>+</code>
  3961. (<a href="#sec-addition-operator-plus">12.7.3</a>) in using &ldquo;and&rdquo; instead of &ldquo;or&rdquo;.</p>
  3962. </div>
  3963. <div class="note">
  3964. <p><span class="nh">NOTE 2</span> The comparison of Strings uses a simple lexicographic ordering on sequences of code unit
  3965. values. There is no attempt to use the more complex, semantically oriented definitions of character or string equality and
  3966. collating order defined in the Unicode specification. Therefore String values that are canonically equal according to the
  3967. Unicode standard could test as unequal. In effect this algorithm assumes that both Strings are already in normalized form.
  3968. Also, note that for strings containing supplementary characters, lexicographic ordering on sequences of UTF-16 code unit
  3969. values differs from that on sequences of code point values.</p>
  3970. </div>
  3971. </section>
  3972. <section id="sec-abstract-equality-comparison">
  3973. <h1><span class="secnum" id="sec-7.2.12"><a href="#sec-abstract-equality-comparison"
  3974. title="link to this section">7.2.12</a></span> Abstract Equality Comparison</h1>
  3975. <p>The comparison <var>x</var> == <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b> or
  3976. <b>false</b>. Such a comparison is performed as follows:</p>
  3977. <ol class="proc">
  3978. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
  3979. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
  3980. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is the same as <a
  3981. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), then
  3982. <ol class="block">
  3983. <li>Return the result of performing Strict Equality Comparison <i>x</i> === <i>y</i>.</li>
  3984. </ol>
  3985. </li>
  3986. <li>If <i>x</i> is <b>null</b> and <i>y</i> is <b>undefined</b>, return <b>true</b>.</li>
  3987. <li>If <i>x</i> is <b>undefined</b> and <i>y</i> is <b>null</b>, return <b>true</b>.</li>
  3988. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number and <a
  3989. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is String,<br>return the result of the comparison
  3990. <i>x</i> == <a href="#sec-tonumber">ToNumber</a>(<i>y</i>).</li>
  3991. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String and <a
  3992. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Number,<br>return the result of the comparison <a
  3993. href="#sec-tonumber">ToNumber</a>(<i>x</i>) == <i>y</i>.</li>
  3994. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, return the result of the comparison
  3995. <a href="#sec-tonumber">ToNumber</a>(<i>x</i>) == <i>y</i>.</li>
  3996. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Boolean, return the result of the comparison
  3997. <i>x</i> == <a href="#sec-tonumber">ToNumber</a>(<i>y</i>).</li>
  3998. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is either String, Number, or Symbol and <a
  3999. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Object, then<br>return the result of the comparison
  4000. <i>x</i> == <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>).</li>
  4001. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Object and <a
  4002. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is either String, Number, or Symbol, then<br>return
  4003. the result of the comparison <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>) == <i>y</i>.</li>
  4004. <li>Return <b>false</b>.</li>
  4005. </ol>
  4006. </section>
  4007. <section id="sec-strict-equality-comparison">
  4008. <h1><span class="secnum" id="sec-7.2.13"><a href="#sec-strict-equality-comparison"
  4009. title="link to this section">7.2.13</a></span> Strict Equality Comparison</h1>
  4010. <p>The comparison <var>x</var> === <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b> or
  4011. <b>false</b>. Such a comparison is performed as follows:</p>
  4012. <ol class="proc">
  4013. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
  4014. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
  4015. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
  4016. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
  4017. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
  4018. <ol class="block">
  4019. <li>If <i>x</i> is <b>NaN</b>, return <b>false</b>.</li>
  4020. <li>If <i>y</i> is <b>NaN</b>, return <b>false</b>.</li>
  4021. <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
  4022. <li>If <i>x</i> is <b>+0</b> and <i>y</i> is <b>&minus;0</b>, return <b>true</b>.</li>
  4023. <li>If <i>x</i> is <b>&minus;0</b> and <i>y</i> is <b>+0</b>, return <b>true</b>.</li>
  4024. <li>Return <b>false</b>.</li>
  4025. </ol>
  4026. </li>
  4027. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
  4028. <ol class="block">
  4029. <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
  4030. corresponding indices), return <b>true</b>.</li>
  4031. <li>Else, return <b>false</b>.</li>
  4032. </ol>
  4033. </li>
  4034. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
  4035. <ol class="block">
  4036. <li>If <i>x</i> and <i>y</i> are both <b>true</b> or both <b>false</b>, return <b>true</b>.</li>
  4037. <li>Else, return <b>false</b>.</li>
  4038. </ol>
  4039. </li>
  4040. <li>If <i>x</i> and <i>y</i> are the same Symbol value, return <b>true</b>.</li>
  4041. <li>If <i>x</i> and <i>y</i> are the same Object value, return <b>true</b>.</li>
  4042. <li>Return <b>false</b>.</li>
  4043. </ol>
  4044. <div class="note">
  4045. <p><span class="nh">NOTE</span> This algorithm differs from <a href="#sec-samevalue">the SameValue Algorithm</a> (<a
  4046. href="#sec-samevalue">7.2.9</a>) in its treatment of signed zeroes and NaNs.</p>
  4047. </div>
  4048. </section>
  4049. </section>
  4050. <section id="sec-operations-on-objects">
  4051. <div class="front">
  4052. <h1><span class="secnum" id="sec-7.3"><a href="#sec-operations-on-objects" title="link to this section">7.3</a></span>
  4053. Operations on Objects</h1>
  4054. </div>
  4055. <section id="sec-get-o-p">
  4056. <h1><span class="secnum" id="sec-7.3.1"><a href="#sec-get-o-p" title="link to this section">7.3.1</a></span> Get (O, P)</h1>
  4057. <p>The abstract operation <span style="font-family: Times New Roman">Get</span> is used to retrieve the value of a specific
  4058. property of an object. The operation is called with arguments <var>O</var> and <var>P</var> where <var>O</var> is the
  4059. object and <var>P</var> is the <a href="#sec-object-type">property key</a>. This abstract operation performs the following
  4060. steps:</p>
  4061. <ol class="proc">
  4062. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4063. Object.</li>
  4064. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4065. <b>true</b>.</li>
  4066. <li>Return <i>O</i>.[[Get]](<i>P</i>, <i>O</i>).</li>
  4067. </ol>
  4068. </section>
  4069. <section id="sec-getv">
  4070. <h1><span class="secnum" id="sec-7.3.2"><a href="#sec-getv" title="link to this section">7.3.2</a></span> GetV (V, P)</h1>
  4071. <p>The abstract operation GetV is used to retrieve the value of a specific property of an <a
  4072. href="#sec-ecmascript-language-types">ECMAScript language value</a>. If the value is not an object, the property lookup is
  4073. performed using a wrapper object appropriate for the type of the value. The operation is called with arguments <var>V</var>
  4074. and <var>P</var> where <var>V</var> is the value and <var>P</var> is the <a href="#sec-object-type">property key</a>. This
  4075. abstract operation performs the following steps:</p>
  4076. <ol class="proc">
  4077. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4078. <b>true</b>.</li>
  4079. <li>Let <i>O</i> be <a href="#sec-toobject">ToObject</a>(<i>V</i>).</li>
  4080. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>O</i>).</li>
  4081. <li>Return <i>O</i>.[[Get]](<i>P</i>, <i>V</i>).</li>
  4082. </ol>
  4083. </section>
  4084. <section id="sec-set-o-p-v-throw">
  4085. <h1><span class="secnum" id="sec-7.3.3"><a href="#sec-set-o-p-v-throw" title="link to this section">7.3.3</a></span> Set (O,
  4086. P, V, Throw)</h1>
  4087. <p>The abstract operation <span style="font-family: Times New Roman">Set</span> is used to set the value of a specific
  4088. property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, <var>V</var>, and <span
  4089. class="nt">Throw</span> where <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>,
  4090. <var>V</var> is the new value for the property and <span class="nt">Throw</span> is a Boolean flag. This abstract operation
  4091. performs the following steps:</p>
  4092. <ol class="proc">
  4093. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4094. Object.</li>
  4095. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4096. <b>true</b>.</li>
  4097. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  4098. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Throw</i>) is Boolean.</li>
  4099. <li>Let <i>success</i> be <i>O</i>.[[Set]](<i>P</i>, <i>V</i>, <i>O</i>).</li>
  4100. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
  4101. <li>If <i>success</i> is <b>false</b> and <i>Throw</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
  4102. <li>Return <i>success</i>.</li>
  4103. </ol>
  4104. </section>
  4105. <section id="sec-createdataproperty">
  4106. <h1><span class="secnum" id="sec-7.3.4"><a href="#sec-createdataproperty" title="link to this section">7.3.4</a></span>
  4107. CreateDataProperty (O, P, V)</h1>
  4108. <p>The abstract operation <span style="font-family: Times New Roman">CreateDataProperty</span> is used to create a new own
  4109. property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where
  4110. <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>, and <var>V</var> is the value
  4111. for the property. This abstract operation performs the following steps:</p>
  4112. <ol class="proc">
  4113. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4114. Object.</li>
  4115. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4116. <b>true</b>.</li>
  4117. <li>Let <i>newDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
  4118. <b>true</b>, [[Configurable]]: <b>true</b>}.</li>
  4119. <li>Return <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>newDesc</i>).</li>
  4120. </ol>
  4121. <div class="note">
  4122. <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
  4123. used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist.
  4124. If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return
  4125. <b>false</b>.</p>
  4126. </div>
  4127. </section>
  4128. <section id="sec-createmethodproperty">
  4129. <h1><span class="secnum" id="sec-7.3.5"><a href="#sec-createmethodproperty" title="link to this section">7.3.5</a></span>
  4130. CreateMethodProperty (O, P, V)</h1>
  4131. <p>The abstract operation <span style="font-family: Times New Roman">CreateMethodProperty</span> is used to create a new own
  4132. property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where
  4133. <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>, and <var>V</var> is the value
  4134. for the property. This abstract operation performs the following steps:</p>
  4135. <ol class="proc">
  4136. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4137. Object.</li>
  4138. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4139. <b>true</b>.</li>
  4140. <li>Let <i>newDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
  4141. <b>false</b>, [[Configurable]]: <b>true</b>}.</li>
  4142. <li>Return <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>newDesc</i>).</li>
  4143. </ol>
  4144. <div class="note">
  4145. <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
  4146. used for built-in methods and methods defined using class declaration syntax. Normally, the property will not already
  4147. exist. If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return
  4148. <b>false</b>.</p>
  4149. </div>
  4150. </section>
  4151. <section id="sec-createdatapropertyorthrow">
  4152. <h1><span class="secnum" id="sec-7.3.6"><a href="#sec-createdatapropertyorthrow"
  4153. title="link to this section">7.3.6</a></span> CreateDataPropertyOrThrow (O, P, V)</h1>
  4154. <p>The abstract operation <span style="font-family: Times New Roman">CreateDataPropertyOrThrow</span> is used to create a
  4155. new own property of an object. It throws a <span class="value">TypeError</span> exception if the requested property update
  4156. cannot be performed. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where <var>O</var>
  4157. is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>, and <var>V</var> is the value for the
  4158. property. This abstract operation performs the following steps:</p>
  4159. <ol class="proc">
  4160. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4161. Object.</li>
  4162. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4163. <b>true</b>.</li>
  4164. <li>Let <i>success</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>O</i>, <i>P</i>, <i>V</i>).</li>
  4165. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
  4166. <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  4167. <li>Return <i>success</i>.</li>
  4168. </ol>
  4169. <div class="note">
  4170. <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
  4171. used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist.
  4172. If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return <b>false</b>
  4173. <span style="font-family: sans-serif">causing this operation to throw a</span> <b>TypeError</b> <span style="font-family:
  4174. sans-serif">exception</span>.</p>
  4175. </div>
  4176. </section>
  4177. <section id="sec-definepropertyorthrow">
  4178. <h1><span class="secnum" id="sec-7.3.7"><a href="#sec-definepropertyorthrow" title="link to this section">7.3.7</a></span>
  4179. DefinePropertyOrThrow (O, P, desc)</h1>
  4180. <p>The abstract operation <span style="font-family: Times New Roman">DefinePropertyOrThrow</span> is used to call the
  4181. [[DefineOwnProperty]] internal method of an object in a manner that will throw a <b>TypeError</b> exception if the requested
  4182. property update cannot be performed. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>desc</var>
  4183. where <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>, and <var>desc</var> is
  4184. the <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> for the property. This abstract operation
  4185. performs the following steps:</p>
  4186. <ol class="proc">
  4187. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4188. Object.</li>
  4189. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4190. <b>true</b>.</li>
  4191. <li>Let <i>success</i> be <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>desc</i>).</li>
  4192. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
  4193. <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  4194. <li>Return <i>success</i>.</li>
  4195. </ol>
  4196. </section>
  4197. <section id="sec-deletepropertyorthrow">
  4198. <h1><span class="secnum" id="sec-7.3.8"><a href="#sec-deletepropertyorthrow" title="link to this section">7.3.8</a></span>
  4199. DeletePropertyOrThrow (O, P)</h1>
  4200. <p>The abstract operation DeletePropertyOrThrow is used to remove a specific own property of an object. It throws an
  4201. exception if the property is not configurable. The operation is called with arguments <var>O</var> and <var>P</var> where
  4202. <var>O</var> is the object and <var>P</var> is the <a href="#sec-object-type">property key</a>. This abstract operation
  4203. performs the following steps:</p>
  4204. <ol class="proc">
  4205. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4206. Object.</li>
  4207. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4208. <b>true</b>.</li>
  4209. <li>Let <i>success</i> be <i>O</i>.[[Delete]](<i>P</i>).</li>
  4210. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
  4211. <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  4212. <li>Return <i>success</i>.</li>
  4213. </ol>
  4214. </section>
  4215. <section id="sec-getmethod">
  4216. <h1><span class="secnum" id="sec-7.3.9"><a href="#sec-getmethod" title="link to this section">7.3.9</a></span> GetMethod (O,
  4217. P)</h1>
  4218. <p>The abstract operation GetMethod is used to get the value of a specific property of an object when the value of the
  4219. property is expected to be a function. The operation is called with arguments <var>O</var> and <var>P</var> where
  4220. <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>. This abstract operation
  4221. performs the following steps:</p>
  4222. <ol class="proc">
  4223. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4224. <b>true</b>.</li>
  4225. <li>Let <i>func</i> be <a href="#sec-getv">GetV</a>(<i>O</i>, <i>P</i>).</li>
  4226. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
  4227. <li>If <i>func</i> is either <b>undefined</b> or <b>null</b>, return <b>undefined</b>.</li>
  4228. <li>If <a href="#sec-iscallable">IsCallable</a>(<i>func</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  4229. <li>Return <i>func</i>.</li>
  4230. </ol>
  4231. </section>
  4232. <section id="sec-hasproperty">
  4233. <h1><span class="secnum" id="sec-7.3.10"><a href="#sec-hasproperty" title="link to this section">7.3.10</a></span>
  4234. HasProperty (O, P)</h1>
  4235. <p>The abstract operation HasProperty is used to determine whether an object has a property with the specified <a
  4236. href="#sec-object-type">property key</a>. The property may be either an own or inherited. A Boolean value is returned. The
  4237. operation is called with arguments <var>O</var> and <var>P</var> where <var>O</var> is the object and <var>P</var> is the
  4238. <a href="#sec-object-type">property key</a>. This abstract operation performs the following steps:</p>
  4239. <ol class="proc">
  4240. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4241. Object.</li>
  4242. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4243. <b>true</b>.</li>
  4244. <li>Return <i>O</i>.[[HasProperty]](<i>P</i>).</li>
  4245. </ol>
  4246. </section>
  4247. <section id="sec-hasownproperty">
  4248. <h1><span class="secnum" id="sec-7.3.11"><a href="#sec-hasownproperty" title="link to this section">7.3.11</a></span>
  4249. HasOwnProperty (O, P)</h1>
  4250. <p>The abstract operation HasOwnProperty is used to determine whether an object has an own property with the specified <a
  4251. href="#sec-object-type">property key</a>. A Boolean value is returned. The operation is called with arguments <var>O</var>
  4252. and <var>P</var> where <var>O</var> is the object and <var>P</var> is the <a href="#sec-object-type">property key</a>. This
  4253. abstract operation performs the following steps:</p>
  4254. <ol class="proc">
  4255. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4256. Object.</li>
  4257. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  4258. <b>true</b>.</li>
  4259. <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
  4260. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
  4261. <li>If <i>desc</i> is <b>undefined</b>, return <b>false</b>.</li>
  4262. <li>Return <b>true</b>.</li>
  4263. </ol>
  4264. </section>
  4265. <section id="sec-call">
  4266. <h1><span class="secnum" id="sec-7.3.12"><a href="#sec-call" title="link to this section">7.3.12</a></span> Call(F, V,
  4267. [argumentsList])</h1>
  4268. <p>The abstract operation Call is used to call the [[Call]] internal method of a function object. The operation is called
  4269. with arguments <var>F</var>, <var>V</var> , and optionally <var>argumentsList</var> where <var>F</var> is the function
  4270. object, <var>V</var> is an <a href="#sec-ecmascript-language-types">ECMAScript language value</a> that is the <b>this</b>
  4271. value of the [[Call]], and <var>argumentsList</var> is the value passed to the corresponding argument of the internal
  4272. method. If <var>argumentsList</var> is not present, an empty <a href="#sec-list-and-record-specification-type">List</a> is
  4273. used as its value. This abstract operation performs the following steps:</p>
  4274. <ol class="proc">
  4275. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>F</i>).</li>
  4276. <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
  4277. href="#sec-list-and-record-specification-type">List</a>.</li>
  4278. <li>If <a href="#sec-iscallable">IsCallable</a>(<i>F</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  4279. <li>Return <i>F</i>.[[Call]](<i>V</i>, <i>argumentsList</i>).</li>
  4280. </ol>
  4281. </section>
  4282. <section id="sec-invoke">
  4283. <h1><span class="secnum" id="sec-7.3.13"><a href="#sec-invoke" title="link to this section">7.3.13</a></span> Invoke(O,P,
  4284. [argumentsList])</h1>
  4285. <p>The abstract operation <span style="font-family: Times New Roman">Invoke</span> is used to call a method property of an
  4286. object. The operation is called with arguments <var>O</var>, <var>P</var> , and optionally <var>argumentsList</var> where
  4287. <var>O</var> serves as both the lookup point for the property and the <b>this</b> value of the call, <var>P</var> is the <a
  4288. href="#sec-object-type">property key</a>, and <var>argumentsList</var> is the list of arguments values passed to the method.
  4289. If <var>argumentsList</var> is not present, an empty <a href="#sec-list-and-record-specification-type">List</a> is used as
  4290. its value. This abstract operation performs the following steps:</p>
  4291. <ol class="proc">
  4292. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>P</i> is a valid <a href="#sec-object-type">property key</a>.</li>
  4293. <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
  4294. href="#sec-list-and-record-specification-type">List</a>.</li>
  4295. <li>Let <i>func</i> be <a href="#sec-getv">GetV</a>(<i>O</i>, <i>P</i>).</li>
  4296. <li>Return <a href="#sec-call">Call</a>(<i>func</i>, <i>O</i>, <i>argumentsList</i>).</li>
  4297. </ol>
  4298. </section>
  4299. <section id="sec-construct">
  4300. <h1><span class="secnum" id="sec-7.3.14"><a href="#sec-construct" title="link to this section">7.3.14</a></span> Construct
  4301. (F, [argumentsList], [newTarget])</h1>
  4302. <p>The abstract operation Construct is used to call the [[Construct]] internal method of a function object. The operation is
  4303. called with arguments <var>F</var>, and optionally <span style="font-family: Times New Roman"><i>argumentsList</i>, and
  4304. <i>newTarget</i></span> where <var>F</var> is the function object. <var>argumentsList</var> and <var>newTarget</var> are the
  4305. values to be passed as the corresponding arguments of the internal method. If <var>argumentsList</var> is not present, an
  4306. empty <a href="#sec-list-and-record-specification-type">List</a> is used as its value. If <var>newTarget</var> is not
  4307. present, <var>F</var> is used as its value. This abstract operation performs the following steps:</p>
  4308. <ol class="proc">
  4309. <li>If <i>newTarget</i> was not passed, let <i>newTarget</i> be <i>F</i>.</li>
  4310. <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
  4311. href="#sec-list-and-record-specification-type">List</a>.</li>
  4312. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>F</i>) is
  4313. <b>true</b>.</li>
  4314. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>newTarget</i>) is
  4315. <b>true</b>.</li>
  4316. <li>Return <i>F</i>.[[Construct]](<i>argumentsList</i>, <i>newTarget</i>).</li>
  4317. </ol>
  4318. <div class="note">
  4319. <p><span class="nh">NOTE</span> If <i>newTarget</i> is not passed, this operation is equivalent to: <code>new
  4320. F(...argumentsList)</code></p>
  4321. </div>
  4322. </section>
  4323. <section id="sec-setintegritylevel">
  4324. <h1><span class="secnum" id="sec-7.3.15"><a href="#sec-setintegritylevel" title="link to this section">7.3.15</a></span>
  4325. SetIntegrityLevel (O, level)</h1>
  4326. <p>The abstract operation <span style="font-family: Times New Roman">SetIntegrityLevel</span> is used to fix the set of own
  4327. properties of an object. This abstract operation performs the following steps:</p>
  4328. <ol class="proc">
  4329. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4330. Object.</li>
  4331. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>level</i> is either <code>"sealed"</code> or
  4332. <code>"frozen"</code>.</li>
  4333. <li>Let <i>status</i> be <i>O</i>.[[PreventExtensions]]().</li>
  4334. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  4335. <li>If <i>status</i> is <b>false</b>, return <b>false</b>.</li>
  4336. <li>Let <i>keys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
  4337. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>keys</i>).</li>
  4338. <li>If <i>level</i> is <code>"sealed"</code>, then
  4339. <ol class="block">
  4340. <li>Repeat for each element <i>k</i> of <i>keys</i>,
  4341. <ol class="block">
  4342. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>O</i>, <i>k</i>,
  4343. PropertyDescriptor{ [[Configurable]]: <b>false</b>}).</li>
  4344. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  4345. </ol>
  4346. </li>
  4347. </ol>
  4348. </li>
  4349. <li>Else <i>level</i> is <code>"frozen"</code>,
  4350. <ol class="block">
  4351. <li>Repeat for each element <i>k</i> of <i>keys</i>,
  4352. <ol class="block">
  4353. <li>Let <i>currentDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>k</i>).</li>
  4354. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>currentDesc</i>).</li>
  4355. <li>If <i>currentDesc</i> is not <b>undefined</b>, then
  4356. <ol class="block">
  4357. <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>currentDesc</i>) is <b>true</b>, then
  4358. <ol class="block">
  4359. <li>Let <i>desc</i> be the PropertyDescriptor{[[Configurable]]: <b>false</b>}.</li>
  4360. </ol>
  4361. </li>
  4362. <li>Else,
  4363. <ol class="block">
  4364. <li>Let <i>desc</i> be the PropertyDescriptor { [[Configurable]]: <b>false</b>, [[Writable]]: <b>false</b>
  4365. }.</li>
  4366. </ol>
  4367. </li>
  4368. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>O</i>, <i>k</i>,
  4369. <i>desc</i>).</li>
  4370. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  4371. </ol>
  4372. </li>
  4373. </ol>
  4374. </li>
  4375. </ol>
  4376. </li>
  4377. <li>Return <b>true</b>.</li>
  4378. </ol>
  4379. </section>
  4380. <section id="sec-testintegritylevel">
  4381. <h1><span class="secnum" id="sec-7.3.16"><a href="#sec-testintegritylevel" title="link to this section">7.3.16</a></span>
  4382. TestIntegrityLevel (O, level)</h1>
  4383. <p>The abstract operation <span style="font-family: Times New Roman">TestIntegrityLevel</span> is used to determine if the
  4384. set of own properties of an object are fixed. This abstract operation performs the following steps:</p>
  4385. <ol class="proc">
  4386. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4387. Object.</li>
  4388. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>level</i> is either <code>"sealed"</code> or
  4389. <code>"frozen"</code>.</li>
  4390. <li>Let <i>status</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>O</i>).</li>
  4391. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  4392. <li>If <i>status</i> is <b>true</b>, return <b>false</b></li>
  4393. <li>NOTE If the object is extensible, none of its properties are examined.</li>
  4394. <li>Let <i>keys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
  4395. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>keys</i>).</li>
  4396. <li>Repeat for each element <i>k</i> of <i>keys</i>,
  4397. <ol class="block">
  4398. <li>Let <i>currentDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>k</i>).</li>
  4399. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>currentDesc</i>).</li>
  4400. <li>If <i>currentDesc</i> is not <b>undefined</b>, then
  4401. <ol class="block">
  4402. <li>If <i>currentDesc</i>.[[Configurable]] is <b>true</b>, return <b>false</b>.</li>
  4403. <li>If <i>level</i> is <code>"frozen"</code> and <a
  4404. href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>currentDesc</i>) is <b>true</b>, then
  4405. <ol class="block">
  4406. <li>If <i>currentDesc</i>.[[Writable]] is <b>true</b>, return <b>false</b>.</li>
  4407. </ol>
  4408. </li>
  4409. </ol>
  4410. </li>
  4411. </ol>
  4412. </li>
  4413. <li>Return <b>true</b>.</li>
  4414. </ol>
  4415. </section>
  4416. <section id="sec-createarrayfromlist">
  4417. <h1><span class="secnum" id="sec-7.3.17"><a href="#sec-createarrayfromlist" title="link to this section">7.3.17</a></span>
  4418. CreateArrayFromList (elements)</h1>
  4419. <p>The abstract operation <span style="font-family: Times New Roman">CreateArrayFromList</span> is used to create an Array
  4420. object whose elements are provided by a <a href="#sec-list-and-record-specification-type">List</a>. This abstract operation
  4421. performs the following steps:</p>
  4422. <ol class="proc">
  4423. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>elements</i> is a <a
  4424. href="#sec-list-and-record-specification-type">List</a> whose elements are all <a
  4425. href="#sec-ecmascript-language-types">ECMAScript language values</a>.</li>
  4426. <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0) (<a href="#sec-arraycreate">see 9.4.2.2</a>).</li>
  4427. <li>Let <i>n</i> be 0.</li>
  4428. <li>For each element <i>e</i> of <i>elements</i>
  4429. <ol class="block">
  4430. <li>Let <i>status</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
  4431. href="#sec-tostring">ToString</a>(<i>n</i>), <i>e</i>).</li>
  4432. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is <b>true</b>.</li>
  4433. <li>Increment <i>n</i> by 1.</li>
  4434. </ol>
  4435. </li>
  4436. <li>Return <i>array</i>.</li>
  4437. </ol>
  4438. </section>
  4439. <section id="sec-createlistfromarraylike">
  4440. <h1><span class="secnum" id="sec-7.3.18"><a href="#sec-createlistfromarraylike"
  4441. title="link to this section">7.3.18</a></span> CreateListFromArrayLike (obj [, elementTypes] )</h1>
  4442. <p>The abstract operation CreateListFromArrayLike is used to create a List value whose elements are provided by the indexed
  4443. properties of an array-like object, <var>obj</var>. The optional argument <var>elementTypes</var> is a <a
  4444. href="#sec-list-and-record-specification-type">List</a> containing the names of ECMAScript Language Types that are allowed
  4445. for element values of the <a href="#sec-list-and-record-specification-type">List</a> that is created. This abstract
  4446. operation performs the following steps:</p>
  4447. <ol class="proc">
  4448. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>obj</i>).</li>
  4449. <li>If <i>elementTypes</i> was not passed, let <i>elementTypes</i> be (Undefined, Null, Boolean, String, Symbol, Number,
  4450. Object).</li>
  4451. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>obj</i>) is not Object, throw a <b>TypeError</b>
  4452. exception.</li>
  4453. <li>Let <i>len</i> be <a href="#sec-tolength">ToLength</a>(<a href="#sec-get-o-p">Get</a>(<i>obj</i>,
  4454. <code>"length"</code>)).</li>
  4455. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
  4456. <li>Let <i>list</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  4457. <li>Let <i>index</i> be 0.</li>
  4458. <li>Repeat while <i>index</i> &lt; <i>len</i>
  4459. <ol class="block">
  4460. <li>Let <i>indexName</i> be <a href="#sec-tostring">ToString</a>(<i>index</i>).</li>
  4461. <li>Let <i>next</i> be <a href="#sec-get-o-p">Get</a>(<i>obj</i>, <i>indexName</i>).</li>
  4462. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
  4463. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>next</i>) is not an element of <i>elementTypes</i>,
  4464. throw a <b>TypeError</b> exception.</li>
  4465. <li>Append <i>next</i> as the last element of <i>list</i>.</li>
  4466. <li>Set <i>index</i> to <i>index</i> + 1.</li>
  4467. </ol>
  4468. </li>
  4469. <li>Return <i>list</i>.</li>
  4470. </ol>
  4471. </section>
  4472. <section id="sec-ordinaryhasinstance">
  4473. <h1><span class="secnum" id="sec-7.3.19"><a href="#sec-ordinaryhasinstance" title="link to this section">7.3.19</a></span>
  4474. OrdinaryHasInstance (C, O)</h1>
  4475. <p>The abstract operation <span style="font-family: Times New Roman">OrdinaryHasInstance</span> implements the default
  4476. algorithm for determining if an object <var>O</var> inherits from the instance object inheritance path provided by
  4477. constructor <var>C</var>. This abstract operation performs the following steps:</p>
  4478. <ol class="proc">
  4479. <li>If <a href="#sec-iscallable">IsCallable</a>(<i>C</i>) is <b>false</b>, return <b>false</b>.</li>
  4480. <li>If <i>C</i> has a <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
  4481. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, then
  4482. <ol class="block">
  4483. <li>Let <i>BC</i> be the value of <i>C&rsquo;s</i> <a
  4484. href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
  4485. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  4486. <li>Return <a href="#sec-instanceofoperator">InstanceofOperator</a>(<i>O</i>,<i>BC</i>) (<a
  4487. href="#sec-instanceofoperator">see 12.9.4</a>).</li>
  4488. </ol>
  4489. </li>
  4490. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is not Object, return <b>false</b>.</li>
  4491. <li>Let <i>P</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, <code>"prototype"</code>).</li>
  4492. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>P</i>).</li>
  4493. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is not Object, throw a <b>TypeError</b>
  4494. exception.</li>
  4495. <li>Repeat
  4496. <ol class="block">
  4497. <li>Let <i>O</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
  4498. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>O</i>).</li>
  4499. <li>If <i>O</i> is <code>null</code>, return <b>false</b>.</li>
  4500. <li>If <a href="#sec-samevalue">SameValue</a>(<i>P</i>, <i>O</i>) is <b>true</b>, return <b>true</b>.</li>
  4501. </ol>
  4502. </li>
  4503. </ol>
  4504. </section>
  4505. <section id="sec-speciesconstructor">
  4506. <h1><span class="secnum" id="sec-7.3.20"><a href="#sec-speciesconstructor" title="link to this section">7.3.20</a></span>
  4507. SpeciesConstructor ( O, defaultConstructor )</h1>
  4508. <p>The abstract operation SpeciesConstructor is used to retrieve the constructor that should be used to create new objects
  4509. that are derived from the argument object <var>O</var>. The <var>defaultConstructor</var> argument is the constructor to use
  4510. if a constructor @@species property cannot be found starting from <var>O</var>. This abstract operation performs the
  4511. following steps:</p>
  4512. <ol class="proc">
  4513. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
  4514. Object.</li>
  4515. <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>O</i>, <code>"constructor"</code>).</li>
  4516. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
  4517. <li>If <i>C</i> is <b>undefined</b>, return <i>defaultConstructor</i>.</li>
  4518. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>C</i>) is not Object, throw a <b>TypeError</b>
  4519. exception.</li>
  4520. <li>Let <i>S</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, @@species).</li>
  4521. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>S</i>).</li>
  4522. <li>If <i>S</i> is either <b>undefined</b> or <b>null</b>, return <i>defaultConstructor</i>.</li>
  4523. <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>S</i>) is <b>true</b>, return <i>S.</i></li>
  4524. <li>Throw a <b>TypeError</b> exception.</li>
  4525. </ol>
  4526. </section>
  4527. <section id="sec-enumerableownnames">
  4528. <h1><span class="secnum" id="sec-7.3.21"><a href="#sec-enumerableownnames" title="link to this section">7.3.21</a></span>
  4529. EnumerableOwnNames (O)</h1>
  4530. <p>When the abstract operation EnumerableOwnNames is called with Object <var>O</var> the following steps are taken:</p>
  4531. <ol class="proc">
  4532. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>)
  4533. is Object.</li>
  4534. <li>Let <i>ownKeys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
  4535. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ownKeys</i>).</li>
  4536. <li>Let <i>names</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  4537. <li>Repeat, for each element <i>key</i> of <i>ownKeys</i> in <a href="#sec-list-and-record-specification-type">List</a>
  4538. order
  4539. <ol class="block">
  4540. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>key</i>) is String, then
  4541. <ol class="block">
  4542. <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>key</i>).</li>
  4543. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
  4544. <li>If <i>desc</i> is not <b>undefined</b>, then
  4545. <ol class="block">
  4546. <li>If <i>desc.</i>[[Enumerable]] is <b>true</b>, append <i>key</i> to <i>names</i>.</li>
  4547. </ol>
  4548. </li>
  4549. </ol>
  4550. </li>
  4551. </ol>
  4552. </li>
  4553. <li>Order the elements of <i>names</i> so they are in the same relative order as would be produced by the Iterator that
  4554. would be returned if the [[Enumerate]] internal method was invoked on <i>O</i>.</li>
  4555. <li>Return <i>names</i>.</li>
  4556. </ol>
  4557. <div class="note">
  4558. <p><span class="nh">NOTE</span> The order of elements is returned list is the same as the enumeration order that used by a
  4559. for-in statement.</p>
  4560. </div>
  4561. </section>
  4562. <section id="sec-getfunctionrealm">
  4563. <h1><span class="secnum" id="sec-7.3.22"><a href="#sec-getfunctionrealm" title="link to this section">7.3.22</a></span>
  4564. GetFunctionRealm ( obj )</h1>
  4565. <p>The abstract operation GetFunctionRealm with argument <var>obj</var> performs the following steps:</p>
  4566. <ol class="proc">
  4567. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>obj</i> is a callable object.</li>
  4568. <li>If <i>obj</i> has a [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, then
  4569. <ol class="block">
  4570. <li>Return <i>obj</i>&rsquo;s [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  4571. slot</a>.</li>
  4572. </ol>
  4573. </li>
  4574. <li>If <i>obj</i> is a <a href="#sec-bound-function-exotic-objects">Bound Function</a> exotic object, then
  4575. <ol class="block">
  4576. <li>Let <i>target</i> be <i>obj</i>&rsquo;s <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a>
  4577. <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  4578. <li>Return GetFunctionRealm(<i>target</i>).</li>
  4579. </ol>
  4580. </li>
  4581. <li>If <i>obj</i> is a Proxy exotic object, then
  4582. <ol class="block">
  4583. <li>If the value of the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
  4584. of <i>obj</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  4585. <li>Let <i>proxyTarget</i> be the value of <i>obj</i>&rsquo;s [[ProxyTarget]] <a
  4586. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  4587. <li>Return GetFunctionRealm(<i>proxyTarget</i>).</li>
  4588. </ol>
  4589. </li>
  4590. <li>Return <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
  4591. href="#sec-code-realms">Realm</a>.</li>
  4592. </ol>
  4593. <div class="note">
  4594. <p><span class="nh">NOTE</span> Step 5 will only be reached if <i>target</i> is a non-standard exotic function object that
  4595. does not have a [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</p>
  4596. </div>
  4597. </section>
  4598. </section>
  4599. <section id="sec-operations-on-iterator-objects">
  4600. <div class="front">
  4601. <h1><span class="secnum" id="sec-7.4"><a href="#sec-operations-on-iterator-objects"
  4602. title="link to this section">7.4</a></span> Operations on Iterator Objects</h1>
  4603. <p>See Common Iteration Interfaces (<a href="#sec-iteration">25.1</a>).</p>
  4604. </div>
  4605. <section id="sec-getiterator">
  4606. <h1><span class="secnum" id="sec-7.4.1"><a href="#sec-getiterator" title="link to this section">7.4.1</a></span> GetIterator
  4607. ( obj, method )</h1>
  4608. <p>The abstract operation GetIterator with argument <span style="font-family: Times New Roman"><i>obj</i> and</span>
  4609. optional argument <var>method</var> performs the following steps:</p>
  4610. <ol class="proc">
  4611. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>obj</i>).</li>
  4612. <li>If <i>method</i> was not passed, then
  4613. <ol class="block">
  4614. <li>Let <i>method</i> be <a href="#sec-getmethod">GetMethod</a>(<i>obj</i>, @@iterator).</li>
  4615. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>method</i>).</li>
  4616. </ol>
  4617. </li>
  4618. <li>Let <i>iterator</i> be <a href="#sec-call">Call</a>(<i>method</i>,<i>obj</i>).</li>
  4619. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>)<i>.</i></li>
  4620. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterator</i>) is not Object, throw a <b>TypeError</b>
  4621. exception.</li>
  4622. <li>Return <i>iterator</i>.</li>
  4623. </ol>
  4624. </section>
  4625. <section id="sec-iteratornext">
  4626. <h1><span class="secnum" id="sec-7.4.2"><a href="#sec-iteratornext" title="link to this section">7.4.2</a></span>
  4627. IteratorNext ( iterator, value )</h1>
  4628. <p>The abstract operation IteratorNext with argument <var>iterator</var> and optional argument <var>value</var> performs the
  4629. following steps:</p>
  4630. <ol class="proc">
  4631. <li>If <i>value</i> was not passed, then
  4632. <ol class="block">
  4633. <li>Let <i>result</i> be <a href="#sec-invoke">Invoke</a>(<i>iterator</i>, <code>"next"</code>, &laquo;&zwj;
  4634. &raquo;).</li>
  4635. </ol>
  4636. </li>
  4637. <li>Else,
  4638. <ol class="block">
  4639. <li>Let <i>result</i> be <a href="#sec-invoke">Invoke</a>(<i>iterator</i>, <code>"next"</code>,
  4640. &laquo;&zwj;<i>value</i>&raquo;).</li>
  4641. </ol>
  4642. </li>
  4643. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
  4644. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, throw a <b>TypeError</b>
  4645. exception.</li>
  4646. <li>Return <i>result</i>.</li>
  4647. </ol>
  4648. </section>
  4649. <section id="sec-iteratorcomplete">
  4650. <h1><span class="secnum" id="sec-7.4.3"><a href="#sec-iteratorcomplete" title="link to this section">7.4.3</a></span>
  4651. IteratorComplete ( iterResult )</h1>
  4652. <p>The abstract operation IteratorComplete with argument <var>iterResult</var> performs the following steps:</p>
  4653. <ol class="proc">
  4654. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  4655. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterResult</i>) is Object.</li>
  4656. <li>Return <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>iterResult</i>,
  4657. <code>"done"</code>)).</li>
  4658. </ol>
  4659. </section>
  4660. <section id="sec-iteratorvalue">
  4661. <h1><span class="secnum" id="sec-7.4.4"><a href="#sec-iteratorvalue" title="link to this section">7.4.4</a></span>
  4662. IteratorValue ( iterResult )</h1>
  4663. <p>The abstract operation IteratorValue with argument <var>iterResult</var> performs the following steps:</p>
  4664. <ol class="proc">
  4665. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  4666. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterResult</i>) is Object.</li>
  4667. <li>Return <a href="#sec-get-o-p">Get</a>(<i>iterResult</i>, <code>"value"</code>).</li>
  4668. </ol>
  4669. </section>
  4670. <section id="sec-iteratorstep">
  4671. <h1><span class="secnum" id="sec-7.4.5"><a href="#sec-iteratorstep" title="link to this section">7.4.5</a></span>
  4672. IteratorStep ( iterator )</h1>
  4673. <p>The abstract operation IteratorStep with argument <var>iterator</var> requests the next value from <var>iterator</var>
  4674. and returns either <span class="value">false</span> indicating that the iterator has reached its end or the IteratorResult
  4675. object if a next value is available. IteratorStep performs the following steps:</p>
  4676. <ol class="proc">
  4677. <li>Let <i>result</i> be <a href="#sec-iteratornext">IteratorNext</a>(<i>iterator</i>).</li>
  4678. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
  4679. <li>Let <i>done</i> be <a href="#sec-iteratorcomplete">IteratorComplete</a>(<i>result</i>).</li>
  4680. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>done</i>).</li>
  4681. <li>If <i>done</i> is <b>true</b>, return <b>false</b>.</li>
  4682. <li>Return <i>result</i>.</li>
  4683. </ol>
  4684. </section>
  4685. <section id="sec-iteratorclose">
  4686. <h1><span class="secnum" id="sec-7.4.6"><a href="#sec-iteratorclose" title="link to this section">7.4.6</a></span>
  4687. IteratorClose( iterator, completion )</h1>
  4688. <p>The abstract operation IteratorClose with arguments <var>iterator</var> and <var>completion</var> is used to notify an
  4689. iterator that it should perform any actions it would normally perform when it has reached its completed state:</p>
  4690. <ol class="proc">
  4691. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  4692. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterator</i>) is Object.</li>
  4693. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>completion</i> is a <a
  4694. href="#sec-completion-record-specification-type">Completion Record</a>.</li>
  4695. <li>Let <i>return</i> be <a href="#sec-getmethod">GetMethod</a>(<i>iterator</i>, <code>"return"</code>).</li>
  4696. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>return</i>).</li>
  4697. <li>If <i>return</i> is <b>undefined</b>, return <a
  4698. href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
  4699. <li>Let <i>innerResult</i> be <a href="#sec-call">Call</a>(<i>return</i>, <i>iterator</i>, &laquo;&zwj; &raquo;).</li>
  4700. <li>If <i>completion</i>.[[type]] is <span style="font-family: sans-serif">throw</span>, return <a
  4701. href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
  4702. <li>If <i>innerResult</i>.[[type]] is <span style="font-family: sans-serif">throw</span>, return <a
  4703. href="#sec-completion-record-specification-type">Completion</a>(<i>innerResult</i>).</li>
  4704. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>innerResult</i>.[[value]]) is not Object<i>,</i> throw
  4705. a <b>TypeError</b> exception.</li>
  4706. <li>Return <a href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
  4707. </ol>
  4708. </section>
  4709. <section id="sec-createiterresultobject">
  4710. <h1><span class="secnum" id="sec-7.4.7"><a href="#sec-createiterresultobject" title="link to this section">7.4.7</a></span>
  4711. CreateIterResultObject ( value, done )</h1>
  4712. <p>The abstract operation CreateIterResultObject with arguments <var>value</var> and <var>done</var> creates an object that
  4713. supports the IteratorResult interface by performing the following steps:</p>
  4714. <ol class="proc">
  4715. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>done</i>)
  4716. is Boolean.</li>
  4717. <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
  4718. sans-serif">%ObjectPrototype%</span>).</li>
  4719. <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <code>"value"</code>, <i>value</i>).</li>
  4720. <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <code>"done"</code>, <i>done</i>).</li>
  4721. <li>Return <i>obj</i>.</li>
  4722. </ol>
  4723. </section>
  4724. <section id="sec-createlistiterator">
  4725. <div class="front">
  4726. <h1><span class="secnum" id="sec-7.4.8"><a href="#sec-createlistiterator" title="link to this section">7.4.8</a></span>
  4727. CreateListIterator ( list )</h1>
  4728. <p>The abstract operation CreateListIterator with argument <var>list</var> creates an Iterator (<a
  4729. href="#sec-iterator-interface">25.1.1.2</a>) object whose next method returns the successive elements of <var>list</var>.
  4730. It performs the following steps:</p>
  4731. <ol class="proc">
  4732. <li>Let <i>iterator</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%IteratorPrototype%, &laquo;[[IteratorNext]],
  4733. [[IteratedList]], [[ListIteratorNextIndex]]&raquo;).</li>
  4734. <li>Set <i>iterator&rsquo;s</i> [[IteratedList]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  4735. slot</a> to <i>list</i>.</li>
  4736. <li>Set <i>iterator&rsquo;s</i> [[ListIteratorNextIndex]] <a
  4737. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to 0.</li>
  4738. <li>Let <i>next</i> be a new built-in function object as defined in ListIterator <code>next</code> (<a
  4739. href="#sec-listiterator-next">7.4.8.1</a>).</li>
  4740. <li>Set <i>iterator&rsquo;s</i> [[IteratorNext]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  4741. slot</a> to <i>next</i>.</li>
  4742. <li>Perform <a href="#sec-createmethodproperty">CreateMethodProperty</a>(<i>iterator</i>, <code>"next"</code>,
  4743. <i>next</i>).</li>
  4744. <li>Return <i>iterator</i>.</li>
  4745. </ol>
  4746. </div>
  4747. <section id="sec-listiterator-next">
  4748. <h1><span class="secnum" id="sec-7.4.8.1"><a href="#sec-listiterator-next" title="link to this section">7.4.8.1</a></span>
  4749. ListIterator next( )</h1>
  4750. <p>The ListIterator <code>next</code> method is a standard built-in function object (<a
  4751. href="#sec-ecmascript-standard-built-in-objects">clause 17</a>) that performs the following steps:</p>
  4752. <ol class="proc">
  4753. <li>Let <i>O</i> be the <b>this</b> value.</li>
  4754. <li>Let <i>f</i> be the active function object.</li>
  4755. <li>If <i>O</i> does not have a [[IteratorNext]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  4756. slot</a>, throw a <b>TypeError</b> exception.</li>
  4757. <li>Let <i>next</i> be the value of the [[IteratorNext]] <a
  4758. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  4759. <li>If <a href="#sec-samevalue">SameValue</a>(<i>f</i>, <i>next</i>) is <b>false</b>, throw a <b>TypeError</b>
  4760. exception.</li>
  4761. <li>If <i>O</i> does not have a [[IteratedList]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  4762. slot</a>, throw a <b>TypeError</b> exception.</li>
  4763. <li>Let <i>list</i> be the value of the [[IteratedList]] <a
  4764. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  4765. <li>Let <i>index</i> be the value of the [[ListIteratorNextIndex]] <a
  4766. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  4767. <li>Let <i>len</i> be the number of elements of <i>list</i>.</li>
  4768. <li>If <i>index</i> &ge; <i>len</i>, then
  4769. <ol class="block">
  4770. <li>Return <a href="#sec-createiterresultobject">CreateIterResultObject</a>(<b>undefined</b>, <b>true</b>).</li>
  4771. </ol>
  4772. </li>
  4773. <li>Set the value of the [[ListIteratorNextIndex]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  4774. slot</a> of <i>O</i> to <i>index</i>+1.</li>
  4775. <li>Return <a href="#sec-createiterresultobject">CreateIterResultObject</a>(<i>list</i>[<i>index</i>],
  4776. <b>false</b>).</li>
  4777. </ol>
  4778. <div class="note">
  4779. <p><span class="nh">NOTE</span> A ListIterator <code>next</code> method will throw an exception if applied to any object
  4780. other than the one with which it was originally associated.</p>
  4781. </div>
  4782. </section>
  4783. </section>
  4784. </section>
  4785. </section>
  4786. <section id="sec-executable-code-and-execution-contexts">
  4787. <div class="front">
  4788. <h1><span class="secnum" id="sec-8"><a href="#sec-executable-code-and-execution-contexts"
  4789. title="link to this section">8</a></span> Executable Code and Execution Contexts</h1>
  4790. </div>
  4791. <section id="sec-lexical-environments">
  4792. <div class="front">
  4793. <h1><span class="secnum" id="sec-8.1"><a href="#sec-lexical-environments" title="link to this section">8.1</a></span>
  4794. Lexical Environments</h1>
  4795. <p>A <i>Lexical Environment</i> is a specification type used to define the association of <span
  4796. class="nt">Identifiers</span> to specific variables and functions based upon the lexical nesting structure of ECMAScript
  4797. code. A Lexical Environment consists of an <a href="#sec-environment-records">Environment Record</a> and a possibly null
  4798. reference to an <i>outer</i> Lexical Environment. Usually a Lexical Environment is associated with some specific syntactic
  4799. structure of ECMAScript code such as a <span class="nt">FunctionDeclaration</span>, a <span
  4800. class="nt">BlockStatement</span>, or a <span class="nt">Catch</span> clause of a <span class="nt">TryStatement</span> and a
  4801. new Lexical Environment is created each time such code is evaluated.</p>
  4802. <p>An <a href="#sec-environment-records">Environment Record</a> records the identifier bindings that are created within the
  4803. scope of its associated Lexical Environment. It is referred to as the Lexical Environment&rsquo;s EnvironmentRecord</p>
  4804. <p>The outer environment reference is used to model the logical nesting of Lexical Environment values. The outer reference
  4805. of a (inner) Lexical Environment is a reference to the Lexical Environment that logically surrounds the inner Lexical
  4806. Environment. An outer Lexical Environment may, of course, have its own outer Lexical Environment. A Lexical Environment may
  4807. serve as the outer environment for multiple inner Lexical Environments. For example, if a <span
  4808. class="nt">FunctionDeclaration</span> contains two nested <span class="nt">FunctionDeclarations</span> then the Lexical
  4809. Environments of each of the nested functions will have as their outer Lexical Environment the Lexical Environment of the
  4810. current evaluation of the surrounding function.</p>
  4811. <p>A <i>global environment</i> is a Lexical Environment which does not have an outer environment. The global
  4812. environment&rsquo;s outer environment reference is <b>null</b>. A global environment&rsquo;s <a
  4813. href="#sec-environment-records">Environment Record</a> may be prepopulated with identifier bindings and includes an
  4814. associated <i>global object</i> whose properties provide some of <a href="#sec-global-environment-records">the global
  4815. environment</a>&rsquo;s identifier bindings. This global object is the value of a global environment&rsquo;s
  4816. <code>this</code> binding. As ECMAScript code is executed, additional properties may be added to the global object and the
  4817. initial properties may be modified.</p>
  4818. <p>A <i>module environment</i> is a Lexical Environment that contains the bindings for the top level declarations of a <span
  4819. class="nt">Module</span>. It also contains the bindings that are explicitly imported by the <span class="nt">Module</span>.
  4820. The outer environment of a module environment is a global environment.</p>
  4821. <p>A <i>function environment</i> is a Lexical Environment that corresponds to the invocation of an <a
  4822. href="#sec-ecmascript-function-objects">ECMAScript function object</a>. A function environment may establish a new
  4823. <code>this</code> binding. A function environment also captures the state necessary to support <code>super</code> method
  4824. invocations.</p>
  4825. <p>Lexical Environments and <a href="#sec-environment-records">Environment Record</a> values are purely specification
  4826. mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an
  4827. ECMAScript program to directly access or manipulate such values.</p>
  4828. </div>
  4829. <section id="sec-environment-records">
  4830. <div class="front">
  4831. <h1><span class="secnum" id="sec-8.1.1"><a href="#sec-environment-records" title="link to this section">8.1.1</a></span>
  4832. Environment Records</h1>
  4833. <p>There are two primary kinds of Environment Record values used in this specification: <i>declarative Environment
  4834. Records</i> and <i>object Environment Records</i>. Declarative Environment Records are used to define the effect of
  4835. ECMAScript language syntactic elements such as <span class="nt">FunctionDeclarations</span>, <span
  4836. class="nt">VariableDeclarations</span>, and <span class="nt">Catch</span> clauses that directly associate identifier
  4837. bindings with <a href="#sec-ecmascript-language-types">ECMAScript language values</a>. Object Environment Records are used
  4838. to define the effect of ECMAScript elements such as <span class="nt">WithStatement</span> that associate identifier
  4839. bindings with the properties of some object. <a href="#sec-global-environment-records">Global Environment Records</a> and
  4840. function Environment Records are specializations that are used for specifically for <span class="nt">Script</span> global
  4841. declarations and for top-level declarations within functions.</p>
  4842. <p>For specification purposes Environment Record values are values of the Record specification type and can be thought of
  4843. as existing in a simple object-oriented hierarchy where Environment Record is an abstract class with three concrete
  4844. subclasses, declarative Environment Record, object Environment Record, and global Environment Record. <a
  4845. href="#sec-function-environment-records">Function Environment Records</a> and module Environment Records are subclasses of
  4846. declarative Environment Record. The abstract class includes the abstract specification methods defined in <a
  4847. href="#table-15">Table 15</a>. These abstract methods have distinct concrete algorithms for each of the concrete
  4848. subclasses.</p>
  4849. <figure>
  4850. <figcaption><span id="table-15">Table 15</span> &mdash; Abstract Methods of Environment Records</figcaption>
  4851. <table class="real-table">
  4852. <tr>
  4853. <th>Method</th>
  4854. <th>Purpose</th>
  4855. </tr>
  4856. <tr>
  4857. <td>HasBinding(N)</td>
  4858. <td>Determine if an Environment Record has a binding for the String value <var>N</var>. Return <b>true</b> if it does and <b>false</b> if it does not</td>
  4859. </tr>
  4860. <tr>
  4861. <td>CreateMutableBinding(N, D)</td>
  4862. <td>Create a new but uninitialized mutable binding in an Environment Record. The String value <var>N</var> is the text of the bound name. If the optional Boolean argument <var>D</var> is <b>true</b> the binding is may be subsequently deleted.</td>
  4863. </tr>
  4864. <tr>
  4865. <td>CreateImmutableBinding(N, S)</td>
  4866. <td>Create a new but uninitialized immutable binding in an Environment Record. The String value N is the text of the bound name. If <var>S</var> is <b>true</b> then attempts to access the value of the binding before it is initialized or set it after it has been initialized will always throw an exception, regardless of the strict mode setting of operations that reference that binding. <var>S</var> is an optional parameter that defaults to <b>false</b>.</td>
  4867. </tr>
  4868. <tr>
  4869. <td>InitializeBinding(N,V)</td>
  4870. <td>Set the value of an already existing but uninitialized binding in an Environment Record. The String value N is the text of the bound name. V is the value for the binding and is a value of any <a href="#sec-ecmascript-language-types">ECMAScript language type</a>.</td>
  4871. </tr>
  4872. <tr>
  4873. <td>SetMutableBinding(N,V, S)</td>
  4874. <td>Set the value of an already existing mutable binding in an Environment Record. The String value <var>N</var> is the text of the bound name. <var>V</var> is the value for the binding and may be a value of any <a href="#sec-ecmascript-language-types">ECMAScript language type</a>. <var>S</var> is a Boolean flag. If <var>S</var> is <b>true</b> and the binding cannot be set throw a <b>TypeError</b> exception.</td>
  4875. </tr>
  4876. <tr>
  4877. <td>GetBindingValue(N,S)</td>
  4878. <td>Returns the value of an already existing binding from an Environment Record. The String value <var>N</var> is the text of the bound name. <var>S</var> is used to identify references originating in <a href="#sec-strict-mode-code">strict mode code</a> or that otherwise require strict mode reference semantics. If <var>S</var> is <b>true</b> and the binding does not exist throw a <b>ReferenceError</b> exception. If the binding exists but is uninitialized a <b>ReferenceError</b> is thrown, regardless of the value of <i><span style="font-family: Times New Roman">S</span>.</i></td>
  4879. </tr>
  4880. <tr>
  4881. <td>DeleteBinding(N)</td>
  4882. <td>Delete a binding from an Environment Record. The String value <var>N</var> is the text of the bound name. If a binding for <var>N</var> exists, remove the binding and return <b>true</b>. If the binding exists but cannot be removed return <b>false</b>. If the binding does not exist return <b>true</b>.</td>
  4883. </tr>
  4884. <tr>
  4885. <td>HasThisBinding()</td>
  4886. <td>Determine if an Environment Record establishes a <code>this</code> binding. Return <b>true</b> if it does and <b>false</b> if it does not.</td>
  4887. </tr>
  4888. <tr>
  4889. <td>HasSuperBinding()</td>
  4890. <td>Determine if an Environment Record establishes a <code>super</code> method binding. Return <b>true</b> if it does and <b>false</b> if it does not.</td>
  4891. </tr>
  4892. <tr>
  4893. <td>WithBaseObject ()</td>
  4894. <td>If this Environment Record is associated with a <code>with</code> statement, return the with object. Otherwise, return <span class="value">undefined</span>.</td>
  4895. </tr>
  4896. </table>
  4897. </figure>
  4898. </div>
  4899. <section id="sec-declarative-environment-records">
  4900. <div class="front">
  4901. <h1><span class="secnum" id="sec-8.1.1.1"><a href="#sec-declarative-environment-records"
  4902. title="link to this section">8.1.1.1</a></span> Declarative Environment Records</h1>
  4903. <p>Each declarative <a href="#sec-environment-records">Environment Record</a> is associated with an ECMAScript program
  4904. scope containing variable, constant, let, class, module, import, and/or function declarations. A declarative <a
  4905. href="#sec-environment-records">Environment Record</a> binds the set of identifiers defined by the declarations
  4906. contained within its scope.</p>
  4907. <p>The behaviour of the concrete specification methods for declarative environment records is defined by the following
  4908. algorithms.</p>
  4909. </div>
  4910. <section id="sec-declarative-environment-records-hasbinding-n">
  4911. <h1><span class="secnum" id="sec-8.1.1.1.1"><a href="#sec-declarative-environment-records-hasbinding-n"
  4912. title="link to this section">8.1.1.1.1</a></span> HasBinding(N)</h1>
  4913. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for declarative Environment
  4914. Records simply determines if the argument identifier is one of the identifiers bound by the record:</p>
  4915. <ol class="proc">
  4916. <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
  4917. method was invoked.</li>
  4918. <li>If <i>envRec</i> has a binding for the name that is the value of <i>N</i>, return <b>true</b>.</li>
  4919. <li>Return <b>false</b>.</li>
  4920. </ol>
  4921. </section>
  4922. <section id="sec-declarative-environment-records-createmutablebinding-n-d">
  4923. <h1><span class="secnum" id="sec-8.1.1.1.2"><a href="#sec-declarative-environment-records-createmutablebinding-n-d"
  4924. title="link to this section">8.1.1.1.2</a></span> CreateMutableBinding (N, D)</h1>
  4925. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for declarative
  4926. Environment Records creates a new mutable binding for the name <var>N</var> that is uninitialized. A binding must not
  4927. already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
  4928. <var>D</var> is provided and has the value <b>true</b> the new binding is marked as being subject to deletion.</p>
  4929. <ol class="proc">
  4930. <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
  4931. method was invoked.</li>
  4932. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
  4933. <li>Create a mutable binding in <i>envRec</i> for <i>N</i> and record that it is uninitialized. If <i>D</i> is
  4934. <b>true</b> record that the newly created binding may be deleted by a subsequent DeleteBinding call.</li>
  4935. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
  4936. sans-serif">empty</span>).</li>
  4937. </ol>
  4938. </section>
  4939. <section id="sec-declarative-environment-records-createimmutablebinding-n-s">
  4940. <h1><span class="secnum" id="sec-8.1.1.1.3"><a href="#sec-declarative-environment-records-createimmutablebinding-n-s"
  4941. title="link to this section">8.1.1.1.3</a></span> CreateImmutableBinding (N, S)</h1>
  4942. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding for declarative
  4943. Environment Records creates a new immutable binding for the name <var>N</var> that is uninitialized. A binding must not
  4944. already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
  4945. <var>S</var> is provided and has the value <b>true</b> the new binding is marked as a strict binding.</p>
  4946. <ol class="proc">
  4947. <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
  4948. method was invoked.</li>
  4949. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
  4950. <li>Create an immutable binding in <i>envRec</i> for <i>N</i> and record that it is uninitialized. If <i>S</i> is
  4951. <b>true</b> record that the newly created binding is a strict binding.</li>
  4952. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
  4953. sans-serif">empty</span>).</li>
  4954. </ol>
  4955. </section>
  4956. <section id="sec-declarative-environment-records-initializebinding-n-v">
  4957. <h1><span class="secnum" id="sec-8.1.1.1.4"><a href="#sec-declarative-environment-records-initializebinding-n-v"
  4958. title="link to this section">8.1.1.1.4</a></span> InitializeBinding (N,V)</h1>
  4959. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for declarative
  4960. Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
  4961. the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
  4962. exist.</p>
  4963. <ol class="proc">
  4964. <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
  4965. method was invoked.</li>
  4966. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> must have an uninitialized binding for
  4967. <i>N</i>.</li>
  4968. <li>Set the bound value for <i>N</i> in <i>envRec</i> to <i>V</i>.</li>
  4969. <li>Record that the binding for <i>N</i> in <i>envRec</i> has been initialized.</li>
  4970. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
  4971. sans-serif">empty</span>).</li>
  4972. </ol>
  4973. </section>
  4974. <section id="sec-declarative-environment-records-setmutablebinding-n-v-s">
  4975. <h1><span class="secnum" id="sec-8.1.1.1.5"><a href="#sec-declarative-environment-records-setmutablebinding-n-v-s"
  4976. title="link to this section">8.1.1.1.5</a></span> SetMutableBinding (N,V,S)</h1>
  4977. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for declarative
  4978. Environment Records attempts to change the bound value of the current binding of the identifier whose name is the value
  4979. of the argument <var>N</var> to the value of argument <var>V</var>. A binding for <var>N</var> normally already exist,
  4980. but in rare cases it may not. If the binding is an immutable binding, a <b>TypeError</b> is thrown if <span
  4981. style="font-family: Times New Roman">S</span> is <span class="value">true</span>.</p>
  4982. <ol class="proc">
  4983. <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
  4984. method was invoked.</li>
  4985. <li>If <i>envRec</i> does not have a binding for <i>N</i>, then
  4986. <ol class="block">
  4987. <li>If <i>S</i> is <b>true</b> throw a <b>ReferenceError</b> exception.</li>
  4988. <li>Perform <i>envRec</i>.CreateMutableBinding(<i>N</i>, <b>true</b>).</li>
  4989. <li>Perform <i>envRec</i>.InitializeBinding(<i>N</i>, <i>V</i>).</li>
  4990. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
  4991. sans-serif">empty</span>).</li>
  4992. </ol>
  4993. </li>
  4994. <li>If the binding for <i>N</i> in <i>envRec</i> is a strict binding, let <i>S</i> be <b>true</b>.</li>
  4995. <li>If the binding for <i>N</i> in <i>envRec</i> has not yet been initialized throw a <b>ReferenceError</b>
  4996. exception.</li>
  4997. <li>Else if the binding for <i>N</i> in <i>envRec</i> is a mutable binding, change its bound value to <i>V</i>.</li>
  4998. <li>Else this must be an attempt to change the value of an immutable binding so if <i>S</i> is <b>true</b> throw a
  4999. <b>TypeError</b> exception.</li>
  5000. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
  5001. sans-serif">empty</span>).</li>
  5002. </ol>
  5003. <div class="note">
  5004. <p><span class="nh">NOTE</span> An example of ECMAScript code that results in a missing binding at step 2 is:</p>
  5005. <pre>function f(){eval("var x; x = (delete x, 0);")}</pre>
  5006. </div>
  5007. </section>
  5008. <section id="sec-declarative-environment-records-getbindingvalue-n-s">
  5009. <h1><span class="secnum" id="sec-8.1.1.1.6"><a href="#sec-declarative-environment-records-getbindingvalue-n-s"
  5010. title="link to this section">8.1.1.1.6</a></span> GetBindingValue(N,S)</h1>
  5011. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for declarative
  5012. Environment Records simply returns the value of its bound identifier whose name is the value of the argument
  5013. <var>N</var>. If the binding exists but is uninitialized a <b>ReferenceError</b> is thrown, regardless of the value of
  5014. <i><span style="font-family: Times New Roman">S</span>.</i></p>
  5015. <ol class="proc">
  5016. <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
  5017. method was invoked.</li>
  5018. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for <i>N</i>.</li>
  5019. <li>If the binding for <i>N</i> in <i>envRec</i> is an uninitialized binding, throw a <b>ReferenceError</b>
  5020. exception.</li>
  5021. <li>Return the value currently bound to <i>N</i> in <i>envRec</i>.</li>
  5022. </ol>
  5023. </section>
  5024. <section id="sec-declarative-environment-records-deletebinding-n">
  5025. <h1><span class="secnum" id="sec-8.1.1.1.7"><a href="#sec-declarative-environment-records-deletebinding-n"
  5026. title="link to this section">8.1.1.1.7</a></span> DeleteBinding (N)</h1>
  5027. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for declarative
  5028. Environment Records can only delete bindings that have been explicitly designated as being subject to deletion.</p>
  5029. <ol class="proc">
  5030. <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
  5031. method was invoked.</li>
  5032. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for the name that is the value of
  5033. <i>N</i>.</li>
  5034. <li>If the binding for <i>N</i> in <i>envRec</i> cannot be deleted, return <b>false</b>.</li>
  5035. <li>Remove the binding for <i>N</i> from <i>envRec</i>.</li>
  5036. <li>Return <b>true</b>.</li>
  5037. </ol>
  5038. </section>
  5039. <section id="sec-declarative-environment-records-hasthisbinding">
  5040. <h1><span class="secnum" id="sec-8.1.1.1.8"><a href="#sec-declarative-environment-records-hasthisbinding"
  5041. title="link to this section">8.1.1.1.8</a></span> HasThisBinding ()</h1>
  5042. <p>Regular declarative Environment Records do not provide a <code>this</code> binding.</p>
  5043. <ol class="proc">
  5044. <li>Return <b>false</b>.</li>
  5045. </ol>
  5046. </section>
  5047. <section id="sec-declarative-environment-records-hassuperbinding">
  5048. <h1><span class="secnum" id="sec-8.1.1.1.9"><a href="#sec-declarative-environment-records-hassuperbinding"
  5049. title="link to this section">8.1.1.1.9</a></span> HasSuperBinding ()</h1>
  5050. <p>Regular declarative Environment Records do not provide a <code>super</code> binding.</p>
  5051. <ol class="proc">
  5052. <li>Return <b>false</b>.</li>
  5053. </ol>
  5054. </section>
  5055. <section id="sec-declarative-environment-records-withbaseobject">
  5056. <h1><span class="secnum" id="sec-8.1.1.1.10"><a href="#sec-declarative-environment-records-withbaseobject"
  5057. title="link to this section">8.1.1.1.10</a></span> WithBaseObject()</h1>
  5058. <p>Declarative Environment Records always return <b>undefined</b> as their WithBaseObject.</p>
  5059. <ol class="proc">
  5060. <li>Return <b>undefined</b>.</li>
  5061. </ol>
  5062. </section>
  5063. </section>
  5064. <section id="sec-object-environment-records">
  5065. <div class="front">
  5066. <h1><span class="secnum" id="sec-8.1.1.2"><a href="#sec-object-environment-records"
  5067. title="link to this section">8.1.1.2</a></span> Object Environment Records</h1>
  5068. <p>Each object <a href="#sec-environment-records">Environment Record</a> is associated with an object called its
  5069. <i>binding object</i>. An object <a href="#sec-environment-records">Environment Record</a> binds the set of string
  5070. identifier names that directly correspond to the property names of its binding object. Property keys that are not
  5071. strings in the form of an <span class="nt">IdentifierName</span> are not included in the set of bound identifiers. Both
  5072. own and inherited properties are included in the set regardless of the setting of their [[Enumerable]] attribute.
  5073. Because properties can be dynamically added and deleted from objects, the set of identifiers bound by an object <a
  5074. href="#sec-environment-records">Environment Record</a> may potentially change as a side-effect of any operation that
  5075. adds or deletes properties. Any bindings that are created as a result of such a side-effect are considered to be a
  5076. mutable binding even if the Writable attribute of the corresponding property has the value <b>false</b>. Immutable
  5077. bindings do not exist for object Environment Records.</p>
  5078. <p>Object Environment Records created for <code>with</code> statements (<a href="#sec-with-statement">13.10</a>) can
  5079. provide their binding object as an implicit <b>this</b> value for use in function calls. The capability is controlled by
  5080. a <var>withEnvironment</var> Boolean value that is associated with each object <a
  5081. href="#sec-environment-records">Environment Record</a>. By default, the value of <var>withEnvironment</var> is
  5082. <b>false</b> for any object <a href="#sec-environment-records">Environment Record</a>.</p>
  5083. <p>The behaviour of the concrete specification methods for object environment records is defined by the following
  5084. algorithms.</p>
  5085. </div>
  5086. <section id="sec-object-environment-records-hasbinding-n">
  5087. <h1><span class="secnum" id="sec-8.1.1.2.1"><a href="#sec-object-environment-records-hasbinding-n"
  5088. title="link to this section">8.1.1.2.1</a></span> HasBinding(N)</h1>
  5089. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for object Environment
  5090. Records determines if its associated binding object has a property whose name is the value of the argument
  5091. <var>N</var>:</p>
  5092. <ol class="proc">
  5093. <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
  5094. invoked.</li>
  5095. <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
  5096. <li>Let <i>foundBinding</i> be <a href="#sec-hasproperty">HasProperty</a>(<i>bindings</i>, <i>N</i>)</li>
  5097. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>foundBinding</i>).</li>
  5098. <li>If <i>foundBinding</i> is <b>false</b>, return <b>false</b>.</li>
  5099. <li>If the <i>withEnvironment</i> flag of <i>envRec</i> is <b>false</b>, return <b>true</b>.</li>
  5100. <li>Let <i>unscopables</i> be <a href="#sec-get-o-p">Get</a>(<i>bindings</i>, @@unscopables).</li>
  5101. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>unscopables</i>).</li>
  5102. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>unscopables</i>) is Object, then
  5103. <ol class="block">
  5104. <li>Let <i>blocked</i> be <a href="#sec-toboolean">ToBoolean</a>(<a
  5105. href="#sec-get-o-p">Get</a>(<i>unscopables</i>, <i>N</i>)).</li>
  5106. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>blocked</i>).</li>
  5107. <li>If <i>blocked</i> is <b>true</b>, return <b>false</b>.</li>
  5108. </ol>
  5109. </li>
  5110. <li>Return <b>true</b>.</li>
  5111. </ol>
  5112. </section>
  5113. <section id="sec-object-environment-records-createmutablebinding-n-d">
  5114. <h1><span class="secnum" id="sec-8.1.1.2.2"><a href="#sec-object-environment-records-createmutablebinding-n-d"
  5115. title="link to this section">8.1.1.2.2</a></span> CreateMutableBinding (N, D)</h1>
  5116. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for object
  5117. Environment Records creates in an Environment Record&rsquo;s associated binding object a property whose name is the
  5118. String value and initializes it to the value <b>undefined</b>. If Boolean argument <var>D</var> is provided and has the
  5119. value <b>true</b> the new property&rsquo;s [[Configurable]] attribute is set to <b>true</b>, otherwise it is set to
  5120. <b>false</b>.</p>
  5121. <ol class="proc">
  5122. <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
  5123. invoked.</li>
  5124. <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
  5125. <li>If <i>D</i> is <b>true</b> then let <i>configValue</i> be <b>true</b> otherwise let <i>configValue</i> be
  5126. <b>false</b>.</li>
  5127. <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>bindings</i>, <i>N</i>,
  5128. PropertyDescriptor{[[Value]]:<b>undefined</b>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>true</b> ,
  5129. [[Configurable]]: <i>configValue</i>}).</li>
  5130. </ol>
  5131. <div class="note">
  5132. <p><span class="nh">NOTE</span> Normally <i>envRec</i> will not have a binding for <i>N</i> but if it does, the
  5133. semantics of <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a> may result in an existing binding being
  5134. replaced or shadowed or cause an <a href="#sec-completion-record-specification-type">abrupt completion</a> to be
  5135. returned.</p>
  5136. </div>
  5137. </section>
  5138. <section id="sec-object-environment-records-createimmutablebinding-n-s">
  5139. <h1><span class="secnum" id="sec-8.1.1.2.3"><a href="#sec-object-environment-records-createimmutablebinding-n-s"
  5140. title="link to this section">8.1.1.2.3</a></span> CreateImmutableBinding (N, S)</h1>
  5141. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding is never used
  5142. within this specification in association with Object Environment Records.</p>
  5143. </section>
  5144. <section id="sec-object-environment-records-initializebinding-n-v">
  5145. <h1><span class="secnum" id="sec-8.1.1.2.4"><a href="#sec-object-environment-records-initializebinding-n-v"
  5146. title="link to this section">8.1.1.2.4</a></span> InitializeBinding (N,V)</h1>
  5147. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for object
  5148. Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
  5149. the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
  5150. exist.</p>
  5151. <ol class="proc">
  5152. <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
  5153. invoked.</li>
  5154. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> must have an uninitialized binding for
  5155. <i>N</i>.</li>
  5156. <li>Record that the binding for <i>N</i> in <i>envRec</i> has been initialized.</li>
  5157. <li>Return <i>envRec</i>.SetMutableBinding(<i>N</i>, <i>V</i>, <b>false</b>).</li>
  5158. </ol>
  5159. <div class="note">
  5160. <p><span class="nh">NOTE</span> In this specification, all uses of CreateMutableBinding for object Environment Records
  5161. are immediately followed by a call to InitializeBinding for the same name. Hence, implementations do not need to
  5162. explicitly track the initialization state of individual object Environment Record bindings.</p>
  5163. </div>
  5164. </section>
  5165. <section id="sec-object-environment-records-setmutablebinding-n-v-s">
  5166. <h1><span class="secnum" id="sec-8.1.1.2.5"><a href="#sec-object-environment-records-setmutablebinding-n-v-s"
  5167. title="link to this section">8.1.1.2.5</a></span> SetMutableBinding (N,V,S)</h1>
  5168. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for object
  5169. Environment Records attempts to set the value of the Environment Record&rsquo;s associated binding object&rsquo;s
  5170. property whose name is the value of the argument <var>N</var> to the value of argument <var>V</var>. A property named
  5171. <var>N</var> normally already exists but if it does not or is not currently writable, error handling is determined by
  5172. the value of the Boolean argument <var>S</var>.</p>
  5173. <ol class="proc">
  5174. <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
  5175. invoked.</li>
  5176. <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
  5177. <li>Return <a href="#sec-set-o-p-v-throw">Set</a>(<i>bindings</i>, <i>N</i>, <i>V</i>, <i>S</i>).</li>
  5178. </ol>
  5179. </section>
  5180. <section id="sec-object-environment-records-getbindingvalue-n-s">
  5181. <h1><span class="secnum" id="sec-8.1.1.2.6"><a href="#sec-object-environment-records-getbindingvalue-n-s"
  5182. title="link to this section">8.1.1.2.6</a></span> GetBindingValue(N,S)</h1>
  5183. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for object Environment
  5184. Records returns the value of its associated binding object&rsquo;s property whose name is the String value of the
  5185. argument identifier <var>N</var>. The property should already exist but if it does not the result depends upon the value
  5186. of the <var>S</var> argument:</p>
  5187. <ol class="proc">
  5188. <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
  5189. invoked.</li>
  5190. <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
  5191. <li>Let <i>value</i> be <a href="#sec-hasproperty">HasProperty</a>(<i>bindings</i>, <i>N</i>).</li>
  5192. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
  5193. <li>If <i>value</i> is <b>false</b>, then
  5194. <ol class="block">
  5195. <li>If <i>S</i> is <b>false</b>, return the value <b>undefined</b>, otherwise throw a <b>ReferenceError</b>
  5196. exception.</li>
  5197. </ol>
  5198. </li>
  5199. <li>Return <a href="#sec-get-o-p">Get</a>(<i>bindings</i>, <i>N</i>).</li>
  5200. </ol>
  5201. </section>
  5202. <section id="sec-object-environment-records-deletebinding-n">
  5203. <h1><span class="secnum" id="sec-8.1.1.2.7"><a href="#sec-object-environment-records-deletebinding-n"
  5204. title="link to this section">8.1.1.2.7</a></span> DeleteBinding (N)</h1>
  5205. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for object Environment
  5206. Records can only delete bindings that correspond to properties of the environment object whose [[Configurable]]
  5207. attribute have the value <b>true</b>.</p>
  5208. <ol class="proc">
  5209. <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
  5210. invoked.</li>
  5211. <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
  5212. <li>Return <i>bindings</i>.[[Delete]](<i>N</i>).</li>
  5213. </ol>
  5214. </section>
  5215. <section id="sec-object-environment-records-hasthisbinding">
  5216. <h1><span class="secnum" id="sec-8.1.1.2.8"><a href="#sec-object-environment-records-hasthisbinding"
  5217. title="link to this section">8.1.1.2.8</a></span> HasThisBinding ()</h1>
  5218. <p>Regular object environment records do not provide a <code>this</code> binding.</p>
  5219. <ol class="proc">
  5220. <li>Return <b>false</b>.</li>
  5221. </ol>
  5222. </section>
  5223. <section id="sec-object-environment-records-hassuperbinding">
  5224. <h1><span class="secnum" id="sec-8.1.1.2.9"><a href="#sec-object-environment-records-hassuperbinding"
  5225. title="link to this section">8.1.1.2.9</a></span> HasSuperBinding ()</h1>
  5226. <p>Regular object environment records do not provide a <code>super</code> binding.</p>
  5227. <ol class="proc">
  5228. <li>Return <b>false</b>.</li>
  5229. </ol>
  5230. </section>
  5231. <section id="sec-object-environment-records-withbaseobject">
  5232. <h1><span class="secnum" id="sec-8.1.1.2.10"><a href="#sec-object-environment-records-withbaseobject"
  5233. title="link to this section">8.1.1.2.10</a></span> WithBaseObject()</h1>
  5234. <p>Object environment records return <b>undefined</b> as their WithBaseObject unless their <var>withEnvironment</var>
  5235. flag is <b>true</b>.</p>
  5236. <ol class="proc">
  5237. <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
  5238. invoked.</li>
  5239. <li>If the <i>withEnvironment</i> flag of <i>envRec</i> is <b>true</b>, return the binding object for
  5240. <i>envRec</i>.</li>
  5241. <li>Otherwise, return <b>undefined</b>.</li>
  5242. </ol>
  5243. </section>
  5244. </section>
  5245. <section id="sec-function-environment-records">
  5246. <div class="front">
  5247. <h1><span class="secnum" id="sec-8.1.1.3"><a href="#sec-function-environment-records"
  5248. title="link to this section">8.1.1.3</a></span> Function Environment Records</h1>
  5249. <p>A function <a href="#sec-environment-records">Environment Record</a> is a declarative <a
  5250. href="#sec-environment-records">Environment Record</a> that is used to represent the top-level scope of a function and,
  5251. if the function is not an <span class="nt">ArrowFunction</span>, provides a <code>this</code> binding. If a function is
  5252. not an <span class="nt">ArrowFunction</span> function and references <code>super</code>, its function <a
  5253. href="#sec-environment-records">Environment Record</a> also contains the state that is used to perform
  5254. <code>super</code> method invocations from within the function.</p>
  5255. <p>Function Environment Records have the additional state fields listed in <a href="#table-16">Table 16</a>.</p>
  5256. <figure>
  5257. <figcaption><span id="table-16">Table 16</span> &mdash; Additional Fields of Function Environment Records</figcaption>
  5258. <table class="real-table">
  5259. <tr>
  5260. <th>Field Name</th>
  5261. <th>Value</th>
  5262. <th>Meaning</th>
  5263. </tr>
  5264. <tr>
  5265. <td>[[thisValue]]</td>
  5266. <td>Any</td>
  5267. <td>This is the <span class="value">this</span> value used for this invocation of the function.</td>
  5268. </tr>
  5269. <tr>
  5270. <td>[[thisBindingStatus]]</td>
  5271. <td><code>"lexical"</code> | <code>"initialized"</code> | <code>"uninitialized"</code></td>
  5272. <td>If the value is <code>"lexical"</code>, this is an <span class="nt">ArrowFunction</span> and does not have a local this value.</td>
  5273. </tr>
  5274. <tr>
  5275. <td>[[FunctionObject]]</td>
  5276. <td>Object</td>
  5277. <td>The function Object whose invocation caused this <a href="#sec-environment-records">Environment Record</a> to be created.</td>
  5278. </tr>
  5279. <tr>
  5280. <td>[[HomeObject]]</td>
  5281. <td>Object | <b>undefined</b></td>
  5282. <td>If the associated function has <code>super</code> property accesses and is not an <span class="nt">ArrowFunction</span>, [[HomeObject]] is the object that the function is bound to as a method. The default value for [[HomeObject]] is <span class="value">undefined</span>.</td>
  5283. </tr>
  5284. <tr>
  5285. <td>[[NewTarget]]</td>
  5286. <td>Object | <b>undefined</b></td>
  5287. <td>If this <a href="#sec-environment-records">Environment Record</a> was created by the [[Construct]] internal method, [[NewTarget]] is the value of the [[Construct]] <var>newTarget</var> parameter. Otherwise, its value is <span class="value">undefined</span>.</td>
  5288. </tr>
  5289. </table>
  5290. </figure>
  5291. <p>Function Environment Records support all of the declarative Environment Record methods listed in <a
  5292. href="#table-15">Table 15</a> and share the same specifications for all of those methods except for HasThisBinding and
  5293. HasSuperBinding. In addition, function Environment Records support the methods listed in <a href="#table-17">Table
  5294. 17</a>:</p>
  5295. <figure>
  5296. <figcaption><span id="table-17">Table 17</span> &mdash; Additional Methods of Function Environment Records</figcaption>
  5297. <table class="real-table">
  5298. <tr>
  5299. <th>Method</th>
  5300. <th>Purpose</th>
  5301. </tr>
  5302. <tr>
  5303. <td><a href="#sec-bindthisvalue">BindThisValue</a>(V)</td>
  5304. <td>Set the [[thisValue]] and record that it has been initialized.</td>
  5305. </tr>
  5306. <tr>
  5307. <td>GetThisBinding()</td>
  5308. <td>Return the value of this <a href="#sec-environment-records">Environment Record</a>&rsquo;s <code>this</code> binding. Throws a <span class="value">ReferenceError</span> if the <code>this</code> binding has not been initialized.</td>
  5309. </tr>
  5310. <tr>
  5311. <td><a href="#sec-getsuperbase">GetSuperBase</a>()</td>
  5312. <td>Return the object that is the base for <code>super</code> property accesses bound in this <a href="#sec-environment-records">Environment Record</a>. The object is derived from this <a href="#sec-environment-records">Environment Record</a>&rsquo;s [[HomeObject]] field. The value <span class="value">undefined</span> indicates that <code>super</code> property accesses will produce runtime errors.</td>
  5313. </tr>
  5314. </table>
  5315. </figure>
  5316. <p>The behaviour of the additional concrete specification methods for function Environment Records is defined by the
  5317. following algorithms:</p>
  5318. </div>
  5319. <section id="sec-bindthisvalue">
  5320. <h1><span class="secnum" id="sec-8.1.1.3.1"><a href="#sec-bindthisvalue"
  5321. title="link to this section">8.1.1.3.1</a></span> BindThisValue(V)</h1>
  5322. <ol class="proc">
  5323. <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
  5324. was invoked.</li>
  5325. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i>.[[thisBindingStatus]] is not
  5326. <code>"lexical"</code>.</li>
  5327. <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"initialized"</code>, throw a <b>ReferenceError</b>
  5328. exception.</li>
  5329. <li>Set <i>envRec</i>.[[thisValue]] to <i>V</i>.</li>
  5330. <li>Set <i>envRec</i>.[[thisBindingStatus]] to <code>"initialized"</code>.</li>
  5331. <li>Return <i>V</i>.</li>
  5332. </ol>
  5333. </section>
  5334. <section id="sec-function-environment-records-hasthisbinding">
  5335. <h1><span class="secnum" id="sec-8.1.1.3.2"><a href="#sec-function-environment-records-hasthisbinding"
  5336. title="link to this section">8.1.1.3.2</a></span> HasThisBinding ()</h1>
  5337. <ol class="proc">
  5338. <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
  5339. was invoked.</li>
  5340. <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"lexical"</code>, return <b>false</b>; otherwise, return
  5341. <b>true</b>.</li>
  5342. </ol>
  5343. </section>
  5344. <section id="sec-function-environment-records-hassuperbinding">
  5345. <h1><span class="secnum" id="sec-8.1.1.3.3"><a href="#sec-function-environment-records-hassuperbinding"
  5346. title="link to this section">8.1.1.3.3</a></span> HasSuperBinding ()</h1>
  5347. <ol class="proc">
  5348. <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
  5349. was invoked.</li>
  5350. <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"lexical"</code>, return <b>false</b>.</li>
  5351. <li>If <i>envRec</i>.[[HomeObject]] has the value <b>undefined</b>, return <b>false</b>, otherwise, return
  5352. <b>true</b>.</li>
  5353. </ol>
  5354. </section>
  5355. <section id="sec-function-environment-records-getthisbinding">
  5356. <h1><span class="secnum" id="sec-8.1.1.3.4"><a href="#sec-function-environment-records-getthisbinding"
  5357. title="link to this section">8.1.1.3.4</a></span> GetThisBinding ()</h1>
  5358. <ol class="proc">
  5359. <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
  5360. was invoked.</li>
  5361. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i>.[[thisBindingStatus]] is not
  5362. <code>"lexical"</code>.</li>
  5363. <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"uninitialized"</code>, throw a <b>ReferenceError</b>
  5364. exception.</li>
  5365. <li>Return <i>envRec</i>.[[thisValue]].</li>
  5366. </ol>
  5367. </section>
  5368. <section id="sec-getsuperbase">
  5369. <h1><span class="secnum" id="sec-8.1.1.3.5"><a href="#sec-getsuperbase"
  5370. title="link to this section">8.1.1.3.5</a></span> GetSuperBase ()</h1>
  5371. <ol class="proc">
  5372. <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
  5373. was invoked.</li>
  5374. <li>Let <i>home</i> be the value of <i>envRec</i>.[[HomeObject]].</li>
  5375. <li>If <i>home</i> has the value <b>undefined</b>, return <b>undefined</b>.</li>
  5376. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  5377. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>home</i>) is Object.</li>
  5378. <li>Return <i>home.</i>[[GetPrototypeOf]]().</li>
  5379. </ol>
  5380. </section>
  5381. </section>
  5382. <section id="sec-global-environment-records">
  5383. <div class="front">
  5384. <h1><span class="secnum" id="sec-8.1.1.4"><a href="#sec-global-environment-records"
  5385. title="link to this section">8.1.1.4</a></span> Global Environment Records</h1>
  5386. <p>A global <a href="#sec-environment-records">Environment Record</a> is used to represent the outer most scope that is
  5387. shared by all of the ECMAScript <span class="nt">Script</span> elements that are processed in a common <a
  5388. href="#sec-code-realms">Realm</a> (<a href="#sec-code-realms">8.2</a>). A global <a
  5389. href="#sec-environment-records">Environment Record</a> provides the bindings for built-in globals (<a
  5390. href="#sec-global-object">clause 18</a>), properties of the global object, and for all top-level declarations (<a
  5391. href="#sec-block-static-semantics-toplevellexicallyscopeddeclarations">13.1.8</a>, <a
  5392. href="#sec-block-static-semantics-toplevelvarscopeddeclarations">13.1.10</a>) that occur within a <span
  5393. class="nt">Script</span>.</p>
  5394. <p>A global <a href="#sec-environment-records">Environment Record</a> is logically a single record but it is specified
  5395. as a composite encapsulating an object <a href="#sec-environment-records">Environment Record</a> and a declarative <a
  5396. href="#sec-environment-records">Environment Record</a>. The object <a href="#sec-environment-records">Environment
  5397. Record</a> has as its base object the global object of the associated <a href="#sec-code-realms">Realm</a>. This global
  5398. object is the value returned by the global <a href="#sec-environment-records">Environment Record</a>&rsquo;s
  5399. GetThisBinding concrete method. The object <a href="#sec-environment-records">Environment Record</a> component of a
  5400. global <a href="#sec-environment-records">Environment Record</a> contains the bindings for all built-in globals (<a
  5401. href="#sec-global-object">clause 18</a>) and all bindings introduced by a <span style="font-family: Times New
  5402. Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, or <span class="nt">VariableStatement</span>
  5403. contained in global code. The bindings for all other ECMAScript declarations in global code are contained in the
  5404. declarative <a href="#sec-environment-records">Environment Record</a> component of the global <a
  5405. href="#sec-environment-records">Environment Record</a>.</p>
  5406. <p>Properties may be created directly on a global object. Hence, the object <a
  5407. href="#sec-environment-records">Environment Record</a> component of a global <a
  5408. href="#sec-environment-records">Environment Record</a> may contain both bindings created explicitly by <span
  5409. style="font-family: Times New Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, or <span
  5410. class="nt">VariableDeclaration</span> declarations and binding created implicitly as properties of the global object. In
  5411. order to identify which bindings were explicitly created using declarations, a global <a
  5412. href="#sec-environment-records">Environment Record</a> maintains a list of the names bound using its
  5413. CreateGlobalVarBindings and CreateGlobalFunctionBindings concrete methods.</p>
  5414. <p>Global Environment Records have the additional fields listed in <a href="#table-18">Table 18</a> and the additional
  5415. methods listed in <a href="#table-19">Table 19</a>.</p>
  5416. <figure>
  5417. <figcaption><span id="table-18">Table 18</span> &mdash; Additional Fields of Global Environment Records</figcaption>
  5418. <table class="real-table">
  5419. <tr>
  5420. <th>Field Name</th>
  5421. <th>Value</th>
  5422. <th>Meaning</th>
  5423. </tr>
  5424. <tr>
  5425. <td>[[ObjectRecord]]</td>
  5426. <td><a href="#sec-object-environment-records">Object Environment Record</a></td>
  5427. <td>Binding object is the global object. It contains global built-in bindings as well as <span style="font-family: Times New Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, and <span class="nt">VariableDeclaration</span> bindings in global code for the associated <a href="#sec-code-realms">Realm</a>.</td>
  5428. </tr>
  5429. <tr>
  5430. <td>[[DeclarativeRecord]]</td>
  5431. <td><a href="#sec-declarative-environment-records">Declarative Environment Record</a></td>
  5432. <td>Contains bindings for all declarations in global code for the associated <a href="#sec-code-realms">Realm</a> code except for <span style="font-family: Times New Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, and <span class="nt">VariableDeclaration</span> <var>bindings</var>.</td>
  5433. </tr>
  5434. <tr>
  5435. <td>[[VarNames]]</td>
  5436. <td><a href="#sec-list-and-record-specification-type">List</a> of String</td>
  5437. <td>The string names bound by <span style="font-family: Times New Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, and <span class="nt">VariableDeclaration</span> declarations in global code for the associated <a href="#sec-code-realms">Realm</a>.</td>
  5438. </tr>
  5439. </table>
  5440. </figure>
  5441. <figure>
  5442. <figcaption><span id="table-19">Table 19</span> &mdash; Additional Methods of Global Environment Records</figcaption>
  5443. <table class="real-table">
  5444. <tr>
  5445. <th>Method</th>
  5446. <th>Purpose</th>
  5447. </tr>
  5448. <tr>
  5449. <td>GetThisBinding()</td>
  5450. <td>Return the value of this <a href="#sec-environment-records">Environment Record</a>&rsquo;s <code>this</code> binding.</td>
  5451. </tr>
  5452. <tr>
  5453. <td><a href="#sec-hasvardeclaration">HasVarDeclaration</a> (N)</td>
  5454. <td>Determines if the argument identifier has a binding in this <a href="#sec-environment-records">Environment Record</a> that was created using a <span style="font-family: Times New Roman"><i>VariableDeclaration</i>,</span> <span class="nt">FunctionDeclaration</span>, or <span style="font-family: Times New Roman"><i>GeneratorDeclaration</i>.</span></td>
  5455. </tr>
  5456. <tr>
  5457. <td><a href="#sec-haslexicaldeclaration">HasLexicalDeclaration</a> (N)</td>
  5458. <td>Determines if the argument identifier has a binding in this <a href="#sec-environment-records">Environment Record</a> that was created using a lexical declaration such as a <span class="nt">LexicalDeclaration</span> or a <span class="nt">ClassDeclaration</span>.</td>
  5459. </tr>
  5460. <tr>
  5461. <td><a href="#sec-hasrestrictedglobalproperty">HasRestrictedGlobalProperty</a> (N)</td>
  5462. <td>Determines if the argument is the name of a global object property that may not be shadowed by a global lexically binding.</td>
  5463. </tr>
  5464. <tr>
  5465. <td><a href="#sec-candeclareglobalvar">CanDeclareGlobalVar</a> (N)</td>
  5466. <td>Determines if a corresponding <a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a> call would succeed if called for the same argument <var>N</var>.</td>
  5467. </tr>
  5468. <tr>
  5469. <td><a href="#sec-candeclareglobalfunction">CanDeclareGlobalFunction</a> (N)</td>
  5470. <td>Determines if a corresponding <a href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a> call would succeed if called for the same argument <var>N</var>.</td>
  5471. </tr>
  5472. <tr>
  5473. <td><a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a>(N, D)</td>
  5474. <td>Used to create and initialize to <b>undefined</b> a global <code>var</code> binding in the [[ObjectRecord]] component of a global <a href="#sec-environment-records">Environment Record</a>. The binding will be a mutable binding. The corresponding global object property will have attribute values appropriate for a <code>var</code>. The String value <var>N</var> is the bound name. If <var>D</var> is <b>true</b> the binding may be deleted. Logically equivalent to CreateMutableBinding followed by a SetMutableBinding but it allows var declarations to receive special treatment.</td>
  5475. </tr>
  5476. <tr>
  5477. <td><a href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a>(N, V, D)</td>
  5478. <td>Create and initialize a global <code>function</code> binding in the [[ObjectRecord]] component of a global <a href="#sec-environment-records">Environment Record</a>. The binding will be a mutable binding. The corresponding global object property will have attribute values appropriate for a <code>function</code>. The String value <var>N</var> is the bound name. <i>V</i> is the initialization value. If the optional Boolean argument <var>D</var> is <b>true</b> the binding is may be deleted. Logically equivalent to CreateMutableBinding followed by a SetMutableBinding but it allows function declarations to receive special treatment.</td>
  5479. </tr>
  5480. </table>
  5481. </figure>
  5482. <p>The behaviour of the concrete specification methods for global Environment Records is defined by the following
  5483. algorithms.</p>
  5484. </div>
  5485. <section id="sec-global-environment-records-hasbinding-n">
  5486. <h1><span class="secnum" id="sec-8.1.1.4.1"><a href="#sec-global-environment-records-hasbinding-n"
  5487. title="link to this section">8.1.1.4.1</a></span> HasBinding(N)</h1>
  5488. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for global Environment
  5489. Records simply determines if the argument identifier is one of the identifiers bound by the record:</p>
  5490. <ol class="proc">
  5491. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5492. invoked.</li>
  5493. <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
  5494. <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, return <b>true</b>.</li>
  5495. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5496. <li>Return <i>ObjRec.</i>HasBinding(<i>N</i>).</li>
  5497. </ol>
  5498. </section>
  5499. <section id="sec-global-environment-records-createmutablebinding-n-d">
  5500. <h1><span class="secnum" id="sec-8.1.1.4.2"><a href="#sec-global-environment-records-createmutablebinding-n-d"
  5501. title="link to this section">8.1.1.4.2</a></span> CreateMutableBinding (N, D)</h1>
  5502. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for global
  5503. Environment Records creates a new mutable binding for the name <var>N</var> that is uninitialized. The binding is
  5504. created in the associated DeclarativeRecord. A binding for <var>N</var> must not already exist in the DeclarativeRecord.
  5505. If Boolean argument <var>D</var> is provided and has the value <b>true</b> the new binding is marked as being subject to
  5506. deletion.</p>
  5507. <ol class="proc">
  5508. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5509. invoked.</li>
  5510. <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
  5511. <li>If <i>DclRec</i>.HasBinding(<i>N</i>) is <b>true</b>, throw a <b>TypeError</b> exception.</li>
  5512. <li>Return <i>DclRec</i>.CreateMutableBinding(<i>N</i>, <i>D</i>).</li>
  5513. </ol>
  5514. </section>
  5515. <section id="sec-global-environment-records-createimmutablebinding-n-s">
  5516. <h1><span class="secnum" id="sec-8.1.1.4.3"><a href="#sec-global-environment-records-createimmutablebinding-n-s"
  5517. title="link to this section">8.1.1.4.3</a></span> CreateImmutableBinding (N, S)</h1>
  5518. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding for global
  5519. Environment Records creates a new immutable binding for the name <var>N</var> that is uninitialized. A binding must not
  5520. already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
  5521. <var>S</var> is provided and has the value <b>true</b> the new binding is marked as a strict binding.</p>
  5522. <ol class="proc">
  5523. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5524. invoked.</li>
  5525. <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
  5526. <li>If <i>DclRec</i>.HasBinding(<i>N</i>) is <b>true</b>, throw a <b>TypeError</b> exception.</li>
  5527. <li>Return <i>DclRec</i>.CreateImmutableBinding(<i>N</i>, <i>S</i>).</li>
  5528. </ol>
  5529. </section>
  5530. <section id="sec-global-environment-records-initializebinding-n-v">
  5531. <h1><span class="secnum" id="sec-8.1.1.4.4"><a href="#sec-global-environment-records-initializebinding-n-v"
  5532. title="link to this section">8.1.1.4.4</a></span> InitializeBinding (N,V)</h1>
  5533. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for global
  5534. Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
  5535. the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
  5536. exist.</p>
  5537. <ol class="proc">
  5538. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5539. invoked.</li>
  5540. <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
  5541. <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
  5542. <ol class="block">
  5543. <li>Return <i>DclRec</i>.InitializeBinding(<i>N</i>, <i>V</i>).</li>
  5544. </ol>
  5545. </li>
  5546. <li><a href="#sec-algorithm-conventions">Assert</a>: If the binding exists it must be in the object <a
  5547. href="#sec-environment-records">Environment Record</a>.</li>
  5548. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5549. <li>Return <i>ObjRec.</i>InitializeBinding(<i>N</i>, <i>V</i>).</li>
  5550. </ol>
  5551. </section>
  5552. <section id="sec-global-environment-records-setmutablebinding-n-v-s">
  5553. <h1><span class="secnum" id="sec-8.1.1.4.5"><a href="#sec-global-environment-records-setmutablebinding-n-v-s"
  5554. title="link to this section">8.1.1.4.5</a></span> SetMutableBinding (N,V,S)</h1>
  5555. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for global
  5556. Environment Records attempts to change the bound value of the current binding of the identifier whose name is the value
  5557. of the argument <var>N</var> to the value of argument <var>V</var>. If the binding is an immutable binding, a
  5558. <b>TypeError</b> is thrown if <span style="font-family: Times New Roman">S</span> is <span class="value">true</span>. A
  5559. property named <var>N</var> normally already exists but if it does not or is not currently writable, error handling is
  5560. determined by the value of the Boolean argument <var>S</var>.</p>
  5561. <ol class="proc">
  5562. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5563. invoked.</li>
  5564. <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
  5565. <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
  5566. <ol class="block">
  5567. <li>Return <i>DclRec.</i>SetMutableBinding(<i>N</i>, <i>V</i>, <i>S</i>).</li>
  5568. </ol>
  5569. </li>
  5570. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5571. <li>Return <i>ObjRec</i>.SetMutableBinding(<i>N</i>, <i>V</i>, <i>S</i>).</li>
  5572. </ol>
  5573. </section>
  5574. <section id="sec-global-environment-records-getbindingvalue-n-s">
  5575. <h1><span class="secnum" id="sec-8.1.1.4.6"><a href="#sec-global-environment-records-getbindingvalue-n-s"
  5576. title="link to this section">8.1.1.4.6</a></span> GetBindingValue(N,S)</h1>
  5577. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for global Environment
  5578. Records returns the value of its bound identifier whose name is the value of the argument <var>N</var>. If the binding
  5579. is an uninitialized binding throw a <b>ReferenceError</b> exception. A property named <var>N</var> normally already
  5580. exists but if it does not or is not currently writable, error handling is determined by the value of the Boolean
  5581. argument <var>S</var>.</p>
  5582. <ol class="proc">
  5583. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5584. invoked.</li>
  5585. <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
  5586. <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
  5587. <ol class="block">
  5588. <li>Return <i>DclRec.</i>GetBindingValue(<i>N</i>, <i>S</i>).</li>
  5589. </ol>
  5590. </li>
  5591. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5592. <li>Return <i>ObjRec</i>.GetBindingValue(<i>N</i>, <i>S</i>).</li>
  5593. </ol>
  5594. </section>
  5595. <section id="sec-global-environment-records-deletebinding-n">
  5596. <h1><span class="secnum" id="sec-8.1.1.4.7"><a href="#sec-global-environment-records-deletebinding-n"
  5597. title="link to this section">8.1.1.4.7</a></span> DeleteBinding (N)</h1>
  5598. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for global Environment
  5599. Records can only delete bindings that have been explicitly designated as being subject to deletion.</p>
  5600. <ol class="proc">
  5601. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5602. invoked.</li>
  5603. <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
  5604. <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
  5605. <ol class="block">
  5606. <li>Return <i>DclRec.</i>DeleteBinding(<i>N</i>).</li>
  5607. </ol>
  5608. </li>
  5609. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5610. <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
  5611. <li>Let <i>existingProp</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject</i>, <i>N</i>).</li>
  5612. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
  5613. <li>If <i>existingProp</i> is <b>true</b>, then
  5614. <ol class="block">
  5615. <li>Let <i>status</i> be <i>ObjRec.</i>DeleteBinding(<i>N</i>).</li>
  5616. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  5617. <li>If <i>status</i> is <b>true</b>, then
  5618. <ol class="block">
  5619. <li>Let <i>varNames</i> be <i>envRec</i>.[[VarNames]].</li>
  5620. <li>If <i>N</i> is an element of <i>varNames</i>, remove that element from the <i>varNames</i>.</li>
  5621. </ol>
  5622. </li>
  5623. <li>Return <i>status</i>.</li>
  5624. </ol>
  5625. </li>
  5626. <li>Return <b>true</b>.</li>
  5627. </ol>
  5628. </section>
  5629. <section id="sec-global-environment-records-hasthisbinding">
  5630. <h1><span class="secnum" id="sec-8.1.1.4.8"><a href="#sec-global-environment-records-hasthisbinding"
  5631. title="link to this section">8.1.1.4.8</a></span> HasThisBinding ()</h1>
  5632. <p><a href="#sec-global-environment-records">Global Environment Records</a> always provide a <code>this</code> binding
  5633. whose value is the associated global object.</p>
  5634. <ol class="proc">
  5635. <li>Return <b>true</b>.</li>
  5636. </ol>
  5637. </section>
  5638. <section id="sec-global-environment-records-hassuperbinding">
  5639. <h1><span class="secnum" id="sec-8.1.1.4.9"><a href="#sec-global-environment-records-hassuperbinding"
  5640. title="link to this section">8.1.1.4.9</a></span> HasSuperBinding ()</h1>
  5641. <ol class="proc">
  5642. <li>Return <b>false</b>.</li>
  5643. </ol>
  5644. </section>
  5645. <section id="sec-global-environment-records-withbaseobject">
  5646. <h1><span class="secnum" id="sec-8.1.1.4.10"><a href="#sec-global-environment-records-withbaseobject"
  5647. title="link to this section">8.1.1.4.10</a></span> WithBaseObject()</h1>
  5648. <p><a href="#sec-global-environment-records">Global Environment Records</a> always return <b>undefined</b> as their
  5649. WithBaseObject.</p>
  5650. <ol class="proc">
  5651. <li>Return <b>undefined</b>.</li>
  5652. </ol>
  5653. </section>
  5654. <section id="sec-global-environment-records-getthisbinding">
  5655. <h1><span class="secnum" id="sec-8.1.1.4.11"><a href="#sec-global-environment-records-getthisbinding"
  5656. title="link to this section">8.1.1.4.11</a></span> GetThisBinding ()</h1>
  5657. <ol class="proc">
  5658. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5659. invoked.</li>
  5660. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5661. <li>Let <i>bindings</i> be the binding object for <i>ObjRec</i>.</li>
  5662. <li>Return <i>bindings</i>.</li>
  5663. </ol>
  5664. </section>
  5665. <section id="sec-hasvardeclaration">
  5666. <h1><span class="secnum" id="sec-8.1.1.4.12"><a href="#sec-hasvardeclaration"
  5667. title="link to this section">8.1.1.4.12</a></span> HasVarDeclaration (N)</h1>
  5668. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasVarDeclaration for global
  5669. Environment Records determines if the argument identifier has a binding in this record that was created using a <span
  5670. class="nt">VariableStatement</span> or a <span class="prod"><span class="nt">FunctionDeclaration</span> <span
  5671. class="geq">:</span></span></p>
  5672. <ol class="proc">
  5673. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5674. invoked.</li>
  5675. <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
  5676. <li>If <i>varDeclaredNames</i> contains the value of <i>N</i>, return <b>true</b>.</li>
  5677. <li>Return <b>false</b>.</li>
  5678. </ol>
  5679. </section>
  5680. <section id="sec-haslexicaldeclaration">
  5681. <h1><span class="secnum" id="sec-8.1.1.4.13"><a href="#sec-haslexicaldeclaration"
  5682. title="link to this section">8.1.1.4.13</a></span> HasLexicalDeclaration (N)</h1>
  5683. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasLexicalDeclaration for global
  5684. Environment Records determines if the argument identifier has a binding in this record that was created using a lexical
  5685. declaration such as a <span class="nt">LexicalDeclaration</span> or a <span class="prod"><span
  5686. class="nt">ClassDeclaration</span> <span class="geq">:</span></span></p>
  5687. <ol class="proc">
  5688. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5689. invoked.</li>
  5690. <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
  5691. <li>Return <i>DclRec.</i>HasBinding(<i>N</i>).</li>
  5692. </ol>
  5693. </section>
  5694. <section id="sec-hasrestrictedglobalproperty">
  5695. <h1><span class="secnum" id="sec-8.1.1.4.14"><a href="#sec-hasrestrictedglobalproperty"
  5696. title="link to this section">8.1.1.4.14</a></span> HasRestrictedGlobalProperty (N)</h1>
  5697. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasRestrictedGlobalProperty for global
  5698. Environment Records determines if the argument identifier is the name of a property of the global object that must not
  5699. be shadowed by a global lexically binding:</p>
  5700. <ol class="proc">
  5701. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5702. invoked.</li>
  5703. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5704. <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
  5705. <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
  5706. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
  5707. <li>If <i>existingProp</i> is <b>undefined</b>, return <b>false</b>.</li>
  5708. <li>If <i>existingProp</i>.[[Configurable]] is <b>true</b>, return <b>false</b>.</li>
  5709. <li>Return <b>true</b>.</li>
  5710. </ol>
  5711. <div class="note">
  5712. <p><span class="nh">NOTE</span> Properties may exist upon a global object that were directly created rather than being
  5713. declared using a var or function declaration. A global lexical binding may not be created that has the same name as a
  5714. non-configurable property of the global object. The global property <code>undefined</code> is an example of such a
  5715. property.</p>
  5716. </div>
  5717. </section>
  5718. <section id="sec-candeclareglobalvar">
  5719. <h1><span class="secnum" id="sec-8.1.1.4.15"><a href="#sec-candeclareglobalvar"
  5720. title="link to this section">8.1.1.4.15</a></span> CanDeclareGlobalVar (N)</h1>
  5721. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CanDeclareGlobalVar for global
  5722. Environment Records determines if a corresponding <a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a> call
  5723. would succeed if called for the same argument <var>N</var>. Redundant var declarations and var declarations for
  5724. pre-existing global object properties are allowed.</p>
  5725. <ol class="proc">
  5726. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5727. invoked.</li>
  5728. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5729. <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
  5730. <li>Let <i>hasProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject, N</i>).</li>
  5731. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasProperty</i>).</li>
  5732. <li>If <i>hasProperty</i> is <b>true</b>, return <b>true</b>.</li>
  5733. <li>Return <a href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
  5734. </ol>
  5735. </section>
  5736. <section id="sec-candeclareglobalfunction">
  5737. <h1><span class="secnum" id="sec-8.1.1.4.16"><a href="#sec-candeclareglobalfunction"
  5738. title="link to this section">8.1.1.4.16</a></span> CanDeclareGlobalFunction (N)</h1>
  5739. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CanDeclareGlobalFunction for global
  5740. Environment Records determines if a corresponding <a
  5741. href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a> call would succeed if called for the same
  5742. argument <var>N</var>.</p>
  5743. <ol class="proc">
  5744. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5745. invoked.</li>
  5746. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5747. <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
  5748. <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
  5749. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
  5750. <li>If <i>existingProp</i> is <b>undefined</b>, return <a
  5751. href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
  5752. <li>If <i>existingProp</i>.[[Configurable]] is <b>true</b>, return <b>true</b>.</li>
  5753. <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>existingProp</i>) is <b>true</b> and
  5754. <i>existingProp</i> has attribute values {[[Writable]]: <b>true</b>, [[Enumerable]]: <b>true</b>}, return
  5755. <b>true</b>.</li>
  5756. <li>Return <b>false</b>.</li>
  5757. </ol>
  5758. </section>
  5759. <section id="sec-createglobalvarbinding">
  5760. <h1><span class="secnum" id="sec-8.1.1.4.17"><a href="#sec-createglobalvarbinding"
  5761. title="link to this section">8.1.1.4.17</a></span> CreateGlobalVarBinding (N, D)</h1>
  5762. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateGlobalVarBinding for global
  5763. Environment Records creates and initializes a mutable binding in the associated object Environment Record and records
  5764. the bound name in the associated [[VarNames]] <a href="#sec-list-and-record-specification-type">List</a>. If a binding
  5765. already exists, it is reused and assumed to be initialized.</p>
  5766. <ol class="proc">
  5767. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5768. invoked.</li>
  5769. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5770. <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
  5771. <li>Let <i>hasProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject, N</i>).</li>
  5772. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasProperty</i>).</li>
  5773. <li>Let <i>extensible</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
  5774. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensible</i>).</li>
  5775. <li>If <i>hasProperty</i> is <b>false</b> and <i>extensible</i> is <b>true</b>, then
  5776. <ol class="block">
  5777. <li>Let <i>status</i> be <i>ObjRec.</i>CreateMutableBinding(<i>N</i>, <i>D</i>).</li>
  5778. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  5779. <li>Let <i>status</i> be <i>ObjRec.</i>InitializeBinding(<i>N</i>, <b>undefined</b>).</li>
  5780. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  5781. </ol>
  5782. </li>
  5783. <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
  5784. <li>If <i>varDeclaredNames</i> does not contain the value of <i>N</i>, then
  5785. <ol class="block">
  5786. <li>Append <i>N</i> to <i>varDeclaredNames</i>.</li>
  5787. </ol>
  5788. </li>
  5789. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
  5790. sans-serif">empty</span>).</li>
  5791. </ol>
  5792. </section>
  5793. <section id="sec-createglobalfunctionbinding">
  5794. <h1><span class="secnum" id="sec-8.1.1.4.18"><a href="#sec-createglobalfunctionbinding"
  5795. title="link to this section">8.1.1.4.18</a></span> CreateGlobalFunctionBinding (N, V, D)</h1>
  5796. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateGlobalFunctionBinding for global
  5797. Environment Records creates and initializes a mutable binding in the associated object Environment Record and records
  5798. the bound name in the associated [[VarNames]] <a href="#sec-list-and-record-specification-type">List</a>. If a binding
  5799. already exists, it is replaced.</p>
  5800. <ol class="proc">
  5801. <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
  5802. invoked.</li>
  5803. <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
  5804. <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
  5805. <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
  5806. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
  5807. <li>If <i>existingProp</i> is <b>undefined</b> or <i>existingProp</i>.[[Configurable]] is <b>true</b>, then
  5808. <ol class="block">
  5809. <li>Let <i>desc</i> be the PropertyDescriptor{[[Value]]:<i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
  5810. <b>true</b> , [[Configurable]]: <i>D</i>}.</li>
  5811. </ol>
  5812. </li>
  5813. <li>Else,
  5814. <ol class="block">
  5815. <li>Let <i>desc</i> be the PropertyDescriptor{[[Value]]:<i>V</i> }.</li>
  5816. </ol>
  5817. </li>
  5818. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>globalObject</i>, <i>N</i>,
  5819. <i>desc</i>).</li>
  5820. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  5821. <li>Let <i>status</i> be <a href="#sec-set-o-p-v-throw">Set</a>(<i>globalObject</i>, <i>N</i>, <i>V</i>,
  5822. <b>false</b>).</li>
  5823. <li>Record that the binding for <i>N</i> in <i>ObjRec</i> has been initialized.</li>
  5824. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  5825. <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
  5826. <li>If <i>varDeclaredNames</i> does not contain the value of <i>N</i>, then
  5827. <ol class="block">
  5828. <li>Append <i>N</i> to <i>varDeclaredNames</i>.</li>
  5829. </ol>
  5830. </li>
  5831. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
  5832. sans-serif">empty</span>).</li>
  5833. </ol>
  5834. <div class="note">
  5835. <p><span class="nh">NOTE</span> Global function declarations are always represented as own properties of the global
  5836. object. If possible, an existing own property is reconfigured to have a standard set of attribute values. Steps 10-12
  5837. are equivalent to what calling the InitializeBinding concrete method would do and if <i>globalObject</i> is a Proxy
  5838. will produce the same sequence of Proxy trap calls.</p>
  5839. </div>
  5840. </section>
  5841. </section>
  5842. <section id="sec-module-environment-records">
  5843. <div class="front">
  5844. <h1><span class="secnum" id="sec-8.1.1.5"><a href="#sec-module-environment-records"
  5845. title="link to this section">8.1.1.5</a></span> Module Environment Records</h1>
  5846. <p>A module <a href="#sec-environment-records">Environment Record</a> is a declarative <a
  5847. href="#sec-environment-records">Environment Record</a> that is used to represent the outer scope of an ECMAScript <span
  5848. class="nt">Module</span>. In additional to normal mutable and immutable bindings, module Environment Records also
  5849. provide immutable import bindings which are bindings that provide indirect access to a target binding that exists in
  5850. another Environment Record.</p>
  5851. <p>Module Environment Records support all of the declarative Environment Record methods listed in <a
  5852. href="#table-15">Table 15</a> and share the same specifications for all of those methods except for GetBindingValue,
  5853. DeleteBinding, HasThisBinding and GetThisBinding. In addition, module Environment Records support the methods listed in
  5854. <a href="#table-20">Table 20</a>:</p>
  5855. <figure>
  5856. <figcaption><span id="table-20">Table 20</span> &mdash; Additional Methods of Module Environment Records</figcaption>
  5857. <table class="real-table">
  5858. <tr>
  5859. <th>Method</th>
  5860. <th>Purpose</th>
  5861. </tr>
  5862. <tr>
  5863. <td><a href="#sec-createimportbinding">CreateImportBinding</a>(N, M, N2 )</td>
  5864. <td>Create an immutable indirect binding in a module <a href="#sec-environment-records">Environment Record</a>. The String value <var>N</var> is the text of the bound name. <var>M</var> is a Module Record (<a href="#sec-abstract-module-records">see 15.2.1.14</a>), and <var>N2</var> is a binding that exists in M&rsquo;s module <a href="#sec-environment-records">Environment Record</a>.</td>
  5865. </tr>
  5866. <tr>
  5867. <td>GetThisBinding()</td>
  5868. <td>Return the value of this <a href="#sec-environment-records">Environment Record</a>&rsquo;s <code>this</code> binding.</td>
  5869. </tr>
  5870. </table>
  5871. </figure>
  5872. <p>The behaviour of the additional concrete specification methods for module Environment Records are defined by the
  5873. following algorithms:</p>
  5874. </div>
  5875. <section id="sec-module-environment-records-getbindingvalue-n-s">
  5876. <h1><span class="secnum" id="sec-8.1.1.5.1"><a href="#sec-module-environment-records-getbindingvalue-n-s"
  5877. title="link to this section">8.1.1.5.1</a></span> GetBindingValue(N,S)</h1>
  5878. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for module Environment
  5879. Records returns the value of its bound identifier whose name is the value of the argument <var>N</var>. However, if the
  5880. binding is an indirect binding the value of the target binding is returned. If the binding exists but is uninitialized a
  5881. <span class="value">ReferenceError</span> is thrown, regardless of the value of <i><span style="font-family: Times New
  5882. Roman">S</span>.</i></p>
  5883. <ol class="proc">
  5884. <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
  5885. invoked.</li>
  5886. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for <i>N</i>.</li>
  5887. <li>If the binding for <i>N</i> is an indirect binding, then
  5888. <ol class="block">
  5889. <li>Let <i>M</i> and <i>N2</i> be the indirection values provided when this binding for <i>N</i> was created.</li>
  5890. <li>If <i>M</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
  5891. <li>Let <i>targetEnv</i> be <i>M</i>.[[Environment]].</li>
  5892. <li>If <i>targetEnv</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
  5893. <li>Let <i>targetER</i> be <i>targetEnv</i>&rsquo;s EnvironmentRecord.</li>
  5894. <li>Return <i>targetER</i>.GetBindingValue(<i>N2</i>, <i>S</i>).</li>
  5895. </ol>
  5896. </li>
  5897. <li>If the binding for <i>N</i> in <i>envRec</i> is an uninitialized binding, throw a <b>ReferenceError</b>
  5898. exception.</li>
  5899. <li>Return the value currently bound to <i>N</i> in <i>envRec</i>.</li>
  5900. </ol>
  5901. <div class="note">
  5902. <p><span class="nh">NOTE</span> Because a <i>Module</i> is always <a href="#sec-strict-mode-code">strict mode
  5903. code</a>, calls to GetBindingValue should always pass <b>true</b> <span style="font-family: sans-serif">as</span>
  5904. <span style="font-family: sans-serif">the value of</span> <i>S</i>.</p>
  5905. </div>
  5906. </section>
  5907. <section id="sec-module-environment-records-deletebinding-n">
  5908. <h1><span class="secnum" id="sec-8.1.1.5.2"><a href="#sec-module-environment-records-deletebinding-n"
  5909. title="link to this section">8.1.1.5.2</a></span> DeleteBinding (N)</h1>
  5910. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for module Environment
  5911. Records refuses to delete bindings.</p>
  5912. <ol class="proc">
  5913. <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
  5914. invoked.</li>
  5915. <li>If <i>envRec</i> does not have a binding for the name that is the value of <i>N</i>, return <b>true</b>.</li>
  5916. <li>Return <b>false</b>.</li>
  5917. </ol>
  5918. <div class="note">
  5919. <p><span class="nh">NOTE</span> Because the bindings of a module <a href="#sec-environment-records">Environment
  5920. Record</a> are not deletable.</p>
  5921. </div>
  5922. </section>
  5923. <section id="sec-module-environment-records-hasthisbinding">
  5924. <h1><span class="secnum" id="sec-8.1.1.5.3"><a href="#sec-module-environment-records-hasthisbinding"
  5925. title="link to this section">8.1.1.5.3</a></span> HasThisBinding ()</h1>
  5926. <p>Module Environment Records provide a <code>this</code> binding.</p>
  5927. <ol class="proc">
  5928. <li>Return <b>true</b>.</li>
  5929. </ol>
  5930. </section>
  5931. <section id="sec-module-environment-records-getthisbinding">
  5932. <h1><span class="secnum" id="sec-8.1.1.5.4"><a href="#sec-module-environment-records-getthisbinding"
  5933. title="link to this section">8.1.1.5.4</a></span> GetThisBinding ()</h1>
  5934. <ol class="proc">
  5935. <li>Return <b>undefined</b>.</li>
  5936. </ol>
  5937. </section>
  5938. <section id="sec-createimportbinding">
  5939. <h1><span class="secnum" id="sec-8.1.1.5.5"><a href="#sec-createimportbinding"
  5940. title="link to this section">8.1.1.5.5</a></span> CreateImportBinding (N, M, N2)</h1>
  5941. <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImportBinding for module
  5942. Environment Records creates a new initialized immutable indirect binding for the name <var>N</var>. A binding must not
  5943. already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. <var>M</var> is a
  5944. Module Record (<a href="#sec-abstract-module-records">see 15.2.1.14</a>), and <var>N2</var> is the name of a binding
  5945. that exists in M&rsquo;s module <a href="#sec-environment-records">Environment Record</a>. Accesses to the value of the
  5946. new binding will indirectly access the bound value of value of the target binding.</p>
  5947. <ol class="proc">
  5948. <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
  5949. invoked.</li>
  5950. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
  5951. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>M</i> is a Module Record.</li>
  5952. <li><a href="#sec-algorithm-conventions">Assert</a>: When <i>M</i>.[[Environment]] is instantiated it will have a
  5953. direct binding for <i>N2</i>.</li>
  5954. <li>Create an immutable indirect binding in <i>envRec</i> for <i>N</i> that references <i>M</i> and <i>N2</i> as its
  5955. target binding and record that the binding is initialized.</li>
  5956. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
  5957. sans-serif">empty</span>).</li>
  5958. </ol>
  5959. </section>
  5960. </section>
  5961. </section>
  5962. <section id="sec-lexical-environment-operations">
  5963. <div class="front">
  5964. <h1><span class="secnum" id="sec-8.1.2"><a href="#sec-lexical-environment-operations"
  5965. title="link to this section">8.1.2</a></span> Lexical Environment Operations</h1>
  5966. <p>The following abstract operations are used in this specification to operate upon lexical environments:</p>
  5967. </div>
  5968. <section id="sec-getidentifierreference">
  5969. <h1><span class="secnum" id="sec-8.1.2.1"><a href="#sec-getidentifierreference"
  5970. title="link to this section">8.1.2.1</a></span> GetIdentifierReference (lex, name, strict)</h1>
  5971. <p>The abstract operation GetIdentifierReference is called with a <a href="#sec-lexical-environments">Lexical
  5972. Environment</a> <var>lex</var>, a String <var>name</var>, and a Boolean flag <var>strict.</var> The value of
  5973. <var>lex</var> may be <b>null</b>. When called, the following steps are performed:</p>
  5974. <ol class="proc">
  5975. <li>If <i>lex</i> is the value <b>null</b>, then
  5976. <ol class="block">
  5977. <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is
  5978. <b>undefined</b>, whose referenced name is <i>name</i>, and whose strict reference flag is <i>strict</i>.</li>
  5979. </ol>
  5980. </li>
  5981. <li>Let <i>envRec</i> be <i>lex</i>&rsquo;s EnvironmentRecord.</li>
  5982. <li>Let <i>exists</i> be <i>envRec</i>.HasBinding(<i>name</i>).</li>
  5983. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exists</i>).</li>
  5984. <li>If <i>exists</i> is <b>true</b>, then
  5985. <ol class="block">
  5986. <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is
  5987. <i>envRec</i>, whose referenced name is <i>name</i>, and whose strict reference flag is <i>strict.</i></li>
  5988. </ol>
  5989. </li>
  5990. <li>Else
  5991. <ol class="block">
  5992. <li>Let <i>outer</i> be the value of <i>lex&rsquo;s</i> <a href="#sec-lexical-environments">outer environment
  5993. reference</a>.</li>
  5994. <li>Return GetIdentifierReference(<i>outer</i>, <i>name</i>, <i>strict</i>).</li>
  5995. </ol>
  5996. </li>
  5997. </ol>
  5998. </section>
  5999. <section id="sec-newdeclarativeenvironment">
  6000. <h1><span class="secnum" id="sec-8.1.2.2"><a href="#sec-newdeclarativeenvironment"
  6001. title="link to this section">8.1.2.2</a></span> NewDeclarativeEnvironment (E)</h1>
  6002. <p>When the abstract operation NewDeclarativeEnvironment is called with a <a href="#sec-lexical-environments">Lexical
  6003. Environment</a> as argument <var>E</var> the following steps are performed:</p>
  6004. <ol class="proc">
  6005. <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
  6006. <li>Let <i>envRec</i> be a new declarative <a href="#sec-environment-records">Environment Record</a> containing no
  6007. bindings.</li>
  6008. <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
  6009. <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
  6010. <li>Return <i>env</i>.</li>
  6011. </ol>
  6012. </section>
  6013. <section id="sec-newobjectenvironment">
  6014. <h1><span class="secnum" id="sec-8.1.2.3"><a href="#sec-newobjectenvironment"
  6015. title="link to this section">8.1.2.3</a></span> NewObjectEnvironment (O, E)</h1>
  6016. <p>When the abstract operation NewObjectEnvironment is called with an Object <var>O</var> and a <a
  6017. href="#sec-lexical-environments">Lexical Environment</a> <var>E</var> as arguments, the following steps are performed:</p>
  6018. <ol class="proc">
  6019. <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
  6020. <li>Let <i>envRec</i> be a new object <a href="#sec-environment-records">Environment Record</a> containing <i>O</i> as
  6021. the binding object.</li>
  6022. <li>Set <i>env&rsquo;s</i> EnvironmentRecord to <i>envRec</i>.</li>
  6023. <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
  6024. <li>Return <i>env</i>.</li>
  6025. </ol>
  6026. </section>
  6027. <section id="sec-newfunctionenvironment">
  6028. <h1><span class="secnum" id="sec-8.1.2.4"><a href="#sec-newfunctionenvironment"
  6029. title="link to this section">8.1.2.4</a></span> NewFunctionEnvironment ( F, newTarget )</h1>
  6030. <p>When the abstract operation NewFunctionEnvironment is called with arguments <var>F</var> and <var>newTarget</var> the
  6031. following steps are performed:</p>
  6032. <ol class="proc">
  6033. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an ECMAScript function.</li>
  6034. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  6035. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Undefined or Object.</li>
  6036. <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
  6037. <li>Let <i>envRec</i> be a new function <a href="#sec-environment-records">Environment Record</a> containing no
  6038. bindings.</li>
  6039. <li>Set <i>envRec</i>.[[FunctionObject]] to <i>F</i>.</li>
  6040. <li>If <i>F&rsquo;s</i> [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is
  6041. <span style="font-family: sans-serif">lexical</span>, set <i>envRec</i>.[[thisBindingStatus]] to
  6042. <code>"lexical"</code>.</li>
  6043. <li>Else, Set <i>envRec</i>.[[thisBindingStatus]] to <code>"uninitialized"</code>.</li>
  6044. <li>Let <i>home</i> be the value of <i>F&rsquo;s</i> [[HomeObject]] <a
  6045. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  6046. <li>Set <i>envRec</i>.[[HomeObject]] to <i>home</i>.</li>
  6047. <li>Set <i>envRec</i>.[[NewTarget]] to <i>newTarget</i>.</li>
  6048. <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
  6049. <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to the value of
  6050. <i>F&rsquo;s</i> [[Environment]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  6051. <li>Return <i>env</i>.</li>
  6052. </ol>
  6053. </section>
  6054. <section id="sec-newglobalenvironment">
  6055. <h1><span class="secnum" id="sec-8.1.2.5"><a href="#sec-newglobalenvironment"
  6056. title="link to this section">8.1.2.5</a></span> NewGlobalEnvironment ( G )</h1>
  6057. <p>When the abstract operation NewGlobalEnvironment is called with an ECMAScript Object <var>G</var> as its argument, the
  6058. following steps are performed:</p>
  6059. <ol class="proc">
  6060. <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
  6061. <li>Let <i>objRec</i> be a new object <a href="#sec-environment-records">Environment Record</a> containing <i>G</i> as
  6062. the binding object.</li>
  6063. <li>Let <i>dclRec</i> be a new declarative <a href="#sec-environment-records">Environment Record</a> containing no
  6064. bindings.</li>
  6065. <li>Let <i>globalRec</i> be a new global <a href="#sec-environment-records">Environment Record</a>.</li>
  6066. <li>Set <i>globalRec</i>.[[ObjectRecord]] to <i>objRec</i>.</li>
  6067. <li>Set <i>globalRec</i>.[[DeclarativeRecord]] to <i>dclRec</i>.</li>
  6068. <li>Set <i>globalRec</i>.[[VarNames]] to a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  6069. <li>Set <i>env&rsquo;s</i> EnvironmentRecord to <i>globalRec</i>.</li>
  6070. <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to
  6071. <b>null</b></li>
  6072. <li>Return <i>env</i>.</li>
  6073. </ol>
  6074. </section>
  6075. <section id="sec-newmoduleenvironment">
  6076. <h1><span class="secnum" id="sec-8.1.2.6"><a href="#sec-newmoduleenvironment"
  6077. title="link to this section">8.1.2.6</a></span> NewModuleEnvironment (E)</h1>
  6078. <p>When the abstract operation NewModuleEnvironment is called with a <a href="#sec-lexical-environments">Lexical
  6079. Environment</a> argument <var>E</var> the following steps are performed:</p>
  6080. <ol class="proc">
  6081. <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
  6082. <li>Let <i>envRec</i> be a new module <a href="#sec-environment-records">Environment Record</a> containing no
  6083. bindings.</li>
  6084. <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
  6085. <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
  6086. <li>Return <i>env</i>.</li>
  6087. </ol>
  6088. </section>
  6089. </section>
  6090. </section>
  6091. <section id="sec-code-realms">
  6092. <div class="front">
  6093. <h1><span class="secnum" id="sec-8.2"><a href="#sec-code-realms" title="link to this section">8.2</a></span> Code
  6094. Realms</h1>
  6095. <p>Before it is evaluated, all ECMAScript code must be associated with a <i>Realm</i>. Conceptually, a realm consists of a
  6096. set of intrinsic objects, an ECMAScript global environment, all of the ECMAScript code that is loaded within the scope of
  6097. that global environment, and other associated state and resources.</p>
  6098. <p>A Realm is specified as a Record with the fields specified in <a href="#table-21">Table 21</a>:</p>
  6099. <figure>
  6100. <figcaption><span id="table-21">Table 21</span> &mdash; Realm Record Fields</figcaption>
  6101. <table class="real-table">
  6102. <tr>
  6103. <th>Field Name</th>
  6104. <th>Value</th>
  6105. <th>Meaning</th>
  6106. </tr>
  6107. <tr>
  6108. <td>[[intrinsics]]</td>
  6109. <td>Record whose field names are intrinsic keys and whose values are objects</td>
  6110. <td>These are the intrinsic values used by code associated with this Realm</td>
  6111. </tr>
  6112. <tr>
  6113. <td>[[globalThis]]</td>
  6114. <td>Object</td>
  6115. <td>The global object for this Realm</td>
  6116. </tr>
  6117. <tr>
  6118. <td>[[globalEnv]]</td>
  6119. <td><a href="#sec-lexical-environments">Lexical Environment</a></td>
  6120. <td>The global environment for this Realm</td>
  6121. </tr>
  6122. <tr>
  6123. <td>[[templateMap]]</td>
  6124. <td>A <a href="#sec-list-and-record-specification-type">List</a> of Record { [[strings]]: <a href="#sec-list-and-record-specification-type">List</a>, [[array]]: Object}.</td>
  6125. <td>Template objects are canonicalized separately for each Realm using its [[templateMap]]. Each [[strings]] value is a <a href="#sec-list-and-record-specification-type">List</a> containing, in source text order, the raw string values of a <span class="nt">TemplateLiteral</span> that has been evaluated. The associated [[array]] value is the corresponding template object that is passed to a tag function.</td>
  6126. </tr>
  6127. </table>
  6128. </figure>
  6129. <p>An implementation may define other, implementation specific fields.</p>
  6130. </div>
  6131. <section id="sec-createrealm">
  6132. <h1><span class="secnum" id="sec-8.2.1"><a href="#sec-createrealm" title="link to this section">8.2.1</a></span> CreateRealm
  6133. ( )</h1>
  6134. <p>The abstract operation CreateRealm with no arguments performs the following steps:</p>
  6135. <ol class="proc">
  6136. <li>Let <i>realmRec</i> be a new Record.</li>
  6137. <li>Perform <a href="#sec-createintrinsics">CreateIntrinsics</a>(<i>realmRec</i>).</li>
  6138. <li>Set <i>realmRec</i>.[[globalThis]] to <b>undefined</b>.</li>
  6139. <li>Set <i>realmRec</i>.[[globalEnv]] to <b>undefined</b>.</li>
  6140. <li>Set <i>realmRec</i>.[[templateMap]] to a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  6141. <li>Return <i>realmRec</i>.</li>
  6142. </ol>
  6143. </section>
  6144. <section id="sec-createintrinsics">
  6145. <h1><span class="secnum" id="sec-8.2.2"><a href="#sec-createintrinsics" title="link to this section">8.2.2</a></span>
  6146. CreateIntrinsics ( realmRec )</h1>
  6147. <p>When the abstract operation CreateIntrinsics with argument <var>realmRec</var> performs the following steps:</p>
  6148. <ol class="proc">
  6149. <li>Let <i>intrinsics</i> be a new Record.</li>
  6150. <li>Set <i>realmRec</i>.[[intrinsics]] to <i>intrinsics</i>.</li>
  6151. <li>Let <i>objProto</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<b>null</b>).</li>
  6152. <li>Set <i>intrinsics</i>.[[%ObjectPrototype%]] to <i>objProto</i>.</li>
  6153. <li>Let <i>throwerSteps</i> be the algorithm steps specified in <a href="#sec-%throwtypeerror%">9.2.7.1</a> for the <a
  6154. href="#sec-%throwtypeerror%">%ThrowTypeError%</a> function.</li>
  6155. <li>Let <i>thrower</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
  6156. <i>throwerSteps</i>, <b>null</b>).</li>
  6157. <li>Set <i>intrinsics</i>.[[<span style="font-family: sans-serif"><a
  6158. href="#sec-%throwtypeerror%">%ThrowTypeError%</a></span>]] to <i>thrower</i>.</li>
  6159. <li>Let <i>noSteps</i> be an empty sequence of algorithm steps.</li>
  6160. <li>Let <i>funcProto</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
  6161. <i>noSteps</i>, <i>objProto</i>).</li>
  6162. <li>Set <i>intrinsics</i>.[[%FunctionPrototype%]] to <i>funcProto</i>.</li>
  6163. <li><a href="#sec-call">Call</a> <i>thrower</i>.[[SetPrototypeOf]](<i>funcProto</i>).</li>
  6164. <li>Perform <a href="#sec-addrestrictedfunctionproperties">AddRestrictedFunctionProperties</a>(<i>funcProto</i>,
  6165. <i>realmRec</i>).</li>
  6166. <li>Set fields of <i>intrinsics</i> with the values listed in <a href="#table-7">Table 7</a> that have not already been
  6167. handled above. The field names are the names listed in column one of the table. The value of each field is a new
  6168. object value fully and recursively populated with property values as defined by the specification of each object in
  6169. clauses 18-26. All object property values are newly created object values. All values that are built-in function
  6170. objects are created by performing <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
  6171. &lt;steps&gt;, &lt;prototype&gt;, &lt;slots&gt;) where &lt;steps&gt; is the definition of that function provided by
  6172. this specification, &lt;prototype&gt; is the specified value of the function&rsquo;s [[Prototype]] <a
  6173. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> and &lt;slots&gt; is a list of the names, if
  6174. any, of the functions specified internal slots. The creation of the intrinsics and their properties must be ordered to
  6175. avoid any dependencies upon objects that have not yet been created.</li>
  6176. <li>Return <i>intrinsics</i>.</li>
  6177. </ol>
  6178. </section>
  6179. <section id="sec-setrealmglobalobject">
  6180. <h1><span class="secnum" id="sec-8.2.3"><a href="#sec-setrealmglobalobject" title="link to this section">8.2.3</a></span>
  6181. SetRealmGlobalObject ( realmRec, globalObj )</h1>
  6182. <p>The abstract operation SetRealmGlobalObject with arguments <var>realmRec</var> and <var>globalObj</var> performs the
  6183. following steps:</p>
  6184. <ol class="proc">
  6185. <li>If <i>globalObj</i> is <b>undefined</b>, then
  6186. <ol class="block">
  6187. <li>Let <i>intrinsics</i> be <i>realmRec</i>.[[intrinsics]].</li>
  6188. <li>Let <i>globalObj</i> be <a
  6189. href="#sec-objectcreate">ObjectCreate</a>(<i>intrinsics</i>.[[%ObjectPrototype%]]).</li>
  6190. </ol>
  6191. </li>
  6192. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  6193. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>globalObj</i>) is Object.</li>
  6194. <li>Set <i>realmRec</i>.[[globalThis]] to <i>globalObj</i>.</li>
  6195. <li>Let <i>newGlobalEnv</i> be <a href="#sec-newglobalenvironment">NewGlobalEnvironment</a>(<i>globalObj</i>).</li>
  6196. <li>Set <i>realmRec</i>.[[globalEnv]] to <i>newGlobalEnv</i>.</li>
  6197. <li>Return <i>realmRec</i>.</li>
  6198. </ol>
  6199. </section>
  6200. <section id="sec-setdefaultglobalbindings">
  6201. <h1><span class="secnum" id="sec-8.2.4"><a href="#sec-setdefaultglobalbindings"
  6202. title="link to this section">8.2.4</a></span> SetDefaultGlobalBindings ( realmRec )</h1>
  6203. <p>The abstract operation SetDefaultGlobalBindings with argument <var>realmRec</var> performs the following steps:</p>
  6204. <ol class="proc">
  6205. <li>Let <i>global</i> be <i>realmRec</i>.[[globalThis]].</li>
  6206. <li>For each property of the Global Object specified in <a href="#sec-global-object">clause 18</a>, do
  6207. <ol class="block">
  6208. <li>Let <i>name</i> be the string value of the property name.</li>
  6209. <li>Let <i>desc</i> be the fully populated data property descriptor for the property containing the specified
  6210. attributes for the property. For properties listed in <a
  6211. href="#sec-function-properties-of-the-global-object">18.2</a>, <a
  6212. href="#sec-constructor-properties-of-the-global-object">18.3</a>, or <a
  6213. href="#sec-other-properties-of-the-global-object">18.4</a> the value of the [[Value]] attribute is the
  6214. corresponding intrinsic object from <i>realmRec</i>.</li>
  6215. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>global</i>, <i>name</i>,
  6216. <i>desc</i>).</li>
  6217. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  6218. </ol>
  6219. </li>
  6220. <li>Return <i>global</i>.</li>
  6221. </ol>
  6222. </section>
  6223. </section>
  6224. <section id="sec-execution-contexts">
  6225. <div class="front">
  6226. <h1><span class="secnum" id="sec-8.3"><a href="#sec-execution-contexts" title="link to this section">8.3</a></span>
  6227. Execution Contexts</h1>
  6228. <p>An <i>execution context</i> is a specification device that is used to track the runtime evaluation of code by an
  6229. ECMAScript implementation. At any point in time, there is at most one execution context that is actually executing code.
  6230. This is known as the <i>running</i> execution context. A stack is used to track execution contexts. The running execution
  6231. context is always the top element of this stack. A new execution context is created whenever control is transferred from the
  6232. executable code associated with the currently running execution context to executable code that is not associated with that
  6233. execution context. The newly created execution context is pushed onto the stack and becomes the running execution
  6234. context.</p>
  6235. <p>An execution context contains whatever implementation specific state is necessary to track the execution progress of its
  6236. associated code. Each execution context has at least the state components listed in <a href="#table-22">Table 22</a>.</p>
  6237. <figure>
  6238. <figcaption><span id="table-22">Table 22</span> &mdash;State Components for All Execution Contexts</figcaption>
  6239. <table class="real-table">
  6240. <tr>
  6241. <th>Component</th>
  6242. <th>Purpose</th>
  6243. </tr>
  6244. <tr>
  6245. <td>code evaluation state</td>
  6246. <td>Any state needed to perform, suspend, and resume evaluation of the code associated with this execution context.</td>
  6247. </tr>
  6248. <tr>
  6249. <td>Function</td>
  6250. <td>If this execution context is evaluating the code of a function object, then the value of this component is that function object. If the context is evaluating the code of a <span class="nt">Script</span> or <span class="nt">Module</span>, the value is <span class="value">null</span>.</td>
  6251. </tr>
  6252. <tr>
  6253. <td><a href="#sec-code-realms">Realm</a></td>
  6254. <td>The <a href="#sec-code-realms">Realm</a> from which associated code accesses ECMAScript resources.</td>
  6255. </tr>
  6256. </table>
  6257. </figure>
  6258. <p>Evaluation of code by the running execution context may be suspended at various points defined within this specification.
  6259. Once the running execution context has been suspended a different execution context may become the running execution context
  6260. and commence evaluating its code. At some later time a suspended execution context may again become the running execution
  6261. context and continue evaluating its code at the point where it had previously been suspended. Transition of the running
  6262. execution context status among execution contexts usually occurs in stack-like last-in/first-out manner. However, some
  6263. ECMAScript features require non-LIFO transitions of the running execution context.</p>
  6264. <p>The value of the <a href="#sec-code-realms">Realm</a> component of the running execution context is also called the
  6265. <i>current <a href="#sec-code-realms">Realm</a></i>. The value of the Function component of the running execution context is
  6266. also called the <i>active function object.</i></p>
  6267. <p>Execution contexts for ECMAScript code have the additional state components listed in <a href="#table-23">Table
  6268. 23</a>.</p>
  6269. <figure>
  6270. <figcaption><span id="table-23">Table 23</span> &mdash; Additional State Components for ECMAScript Code Execution Contexts</figcaption>
  6271. <table class="real-table">
  6272. <tr>
  6273. <th>Component</th>
  6274. <th>Purpose</th>
  6275. </tr>
  6276. <tr>
  6277. <td>LexicalEnvironment</td>
  6278. <td>Identifies the <a href="#sec-lexical-environments">Lexical Environment</a> used to resolve identifier references made by code within this execution context.</td>
  6279. </tr>
  6280. <tr>
  6281. <td>VariableEnvironment</td>
  6282. <td>Identifies the <a href="#sec-lexical-environments">Lexical Environment</a> whose EnvironmentRecord holds bindings created by <span class="nt">VariableStatements</span> within this execution context.</td>
  6283. </tr>
  6284. </table>
  6285. </figure>
  6286. <p>The LexicalEnvironment and VariableEnvironment components of an execution context are always Lexical Environments. When
  6287. an execution context is created its LexicalEnvironment and VariableEnvironment components initially have the same value.</p>
  6288. <p>Execution contexts representing the evaluation of generator objects have the additional state components listed in <a
  6289. href="#table-24">Table 24</a>.</p>
  6290. <figure>
  6291. <figcaption><span id="table-24">Table 24</span> &mdash; Additional State Components for Generator Execution Contexts</figcaption>
  6292. <table class="real-table">
  6293. <tr>
  6294. <th>Component</th>
  6295. <th>Purpose</th>
  6296. </tr>
  6297. <tr>
  6298. <td>Generator</td>
  6299. <td>The GeneratorObject that this execution context is evaluating.</td>
  6300. </tr>
  6301. </table>
  6302. </figure>
  6303. <p>In most situations only the running execution context (the top of the execution context stack) is directly manipulated by
  6304. algorithms within this specification. Hence when the terms &ldquo;LexicalEnvironment&rdquo;, and
  6305. &ldquo;VariableEnvironment&rdquo; are used without qualification they are in reference to those components of the running
  6306. execution context.</p>
  6307. <p>An execution context is purely a specification mechanism and need not correspond to any particular artefact of an
  6308. ECMAScript implementation. It is impossible for ECMAScript code to directly access or observe an execution context.</p>
  6309. </div>
  6310. <section id="sec-resolvebinding">
  6311. <h1><span class="secnum" id="sec-8.3.1"><a href="#sec-resolvebinding" title="link to this section">8.3.1</a></span>
  6312. ResolveBinding ( name, [env] )</h1>
  6313. <p>The ResolveBinding abstract operation is used to determine the binding of <var>name</var> passed as a string value. The
  6314. optional argument <var>env</var> can be used to explicitly provide the <a href="#sec-lexical-environments">Lexical
  6315. Environment</a> that is to be searched for the binding. During execution of ECMAScript code, ResolveBinding is performed
  6316. using the following algorithm:</p>
  6317. <ol class="proc">
  6318. <li>If <i>env</i> was not passed or if <i>env</i> is <b>undefined</b>, then
  6319. <ol class="block">
  6320. <li>Let <i>env</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
  6321. href="#sec-execution-contexts">LexicalEnvironment</a>.</li>
  6322. </ol>
  6323. </li>
  6324. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>env</i> is a <a href="#sec-lexical-environments">Lexical
  6325. Environment</a>.</li>
  6326. <li>If the code matching the syntactic production that is being evaluated is contained in <a
  6327. href="#sec-strict-mode-code">strict mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be
  6328. <b>false</b>.</li>
  6329. <li>Return <a href="#sec-getidentifierreference">GetIdentifierReference</a>(<i>env</i>, <i>name</i>, <i>strict</i> ).</li>
  6330. </ol>
  6331. <div class="note">
  6332. <p><span class="nh">NOTE</span> The result of ResolveBinding is always a <a
  6333. href="#sec-reference-specification-type">Reference</a> value with its referenced name component equal to the <i>name</i>
  6334. argument.</p>
  6335. </div>
  6336. </section>
  6337. <section id="sec-getthisenvironment">
  6338. <h1><span class="secnum" id="sec-8.3.2"><a href="#sec-getthisenvironment" title="link to this section">8.3.2</a></span>
  6339. GetThisEnvironment ( )</h1>
  6340. <p>The abstract operation <span style="font-family: Times New Roman">GetThisEnvironment</span> finds the <a
  6341. href="#sec-environment-records">Environment Record</a> that currently supplies the binding of the keyword <code>this</code>.
  6342. <span style="font-family: Times New Roman">GetThisEnvironment</span> performs the following steps:</p>
  6343. <ol class="proc">
  6344. <li>Let <i>lex</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
  6345. href="#sec-execution-contexts">LexicalEnvironment</a>.</li>
  6346. <li>Repeat
  6347. <ol class="block">
  6348. <li>Let <i>envRec</i> be <i>lex</i>&rsquo;s EnvironmentRecord.</li>
  6349. <li>Let <i>exists</i> be <i>envRec</i>.HasThisBinding().</li>
  6350. <li>If <i>exists</i> is <b>true</b>, return <i>envRec</i>.</li>
  6351. <li>Let <i>outer</i> be the value of <i>lex&rsquo;s</i> <a href="#sec-lexical-environments">outer environment
  6352. reference</a>.</li>
  6353. <li>Let <i>lex</i> be <i>outer</i>.</li>
  6354. </ol>
  6355. </li>
  6356. </ol>
  6357. <div class="note">
  6358. <p><span class="nh">NOTE</span> The loop in step 2 will always terminate because the list of environments always ends with
  6359. <a href="#sec-global-environment-records">the global environment</a> which has a <code>this</code> binding.</p>
  6360. </div>
  6361. </section>
  6362. <section id="sec-resolvethisbinding">
  6363. <h1><span class="secnum" id="sec-8.3.3"><a href="#sec-resolvethisbinding" title="link to this section">8.3.3</a></span>
  6364. ResolveThisBinding ( )</h1>
  6365. <p>The abstract operation ResolveThisBinding determines the binding of the keyword <code>this</code> using the <a
  6366. href="#sec-execution-contexts">LexicalEnvironment</a> of <a href="#sec-execution-contexts">the running execution
  6367. context</a>. ResolveThisBinding performs the following steps:</p>
  6368. <ol class="proc">
  6369. <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
  6370. <li>Return <i>envRec</i>.GetThisBinding().</li>
  6371. </ol>
  6372. </section>
  6373. <section id="sec-getnewtarget">
  6374. <h1><span class="secnum" id="sec-8.3.4"><a href="#sec-getnewtarget" title="link to this section">8.3.4</a></span>
  6375. GetNewTarget ( )</h1>
  6376. <p>The abstract operation GetNewTarget determines the NewTarget value using the <a
  6377. href="#sec-execution-contexts">LexicalEnvironment</a> of <a href="#sec-execution-contexts">the running execution
  6378. context</a>. GetNewTarget performs the following steps:</p>
  6379. <ol class="proc">
  6380. <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
  6381. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a [[NewTarget]] field.</li>
  6382. <li>Return <i>envRec</i>.[[NewTarget]].</li>
  6383. </ol>
  6384. </section>
  6385. <section id="sec-getglobalobject">
  6386. <h1><span class="secnum" id="sec-8.3.5"><a href="#sec-getglobalobject" title="link to this section">8.3.5</a></span>
  6387. GetGlobalObject ( )</h1>
  6388. <p>The abstract operation <span style="font-family: Times New Roman">GetGlobalObject</span> returns the global object used
  6389. by <a href="#sec-execution-contexts">the currently running execution context</a>. <span style="font-family: Times New
  6390. Roman">GetGlobalObject</span> performs the following steps:</p>
  6391. <ol class="proc">
  6392. <li>Let <i>ctx</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
  6393. <li>Let <i>currentRealm</i> be <i>ctx&rsquo;s</i> <a href="#sec-code-realms">Realm</a>.</li>
  6394. <li>Return <i>currentRealm</i>.[[globalThis]].</li>
  6395. </ol>
  6396. </section>
  6397. </section>
  6398. <section id="sec-jobs-and-job-queues">
  6399. <div class="front">
  6400. <h1><span class="secnum" id="sec-8.4"><a href="#sec-jobs-and-job-queues" title="link to this section">8.4</a></span> Jobs
  6401. and Job Queues</h1>
  6402. <p>A Job is an abstract operation that initiates an ECMAScript computation when no other ECMAScript computation is currently
  6403. in progress. A Job abstract operation may be defined to accept an arbitrary set of job parameters.</p>
  6404. <p>Execution of a Job can be initiated only when there is no running <a href="#sec-execution-contexts">execution context</a>
  6405. and <a href="#sec-execution-contexts">the execution context stack</a> is empty. A PendingJob is a request for the future
  6406. execution of a Job. A PendingJob is an internal Record whose fields are specified in <a href="#table-25">Table 25</a>. Once
  6407. execution of a Job is initiated, the Job always executes to completion. No other Job may be initiated until the currently
  6408. running Job completes. However, the currently running Job or external events may cause the enqueuing of additional
  6409. PendingJobs that may be initiated sometime after completion of the currently running Job.</p>
  6410. <figure>
  6411. <figcaption><span id="table-25">Table 25</span> &mdash; PendingJob Record Fields</figcaption>
  6412. <table class="real-table">
  6413. <tr>
  6414. <th>Field Name</th>
  6415. <th>Value</th>
  6416. <th>Meaning</th>
  6417. </tr>
  6418. <tr>
  6419. <td>[[Job]]</td>
  6420. <td>The name of a Job abstract operation</td>
  6421. <td>This is the abstract operation that is performed when execution of this PendingJob is initiated. Jobs are abstract operations that use NextJob rather than Return to indicate that they have completed.</td>
  6422. </tr>
  6423. <tr>
  6424. <td>[[Arguments]]</td>
  6425. <td>A <a href="#sec-list-and-record-specification-type">List</a></td>
  6426. <td>The <a href="#sec-list-and-record-specification-type">List</a> of argument values that are to be passed to [[Job]] when it is activated.</td>
  6427. </tr>
  6428. <tr>
  6429. <td>[[Realm]]</td>
  6430. <td>A <a href="#sec-code-realms">Realm</a> Record</td>
  6431. <td>The <a href="#sec-code-realms">Realm</a> for the initial <a href="#sec-execution-contexts">execution context</a> when this Pending Job is initiated.</td>
  6432. </tr>
  6433. <tr>
  6434. <td>[[HostDefined]]</td>
  6435. <td>Any, default value is <span class="value">undefined</span>.</td>
  6436. <td>Field reserved for use by host environments that need to associate additional information with a pending Job.</td>
  6437. </tr>
  6438. </table>
  6439. </figure>
  6440. <p>A Job Queue is a FIFO queue of PendingJob records. Each Job Queue has a name and the full set of available Job Queues are
  6441. defined by an ECMAScript implementation. Every ECMAScript implementation has at least the Job Queues defined in <a
  6442. href="#table-26">Table 26</a>.</p>
  6443. <figure>
  6444. <figcaption><span id="table-26">Table 26</span> &mdash; Required Job Queues</figcaption>
  6445. <table class="real-table">
  6446. <tr>
  6447. <th>Name</th>
  6448. <th>Purpose</th>
  6449. </tr>
  6450. <tr>
  6451. <td>ScriptJobs</td>
  6452. <td>Jobs that validate and evaluate ECMAScript <span class="nt">Script</span> and <span class="nt">Module</span> source text. See clauses 10 and 15.</td>
  6453. </tr>
  6454. <tr>
  6455. <td>PromiseJobs</td>
  6456. <td>Jobs that are responses to the settlement of a Promise (<a href="#sec-promise-objects">see 25.4</a>).</td>
  6457. </tr>
  6458. </table>
  6459. </figure>
  6460. <p>A request for the future execution of a Job is made by enqueueing, on a Job Queue, a PendingJob record that includes a
  6461. Job abstract operation name and any necessary argument values. When there is no running <a
  6462. href="#sec-execution-contexts">execution context</a> and <a href="#sec-execution-contexts">the execution context stack</a>
  6463. is empty, the ECMAScript implementation removes the first PendingJob from a Job Queue and uses the information contained in
  6464. it to create an <a href="#sec-execution-contexts">execution context</a> and starts execution of the associated Job abstract
  6465. operation.</p>
  6466. <p>The PendingJob records from a single Job Queue are always initiated in FIFO order. This specification does not define the
  6467. order in which multiple Job Queues are serviced. An ECMAScript implementation may interweave the FIFO evaluation of the
  6468. PendingJob records of a Job Queue with the evaluation of the PendingJob records of one or more other Job Queues. An
  6469. implementation must define what occurs when there are no running <a href="#sec-execution-contexts">execution context</a> and
  6470. all Job Queues are empty.</p>
  6471. <div class="note">
  6472. <p><span class="nh">NOTE</span> Typically an ECMAScript implementation will have its Job Queues pre-initialized with at
  6473. least one PendingJob and one of those Jobs will be the first to be executed. An implementation might choose to free all
  6474. resources and terminate if the current Job completes and all Job Queues are empty. Alternatively, it might choose to wait
  6475. for a some implementation specific agent or mechanism to enqueue new PendingJob requests.</p>
  6476. </div>
  6477. <p>The following abstract operations are used to create and manage Jobs and Job Queues:</p>
  6478. </div>
  6479. <section id="sec-enqueuejob">
  6480. <h1><span class="secnum" id="sec-8.4.1"><a href="#sec-enqueuejob" title="link to this section">8.4.1</a></span> EnqueueJob (
  6481. queueName, job, arguments)</h1>
  6482. <p>The EnqueueJob abstract operation requires three arguments: <var>queueName</var>, <var>job</var>, and
  6483. <var>arguments</var>. It performs the following steps:</p>
  6484. <ol class="proc">
  6485. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  6486. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>queueName</i>) is String and its value is the name of a Job
  6487. Queue recognized by this implementation.</li>
  6488. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>job</i> is the name of a Job.</li>
  6489. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>arguments</i> is a <a
  6490. href="#sec-list-and-record-specification-type">List</a> that has the same number of elements as the number of
  6491. parameters required by <i>job</i>.</li>
  6492. <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
  6493. <li>Let <i>callerRealm</i> be <i>callerContext&rsquo;s</i> <a href="#sec-code-realms">Realm</a>.</li>
  6494. <li>Let <i>pending</i> be PendingJob{ [[Job]]: <i>job</i>, [[Arguments]]: <i>arguments</i>, [[Realm]]: <i>callerRealm</i>,
  6495. [[HostDefined]]: <b>undefined</b> }.</li>
  6496. <li>Perform any implementation or host environment defined processing of <i>pending</i>. This may include modifying the
  6497. [[HostDefined]] field or any other field of <i>pending</i>.</li>
  6498. <li>Add <i>pending</i> at the back of the Job Queue named by <i>queueName</i>.</li>
  6499. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>).</li>
  6500. </ol>
  6501. </section>
  6502. <section id="sec-nextjob-result">
  6503. <h1><span class="secnum" id="sec-8.4.2"><a href="#sec-nextjob-result" title="link to this section">8.4.2</a></span> NextJob
  6504. result</h1>
  6505. <p>An algorithm step such as:</p>
  6506. <ol class="proc">
  6507. <li>NextJob <i>result</i>.</li>
  6508. </ol>
  6509. <p>is used in Job abstract operations in place of:</p>
  6510. <ol class="proc">
  6511. <li>Return <i>result</i>.</li>
  6512. </ol>
  6513. <p>Job abstract operations must not contain a Return step or a <a href="#sec-returnifabrupt">ReturnIfAbrupt</a> step. The
  6514. NextJob <var>result</var> operation is equivalent to the following steps:</p>
  6515. <ol class="proc">
  6516. <li>If <i>result</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, perform
  6517. implementation defined unhandled exception processing.</li>
  6518. <li><a href="#sec-execution-contexts">Suspend</a> <a href="#sec-execution-contexts">the running execution context</a> and
  6519. remove it from <a href="#sec-execution-contexts">the execution context stack</a>.</li>
  6520. <li><a href="#sec-algorithm-conventions">Assert</a>: The <a href="#sec-execution-contexts">execution context stack</a> is
  6521. now empty.</li>
  6522. <li>Let <i>nextQueue</i> be a non-empty Job Queue chosen in an implementation defined manner. If all Job Queues are empty,
  6523. the result is implementation defined.</li>
  6524. <li>Let <i>nextPending</i> be the PendingJob record at the front of <i>nextQueue</i>. Remove that record from
  6525. <i>nextQueue</i>.</li>
  6526. <li>Let <i>newContext</i> be a new <a href="#sec-execution-contexts">execution context</a>.</li>
  6527. <li>Set <i>newContext</i>&rsquo;s <a href="#sec-code-realms">Realm</a> to <i>nextPending</i>.[[Realm]].</li>
  6528. <li>Push <i>newContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>newContext</i> is
  6529. now <a href="#sec-execution-contexts">the running execution context</a>.</li>
  6530. <li>Perform any implementation or host environment defined job initialization using <i>nextPending</i>.</li>
  6531. <li>Perform the abstract operation named by <i>nextPending</i>.[[Job]] using the elements of
  6532. <i>nextPending</i>.[[Arguments]] as its arguments.</li>
  6533. </ol>
  6534. </section>
  6535. </section>
  6536. <section id="sec-ecmascript-initialization">
  6537. <div class="front">
  6538. <h1><span class="secnum" id="sec-8.5"><a href="#sec-ecmascript-initialization" title="link to this section">8.5</a></span>
  6539. ECMAScript Initialization()</h1>
  6540. <p>An ECMAScript implementation performs the following steps prior to the execution of any Jobs or the evaluation of any
  6541. ECMAScript code:</p>
  6542. <ol class="proc">
  6543. <li>Let <i>realm</i> be <a href="#sec-createrealm">CreateRealm</a>().</li>
  6544. <li>Let <i>newContext</i> be a new <a href="#sec-execution-contexts">execution context</a>.</li>
  6545. <li>Set the Function of <i>newContext</i> to <b>null</b>.</li>
  6546. <li>Set the <a href="#sec-code-realms">Realm</a> of <i>newContext</i> to <i>realm</i>.</li>
  6547. <li>Push <i>newContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>newContext</i> is
  6548. now <a href="#sec-execution-contexts">the running execution context</a>.</li>
  6549. <li>Let <i>status</i> be <a href="#sec-initializehostdefinedrealm">InitializeHostDefinedRealm</a>(<i>realm</i>).</li>
  6550. <li>If <i>status</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, then
  6551. <ol class="block">
  6552. <li><a href="#sec-algorithm-conventions">Assert</a>: The first realm could not be created.</li>
  6553. <li>Terminate ECMAScript execution.</li>
  6554. </ol>
  6555. </li>
  6556. <li>In an implementation dependent manner, obtain the ECMAScript source texts (see <a
  6557. href="#sec-ecmascript-language-source-code">clause 10</a>) for zero or more ECMAScript scripts and/or ECMAScript
  6558. modules. For each such <i>sourceText</i> do,
  6559. <ol class="block">
  6560. <li>If <i>sourceText</i> is the source code of a script, then
  6561. <ol class="block">
  6562. <li>Perform <a href="#sec-enqueuejob">EnqueueJob</a>(<code>"ScriptJobs"</code>, <a
  6563. href="#sec-scriptevaluationjob">ScriptEvaluationJob</a>, &laquo; <i>sourceText</i> &raquo;).</li>
  6564. </ol>
  6565. </li>
  6566. <li>Else <i>sourceText</i> is the source code of a module,
  6567. <ol class="block">
  6568. <li>Perform <a href="#sec-enqueuejob">EnqueueJob</a>(<code>"ScriptJobs"</code>, <a
  6569. href="#sec-toplevelmoduleevaluationjob">TopLevelModuleEvaluationJob</a>, &laquo; <i>sourceText</i>
  6570. &raquo;).</li>
  6571. </ol>
  6572. </li>
  6573. </ol>
  6574. </li>
  6575. <li>NextJob <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  6576. </ol>
  6577. </div>
  6578. <section id="sec-initializehostdefinedrealm">
  6579. <h1><span class="secnum" id="sec-8.5.1"><a href="#sec-initializehostdefinedrealm"
  6580. title="link to this section">8.5.1</a></span> InitializeHostDefinedRealm ( realm )</h1>
  6581. <p>The abstract operation InitializeHostDefinedRealm with parameter <var>realm</var> performs the following steps:</p>
  6582. <ol class="proc">
  6583. <li>If this implementation requires use of an exotic object to serve as <i>realm</i>&rsquo;s global object, let
  6584. <i>global</i> be such an object created in an implementation defined manner. Otherwise, let <i>global</i> be
  6585. <b>undefined</b> indicating that an ordinary object should be created as the global object.</li>
  6586. <li>Perform <a href="#sec-setrealmglobalobject">SetRealmGlobalObject</a>(<i>realm</i>, <i>global</i>).</li>
  6587. <li>Let <i>globalObj</i> be <a href="#sec-setdefaultglobalbindings">SetDefaultGlobalBindings</a>(<i>realm</i>).</li>
  6588. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>globalObj</i>).</li>
  6589. <li>Create any implementation defined global object properties on <i>globalObj</i>.</li>
  6590. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  6591. </ol>
  6592. </section>
  6593. </section>
  6594. </section>
  6595. <section id="sec-ordinary-and-exotic-objects-behaviours">
  6596. <div class="front">
  6597. <h1><span class="secnum" id="sec-9"><a href="#sec-ordinary-and-exotic-objects-behaviours"
  6598. title="link to this section">9</a></span> Ordinary and Exotic Objects Behaviours</h1>
  6599. </div>
  6600. <section id="sec-ordinary-object-internal-methods-and-internal-slots">
  6601. <div class="front">
  6602. <h1><span class="secnum" id="sec-9.1"><a href="#sec-ordinary-object-internal-methods-and-internal-slots"
  6603. title="link to this section">9.1</a></span> Ordinary Object Internal Methods and Internal Slots</h1>
  6604. <p>All ordinary objects have an <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called
  6605. [[Prototype]]. The value of this <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is either
  6606. <b>null</b> or an object and is used for implementing inheritance. Data properties of the [[Prototype]] object are inherited
  6607. (are visible as properties of the child object) for the purposes of get access, but not for set access. Accessor properties
  6608. are inherited for both get access and set access.</p>
  6609. <p>Every ordinary object has a Boolean-valued [[Extensible]] <a
  6610. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> that controls whether or not properties may be
  6611. added to the object. If the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  6612. slot</a> is <b>false</b> then additional properties may not be added to the object. In addition, if [[Extensible]] is
  6613. <b>false</b> the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
  6614. the object may not be modified. Once the value of an object&rsquo;s [[Extensible]] <a
  6615. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> has been set to <b>false</b> it may not be
  6616. subsequently changed to <b>true</b>.</p>
  6617. <p>In the following algorithm descriptions, assume <var>O</var> is an ordinary object, <var>P</var> is a <a
  6618. href="#sec-object-type">property key value</a>, <var>V</var> is any <a href="#sec-ecmascript-language-types">ECMAScript
  6619. language value</a>, and <span class="nt">Desc</span> is a <a href="#sec-property-descriptor-specification-type">Property
  6620. Descriptor</a> record.</p>
  6621. </div>
  6622. <section id="sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof">
  6623. <h1><span class="secnum" id="sec-9.1.1"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof"
  6624. title="link to this section">9.1.1</a></span> [[GetPrototypeOf]] ( )</h1>
  6625. <p>When the [[GetPrototypeOf]] internal method of <var>O</var> is called the following steps are taken:</p>
  6626. <ol class="proc">
  6627. <li>Return the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
  6628. <i>O</i>.</li>
  6629. </ol>
  6630. </section>
  6631. <section id="sec-ordinary-object-internal-methods-and-internal-slots-setprototypeof-v">
  6632. <h1><span class="secnum" id="sec-9.1.2"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-setprototypeof-v"
  6633. title="link to this section">9.1.2</a></span> [[SetPrototypeOf]] (V)</h1>
  6634. <p>When the [[SetPrototypeOf]] internal method of <var>O</var> is called with argument <var>V</var> the following steps are
  6635. taken:</p>
  6636. <ol class="proc">
  6637. <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
  6638. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
  6639. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
  6640. <li>Let <i>extensible</i> be the value of the [[Extensible]] <a
  6641. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  6642. <li>Let <i>current</i> be the value of the [[Prototype]] <a
  6643. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  6644. <li>If <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>current</i>), return <b>true.</b></li>
  6645. <li>If <i>extensible</i> is <b>false</b>, return <b>false</b>.</li>
  6646. <li>Let <i>p</i> be <i>V</i>.</li>
  6647. <li>Let <i>done</i> be <b>false</b>.</li>
  6648. <li>Repeat while <i>done</i> is <b>false</b>,
  6649. <ol class="block">
  6650. <li>If <i>p</i> is <b>null</b>, let <i>done</i> be <b>true</b>.</li>
  6651. <li>Else, if <a href="#sec-samevalue">SameValue</a>(<i>p</i>, <i>O</i>) is <b>true</b>, return <b>false</b>.</li>
  6652. <li>Else,
  6653. <ol class="block">
  6654. <li>If the [[GetPrototypeOf]] internal method of <i>p</i> is not the ordinary object internal method defined in <a
  6655. href="#sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof">9.1.1</a>, let <i>done</i> be
  6656. <b>true</b>.</li>
  6657. <li>Else, let <i>p</i> be the value of <i>p</i>&rsquo;s [[Prototype]] <a
  6658. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  6659. </ol>
  6660. </li>
  6661. </ol>
  6662. </li>
  6663. <li>Set the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
  6664. <i>O</i> to <i>V</i>.</li>
  6665. <li>Return <b>true</b>.</li>
  6666. </ol>
  6667. <div class="note">
  6668. <p><span class="nh">NOTE</span> The loop in step 8 guarantees that there will be no circularities in any prototype chain
  6669. that only includes objects that use the ordinary object definitions for [[GetPrototypeOf]] and [[SetPrototypeOf]].</p>
  6670. </div>
  6671. </section>
  6672. <section id="sec-ordinary-object-internal-methods-and-internal-slots-isextensible">
  6673. <h1><span class="secnum" id="sec-9.1.3"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-isextensible"
  6674. title="link to this section">9.1.3</a></span> [[IsExtensible]] ( )</h1>
  6675. <p>When the [[IsExtensible]] internal method of <var>O</var> is called the following steps are taken:</p>
  6676. <ol class="proc">
  6677. <li>Return the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
  6678. <i>O</i>.</li>
  6679. </ol>
  6680. </section>
  6681. <section id="sec-ordinary-object-internal-methods-and-internal-slots-preventextensions">
  6682. <h1><span class="secnum" id="sec-9.1.4"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-preventextensions"
  6683. title="link to this section">9.1.4</a></span> [[PreventExtensions]] ( )</h1>
  6684. <p>When the [[PreventExtensions]] internal method of <var>O</var> is called the following steps are taken:</p>
  6685. <ol class="proc">
  6686. <li>Set the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
  6687. <i>O</i> to <b>false</b>.</li>
  6688. <li>Return <b>true.</b></li>
  6689. </ol>
  6690. </section>
  6691. <section id="sec-ordinary-object-internal-methods-and-internal-slots-getownproperty-p">
  6692. <div class="front">
  6693. <h1><span class="secnum" id="sec-9.1.5"><a
  6694. href="#sec-ordinary-object-internal-methods-and-internal-slots-getownproperty-p"
  6695. title="link to this section">9.1.5</a></span> [[GetOwnProperty]] (P)</h1>
  6696. <p>When the [[GetOwnProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
  6697. <var>P</var>, the following steps are taken:</p>
  6698. <ol class="proc">
  6699. <li>Return <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
  6700. </ol>
  6701. </div>
  6702. <section id="sec-ordinarygetownproperty">
  6703. <h1><span class="secnum" id="sec-9.1.5.1"><a href="#sec-ordinarygetownproperty"
  6704. title="link to this section">9.1.5.1</a></span> OrdinaryGetOwnProperty (O, P)</h1>
  6705. <p>When the abstract operation OrdinaryGetOwnProperty is called with Object <var>O</var> and with <a
  6706. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  6707. <ol class="proc">
  6708. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  6709. <b>true</b>.</li>
  6710. <li>If <i>O</i> does not have an own property with key <i>P</i>, return <b>undefined</b>.</li>
  6711. <li>Let <i>D</i> be a newly created <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> with
  6712. no fields.</li>
  6713. <li>Let <i>X</i> be <i>O</i>&rsquo;s own property whose key is <i>P</i>.</li>
  6714. <li>If <i>X</i> is a data property, then
  6715. <ol class="block">
  6716. <li>Set <i>D</i>.[[Value]] to the value of <i>X</i>&rsquo;s [[Value]] attribute.</li>
  6717. <li>Set <i>D</i>.[[Writable]] to the value of <i>X</i>&rsquo;s [[Writable]] attribute</li>
  6718. </ol>
  6719. </li>
  6720. <li>Else <i>X</i> is an accessor property, so
  6721. <ol class="block">
  6722. <li>Set <i>D</i>.[[Get]] to the value of <i>X</i>&rsquo;s [[Get]] attribute.</li>
  6723. <li>Set <i>D</i>.[[Set]] to the value of <i>X</i>&rsquo;s [[Set]] attribute.</li>
  6724. </ol>
  6725. </li>
  6726. <li>Set <i>D</i>.[[Enumerable]] to the value of <i>X</i>&rsquo;s [[Enumerable]] attribute.</li>
  6727. <li>Set <i>D</i>.[[Configurable]] to the value of <i>X</i>&rsquo;s [[Configurable]] attribute.</li>
  6728. <li>Return <i>D</i>.</li>
  6729. </ol>
  6730. </section>
  6731. </section>
  6732. <section id="sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc">
  6733. <div class="front">
  6734. <h1><span class="secnum" id="sec-9.1.6"><a
  6735. href="#sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc"
  6736. title="link to this section">9.1.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
  6737. <p>When the [[DefineOwnProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property
  6738. key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span
  6739. class="nt">Desc</span>, the following steps are taken:</p>
  6740. <ol class="proc">
  6741. <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>O</i>, <i>P</i>, <i>Desc</i>).</li>
  6742. </ol>
  6743. </div>
  6744. <section id="sec-ordinarydefineownproperty">
  6745. <h1><span class="secnum" id="sec-9.1.6.1"><a href="#sec-ordinarydefineownproperty"
  6746. title="link to this section">9.1.6.1</a></span> OrdinaryDefineOwnProperty (O, P, Desc)</h1>
  6747. <p>When the abstract operation <span style="font-family: Times New Roman">OrdinaryDefineOwnProperty</span> is called with
  6748. Object <var>O</var>, <a href="#sec-object-type">property key</a> <span style="font-family: Times New
  6749. Roman"><i>P</i>,</span> and <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span
  6750. class="nt">Desc</span> the following steps are taken:</p>
  6751. <ol class="proc">
  6752. <li>Let <i>current</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
  6753. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>current</i>).</li>
  6754. <li>Let <i>extensible</i> be the value of the [[Extensible]] <a
  6755. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  6756. <li>Return <a href="#sec-validateandapplypropertydescriptor">ValidateAndApplyPropertyDescriptor</a>(<i>O</i>, <i>P</i>,
  6757. <i>extensible</i>, <i>Desc</i>, <i>current</i>).</li>
  6758. </ol>
  6759. </section>
  6760. <section id="sec-iscompatiblepropertydescriptor">
  6761. <h1><span class="secnum" id="sec-9.1.6.2"><a href="#sec-iscompatiblepropertydescriptor"
  6762. title="link to this section">9.1.6.2</a></span> IsCompatiblePropertyDescriptor (Extensible, Desc, Current)</h1>
  6763. <p>When the abstract operation <span style="font-family: Times New Roman">IsCompatiblePropertyDescriptor</span> is called
  6764. with Boolean value <span class="nt">Extensible</span>, and Property Descriptors <span class="nt">Desc</span>, and <span
  6765. class="nt">Current</span> the following steps are taken:</p>
  6766. <ol class="proc">
  6767. <li>Return <a href="#sec-validateandapplypropertydescriptor">ValidateAndApplyPropertyDescriptor</a>(<b>undefined</b>,
  6768. <b>undefined</b>, <i>Extensible</i>, <i>Desc</i>, <i>Current</i>).</li>
  6769. </ol>
  6770. </section>
  6771. <section id="sec-validateandapplypropertydescriptor">
  6772. <h1><span class="secnum" id="sec-9.1.6.3"><a href="#sec-validateandapplypropertydescriptor"
  6773. title="link to this section">9.1.6.3</a></span> ValidateAndApplyPropertyDescriptor (O, P, extensible, Desc,
  6774. current)</h1>
  6775. <p>When the abstract operation <span style="font-family: Times New Roman">ValidateAndApplyPropertyDescriptor</span> is
  6776. called with Object <var>O</var>, <a href="#sec-object-type">property key</a> <span style="font-family: Times New
  6777. Roman"><i>P</i>,</span> Boolean value <var>extensible</var>, and Property Descriptors <span class="nt">Desc</span>, and
  6778. <var>current</var> the following steps are taken:</p>
  6779. <p>This algorithm contains steps that test various fields of the <a
  6780. href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> for specific
  6781. values. The fields that are tested in this manner need not actually exist in <span class="nt">Desc</span>. If a field is
  6782. absent then its value is considered to be <b>false</b>.</p>
  6783. <div class="note">
  6784. <p><span class="nh">NOTE</span> If <b>undefined</b> is passed as the <i>O</i> argument only validation is performed and
  6785. no object updates are performed.</p>
  6786. </div>
  6787. <ol class="proc">
  6788. <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>O</i> is not <b>undefined</b> then <i>P</i> is a valid <a
  6789. href="#sec-object-type">property key</a>.</li>
  6790. <li>If <i>current</i> is <b>undefined</b>, then
  6791. <ol class="block">
  6792. <li>If <i>extensible</i> is <b>false</b>, return <b>false</b>.</li>
  6793. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>extensible</i> is <b>true</b>.</li>
  6794. <li>If <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) or <a
  6795. href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
  6796. <ol class="block">
  6797. <li>If <i>O</i> is not <b>undefined</b>, create an own data property named <i>P</i> of object <i>O</i> whose
  6798. [[Value]], [[Writable]], [[Enumerable]] and [[Configurable]] attribute values are described by <i>Desc</i>.
  6799. If the value of an attribute field of <i>Desc</i> is absent, the attribute of the newly created property is
  6800. set to its default value.</li>
  6801. </ol>
  6802. </li>
  6803. <li>Else <i>Desc</i> must be an accessor <a href="#sec-property-descriptor-specification-type">Property
  6804. Descriptor</a>,
  6805. <ol class="block">
  6806. <li>If <i>O</i> is not <b>undefined</b>, create an own accessor property named <i>P</i> of object <i>O</i> whose
  6807. [[Get]], [[Set]], [[Enumerable]] and [[Configurable]] attribute values are described by <i>Desc</i>. If the
  6808. value of an attribute field of <i>Desc</i> is absent, the attribute of the newly created property is set to
  6809. its default value.</li>
  6810. </ol>
  6811. </li>
  6812. <li>Return <b>true</b>.</li>
  6813. </ol>
  6814. </li>
  6815. <li>Return <b>true</b>, if every field in <i>Desc</i> is absent.</li>
  6816. <li>Return <b>true</b>, if every field in <i>Desc</i> also occurs in <i>current</i> and the value of every field in
  6817. <i>Desc</i> is the same value as the corresponding field in <i>current</i> when compared using <a
  6818. href="#sec-samevalue">the SameValue algorithm</a>.</li>
  6819. <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
  6820. <ol class="block">
  6821. <li>Return <b>false</b>, if the [[Configurable]] field of <i>Desc</i> is <b>true</b>.</li>
  6822. <li>Return <b>false</b>, if the [[Enumerable]] field of <i>Desc</i> is present and the [[Enumerable]] fields of
  6823. <i>current</i> and <i>Desc</i> are the Boolean negation of each other.</li>
  6824. </ol>
  6825. </li>
  6826. <li>If <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) is <b>true</b>, no further validation is
  6827. required.</li>
  6828. <li>Else if <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) and <a
  6829. href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) have different results, then
  6830. <ol class="block">
  6831. <li>Return <b>false</b>, if the [[Configurable]] field of <i>current</i> is <b>false</b>.</li>
  6832. <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) is <b>true</b>, then
  6833. <ol class="block">
  6834. <li>If <i>O</i> is not <b>undefined</b>, convert the property named <i>P</i> of object <i>O</i> from a data
  6835. property to an accessor property. Preserve the existing values of the converted property&rsquo;s
  6836. [[Configurable]] and [[Enumerable]] attributes and set the rest of the property&rsquo;s attributes to their
  6837. default values.</li>
  6838. </ol>
  6839. </li>
  6840. <li>Else,
  6841. <ol class="block">
  6842. <li>If <i>O</i> is not <b>undefined</b>, convert the property named <i>P</i> of object <i>O</i> from an accessor
  6843. property to a data property. Preserve the existing values of the converted property&rsquo;s [[Configurable]]
  6844. and [[Enumerable]] attributes and set the rest of the property&rsquo;s attributes to their default
  6845. values.</li>
  6846. </ol>
  6847. </li>
  6848. </ol>
  6849. </li>
  6850. <li>Else if <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) and <a
  6851. href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) are both <b>true</b>, then
  6852. <ol class="block">
  6853. <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
  6854. <ol class="block">
  6855. <li>Return <b>false</b>, if the [[Writable]] field of <i>current</i> is <b>false</b> and the [[Writable]] field
  6856. of <i>Desc</i> is <b>true</b>.</li>
  6857. <li>If the [[Writable]] field of <i>current</i> is <b>false</b>, then
  6858. <ol class="block">
  6859. <li>Return <b>false</b>, if the [[Value]] field of <i>Desc</i> is present and <a
  6860. href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Value]], <i>current</i>.[[Value]]) is
  6861. <b>false</b>.</li>
  6862. </ol>
  6863. </li>
  6864. </ol>
  6865. </li>
  6866. <li>Else the [[Configurable]] field of <i>current</i> is <b>true</b>, so any change is acceptable.</li>
  6867. </ol>
  6868. </li>
  6869. <li>Else <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>current</i>) and <a
  6870. href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) are both <b>true</b>,
  6871. <ol class="block">
  6872. <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
  6873. <ol class="block">
  6874. <li>Return <b>false</b>, if the [[Set]] field of <i>Desc</i> is present and <a
  6875. href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Set]], <i>current</i>.[[Set]]) is <b>false</b>.</li>
  6876. <li>Return <b>false</b>, if the [[Get]] field of <i>Desc</i> is present and <a
  6877. href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Get]], <i>current</i>.[[Get]]) is <b>false</b>.</li>
  6878. </ol>
  6879. </li>
  6880. </ol>
  6881. </li>
  6882. <li>If <i>O</i> is not <b>undefined</b>, then
  6883. <ol class="block">
  6884. <li>For each field of <i>Desc</i> that is present, set the corresponding attribute of the property named <i>P</i> of
  6885. object <i>O</i> to the value of the field.</li>
  6886. </ol>
  6887. </li>
  6888. <li>Return <b>true</b>.</li>
  6889. </ol>
  6890. <div class="note">
  6891. <p><span class="nh">NOTE</span> Step 8.b allows any field of Desc to be different from the corresponding field of
  6892. current if current&rsquo;s [[Configurable]] field is <b>true</b>. This even permits changing the [[Value]] of a property
  6893. whose [[Writable]] attribute is <b>false</b>. This is allowed because a <b>true</b> [[Configurable]] attribute would
  6894. permit an equivalent sequence of calls where [[Writable]] is first set to <b>true</b>, a new [[Value]] is set, and then
  6895. [[Writable]] is set to <b>false</b>.</p>
  6896. </div>
  6897. </section>
  6898. </section>
  6899. <section id="sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p">
  6900. <div class="front">
  6901. <h1><span class="secnum" id="sec-9.1.7"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p"
  6902. title="link to this section">9.1.7</a></span> [[HasProperty]](P)</h1>
  6903. <p>When the [[HasProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
  6904. <var>P</var>, the following steps are taken:</p>
  6905. <ol class="proc">
  6906. <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
  6907. </ol>
  6908. </div>
  6909. <section id="sec-ordinaryhasproperty">
  6910. <h1><span class="secnum" id="sec-9.1.7.1"><a href="#sec-ordinaryhasproperty"
  6911. title="link to this section">9.1.7.1</a></span> OrdinaryHasProperty (O, P)</h1>
  6912. <p>When the abstract operation OrdinaryHasProperty is called with Object <var>O</var> and with <a
  6913. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  6914. <ol class="proc">
  6915. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  6916. <b>true</b>.</li>
  6917. <li>Let <i>hasOwn</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
  6918. <li>If <i>hasOwn</i> is not <b>undefined</b>, return <b>true</b>.</li>
  6919. <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
  6920. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
  6921. <li>If <i>parent</i> is not <b>null</b>, then
  6922. <ol class="block">
  6923. <li>Return <i>parent</i>.[[HasProperty]](<i>P</i>).</li>
  6924. </ol>
  6925. </li>
  6926. <li>Return <b>false</b>.</li>
  6927. </ol>
  6928. </section>
  6929. </section>
  6930. <section id="sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">
  6931. <h1><span class="secnum" id="sec-9.1.8"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver"
  6932. title="link to this section">9.1.8</a></span> [[Get]] (P, Receiver)</h1>
  6933. <p>When the [[Get]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>
  6934. and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span> the following
  6935. steps are taken:</p>
  6936. <ol class="proc">
  6937. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  6938. <b>true</b>.</li>
  6939. <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
  6940. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
  6941. <li>If <i>desc</i> is <b>undefined</b>, then
  6942. <ol class="block">
  6943. <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
  6944. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
  6945. <li>If <i>parent</i> is <b>null</b>, return <b>undefined.</b></li>
  6946. <li>Return <i>parent</i>.[[Get]](<i>P</i>, <i>Receiver</i>).</li>
  6947. </ol>
  6948. </li>
  6949. <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>desc</i>) is <b>true</b>, return
  6950. <i>desc</i>.[[Value]].</li>
  6951. <li>Otherwise, <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>desc</i>) must be <b>true</b> so, let
  6952. <i>getter</i> be <i>desc</i>.[[Get]].</li>
  6953. <li>If <i>getter</i> is <b>undefined</b>, return <b>undefined</b>.</li>
  6954. <li>Return <a href="#sec-call">Call</a>(<i>getter,</i> <i>Receiver</i>).</li>
  6955. </ol>
  6956. </section>
  6957. <section id="sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver">
  6958. <h1><span class="secnum" id="sec-9.1.9"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver"
  6959. title="link to this section">9.1.9</a></span> [[Set]] ( P, V, Receiver)</h1>
  6960. <p>When the [[Set]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>,
  6961. value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
  6962. class="nt">Receiver</span>, the following steps are taken:</p>
  6963. <ol class="proc">
  6964. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  6965. <b>true</b>.</li>
  6966. <li>Let <i>ownDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
  6967. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ownDesc</i>).</li>
  6968. <li>If <i>ownDesc</i> is <b>undefined</b>, then
  6969. <ol class="block">
  6970. <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
  6971. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
  6972. <li>If <i>parent</i> is not <b>null</b>, then
  6973. <ol class="block">
  6974. <li>Return <i>parent</i>.[[Set]](<i>P</i>, <i>V</i>, <i>Receiver</i>).</li>
  6975. </ol>
  6976. </li>
  6977. <li>Else,
  6978. <ol class="block">
  6979. <li>Let <i>ownDesc</i> be the PropertyDescriptor{[[Value]]: <b>undefined</b>, [[Writable]]: <b>true</b>,
  6980. [[Enumerable]]: <b>true</b>, [[Configurable]]: <b>true</b>}.</li>
  6981. </ol>
  6982. </li>
  6983. </ol>
  6984. </li>
  6985. <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>ownDesc</i>) is <b>true</b>, then
  6986. <ol class="block">
  6987. <li>If <i>ownDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
  6988. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Receiver</i>) is not Object, return
  6989. <b>false</b>.</li>
  6990. <li>Let <i>existingDescriptor</i> be <i>Receiver</i>.[[GetOwnProperty]](<i>P</i>).</li>
  6991. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingDescriptor</i>).</li>
  6992. <li>If <i>existingDescriptor</i> is not <b>undefined</b>, then
  6993. <ol class="block">
  6994. <li>Let <i>valueDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>}.</li>
  6995. <li>Return <i>Receiver</i>.[[DefineOwnProperty]](<i>P</i>, <i>valueDesc</i>).</li>
  6996. </ol>
  6997. </li>
  6998. <li>Else <i>Receiver</i> does not currently have a property <i>P</i>,
  6999. <ol class="block">
  7000. <li>Return <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>Receiver</i>, <i>P</i>, <i>V</i>).</li>
  7001. </ol>
  7002. </li>
  7003. </ol>
  7004. </li>
  7005. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  7006. href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>ownDesc</i>) is <b>true</b>.</li>
  7007. <li>Let <i>setter</i> be <i>ownDesc</i>.[[Set]].</li>
  7008. <li>If <i>setter</i> is <b>undefined</b>, return <b>false</b>.</li>
  7009. <li>Let <i>setterResult</i> be <a href="#sec-call">Call</a>(<i>setter</i>, <i>Receiver</i>, &laquo;<i>V</i>&raquo;).</li>
  7010. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>setterResult</i>).</li>
  7011. <li>Return <b>true</b>.</li>
  7012. </ol>
  7013. </section>
  7014. <section id="sec-ordinary-object-internal-methods-and-internal-slots-delete-p">
  7015. <h1><span class="secnum" id="sec-9.1.10"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-delete-p"
  7016. title="link to this section">9.1.10</a></span> [[Delete]] (P)</h1>
  7017. <p>When the [[Delete]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
  7018. <var>P</var> the following steps are taken:</p>
  7019. <ol class="proc">
  7020. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  7021. <b>true</b>.</li>
  7022. <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
  7023. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
  7024. <li>If <i>desc</i> is <b>undefined</b>, return <b>true</b>.</li>
  7025. <li>If <i>desc</i>.[[Configurable]] is <b>true</b>, then
  7026. <ol class="block">
  7027. <li>Remove the own property with name <i>P</i> from <i>O</i>.</li>
  7028. <li>Return <b>true</b>.</li>
  7029. </ol>
  7030. </li>
  7031. <li>Return <b>false</b>.</li>
  7032. </ol>
  7033. </section>
  7034. <section id="sec-ordinary-object-internal-methods-and-internal-slots-enumerate">
  7035. <h1><span class="secnum" id="sec-9.1.11"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-enumerate"
  7036. title="link to this section">9.1.11</a></span> [[Enumerate]] ()</h1>
  7037. <p>When the [[Enumerate]] internal method of <var>O</var> is called the following steps are taken:</p>
  7038. <ol class="proc">
  7039. <li>Return an Iterator object (<a href="#sec-iterator-interface">25.1.1.2</a>) whose <code>next</code> method iterates
  7040. over all the String-valued keys of enumerable properties of <i>O</i>. The Iterator object must inherit from
  7041. %IteratorPrototype% (<a href="#sec-%iteratorprototype%-object">25.1.2</a>). The mechanics and order of enumerating the
  7042. properties is not specified but must conform to the rules specified below.</li>
  7043. </ol>
  7044. <p>The iterator&rsquo;s <code>next</code> method processes object properties to determine whether the <a
  7045. href="#sec-object-type">property key</a> should be returned as an iterator value. Returned property keys do not include keys
  7046. that are Symbols. Properties of the target object may be deleted during enumeration. A property that is deleted before it is
  7047. processed by the iterator&rsquo;s <code>next</code> method is ignored. If new properties are added to the target object
  7048. during enumeration, the newly added properties are not guaranteed to be processed in the active enumeration. A property name
  7049. will be returned by the iterator&rsquo;s <code>next</code> method at most once in any enumeration.</p>
  7050. <p>Enumerating the properties of the target object includes enumerating properties of its prototype, and the prototype of
  7051. the prototype, and so on, recursively; but a property of a prototype is not processed if it has the same name as a property
  7052. that has already been processed by the iterator&rsquo;s <code>next</code> method. The values of [[Enumerable]] attributes
  7053. are not considered when determining if a property of a prototype object has already been processed. The enumerable property
  7054. names of prototype objects must be obtained as if by invoking the prototype object&rsquo;s [[Enumerate]] internal method.
  7055. [[Enumerate]] must obtain the own property keys of the target object as if by calling its [[OwnPropertyKeys]] internal
  7056. method. Property attributes of the target object must be obtained as if by calling its [[GetOwnProperty]] internal
  7057. method.</p>
  7058. <p class="Note">NOTE The following is an informative definition of an ECMAScript generator function that conforms to these
  7059. rules:</p>
  7060. <pre>function* enumerate(obj) {</pre>
  7061. <pre>let visited=new Set;</pre>
  7062. <pre>for (let key of <a href="#sec-reflect.ownkeys">Reflect.ownKeys</a>(obj)) {</pre>
  7063. <pre>if (typeof key === "string") {</pre>
  7064. <pre>let desc = <a href="#sec-reflect.getownpropertydescriptor">Reflect.getOwnPropertyDescriptor</a>(obj,key);</pre>
  7065. <pre>if (desc) {</pre>
  7066. <pre>visited.add(key);</pre>
  7067. <pre>if (desc.enumerable) yield key;</pre>
  7068. <pre>}</pre>
  7069. <pre>}</pre>
  7070. <pre>}</pre>
  7071. <pre>let proto = <a href="#sec-reflect.getprototypeof">Reflect.getPrototypeOf</a>(obj)</pre>
  7072. <pre>if (proto === null) return;</pre>
  7073. <pre>for (let protoName of <a href="#sec-reflect.enumerate">Reflect.enumerate</a>(proto)) {</pre>
  7074. <pre>if (!visited.has(protoName)) yield protoName;</pre>
  7075. <pre>}</pre>
  7076. <pre>}</pre>
  7077. </section>
  7078. <section id="sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys">
  7079. <h1><span class="secnum" id="sec-9.1.12"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys"
  7080. title="link to this section">9.1.12</a></span> [[OwnPropertyKeys]] ( )</h1>
  7081. <p>When the [[OwnPropertyKeys]] internal method of <var>O</var> is called the following steps are taken:</p>
  7082. <ol class="proc">
  7083. <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  7084. <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> that is an integer index, in ascending
  7085. numeric index order
  7086. <ol class="block">
  7087. <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
  7088. </ol>
  7089. </li>
  7090. <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> that is a String but is not an integer
  7091. index, in property creation order
  7092. <ol class="block">
  7093. <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
  7094. </ol>
  7095. </li>
  7096. <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> that is a Symbol, in property creation
  7097. order
  7098. <ol class="block">
  7099. <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
  7100. </ol>
  7101. </li>
  7102. <li>Return <i>keys</i>.</li>
  7103. </ol>
  7104. </section>
  7105. <section id="sec-objectcreate">
  7106. <h1><span class="secnum" id="sec-9.1.13"><a href="#sec-objectcreate" title="link to this section">9.1.13</a></span>
  7107. ObjectCreate(proto, internalSlotsList)</h1>
  7108. <p>The abstract operation ObjectCreate with argument <var>proto</var> (an object or null) is used to specify the runtime
  7109. creation of new ordinary objects. The optional argument <var>internalSlotsList</var> is a <a
  7110. href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
  7111. part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
  7112. used. This abstract operation performs the following steps:</p>
  7113. <ol class="proc">
  7114. <li>If <i>internalSlotsList</i> was not provided, let <i>internalSlotsList</i> be an empty <a
  7115. href="#sec-list-and-record-specification-type">List</a>.</li>
  7116. <li>Let <i>obj</i> be a newly created object with an <a href="#sec-object-internal-methods-and-internal-slots">internal
  7117. slot</a> for each name in <i>internalSlotsList</i>.</li>
  7118. <li>Set <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
  7119. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
  7120. <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
  7121. <i>proto</i>.</li>
  7122. <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
  7123. <b>true</b>.</li>
  7124. <li>Return <i>obj</i>.</li>
  7125. </ol>
  7126. </section>
  7127. <section id="sec-ordinarycreatefromconstructor">
  7128. <h1><span class="secnum" id="sec-9.1.14"><a href="#sec-ordinarycreatefromconstructor"
  7129. title="link to this section">9.1.14</a></span> OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto,
  7130. internalSlotsList )</h1>
  7131. <p>The abstract operation OrdinaryCreateFromConstructor creates an ordinary object whose [[Prototype]] value is retrieved
  7132. from a constructor&rsquo;s <code>prototype</code> property, if it exists. Otherwise the intrinsic named by
  7133. <var>intrinsicDefaultProto</var> is used for [[Prototype]]. The optional <var>internalSlotsList</var> is a <a
  7134. href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
  7135. part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
  7136. used. This abstract operation performs the following steps:</p>
  7137. <ol class="proc">
  7138. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>intrinsicDefaultProto</i> is a string value that is this
  7139. specification&rsquo;s name of an intrinsic object. The corresponding object must be an intrinsic that is intended to
  7140. be used as the [[Prototype]] value of an object.</li>
  7141. <li>Let <i>proto</i> be <a href="#sec-getprototypefromconstructor">GetPrototypeFromConstructor</a>(<i>constructor</i>,
  7142. <i>intrinsicDefaultProto</i>).</li>
  7143. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
  7144. <li>Return <a href="#sec-objectcreate">ObjectCreate</a>(<i>proto</i>, <i>internalSlotsList</i>).</li>
  7145. </ol>
  7146. </section>
  7147. <section id="sec-getprototypefromconstructor">
  7148. <h1><span class="secnum" id="sec-9.1.15"><a href="#sec-getprototypefromconstructor"
  7149. title="link to this section">9.1.15</a></span> GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )</h1>
  7150. <p>The abstract operation GetPrototypeFromConstructor determines the [[Prototype]] value that should be used to create an
  7151. object corresponding to a specific constructor. The value is retrieved from the constructor&rsquo;s <code>prototype</code>
  7152. property, if it exists. Otherwise the intrinsic named by <var>intrinsicDefaultProto</var> is used for [[Prototype]]. This
  7153. abstract operation performs the following steps:</p>
  7154. <ol class="proc">
  7155. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>intrinsicDefaultProto</i> is a string value that is this
  7156. specification&rsquo;s name of an intrinsic object. The corresponding object must be an intrinsic that is intended to
  7157. be used as the [[Prototype]] value of an object.</li>
  7158. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>constructor</i>)
  7159. is <b>true</b>.</li>
  7160. <li>Let <i>proto</i> be <a href="#sec-get-o-p">Get</a>(<i>constructor</i>, <code>"prototype"</code>).</li>
  7161. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
  7162. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>proto</i>) is not Object, then
  7163. <ol class="block">
  7164. <li>Let <i>realm</i> be <a href="#sec-getfunctionrealm">GetFunctionRealm</a>(<i>constructor</i>).</li>
  7165. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>realm</i>).</li>
  7166. <li>Let <i>proto</i> be <i>realm&rsquo;s</i> intrinsic object named <i>intrinsicDefaultProto</i>.</li>
  7167. </ol>
  7168. </li>
  7169. <li>Return <i>proto</i>.</li>
  7170. </ol>
  7171. <div class="note">
  7172. <p><span class="nh">NOTE</span> If <i>constructor</i> does not supply a [[Prototype]] value, the default value that is
  7173. used is obtained from the <a href="#sec-code-realms">Code Realm</a> of the <i>constructor</i> function rather than from <a
  7174. href="#sec-execution-contexts">the running execution context</a>.</p>
  7175. </div>
  7176. </section>
  7177. </section>
  7178. <section id="sec-ecmascript-function-objects">
  7179. <div class="front">
  7180. <h1><span class="secnum" id="sec-9.2"><a href="#sec-ecmascript-function-objects" title="link to this section">9.2</a></span>
  7181. ECMAScript Function Objects</h1>
  7182. <p>ECMAScript function objects encapsulate parameterized ECMAScript code closed over a <a
  7183. href="#sec-lexical-environments">lexical environment</a> and support the dynamic evaluation of that code. An ECMAScript
  7184. function object is an ordinary object and has the same internal slots and the same internal methods as other ordinary
  7185. objects. The code of an ECMAScript function object may be either <a href="#sec-strict-mode-code">strict mode code</a> (<a
  7186. href="#sec-strict-mode-code">10.2.1</a>) or non-<a href="#sec-strict-mode-code">strict mode code</a>. An ECMAScript function
  7187. object whose code is <a href="#sec-strict-mode-code">strict mode code</a> is called a <i>strict function</i>. One whose code
  7188. is not <a href="#sec-strict-mode-code">strict mode code</a> is called a <i>non-strict function</i>.</p>
  7189. <p>ECMAScript function objects have the additional internal slots listed in <a href="#table-27">Table 27</a>.</p>
  7190. <figure>
  7191. <figcaption><span id="table-27">Table 27</span> &mdash; Internal Slots of ECMAScript Function Objects</figcaption>
  7192. <table class="real-table">
  7193. <tr>
  7194. <th>Internal Slot</th>
  7195. <th>Type</th>
  7196. <th>Description</th>
  7197. </tr>
  7198. <tr>
  7199. <td>[[Environment]]</td>
  7200. <td><a href="#sec-lexical-environments">Lexical Environment</a></td>
  7201. <td>The <a href="#sec-lexical-environments">Lexical Environment</a> that the function was closed over. Used as the outer environment when evaluating the code of the function.</td>
  7202. </tr>
  7203. <tr>
  7204. <td>[[FormalParameters]]</td>
  7205. <td>Parse Node</td>
  7206. <td>The root parse node of the source text that defines the function&rsquo;s formal parameter list.</td>
  7207. </tr>
  7208. <tr>
  7209. <td>[[FunctionKind]]</td>
  7210. <td>String</td>
  7211. <td>Either <code>"normal"</code>, <code>"classConstructor"</code> or <code>"generator"</code>.</td>
  7212. </tr>
  7213. <tr>
  7214. <td>[[ECMAScriptCode]]</td>
  7215. <td>Parse Node</td>
  7216. <td>The root parse node of the source text that defines the function&rsquo;s body.</td>
  7217. </tr>
  7218. <tr>
  7219. <td>[[ConstructorKind]]</td>
  7220. <td>String</td>
  7221. <td>Either <code>"base"</code> or <code>"derived"</code>.</td>
  7222. </tr>
  7223. <tr>
  7224. <td>[[Realm]]</td>
  7225. <td><a href="#sec-code-realms">Realm</a> Record</td>
  7226. <td>The <a href="#sec-code-realms">Code Realm</a> in which the function was created and which provides any intrinsic objects that are accessed when evaluating the function.</td>
  7227. </tr>
  7228. <tr>
  7229. <td>[[ThisMode]]</td>
  7230. <td>(lexical, strict, global)</td>
  7231. <td>Defines how <code>this</code> references are interpreted within the formal parameters and code body of the function. <b>lexical</b> means that <code>this</code> refers to the <b>this</b> value of a lexically enclosing function. <b>strict</b> means that the <b>this</b> value is used exactly as provided by an invocation of the function. <b>global</b> means that a <b>this</b> value of <span class="value">undefined</span> is interpreted as a reference to the global object.</td>
  7232. </tr>
  7233. <tr>
  7234. <td>[[Strict]]</td>
  7235. <td>Boolean</td>
  7236. <td><span class="value">true</span> if this is a strict mode function, <span class="value">false</span> if this is not a strict mode function.</td>
  7237. </tr>
  7238. <tr>
  7239. <td>[[HomeObject]]</td>
  7240. <td>Object</td>
  7241. <td>If the function uses <code>super</code>, this is the object whose [[GetPrototypeOf]] provides the object where <code>super</code> property lookups begin.</td>
  7242. </tr>
  7243. </table>
  7244. </figure>
  7245. <p>All ECMAScript function objects have the [[Call]] internal method defined here. ECMAScript functions that are also
  7246. constructors in addition have the [[Construct]] internal method. ECMAScript function objects whose code is not <a
  7247. href="#sec-strict-mode-code">strict mode code</a> have the [[GetOwnProperty]] internal method defined here.</p>
  7248. </div>
  7249. <section id="sec-ecmascript-function-objects-call-thisargument-argumentslist">
  7250. <div class="front">
  7251. <h1><span class="secnum" id="sec-9.2.1"><a href="#sec-ecmascript-function-objects-call-thisargument-argumentslist"
  7252. title="link to this section">9.2.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
  7253. <p>The [[Call]] internal method for an <a href="#sec-ecmascript-function-objects">ECMAScript function object</a>
  7254. <var>F</var> is called with parameters <var>thisArgument</var> and <var>argumentsList</var>, a <a
  7255. href="#sec-list-and-record-specification-type">List</a> of <a href="#sec-ecmascript-language-types">ECMAScript language
  7256. values</a>. The following steps are taken:</p>
  7257. <ol class="proc">
  7258. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a
  7259. href="#sec-ecmascript-function-objects">ECMAScript function object</a>.</li>
  7260. <li>If <i>F</i>&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is
  7261. <code>"classConstructor"</code>, throw a <b>TypeError</b> exception.</li>
  7262. <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
  7263. <li>Let <i>calleeContext</i> be <a href="#sec-prepareforordinarycall">PrepareForOrdinaryCall</a>(<i>F</i>,
  7264. <b>undefined</b>).</li>
  7265. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>calleeContext</i> is now <a href="#sec-execution-contexts">the
  7266. running execution context</a>.</li>
  7267. <li>Perform <a href="#sec-ordinarycallbindthis">OrdinaryCallBindThis</a>(<i>F</i>, <i>calleeContext</i>,
  7268. <i>thisArgument</i>).</li>
  7269. <li>Let <i>result</i> be <a href="#sec-ordinarycallevaluatebody">OrdinaryCallEvaluateBody</a>(<i>F</i>,
  7270. <i>argumentsList</i>).</li>
  7271. <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
  7272. <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
  7273. <li>If <i>result</i>.[[type]] is <span style="font-family: sans-serif">return</span>, return <a
  7274. href="#sec-normalcompletion">NormalCompletion</a>(<i>result</i>.[[value]]).</li>
  7275. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
  7276. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  7277. </ol>
  7278. <div class="note">
  7279. <p><span class="nh">NOTE</span> When <i>calleeContext</i> is removed from <a href="#sec-execution-contexts">the
  7280. execution context stack</a> in step 8 it must not be destroyed if it is <a href="#sec-execution-contexts">suspended</a>
  7281. and retained for later resumption by an accessible generator object<i>.</i></p>
  7282. </div>
  7283. </div>
  7284. <section id="sec-prepareforordinarycall">
  7285. <h1><span class="secnum" id="sec-9.2.1.1"><a href="#sec-prepareforordinarycall"
  7286. title="link to this section">9.2.1.1</a></span> PrepareForOrdinaryCall( F, newTarget )</h1>
  7287. <p>When the abstract operation PrepareForOrdinaryCall is called with function object <var>F</var> <span
  7288. style="font-family: Times New Roman">and <a href="#sec-ecmascript-language-types">ECMAScript language value</a>
  7289. <i>newTarget</i></span>, the following steps are taken:</p>
  7290. <ol class="proc">
  7291. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  7292. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Undefined or Object.</li>
  7293. <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
  7294. <li>Let <i>calleeContext</i> be a new <a href="#sec-execution-contexts">ECMAScript code execution context</a>.</li>
  7295. <li>Set the Function of <i>calleeContext</i> to <i>F</i>.</li>
  7296. <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
  7297. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  7298. <li>Set the <a href="#sec-code-realms">Realm</a> of <i>calleeContext</i> to <i>calleeRealm</i>.</li>
  7299. <li>Let <i>localEnv</i> be <a href="#sec-newfunctionenvironment">NewFunctionEnvironment</a>(<i>F</i>,
  7300. <i>newTarget</i>).</li>
  7301. <li>Set the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i> to <i>localEnv</i>.</li>
  7302. <li>Set the <a href="#sec-execution-contexts">VariableEnvironment</a> of <i>calleeContext</i> to <i>localEnv</i>.</li>
  7303. <li>If <i>callerContext</i> is not already <a href="#sec-execution-contexts">suspended</a>, <a
  7304. href="#sec-execution-contexts">Suspend</a> <i>callerContext</i>.</li>
  7305. <li>Push <i>calleeContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>;
  7306. <i>calleeContext</i> is now <a href="#sec-execution-contexts">the running execution context</a>.</li>
  7307. <li><span style="font-family: sans-serif">NOTE Any exception objects produced after this point are associated
  7308. with</span> <i>calleeRealm</i>.</li>
  7309. <li>Return <i>calleeContext</i>.</li>
  7310. </ol>
  7311. </section>
  7312. <section id="sec-ordinarycallbindthis">
  7313. <h1><span class="secnum" id="sec-9.2.1.2"><a href="#sec-ordinarycallbindthis"
  7314. title="link to this section">9.2.1.2</a></span> OrdinaryCallBindThis ( F, calleeContext, thisArgument )</h1>
  7315. <p>When the abstract operation OrdinaryCallBindThis is called with function object <var>F</var>, <a
  7316. href="#sec-execution-contexts">execution context</a> <var>calleeContext</var>, and ECMAScript value
  7317. <var>thisArgument</var> the following steps are taken:</p>
  7318. <ol class="proc">
  7319. <li>Let <i>thisMode</i> be the value of <i>F</i>&rsquo;s [[ThisMode]] <a
  7320. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  7321. <li>If <i>thisMode</i> is <span style="font-family: sans-serif">lexical</span>, return <a
  7322. href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  7323. <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
  7324. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  7325. <li>Let <i>localEnv</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i>.</li>
  7326. <li>If <i>thisMode</i> is <span style="font-family: sans-serif">strict</span>, let <i>thisValue</i> be
  7327. <i>thisArgument</i>.</li>
  7328. <li>Else
  7329. <ol class="block">
  7330. <li>if <i>thisArgument</i> is <b>null</b> or <b>undefined</b>, then
  7331. <ol class="block">
  7332. <li>Let <i>thisValue</i> be <i>calleeRealm</i>.[[globalThis]].</li>
  7333. </ol>
  7334. </li>
  7335. <li>Else
  7336. <ol class="block">
  7337. <li>Let <i>thisValue</i> be <a href="#sec-toobject">ToObject</a>(<i>thisArgument</i>).</li>
  7338. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>thisValue</i> is not an <a
  7339. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7340. <li><span style="font-family: sans-serif">NOTE <a href="#sec-toobject">ToObject</a> produces</span> <span
  7341. style="font-family: sans-serif">wrapper objects using</span> <i>calleeRealm</i>.</li>
  7342. </ol>
  7343. </li>
  7344. </ol>
  7345. </li>
  7346. <li>Let <i>envRec</i> be <i>localEnv</i>&rsquo;s EnvironmentRecord.</li>
  7347. <li><a href="#sec-algorithm-conventions">Assert</a>: The next step never returns an <a
  7348. href="#sec-completion-record-specification-type">abrupt completion</a> because <i>envRec</i>.[[thisBindingStatus]]
  7349. is <code>"uninitialized"</code>.</li>
  7350. <li>Return <i>envRec</i>.<a href="#sec-bindthisvalue">BindThisValue</a>(<i>thisValue</i>).</li>
  7351. </ol>
  7352. </section>
  7353. <section id="sec-ordinarycallevaluatebody">
  7354. <h1><span class="secnum" id="sec-9.2.1.3"><a href="#sec-ordinarycallevaluatebody"
  7355. title="link to this section">9.2.1.3</a></span> OrdinaryCallEvaluateBody ( F, argumentsList )</h1>
  7356. <p>When the abstract operation OrdinaryCallEvaluateBody is called with function object <var>F</var> and <a
  7357. href="#sec-list-and-record-specification-type">List</a> <var>argumentsList</var> the following steps are taken:</p>
  7358. <ol class="proc">
  7359. <li>Let <i>status</i> be <a href="#sec-functiondeclarationinstantiation">FunctionDeclarationInstantiation</a>(<i>F</i>,
  7360. <i>argumentsList</i>).</li>
  7361. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>)</li>
  7362. <li>Return the result of EvaluateBody of the parsed code that is the value of <i>F</i>'s [[ECMAScriptCode]] <a
  7363. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> passing <i>F</i> as the argument.</li>
  7364. </ol>
  7365. </section>
  7366. </section>
  7367. <section id="sec-ecmascript-function-objects-construct-argumentslist-newtarget">
  7368. <h1><span class="secnum" id="sec-9.2.2"><a href="#sec-ecmascript-function-objects-construct-argumentslist-newtarget"
  7369. title="link to this section">9.2.2</a></span> [[Construct]] ( argumentsList, newTarget)</h1>
  7370. <p>The [[Construct]] internal method for an <a href="#sec-ecmascript-function-objects">ECMAScript Function object</a>
  7371. <var>F</var> is called with parameters <var>argumentsList</var> and <span style="font-family: Times New
  7372. Roman"><i>newTarget</i>. <i>argumentsList</i></span> is a possibly empty <a
  7373. href="#sec-list-and-record-specification-type">List</a> of <a href="#sec-ecmascript-language-types">ECMAScript language
  7374. values</a>. The following steps are taken:</p>
  7375. <ol class="proc">
  7376. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
  7377. function object</a>.</li>
  7378. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  7379. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Object.</li>
  7380. <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
  7381. <li>Let <i>kind</i> be <i>F</i>&rsquo;s [[ConstructorKind]] <a
  7382. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  7383. <li>If <i>kind</i> is <code>"base"</code>, then
  7384. <ol class="block">
  7385. <li>Let <i>thisArgument</i> be <a
  7386. href="#sec-ordinarycreatefromconstructor">OrdinaryCreateFromConstructor</a>(<i>newTarget</i>,
  7387. <code>"%ObjectPrototype%"</code>).</li>
  7388. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>thisArgument</i>).</li>
  7389. </ol>
  7390. </li>
  7391. <li>Let <i>calleeContext</i> be <a href="#sec-prepareforordinarycall">PrepareForOrdinaryCall</a>(<i>F</i>,
  7392. <i>newTarget</i>).</li>
  7393. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>calleeContext</i> is now <a href="#sec-execution-contexts">the
  7394. running execution context</a>.</li>
  7395. <li>If <i>kind</i> is <code>"base"</code>, perform <a href="#sec-ordinarycallbindthis">OrdinaryCallBindThis</a>(<i>F</i>,
  7396. <i>calleeContext</i>, <i>thisArgument</i>).</li>
  7397. <li>Let <i>constructorEnv</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of
  7398. <i>calleeContext</i>.</li>
  7399. <li>Let <i>envRec</i> be <i>constructorEnv</i>&rsquo;s EnvironmentRecord.</li>
  7400. <li>Let <i>result</i> be <a href="#sec-ordinarycallevaluatebody">OrdinaryCallEvaluateBody</a>(<i>F</i>,
  7401. <i>argumentsList</i>).</li>
  7402. <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
  7403. <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
  7404. <li>If <i>result</i>.[[type]] is <span style="font-family: sans-serif">return</span>, then
  7405. <ol class="block">
  7406. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>.[[value]]) is Object, return <a
  7407. href="#sec-normalcompletion">NormalCompletion</a>(<i>result</i>.[[value]]).</li>
  7408. <li>If <i>kind</i> is <code>"base"</code>, return <a
  7409. href="#sec-normalcompletion">NormalCompletion</a>(<i>thisArgument</i>).</li>
  7410. <li>If <i>result</i>.[[value]] is not <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
  7411. </ol>
  7412. </li>
  7413. <li>Else, <a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
  7414. <li>Return <i>envRec</i>.GetThisBinding().</li>
  7415. </ol>
  7416. </section>
  7417. <section id="sec-functionallocate">
  7418. <h1><span class="secnum" id="sec-9.2.3"><a href="#sec-functionallocate" title="link to this section">9.2.3</a></span>
  7419. FunctionAllocate (functionPrototype, strict [,functionKind] )</h1>
  7420. <p>The abstract operation FunctionAllocate requires the two arguments <span style="font-family: Times New
  7421. Roman"><i>functionPrototype</i> and <i>strict</i>.</span> It also accepts one optional argument, <var>functionKind</var>.
  7422. FunctionAllocate performs the following steps:</p>
  7423. <ol class="proc">
  7424. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  7425. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>functionPrototype</i>) is Object.</li>
  7426. <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>functionKind</i> is present, its value is either
  7427. <code>"normal"</code>, <code>"non-constructor"</code> or <code>"generator"</code>.</li>
  7428. <li>If <i>functionKind</i> is not present, let <i>functionKind</i> be <code>"normal"</code>.</li>
  7429. <li>If <i>functionKind</i> is <code>"non-constructor"</code>, then
  7430. <ol class="block">
  7431. <li>Let <i>functionKind</i> be <code>"normal"</code>.</li>
  7432. <li>Let <i>needsConstruct</i> be <b>false</b>.</li>
  7433. </ol>
  7434. </li>
  7435. <li>Else let <i>needsConstruct</i> be <b>true</b>.</li>
  7436. <li>Let <i>F</i> be a newly created <a href="#sec-ecmascript-function-objects">ECMAScript function object</a> with the
  7437. internal slots listed in <a href="#table-27">Table 27</a>. All of those internal slots are initialized to
  7438. <b>undefined</b>.</li>
  7439. <li>Set <i>F</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
  7440. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
  7441. <li>Set <i>F</i>&rsquo;s [[Call]] internal method to the definition specified in <a
  7442. href="#sec-ecmascript-function-objects-call-thisargument-argumentslist">9.2.1</a>.</li>
  7443. <li>If <i>needsConstruct</i> is <b>true</b>, then
  7444. <ol class="block">
  7445. <li>Set <i>F</i>&rsquo;s [[Construct]] internal method to the definition specified in <a
  7446. href="#sec-ecmascript-function-objects-construct-argumentslist-newtarget">9.2.2</a>.</li>
  7447. <li>If <i>functionKind</i> is <code>"generator"</code>, set the [[ConstructorKind]] <a
  7448. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
  7449. <code>"derived"</code>.</li>
  7450. <li>Else, set the [[ConstructorKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
  7451. <i>F</i> to <code>"base"</code>.</li>
  7452. <li>NOTE Generator functions are tagged as <code>"derived"</code> constructors to prevent [[Construct]] from
  7453. preallocating a generator instance. Generator instance objects are allocated when EvaluateBody is applied to the
  7454. <span class="nt">GeneratorBody</span> of a generator function.</li>
  7455. </ol>
  7456. </li>
  7457. <li>Set the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
  7458. <i>strict</i>.</li>
  7459. <li>Set the [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
  7460. <i>functionKind</i>.</li>
  7461. <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
  7462. <i>functionPrototype</i>.</li>
  7463. <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
  7464. <b>true</b>.</li>
  7465. <li>Set the [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <a
  7466. href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a href="#sec-code-realms">Realm</a>.</li>
  7467. <li>Return <i>F</i>.</li>
  7468. </ol>
  7469. </section>
  7470. <section id="sec-functioninitialize">
  7471. <h1><span class="secnum" id="sec-9.2.4"><a href="#sec-functioninitialize" title="link to this section">9.2.4</a></span>
  7472. FunctionInitialize (F, kind, ParameterList, Body, Scope)</h1>
  7473. <p>The abstract operation FunctionInitialize requires the arguments: a function object <var>F</var>, <var>kind</var> which
  7474. is one of (Normal, Method, Arrow), a parameter list production specified by <span class="nt">ParameterList</span>, a body
  7475. production specified by <span class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a>
  7476. specified by <span style="font-family: Times New Roman"><i>Scope</i>.</span> FunctionInitialize performs the following
  7477. steps:</p>
  7478. <ol class="proc">
  7479. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
  7480. <code>length</code> own property.</li>
  7481. <li>Let <i>len</i> be the ExpectedArgumentCount of <i>ParameterList</i>.</li>
  7482. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"length"</code>,
  7483. PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
  7484. <b>true</b>}).</li>
  7485. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
  7486. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7487. <li>Let <i>Strict</i> be the value of the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  7488. slot</a> of <i>F</i>.</li>
  7489. <li>Set the [[Environment]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to the
  7490. value of <i>Scope</i>.</li>
  7491. <li>Set the [[FormalParameters]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i>
  7492. to <i>ParameterList</i> .</li>
  7493. <li>Set the [[ECMAScriptCode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
  7494. <i>Body</i>.</li>
  7495. <li>If <i>kind</i> is <span style="font-family: sans-serif">Arrow</span>, set the [[ThisMode]] <a
  7496. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <span style="font-family:
  7497. sans-serif">lexical</span>.</li>
  7498. <li>Else if <i>Strict</i> is <b>true</b>, set the [[ThisMode]] <a
  7499. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <span style="font-family:
  7500. sans-serif">strict</span>.</li>
  7501. <li>Else set the [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
  7502. <span style="font-family: sans-serif">global</span>.</li>
  7503. <li>Return <i>F</i>.</li>
  7504. </ol>
  7505. </section>
  7506. <section id="sec-functioncreate">
  7507. <h1><span class="secnum" id="sec-9.2.5"><a href="#sec-functioncreate" title="link to this section">9.2.5</a></span>
  7508. FunctionCreate (kind, ParameterList, Body, Scope, Strict, prototype)</h1>
  7509. <p>The abstract operation FunctionCreate requires the arguments: <var>kind</var> which is one of (Normal, Method, Arrow), a
  7510. parameter list production specified by <span class="nt">ParameterList</span>, a body production specified by <span
  7511. class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a> specified by <span
  7512. class="nt">Scope</span>, a Boolean flag <span class="nt">Strict</span>, and optionally, an object <span style="font-family:
  7513. Times New Roman"><i>prototype</i>.</span> FunctionCreate performs the following steps:</p>
  7514. <ol class="proc">
  7515. <li>If the <i>prototype</i> argument was not passed, then
  7516. <ol class="block">
  7517. <li>Let <i>prototype</i> be the intrinsic object %FunctionPrototype%.</li>
  7518. </ol>
  7519. </li>
  7520. <li>If <i>kind</i> is not <span style="font-family: sans-serif">Normal</span>, let <i>allocKind</i> be
  7521. <code>"non-constructor"</code>.</li>
  7522. <li>Else let <i>allocKind</i> be <code>"normal"</code>.</li>
  7523. <li>Let <i>F</i> be <a href="#sec-functionallocate">FunctionAllocate</a>(<i>prototype</i>, <i>Strict</i>,
  7524. <i>allocKind</i>).</li>
  7525. <li>Return <a href="#sec-functioninitialize">FunctionInitialize</a>(<i>F</i>, <i>kind</i>, <i>ParameterList</i>,
  7526. <i>Body</i>, <i>Scope</i>).</li>
  7527. </ol>
  7528. </section>
  7529. <section id="sec-generatorfunctioncreate">
  7530. <h1><span class="secnum" id="sec-9.2.6"><a href="#sec-generatorfunctioncreate" title="link to this section">9.2.6</a></span>
  7531. GeneratorFunctionCreate (kind, ParameterList, Body, Scope, Strict)</h1>
  7532. <p>The abstract operation GeneratorFunctionCreate requires the arguments: <var>kind</var> which is one of (Normal, Method),
  7533. a parameter list production specified by <span class="nt">ParameterList</span>, a body production specified by <span
  7534. class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a> specified by <span
  7535. class="nt">Scope</span>, and a Boolean flag <span class="nt">Strict</span>. GeneratorFunctionCreate performs the following
  7536. steps:</p>
  7537. <ol class="proc">
  7538. <li>Let <i>functionPrototype</i> be the intrinsic object %Generator%.</li>
  7539. <li>Let <i>F</i> be <a href="#sec-functionallocate">FunctionAllocate</a>(<i>functionPrototype</i>, <i>Strict</i>,
  7540. <code>"generator"</code>).</li>
  7541. <li>Return <a href="#sec-functioninitialize">FunctionInitialize</a>(<i>F</i>, <i>kind</i>, <i>ParameterList</i>,
  7542. <i>Body</i>, <i>Scope</i>).</li>
  7543. </ol>
  7544. </section>
  7545. <section id="sec-addrestrictedfunctionproperties">
  7546. <div class="front">
  7547. <h1><span class="secnum" id="sec-9.2.7"><a href="#sec-addrestrictedfunctionproperties"
  7548. title="link to this section">9.2.7</a></span> AddRestrictedFunctionProperties ( F, realm )</h1>
  7549. <p>The abstract operation AddRestrictedFunctionProperties is called with a function object <var>F</var> and <a
  7550. href="#sec-code-realms">Realm</a> Record <var>realm</var> as its argument. It performs the following steps:</p>
  7551. <ol class="proc">
  7552. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>realm</i>.[[intrinsics]].[[<span style="font-family:
  7553. sans-serif">%ThrowTypeError%]] exists and has been initialized.</span></li>
  7554. <li>Let <i>thrower</i> be <i>realm</i>.[[intrinsics]].[[<span style="font-family:
  7555. sans-serif">%ThrowTypeError%]].</span></li>
  7556. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"caller"</code>,
  7557. PropertyDescriptor {[[Get]]: <i>thrower</i>, [[Set]]: <i>thrower</i>, [[Enumerable]]: <b>false</b>,
  7558. [[Configurable]]: <b>true</b>}).</li>
  7559. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
  7560. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7561. <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i> , <code>"arguments"</code>,
  7562. PropertyDescriptor {[[Get]]: <i>thrower</i>, [[Set]]: <i>thrower</i>, [[Enumerable]]: <b>false</b>,
  7563. [[Configurable]]: <b>true</b>}).</li>
  7564. <li><a href="#sec-algorithm-conventions">Assert</a>: The above returned value is not an <a
  7565. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7566. </ol>
  7567. </div>
  7568. <section id="sec-%throwtypeerror%">
  7569. <h1><span class="secnum" id="sec-9.2.7.1"><a href="#sec-%throwtypeerror%" title="link to this section">9.2.7.1</a></span>
  7570. %ThrowTypeError% ( )</h1>
  7571. <p>The %ThrowTypeError% intrinsic is an anonymous built-in function object that is defined once for each <a
  7572. href="#sec-code-realms">Realm</a>. When %ThrowTypeError% is called it performs the following steps:</p>
  7573. <ol class="proc">
  7574. <li>Throw a <b>TypeError</b> exception.</li>
  7575. </ol>
  7576. <p>The value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of a
  7577. %ThrowTypeError% function is <span class="value">false</span>.</p>
  7578. <p>The <code>length</code> property of a %ThrowTypeError% function has the attributes {&nbsp;[[Writable]]: <b>false</b>,
  7579. [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b> }.</p>
  7580. </section>
  7581. </section>
  7582. <section id="sec-makeconstructor">
  7583. <h1><span class="secnum" id="sec-9.2.8"><a href="#sec-makeconstructor" title="link to this section">9.2.8</a></span>
  7584. MakeConstructor (F, writablePrototype, prototype)</h1>
  7585. <p>The abstract operation MakeConstructor requires a Function argument <var>F</var> and optionally, a Boolean
  7586. <var>writablePrototype</var> and an object <var>prototype</var>. If <var>prototype</var> is provided it is assumed to
  7587. already contain, if needed, a <code>"constructor"</code> property whose value is <var>F</var>. This operation converts
  7588. <var>F</var> into a constructor by performing the following steps:</p>
  7589. <ol class="proc">
  7590. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
  7591. function object</a>.</li>
  7592. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> has a [[Construct]] internal method.</li>
  7593. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
  7594. <code>prototype</code> own property.</li>
  7595. <li>Let <i>installNeeded</i> be <b>false</b>.</li>
  7596. <li>If the <i>prototype</i> argument was not provided, then
  7597. <ol class="block">
  7598. <li>Let <i>installNeeded</i> be <b>true</b>.</li>
  7599. <li>Let <i>prototype</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
  7600. sans-serif">%ObjectPrototype%</span>).</li>
  7601. </ol>
  7602. </li>
  7603. <li>If the <i>writablePrototype</i> argument was not provided, then
  7604. <ol class="block">
  7605. <li>Let <i>writablePrototype</i> be <b>true</b>.</li>
  7606. </ol>
  7607. </li>
  7608. <li>If <i>installNeeded</i>, then
  7609. <ol class="block">
  7610. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>prototype</i>,
  7611. <code>"constructor"</code>, PropertyDescriptor{[[Value]]: <i>F</i>, [[Writable]]: <i>writablePrototype</i>,
  7612. [[Enumerable]]: <b>false</b>, [[Configurable]]: <i>writablePrototype</i> }).</li>
  7613. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
  7614. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7615. </ol>
  7616. </li>
  7617. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>,
  7618. <code>"prototype"</code>, PropertyDescriptor{[[Value]]: <i>prototype</i>, [[Writable]]: <i>writablePrototype</i>,
  7619. [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b>}).</li>
  7620. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
  7621. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7622. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  7623. </ol>
  7624. </section>
  7625. <section id="sec-makeclassconstructor">
  7626. <h1><span class="secnum" id="sec-9.2.9"><a href="#sec-makeclassconstructor" title="link to this section">9.2.9</a></span>
  7627. MakeClassConstructor ( F)</h1>
  7628. <p>The abstract operation MakeClassConstructor with argument <var>F</var> performs the following steps:</p>
  7629. <ol class="proc">
  7630. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
  7631. function object</a>.</li>
  7632. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i>&rsquo;s [[FunctionKind]] <a
  7633. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is <code>"normal"</code>.</li>
  7634. <li>Set <i>F</i>&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
  7635. <code>"classConstructor"</code>.</li>
  7636. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  7637. </ol>
  7638. </section>
  7639. <section id="sec-makemethod">
  7640. <h1><span class="secnum" id="sec-9.2.10"><a href="#sec-makemethod" title="link to this section">9.2.10</a></span> MakeMethod
  7641. ( F, homeObject)</h1>
  7642. <p>The abstract operation MakeMethod with arguments <var>F</var> and <var>homeObject</var> configures <var>F</var> as a
  7643. method by performing the following steps:</p>
  7644. <ol class="proc">
  7645. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
  7646. function object</a>.</li>
  7647. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  7648. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>homeObject</i> ) is Object.</li>
  7649. <li>Set the [[HomeObject]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
  7650. <i>homeObject</i>.</li>
  7651. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  7652. </ol>
  7653. </section>
  7654. <section id="sec-setfunctionname">
  7655. <h1><span class="secnum" id="sec-9.2.11"><a href="#sec-setfunctionname" title="link to this section">9.2.11</a></span>
  7656. SetFunctionName (F, name, prefix)</h1>
  7657. <p>The abstract operation SetFunctionName requires a Function argument <var>F</var>, a String or Symbol argument
  7658. <var>name</var> and optionally a String argument <var>prefix</var>. This operation adds a <code>name</code> property to
  7659. <var>F</var> by performing the following steps:</p>
  7660. <ol class="proc">
  7661. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
  7662. <code>name</code> own property.</li>
  7663. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>)
  7664. is either Symbol or String.</li>
  7665. <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>prefix</i> was passed then <a
  7666. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>prefix</i>) is String.</li>
  7667. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>) is Symbol, then
  7668. <ol class="block">
  7669. <li>Let <i>description</i> be <i>name</i>&rsquo;s [[Description]] value.</li>
  7670. <li>If <i>description</i> is <b>undefined</b>, let <i>name</i> be the empty String.</li>
  7671. <li>Else, let <i>name</i> be the concatenation of <code>"["</code>, <i>description</i>, and <code>"]"</code>.</li>
  7672. </ol>
  7673. </li>
  7674. <li>If <i>prefix</i> was passed, then
  7675. <ol class="block">
  7676. <li>Let <i>name</i> be the concatenation of <i>prefix</i>, code unit 0x0020 (SPACE), and <i>name</i>.</li>
  7677. </ol>
  7678. </li>
  7679. <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"name"</code>,
  7680. PropertyDescriptor{[[Value]]: <i>name</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
  7681. <b>true</b>}).</li>
  7682. <li><a href="#sec-algorithm-conventions">Assert</a>: the result is never an <a
  7683. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7684. </ol>
  7685. </section>
  7686. <section id="sec-functiondeclarationinstantiation">
  7687. <h1><span class="secnum" id="sec-9.2.12"><a href="#sec-functiondeclarationinstantiation"
  7688. title="link to this section">9.2.12</a></span> FunctionDeclarationInstantiation(func, argumentsList)</h1>
  7689. <div class="note">
  7690. <p><span class="nh">NOTE</span> When an <a href="#sec-execution-contexts">execution context</a> is established for
  7691. evaluating an ECMAScript function a new function <a href="#sec-environment-records">Environment Record</a> is created and
  7692. bindings for each formal parameter are instantiated in that <a href="#sec-environment-records">Environment Record</a>.
  7693. Each declaration in the function body is also instantiated. If the function&rsquo;s formal parameters do not include any
  7694. default value initializers then the body declarations are instantiated in the same <a
  7695. href="#sec-environment-records">Environment Record</a> as the parameters. If default value parameter initializers exist, a
  7696. second <a href="#sec-environment-records">Environment Record</a> is created for the body declarations. Formal parameters
  7697. and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during
  7698. evaluation of the function body.</p>
  7699. </div>
  7700. <p>FunctionDeclarationInstantiation is performed as follows using arguments <var>func</var> and <var>argumentsList</var>.
  7701. <var>func</var> is the function object for which the <a href="#sec-execution-contexts">execution context</a> is being
  7702. established.</p>
  7703. <ol class="proc">
  7704. <li>Let <i>calleeContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
  7705. <li>Let <i>env</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i>.</li>
  7706. <li>Let <i>envRec</i> be <i>env</i>&rsquo;s <a href="#sec-environment-records">Environment Record</a>.</li>
  7707. <li>Let <i>code</i> be the value of the [[ECMAScriptCode]] <a
  7708. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i>.</li>
  7709. <li>Let <i>strict</i> be the value of the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal
  7710. slot</a> of <i>func</i>.</li>
  7711. <li>Let <i>formals</i> be the value of the [[FormalParameters]] <a
  7712. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i>.</li>
  7713. <li>Let <i>parameterNames</i> be the BoundNames of <i>formals</i>.</li>
  7714. <li>If <i>parameterNames</i> has any duplicate entries, let <i>hasDuplicates</i> be <b>true</b>. Otherwise, let
  7715. <i>hasDuplicates</i> be <b>false</b>.</li>
  7716. <li>Let <i>simpleParameterList</i> be IsSimpleParameterList of <i>formals</i>.</li>
  7717. <li>Let <i>hasParameterExpressions</i> be ContainsExpression of <i>formals.</i></li>
  7718. <li>Let <i>varNames</i> be the VarDeclaredNames of <i>code</i>.</li>
  7719. <li>Let <i>varDeclarations</i> be the VarScopedDeclarations of <i>code</i>.</li>
  7720. <li>Let <i>lexicalNames</i> be the LexicallyDeclaredNames of <i>code</i>.</li>
  7721. <li>Let <i>functionNames</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  7722. <li>Let <i>functionsToInitialize</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  7723. <li>For each <i>d</i> in <i>varDeclarations</i>, in reverse list order do
  7724. <ol class="block">
  7725. <li>If <i>d</i> is neither a <i>VariableDeclaration</i> or a <i>ForBinding</i>, then
  7726. <ol class="block">
  7727. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>d</i> is either a <i>FunctionDeclaration</i> or a
  7728. <i>GeneratorDeclaration</i>.</li>
  7729. <li>Let <i>fn</i> be the sole element of the BoundNames of <i>d.</i></li>
  7730. <li>If <i>fn</i> is not an element of <i>functionNames</i>, then
  7731. <ol class="block">
  7732. <li>Insert <i>fn</i> as the first element of <i>functionNames</i>.</li>
  7733. <li>NOTE If there are multiple <span style="font-family: Times New Roman"><i>FunctionDeclarations</i> or
  7734. <i>GeneratorDeclarations</i></span> for the same name, the last declaration is used.</li>
  7735. <li>Insert <i>d</i> as the first element of <i>functionsToInitialize</i>.</li>
  7736. </ol>
  7737. </li>
  7738. </ol>
  7739. </li>
  7740. </ol>
  7741. </li>
  7742. <li>Let <i>argumentsObjectNeeded</i> be <b>true</b>.</li>
  7743. <li>If the value of the [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
  7744. <i>func</i> is <span style="font-family: sans-serif">lexical</span>, then
  7745. <ol class="block">
  7746. <li>NOTE Arrow functions never have an arguments objects.</li>
  7747. <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
  7748. </ol>
  7749. </li>
  7750. <li>Else if <code>"arguments"</code> is an element of <i>parameterNames</i>, then
  7751. <ol class="block">
  7752. <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
  7753. </ol>
  7754. </li>
  7755. <li>Else if <i>hasParameterExpressions</i> is <b>false</b>, then
  7756. <ol class="block">
  7757. <li>If <code>"arguments"</code> is an element of <i>functionNames</i> or if <code>"arguments"</code> is an element of
  7758. <i>lexicalNames</i>, then
  7759. <ol class="block">
  7760. <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
  7761. </ol>
  7762. </li>
  7763. </ol>
  7764. </li>
  7765. <li>For each String <i>paramName</i> in <i>parameterNames</i>, do
  7766. <ol class="block">
  7767. <li>Let <i>alreadyDeclared</i> be <i>envRec</i>.HasBinding(<i>paramName</i>).</li>
  7768. <li>NOTE Early errors ensure that duplicate parameter names can only occur in non-strict functions that do not have
  7769. parameter default values or rest parameters.</li>
  7770. <li>If <i>alreadyDeclared</i> is <b>false</b>, then
  7771. <ol class="block">
  7772. <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<i>paramName</i>).</li>
  7773. <li>If <i>hasDuplicates</i> is <b>true</b>, then
  7774. <ol class="block">
  7775. <li>Let <i>status</i> be <i>envRec</i>.InitializeBinding(<i>paramName</i>, <b>undefined</b>).</li>
  7776. </ol>
  7777. </li>
  7778. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
  7779. href="#sec-completion-record-specification-type">abrupt completion</a> for either of the above
  7780. operations.</li>
  7781. </ol>
  7782. </li>
  7783. </ol>
  7784. </li>
  7785. <li>If <i>argumentsObjectNeeded</i> is <b>true</b>, then
  7786. <ol class="block">
  7787. <li>If <i>strict</i> is <b>true</b> or if <i>simpleParameterList</i> is <b>false</b>, then
  7788. <ol class="block">
  7789. <li>Let <i>ao</i> be <a
  7790. href="#sec-createunmappedargumentsobject">CreateUnmappedArgumentsObject</a>(<i>argumentsList</i>)<i>.</i></li>
  7791. </ol>
  7792. </li>
  7793. <li>Else,
  7794. <ol class="block">
  7795. <li>NOTE mapped argument object is only provided for non-strict functions that don&rsquo;t have a rest parameter,
  7796. any parameter default value initializers, or any destructured parameters .</li>
  7797. <li>Let <i>ao</i> be <a href="#sec-createmappedargumentsobject">CreateMappedArgumentsObject</a>(<i>func</i>,
  7798. <i>formals</i>, <i>argumentsList</i>, <i>env</i>).</li>
  7799. </ol>
  7800. </li>
  7801. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ao</i>).</li>
  7802. <li>If <i>strict</i> is <b>true</b>, then
  7803. <ol class="block">
  7804. <li>Let <i>status</i> be <i>envRec</i>.CreateImmutableBinding(<code>"arguments"</code>).</li>
  7805. </ol>
  7806. </li>
  7807. <li>Else,
  7808. <ol class="block">
  7809. <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<code>"arguments"</code>).</li>
  7810. </ol>
  7811. </li>
  7812. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
  7813. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7814. <li><a href="#sec-call">Call</a> <i>envRec</i>.InitializeBinding(<code>"arguments"</code>, <i>ao</i>).</li>
  7815. <li>Append <code>"arguments"</code> to <i>parameterNames</i>.</li>
  7816. </ol>
  7817. </li>
  7818. <li>Let <i>iteratorRecord</i> be Record {[[iterator]]: <a
  7819. href="#sec-createlistiterator">CreateListIterator</a>(<i>argumentsList</i>), [[done]]: <b>false</b>}.</li>
  7820. <li>If <i>hasDuplicates</i> is <b>true</b>, then
  7821. <ol class="block">
  7822. <li>Let <i>formalStatus</i> be IteratorBindingInitialization for <i>formals</i> with <i>iteratorRecord</i> and
  7823. <b>undefined</b> as arguments.</li>
  7824. </ol>
  7825. </li>
  7826. <li>Else,
  7827. <ol class="block">
  7828. <li>Let <i>formalStatus</i> be IteratorBindingInitialization for <i>formals</i> with <i>iteratorRecord</i> and
  7829. <i>envRec</i> as arguments.</li>
  7830. </ol>
  7831. </li>
  7832. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>formalStatus</i>).</li>
  7833. <li>If <i>hasParameterExpressions</i> is <b>false</b>, then
  7834. <ol class="block">
  7835. <li>NOTE Only a single <a href="#sec-lexical-environments">lexical environment</a> is needed for the parameters and
  7836. top-level vars.</li>
  7837. <li>Let <i>instantiatedVarNames</i> be a copy of the <a href="#sec-list-and-record-specification-type">List</a>
  7838. <i>parameterNames</i>.</li>
  7839. <li>For each <i>n</i> in <i>varNames</i>, do
  7840. <ol class="block">
  7841. <li>If <i>n</i> is not an element of <i>instantiatedVarNames</i>, then
  7842. <ol class="block">
  7843. <li>Append <i>n</i> to <i>instantiatedVarNames</i>.</li>
  7844. <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<i>n</i>).</li>
  7845. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
  7846. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7847. <li><a href="#sec-call">Call</a> <i>envRec</i>.InitializeBinding(<i>n</i>, <b>undefined</b>).</li>
  7848. </ol>
  7849. </li>
  7850. </ol>
  7851. </li>
  7852. <li>Let <i>varEnv</i> be <i>env</i>.</li>
  7853. <li>Let <i>varEnvRec</i> be <i>envRec</i>.</li>
  7854. </ol>
  7855. </li>
  7856. <li>Else,
  7857. <ol class="block">
  7858. <li>NOTE A separate <a href="#sec-environment-records">Environment Record</a> is needed to ensure that closures
  7859. created by expressions in the formal parameter list do not have visibility of declarations in the function
  7860. body.</li>
  7861. <li>Let <i>varEnv</i> be <a href="#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a>(<i>env</i>).</li>
  7862. <li>Let <i>varEnvRec</i> be <i>varEnv</i>&rsquo;s EnvironmentRecord.</li>
  7863. <li>Set the <a href="#sec-execution-contexts">VariableEnvironment</a> of <i>calleeContext</i> to <i>varEnv</i>.</li>
  7864. <li>Let <i>instantiatedVarNames</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  7865. <li>For each <i>n</i> in <i>varNames</i>, do
  7866. <ol class="block">
  7867. <li>If <i>n</i> is not an element of <i>instantiatedVarNames</i>, then
  7868. <ol class="block">
  7869. <li>Append <i>n</i> to <i>instantiatedVarNames</i>.</li>
  7870. <li>Let <i>status</i> be <i>varEnvRec</i>.CreateMutableBinding(<i>n</i>).</li>
  7871. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
  7872. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7873. <li>If <i>n</i> is not an element of <i>parameterNames</i> or if <i>n</i> is an element of
  7874. <i>functionNames</i>, let <i>initialValue</i> be <b>undefined</b>.</li>
  7875. <li>else,
  7876. <ol class="block">
  7877. <li>Let <i>initialValue</i> be <i>envRec.</i>GetBindingValue(<i>n</i>, <b>false</b>).</li>
  7878. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initialValue</i>).</li>
  7879. </ol>
  7880. </li>
  7881. <li><a href="#sec-call">Call</a> <i>varEnvRec</i>.InitializeBinding(<i>n</i>, <i>initialValue</i>).</li>
  7882. <li>NOTE vars whose names are the same as a formal parameter, initially have the same value as the
  7883. corresponding initialized parameter.</li>
  7884. </ol>
  7885. </li>
  7886. </ol>
  7887. </li>
  7888. </ol>
  7889. </li>
  7890. <li>NOTE: Annex <a href="#sec-block-level-function-declarations-web-legacy-compatibility-semantics">B.3.3</a> adds
  7891. additional steps at this point.</li>
  7892. <li>If <i>strict</i> is <b>false</b>, then
  7893. <ol class="block">
  7894. <li>Let <i>lexEnv</i> be <a href="#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a>(<i>varEnv</i>).</li>
  7895. <li>NOTE: Non-strict functions use a separate lexical <a href="#sec-environment-records">Environment Record</a> for
  7896. top-level lexical declarations so that a direct <code>eval</code> (<a
  7897. href="#sec-function-calls-runtime-semantics-evaluation">see 12.3.4.1</a>) can determine whether any var scoped
  7898. declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This
  7899. is not needed for strict functions because a strict direct <code>eval</code> always places all declarations into a
  7900. new <a href="#sec-environment-records">Environment Record</a>.</li>
  7901. </ol>
  7902. </li>
  7903. <li>Else, let <i>lexEnv</i> be <i>varEnv</i>.</li>
  7904. <li>Let <i>lexEnvRec</i> be <i>lexEnv</i>&rsquo;s EnvironmentRecord.</li>
  7905. <li>Set the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i> to <i>lexEnv</i>.</li>
  7906. <li>Let <i>lexDeclarations</i> be the LexicallyScopedDeclarations of <i>code</i>.</li>
  7907. <li>For each element <i>d</i> in <i>lexDeclarations</i> do
  7908. <ol class="block">
  7909. <li>NOTE A lexically declared name cannot be the same as a function/generator declaration, formal parameter, or a var
  7910. name. Lexically declared names are only instantiated here but not initialized.</li>
  7911. <li>For each element <i>dn</i> of the BoundNames of <i>d</i> do
  7912. <ol class="block">
  7913. <li>If IsConstantDeclaration of <i>d</i> is <b>true</b>, then
  7914. <ol class="block">
  7915. <li>Let <i>status</i> be <i>lexEnvRec</i>.CreateImmutableBinding(<i>dn</i>, <b>true</b>).</li>
  7916. </ol>
  7917. </li>
  7918. <li>Else,
  7919. <ol class="block">
  7920. <li>Let <i>status</i> be <i>lexEnvRec</i>.CreateMutableBinding(<i>dn</i>, <b>false</b>).</li>
  7921. </ol>
  7922. </li>
  7923. </ol>
  7924. </li>
  7925. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
  7926. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7927. </ol>
  7928. </li>
  7929. <li>For each parsed grammar phrase <i>f</i> in <i>functionsToInitialize</i>, do
  7930. <ol class="block">
  7931. <li>Let <i>fn</i> be the sole element of the BoundNames of <i>f.</i></li>
  7932. <li>Let <i>fo</i> be the result of performing InstantiateFunctionObject for <i>f</i> with argument <i>lexEnv</i>.</li>
  7933. <li>Let <i>status</i> be <i>varEnvRec</i>.SetMutableBinding(<i>fn</i>, <i>fo</i>, <b>false</b>).</li>
  7934. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
  7935. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  7936. </ol>
  7937. </li>
  7938. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>).</li>
  7939. </ol>
  7940. <div class="note">
  7941. <p><span class="nh">NOTE 1</span> <a
  7942. href="#sec-block-level-function-declarations-web-legacy-compatibility-semantics">B.3.3</a> provides an extension to the
  7943. above algorithm that is necessary for backwards compatibility with web browser implementations of ECMAScript that predate
  7944. the sixth edition of ECMA-262.</p>
  7945. </div>
  7946. <div class="note">
  7947. <p><span class="nh">NOTE 2</span> Parameter <i>Initializers</i> may contain direct eval expressions (<a
  7948. href="#sec-function-calls-runtime-semantics-evaluation">12.3.4.1</a>). Any top level declarations of such evals are only
  7949. visible to the eval code (<a href="#sec-types-of-source-code">10.2</a>). The creation of the environment for such
  7950. declarations is described in <a
  7951. href="#sec-function-definitions-runtime-semantics-iteratorbindinginitialization">14.1.18</a>.</p>
  7952. </div>
  7953. </section>
  7954. </section>
  7955. <section id="sec-built-in-function-objects">
  7956. <div class="front">
  7957. <h1><span class="secnum" id="sec-9.3"><a href="#sec-built-in-function-objects" title="link to this section">9.3</a></span>
  7958. Built-in Function Objects</h1>
  7959. <p>The built-in function objects defined in this specification may be implemented as either ECMAScript function objects (<a
  7960. href="#sec-ecmascript-function-objects">9.2</a>) whose behaviour is provided using ECMAScript code or as implementation
  7961. provided exotic function objects whose behaviour is provided in some other manner. In either case, the effect of calling
  7962. such functions must conform to their specifications. An implementation may also provide additional built-in function objects
  7963. that are not defined in this specification.</p>
  7964. <p>If a built-in function object is implemented as an exotic object it must have the ordinary object behaviour specified in
  7965. <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>. All such exotic function objects also have
  7966. [[Prototype]], [[Extensible]], and [[Realm]] internal slots.</p>
  7967. <p>Unless otherwise specified every built-in function object has the %FunctionPrototype% object (<a
  7968. href="#sec-properties-of-the-function-prototype-object">19.2.3</a>) as the initial value of its [[Prototype]] <a
  7969. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</p>
  7970. <p>The behaviour specified for each built-in function via algorithm steps or other means is the specification of the
  7971. function body behaviour for both [[Call]] and [[Construct]] invocations of the function. However, [[Construct]] invocation
  7972. is not supported by all built-in functions. For each built-in function, when invoked with [[Call]], the [[Call]]
  7973. <var>thisArgument</var> provides the <span class="value">this</span> value, the [[Call]] <var>argumentsList</var> provides
  7974. the named parameters, and the NewTarget value is <span class="value">undefined</span>. When invoked with [[Construct]], the
  7975. <span class="value">this</span> value is uninitialized, the [[Construct]] <var>argumentsList</var> provides the named
  7976. parameters, and the [[Construct]] <var>newTarget</var> parameter provides the NewTarget value. If the built-in function is
  7977. implemented as an <a href="#sec-ecmascript-function-objects">ECMAScript function object</a> then this specified behaviour
  7978. must be implemented by the ECMAScript code that is the body of the function. Built-in functions that are ECMAScript function
  7979. objects must be strict mode functions. If a built-in constructor has any [[Call]] behaviour other than throwing a <span
  7980. class="value">TypeError</span> exception, an ECMAScript implementation of the function must be done in a manner that does
  7981. not cause the function&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
  7982. to have the value <code>"classConstructor"</code>.</p>
  7983. <p>Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method
  7984. unless otherwise specified in the description of a particular function. When a built-in constructor is called as part of a
  7985. <code>new</code> expression the <var>argumentsList</var> parameter of the invoked [[Construct]] internal method provides the
  7986. values for the built-in constructor&rsquo;s named parameters.</p>
  7987. <p>Built-in functions that are not constructors do not have a <code>prototype</code> property unless otherwise specified in
  7988. the description of a particular function.</p>
  7989. <p>If a built-in function object is not implemented as an ECMAScript function it must provide [[Call]] and [[Construct]]
  7990. internal methods that conform to the following definitions:</p>
  7991. </div>
  7992. <section id="sec-built-in-function-objects-call-thisargument-argumentslist">
  7993. <h1><span class="secnum" id="sec-9.3.1"><a href="#sec-built-in-function-objects-call-thisargument-argumentslist"
  7994. title="link to this section">9.3.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
  7995. <p>The [[Call]] internal method for a built-in function object <var>F</var> is called with parameters
  7996. <var>thisArgument</var> and <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
  7997. href="#sec-ecmascript-language-types">ECMAScript language values</a>. The following steps are taken:</p>
  7998. <ol class="proc">
  7999. <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
  8000. <li>If <i>callerContext</i> is not already <a href="#sec-execution-contexts">suspended</a>, <a
  8001. href="#sec-execution-contexts">Suspend</a> <i>callerContext</i>.</li>
  8002. <li>Let <i>calleeContext</i> be a new <a href="#sec-execution-contexts">ECMAScript code execution context</a>.</li>
  8003. <li>Set the Function of <i>calleeContext</i> to <i>F</i>.</li>
  8004. <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
  8005. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8006. <li>Set the <a href="#sec-code-realms">Realm</a> of <i>calleeContext</i> to <i>calleeRealm</i>.</li>
  8007. <li>Perform any necessary implementation defined initialization of <i>calleeContext</i>.</li>
  8008. <li>Push <i>calleeContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>calleeContext</i>
  8009. is now <a href="#sec-execution-contexts">the running execution context</a>.</li>
  8010. <li>Let <i>result</i> be the <a href="#sec-completion-record-specification-type">Completion Record</a> that is the result
  8011. of evaluating <i>F</i> in an implementation defined manner that conforms to the specification of <i>F</i>.
  8012. <i>thisArgument</i> is the <b>this</b> value, <i>argumentsList</i> provides the named parameters, and the NewTarget
  8013. value is <b>undefined</b>.</li>
  8014. <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
  8015. <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
  8016. <li>Return <i>result</i>.</li>
  8017. </ol>
  8018. <div class="note">
  8019. <p><span class="nh">NOTE 1</span> When <i>calleeContext</i> is removed from <a href="#sec-execution-contexts">the
  8020. execution context stack</a> it must not be destroyed if it has been <a href="#sec-execution-contexts">suspended</a> and
  8021. retained by an accessible generator object for later resumption<i>.</i></p>
  8022. </div>
  8023. </section>
  8024. <section id="sec-built-in-function-objects-construct-argumentslist-newtarget">
  8025. <h1><span class="secnum" id="sec-9.3.2"><a href="#sec-built-in-function-objects-construct-argumentslist-newtarget"
  8026. title="link to this section">9.3.2</a></span> [[Construct]] (argumentsList, newTarget)</h1>
  8027. <p>The [[Construct]] internal method for built-in function object <var>F</var> is called with parameters
  8028. <var>argumentsList</var> and <var>newTarget</var>. The steps performed are the same as [[Call]] (<a
  8029. href="#sec-built-in-function-objects-call-thisargument-argumentslist">see 9.3.1</a>) except that step 9 is replaced by:</p>
  8030. <ol class="proc">
  8031. <li>Let <i>result</i> be the <a href="#sec-completion-record-specification-type">Completion Record</a> that is the result
  8032. of evaluating <i>F</i> in an implementation defined manner that conforms to the specification of <i>F</i>. The
  8033. <b>this</b> value is uninitialized, <i>argumentsList</i> provides the named parameters, and <i>newTarget</i> provides
  8034. the NewTarget value.</li>
  8035. </ol>
  8036. </section>
  8037. <section id="sec-createbuiltinfunction">
  8038. <h1><span class="secnum" id="sec-9.3.3"><a href="#sec-createbuiltinfunction" title="link to this section">9.3.3</a></span>
  8039. CreateBuiltinFunction(realm, steps, prototype, internalSlotsList)</h1>
  8040. <p>The abstract operation CreateBuiltinFunction takes arguments <span style="font-family: Times New Roman"><i>realm</i>,
  8041. <i>prototype</i>,</span> and <var>steps</var>. The optional argument <var>internalSlotsList</var> is a <a
  8042. href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
  8043. part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
  8044. used. CreateBuiltinFunction returns a built-in function object created by the following steps:</p>
  8045. <ol class="proc">
  8046. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>realm</i> is a <a href="#sec-code-realms">Realm</a> Record.</li>
  8047. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>steps</i> is either a set of algorithm steps or other definition
  8048. of a functions behaviour provided in this specification.</li>
  8049. <li>Let <i>func</i> be a new built-in function object that when called performs the action described by <i>steps</i>. The
  8050. new function object has internal slots whose names are the elements of <i>internalSlotsList</i>. The initial value of
  8051. each of those internal slots is <b>undefined<i>.</i></b></li>
  8052. <li>Set the [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i> to
  8053. <i>realm</i>.</li>
  8054. <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i> to
  8055. <i>prototype</i>.</li>
  8056. <li>Return <i>func</i>.</li>
  8057. </ol>
  8058. <p>Each built-in function defined in this specification is created as if by calling the CreateBuiltinFunction abstract
  8059. operation, unless otherwise specified.</p>
  8060. </section>
  8061. </section>
  8062. <section id="sec-built-in-exotic-object-internal-methods-and-slots">
  8063. <div class="front">
  8064. <h1><span class="secnum" id="sec-9.4"><a href="#sec-built-in-exotic-object-internal-methods-and-slots"
  8065. title="link to this section">9.4</a></span> Built-in Exotic Object Internal Methods and Slots</h1>
  8066. <p>This specification defines several kinds of built-in exotic objects. These objects generally behave similar to ordinary
  8067. objects except for a few specific situations. The following exotic objects use the ordinary object internal methods except
  8068. where it is explicitly specified otherwise below:</p>
  8069. </div>
  8070. <section id="sec-bound-function-exotic-objects">
  8071. <div class="front">
  8072. <h1><span class="secnum" id="sec-9.4.1"><a href="#sec-bound-function-exotic-objects"
  8073. title="link to this section">9.4.1</a></span> Bound Function Exotic Objects</h1>
  8074. <p>A <i>bound function</i> is an exotic object that wraps another function object. A bound function is callable (it has a
  8075. [[Call]] internal method and may have a [[Construct]] internal method). Calling a bound function generally results in a
  8076. call of its wrapped function.</p>
  8077. <p>Bound function objects do not have the internal slots of ECMAScript function objects defined in <a
  8078. href="#table-27">Table 27</a>. Instead they have the internal slots defined in <a href="#table-28">Table 28</a>.</p>
  8079. <figure>
  8080. <figcaption><span id="table-28">Table 28</span> &mdash; Internal Slots of Exotic Bound Function Objects</figcaption>
  8081. <table class="real-table">
  8082. <tr>
  8083. <th>Internal Slot</th>
  8084. <th>Type</th>
  8085. <th>Description</th>
  8086. </tr>
  8087. <tr>
  8088. <td>[[BoundTargetFunction]]</td>
  8089. <td>Callable Object</td>
  8090. <td>The wrapped function object.</td>
  8091. </tr>
  8092. <tr>
  8093. <td>[[BoundThis]]</td>
  8094. <td>Any</td>
  8095. <td>The value that is always passed as the <b>this</b> value when calling the wrapped function.</td>
  8096. </tr>
  8097. <tr>
  8098. <td>[[BoundArguments]]</td>
  8099. <td><a href="#sec-list-and-record-specification-type">List</a> of Any</td>
  8100. <td>A list of values whose elements are used as the first arguments to any call to the wrapped function.</td>
  8101. </tr>
  8102. </table>
  8103. </figure>
  8104. <p>Unlike ECMAScript function objects, bound function objects do not use an alternative definition of the
  8105. [[GetOwnProperty]] internal methods. Bound function objects provide all of the essential internal methods as specified in
  8106. <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>. However, they use the following definitions
  8107. for the essential internal methods of function objects.</p>
  8108. </div>
  8109. <section id="sec-bound-function-exotic-objects-call-thisargument-argumentslist">
  8110. <h1><span class="secnum" id="sec-9.4.1.1"><a href="#sec-bound-function-exotic-objects-call-thisargument-argumentslist"
  8111. title="link to this section">9.4.1.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
  8112. <p>When the [[Call]] internal method of an exotic <a href="#sec-bound-function-exotic-objects">bound function</a> object,
  8113. <var>F</var>, which was created using the bind function is called with parameters <var>thisArgument</var> and
  8114. <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
  8115. href="#sec-ecmascript-language-types">ECMAScript language values</a>, the following steps are taken:</p>
  8116. <ol class="proc">
  8117. <li>Let <i>target</i> be the value of <i>F&rsquo;s</i> <a
  8118. href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
  8119. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8120. <li>Let <i>boundThis</i> be the value of <i>F&rsquo;s</i> <a href="#sec-bound-function-exotic-objects">[[BoundThis]]</a>
  8121. <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8122. <li>Let <i>boundArgs</i> be the value of <i>F&rsquo;s</i> <a
  8123. href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
  8124. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8125. <li>Let <i>args</i> be a new list containing the same values as the list <i>boundArgs</i> in the same order followed by
  8126. the same values as the list <i>argumentsList</i> in the same order.</li>
  8127. <li>Return <a href="#sec-call">Call</a>(<i>target</i>, <i>boundThis</i>, <i>args</i>).</li>
  8128. </ol>
  8129. </section>
  8130. <section id="sec-bound-function-exotic-objects-construct-argumentslist-newtarget">
  8131. <h1><span class="secnum" id="sec-9.4.1.2"><a href="#sec-bound-function-exotic-objects-construct-argumentslist-newtarget"
  8132. title="link to this section">9.4.1.2</a></span> [[Construct]] (argumentsList, newTarget)</h1>
  8133. <p>When the [[Construct]] internal method of an exotic <a href="#sec-bound-function-exotic-objects">bound function</a>
  8134. object, <var>F</var> that was created using the bind function is called with a list of arguments <span style="font-family:
  8135. Times New Roman"><i>argumentsList</i> and <i>newTarget</i></span>, the following steps are taken:</p>
  8136. <ol class="proc">
  8137. <li>Let <i>target</i> be the value of <i>F&rsquo;s</i> <a
  8138. href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
  8139. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8140. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>target</i> has a [[Construct]] internal method.</li>
  8141. <li>Let <i>boundArgs</i> be the value of <i>F&rsquo;s</i> <a
  8142. href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
  8143. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8144. <li>Let <i>args</i> be a new list containing the same values as the list <i>boundArgs</i> in the same order followed by
  8145. the same values as the list <i>argumentsList</i> in the same order.</li>
  8146. <li>If <a href="#sec-samevalue">SameValue</a>(<i>F</i>, <i>newTarget</i>) is <b>true</b>, let <i>newTarget</i> be
  8147. <i>target</i>.</li>
  8148. <li>Return <a href="#sec-construct">Construct</a>(<i>target</i>, <i>args</i>, <i>newTarget</i>).</li>
  8149. </ol>
  8150. </section>
  8151. <section id="sec-boundfunctioncreate">
  8152. <h1><span class="secnum" id="sec-9.4.1.3"><a href="#sec-boundfunctioncreate"
  8153. title="link to this section">9.4.1.3</a></span> BoundFunctionCreate (targetFunction, boundThis, boundArgs)</h1>
  8154. <p>The abstract operation BoundFunctionCreate with arguments <var>targetFunction</var>, <var>boundThis</var> and
  8155. <var>boundArgs</var> is used to specify the creation of new <a href="#sec-bound-function-exotic-objects">Bound
  8156. Function</a> exotic objects. It performs the following steps:</p>
  8157. <ol class="proc">
  8158. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  8159. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>targetFunction</i>) is Object.</li>
  8160. <li>Let <i>proto</i> be <i>targetFunction</i>.[[GetPrototypeOf]]().</li>
  8161. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
  8162. <li>Let <i>obj</i> be a newly created object.</li>
  8163. <li>Set <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
  8164. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
  8165. <li>Set the [[Call]] internal method of <i>obj</i> as described in <a
  8166. href="#sec-bound-function-exotic-objects-call-thisargument-argumentslist">9.4.1.1</a>.</li>
  8167. <li>If <i>targetFunction</i> has a [[Construct]] internal method, then
  8168. <ol class="block">
  8169. <li>Set the [[Construct]] internal method of <i>obj</i> as described in <a
  8170. href="#sec-bound-function-exotic-objects-construct-argumentslist-newtarget">9.4.1.2</a>.</li>
  8171. </ol>
  8172. </li>
  8173. <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
  8174. <i>proto</i>.</li>
  8175. <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
  8176. <b>true</b>.</li>
  8177. <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
  8178. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
  8179. <i>targetFunction</i>.</li>
  8180. <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundThis]]</a> <a
  8181. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to the value of
  8182. <i>boundThis</i>.</li>
  8183. <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
  8184. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to <i>boundArgs</i>.</li>
  8185. <li>Return <i>obj</i>.</li>
  8186. </ol>
  8187. </section>
  8188. </section>
  8189. <section id="sec-array-exotic-objects">
  8190. <div class="front">
  8191. <h1><span class="secnum" id="sec-9.4.2"><a href="#sec-array-exotic-objects" title="link to this section">9.4.2</a></span>
  8192. Array Exotic Objects</h1>
  8193. <p>An <i>Array object</i> is an exotic object that gives special treatment to array index property keys (<a
  8194. href="#sec-object-type">see 6.1.7</a>). A property whose property name is an array index is also called an <i>element</i>.
  8195. Every Array object has a <code>length</code> property whose value is always a nonnegative integer less than <span
  8196. style="font-family: Times New Roman">2<sup>32</sup></span>. The value of the <code>length</code> property is numerically
  8197. greater than the name of every own property whose name is an array index; whenever an own property of an Array object is
  8198. created or changed, other properties are adjusted as necessary to maintain this invariant. Specifically, whenever an own
  8199. property is added whose name is an array index, the value of the <code>length</code> property is changed, if necessary, to
  8200. be one more than the numeric value of that array index; and whenever the value of the <code>length</code> property is
  8201. changed, every own property whose name is an array index whose value is not smaller than the new length is deleted. This
  8202. constraint applies only to own properties of an Array object and is unaffected by <code>length</code> or array index
  8203. properties that may be inherited from its prototypes.</p>
  8204. <div class="note">
  8205. <p><span class="nh">NOTE</span> A String property name <i>P</i> is an <i>array index</i> if and only if <a
  8206. href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>P</i>)) is equal to <i>P</i> and <a
  8207. href="#sec-touint32">ToUint32</a>(<i>P</i>) is not equal to 2<sup>32</sup>&minus;1.</p>
  8208. </div>
  8209. <p>Array exotic objects always have a non-configurable property named <code>"length"</code>.</p>
  8210. <p>Array exotic objects provide an alternative definition for the [[DefineOwnProperty]] internal method. Except for that
  8211. internal method, Array exotic objects provide all of the other essential internal methods as specified in <a
  8212. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
  8213. </div>
  8214. <section id="sec-array-exotic-objects-defineownproperty-p-desc">
  8215. <h1><span class="secnum" id="sec-9.4.2.1"><a href="#sec-array-exotic-objects-defineownproperty-p-desc"
  8216. title="link to this section">9.4.2.1</a></span> [[DefineOwnProperty]] ( P, Desc)</h1>
  8217. <p>When the [[DefineOwnProperty]] internal method of an <a href="#sec-array-exotic-objects">Array exotic object</a>
  8218. <var>A</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>, and <a
  8219. href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
  8220. steps are taken:</p>
  8221. <ol class="proc">
  8222. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  8223. <b>true</b>.</li>
  8224. <li>If <i>P</i> is <code>"length"</code>, then
  8225. <ol class="block">
  8226. <li>Return <a href="#sec-arraysetlength">ArraySetLength</a>(<i>A</i>, <i>Desc</i>).</li>
  8227. </ol>
  8228. </li>
  8229. <li>Else if <i>P</i> is an array index, then
  8230. <ol class="block">
  8231. <li>Let <i>oldLenDesc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>A</i>,
  8232. <code>"length"</code>).</li>
  8233. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>oldLenDesc</i> will never be <b>undefined</b> or an accessor
  8234. descriptor because Array objects are created with a length data property that cannot be deleted or
  8235. reconfigured.</li>
  8236. <li>Let <i>oldLen</i> be <i>oldLenDesc</i>.[[Value]].</li>
  8237. <li>Let <i>index</i> be <a href="#sec-touint32">ToUint32</a>(<i>P</i>).</li>
  8238. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>index</i> will never be an <a
  8239. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8240. <li>If <i>index</i> &ge; <i>oldLen</i> and <i>oldLenDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
  8241. <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
  8242. <i>P</i>, <i>Desc</i>).</li>
  8243. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
  8244. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8245. <li>If <i>succeeded</i> is <b>false</b>, return <b>false</b>.</li>
  8246. <li>If <i>index</i> &ge; <i>oldLen</i>
  8247. <ol class="block">
  8248. <li>Set <i>oldLenDesc</i>.[[Value]] to <i>index</i> + 1.</li>
  8249. <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
  8250. <code>"length"</code>, <i>oldLenDesc</i>).</li>
  8251. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is <b>true</b>.</li>
  8252. </ol>
  8253. </li>
  8254. <li>Return <b>true</b>.</li>
  8255. </ol>
  8256. </li>
  8257. <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <i>P</i>, <i>Desc</i>).</li>
  8258. </ol>
  8259. </section>
  8260. <section id="sec-arraycreate">
  8261. <h1><span class="secnum" id="sec-9.4.2.2"><a href="#sec-arraycreate" title="link to this section">9.4.2.2</a></span>
  8262. ArrayCreate(length, proto)</h1>
  8263. <p>The abstract operation ArrayCreate with argument <var>length</var> (a positive integer) and optional argument
  8264. <var>proto</var> is used to specify the creation of new Array exotic objects. It performs the following steps:</p>
  8265. <ol class="proc">
  8266. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>length</i> is an integer Number &ge; 0.</li>
  8267. <li>If <i>length</i> is &minus;0, let <i>length</i> be +0.</li>
  8268. <li>If <i>length</i>&gt;2<sup>32</sup>-1, throw a <b>RangeError</b> exception.</li>
  8269. <li>If the <i>proto</i> argument was not passed, let <i>proto</i> be the intrinsic object <span style="font-family:
  8270. sans-serif">%ArrayPrototype%</span>.</li>
  8271. <li>Let <i>A</i> be a newly created <a href="#sec-array-exotic-objects">Array exotic object</a>.</li>
  8272. <li>Set <i>A</i>&rsquo;s essential internal methods except for [[DefineOwnProperty]] to the default ordinary object
  8273. definitions specified in <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
  8274. <li>Set the [[DefineOwnProperty]] internal method of <i>A</i> as specified in <a
  8275. href="#sec-array-exotic-objects-defineownproperty-p-desc">9.4.2.1</a>.</li>
  8276. <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
  8277. <i>proto</i>.</li>
  8278. <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
  8279. <b>true</b>.</li>
  8280. <li>Perform <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
  8281. PropertyDescriptor{[[Value]]: <i>length</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
  8282. [[Configurable]]: <b>false</b>}).</li>
  8283. <li><a href="#sec-algorithm-conventions">Assert</a>: the preceding step never produces an <a
  8284. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8285. <li>Return <i>A</i>.</li>
  8286. </ol>
  8287. </section>
  8288. <section id="sec-arrayspeciescreate">
  8289. <h1><span class="secnum" id="sec-9.4.2.3"><a href="#sec-arrayspeciescreate"
  8290. title="link to this section">9.4.2.3</a></span> ArraySpeciesCreate(originalArray, length)</h1>
  8291. <p>The abstract operation ArraySpeciesCreate with arguments <var>originalArray</var> and <var>length</var> is used to
  8292. specify the creation of a new Array object using a constructor function that is derived from <var>originalArray</var>. It
  8293. performs the following steps:</p>
  8294. <ol class="proc">
  8295. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>length</i> is an integer Number &ge; 0.</li>
  8296. <li>If <i>length</i> is &minus;0, let <i>length</i> be +0.</li>
  8297. <li>Let <i>C</i> be <b>undefined</b>.</li>
  8298. <li>Let <i>isArray</i> be <a href="#sec-isarray">IsArray</a>(<i>originalArray</i>).</li>
  8299. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>isArray</i>).</li>
  8300. <li>If <i>isArray</i> is <b>true</b>, then
  8301. <ol class="block">
  8302. <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>originalArray</i>, <code>"constructor"</code>).</li>
  8303. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
  8304. <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>C</i>) is <b>true</b>, then
  8305. <ol class="block">
  8306. <li>Let <i>thisRealm</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
  8307. href="#sec-code-realms">Realm</a>.</li>
  8308. <li>Let <i>realmC</i> be <a href="#sec-getfunctionrealm">GetFunctionRealm</a>(<i>C</i>).</li>
  8309. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>realmC</i>).</li>
  8310. <li>If <i>thisRealm</i> and <i>realmC</i> are not the same <a href="#sec-code-realms">Realm</a> Record, then
  8311. <ol class="block">
  8312. <li>If <a href="#sec-samevalue">SameValue</a>(<i>C</i>, <i>realmC</i>.[[intrinsics]].[[%Array%]]) is
  8313. <b>true</b>, let <i>C</i> be <b>undefined</b>.</li>
  8314. </ol>
  8315. </li>
  8316. </ol>
  8317. </li>
  8318. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>C</i>) is Object, then
  8319. <ol class="block">
  8320. <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, @@species).</li>
  8321. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
  8322. <li>If <i>C</i> is <b>null</b>, let <i>C</i> be <b>undefined</b>.</li>
  8323. </ol>
  8324. </li>
  8325. </ol>
  8326. </li>
  8327. <li>If <i>C</i> is <b>undefined</b>, return <a href="#sec-arraycreate">ArrayCreate</a>(<i>length</i>).</li>
  8328. <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>C</i>) is <b>false</b>, throw a <b>TypeError</b>
  8329. exception<i>.</i></li>
  8330. <li>Return <a href="#sec-construct">Construct</a>(<i>C</i>, &laquo;<i>length</i>&raquo;).</li>
  8331. </ol>
  8332. <div class="note">
  8333. <p><span class="nh">NOTE</span> If <i>originalArray</i> was created using the standard built-in Array constructor for a
  8334. <a href="#sec-code-realms">Realm</a> that is not the <a href="#sec-code-realms">Realm</a> of <a
  8335. href="#sec-execution-contexts">the running execution context</a>, then a new Array is created using the <a
  8336. href="#sec-code-realms">Realm</a> of <a href="#sec-execution-contexts">the running execution context</a>. This maintains
  8337. compatibility with Web browsers that have historically had that behaviour for the Array.prototype methods that now are
  8338. defined using ArraySpeciesCreate.</p>
  8339. </div>
  8340. </section>
  8341. <section id="sec-arraysetlength">
  8342. <h1><span class="secnum" id="sec-9.4.2.4"><a href="#sec-arraysetlength" title="link to this section">9.4.2.4</a></span>
  8343. ArraySetLength(A, Desc)</h1>
  8344. <p>When the abstract operation ArraySetLength is called with an <a href="#sec-array-exotic-objects">Array exotic
  8345. object</a> <span style="font-family: Times New Roman"><i>A</i>,</span> and <a
  8346. href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
  8347. steps are taken:</p>
  8348. <ol class="proc">
  8349. <li>If the [[Value]] field of <i>Desc</i> is absent, then
  8350. <ol class="block">
  8351. <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
  8352. <i>Desc</i>).</li>
  8353. </ol>
  8354. </li>
  8355. <li>Let <i>newLenDesc</i> be a copy of <i>Desc</i>.</li>
  8356. <li>Let <i>newLen</i> be <a href="#sec-touint32">ToUint32</a>(<i>Desc</i>.[[Value]]).</li>
  8357. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newLen</i>).</li>
  8358. <li>Let <i>numberLen</i> be <a href="#sec-tonumber">ToNumber</a>(<i>Desc</i>.[[Value]]).</li>
  8359. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newLen</i>).</li>
  8360. <li>If <i>newLen</i> &ne; <i>numberLen</i>, throw a <b>RangeError</b> exception.</li>
  8361. <li>Set <i>newLenDesc</i>.[[Value]] to <i>newLen</i>.</li>
  8362. <li>Let <i>oldLenDesc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>A</i>,
  8363. <code>"length"</code>).</li>
  8364. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>oldLenDesc</i> will never be <b>undefined</b> or an accessor
  8365. descriptor because Array objects are created with a length data property that cannot be deleted or
  8366. reconfigured.</li>
  8367. <li>Let <i>oldLen</i> be <i>oldLenDesc</i>.[[Value]].</li>
  8368. <li>If <i>newLen</i> &ge;<i>oldLen</i>, then
  8369. <ol class="block">
  8370. <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
  8371. <i>newLenDesc</i>).</li>
  8372. </ol>
  8373. </li>
  8374. <li>If <i>oldLenDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
  8375. <li>If <i>newLenDesc</i>.[[Writable]] is absent or has the value <b>true</b>, let <i>newWritable</i> be
  8376. <b>true</b>.</li>
  8377. <li>Else,
  8378. <ol class="block">
  8379. <li>Need to defer setting the [[Writable]] attribute to <b>false</b> in case any elements cannot be deleted.</li>
  8380. <li>Let <i>newWritable</i> be <b>false</b>.</li>
  8381. <li>Set <i>newLenDesc</i>.[[Writable]] to <b>true</b>.</li>
  8382. </ol>
  8383. </li>
  8384. <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
  8385. <code>"length"</code>, <i>newLenDesc</i>).</li>
  8386. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
  8387. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8388. <li>If <i>succeeded</i> is <b>false</b>, return <b>false</b>.</li>
  8389. <li>While <i>newLen</i> &lt; <i>oldLen</i> repeat,
  8390. <ol class="block">
  8391. <li>Set <i>oldLen</i> to <i>oldLen</i> &ndash; 1.</li>
  8392. <li>Let <i>deleteSucceeded</i> be <i>A</i>.[[Delete]](<a href="#sec-tostring">ToString</a>(<i>oldLen</i>)).</li>
  8393. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>deleteSucceeded</i> is not an <a
  8394. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8395. <li>If <i>deleteSucceeded</i> is <b>false</b>, then
  8396. <ol class="block">
  8397. <li>Set <i>newLenDesc</i>.[[Value]] to <i>oldLen</i> <i>+</i> 1.</li>
  8398. <li>If <i>newWritable</i> is <b>false</b>, set <i>newLenDesc</i>.[[Writable]] to <b>false</b>.</li>
  8399. <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
  8400. <code>"length"</code>, <i>newLenDesc</i>).</li>
  8401. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
  8402. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8403. <li>Return <b>false</b>.</li>
  8404. </ol>
  8405. </li>
  8406. </ol>
  8407. </li>
  8408. <li>If <i>newWritable</i> is <b>false</b>, then
  8409. <ol class="block">
  8410. <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
  8411. PropertyDescriptor{[[Writable]]: <b>false</b>}). This call will always return <b>true</b>.</li>
  8412. </ol>
  8413. </li>
  8414. <li>Return <b>true</b>.</li>
  8415. </ol>
  8416. <div class="note">
  8417. <p><span class="nh">NOTE</span> In steps 3 and 4, if <i>Desc</i>.[[Value]] is an object then its <code>valueOf</code>
  8418. method is called twice. This is legacy behaviour that was specified with this effect starting with the 2<sup>nd</sup>
  8419. Edition of this specification.</p>
  8420. </div>
  8421. </section>
  8422. </section>
  8423. <section id="sec-string-exotic-objects">
  8424. <div class="front">
  8425. <h1><span class="secnum" id="sec-9.4.3"><a href="#sec-string-exotic-objects" title="link to this section">9.4.3</a></span>
  8426. String Exotic Objects</h1>
  8427. <p>A <i>String object</i> is an exotic object that encapsulates a String value and exposes virtual integer indexed data
  8428. properties corresponding to the individual code unit elements of the string value. Exotic String objects always have a
  8429. data property named <code>"length"</code> whose value is the number of code unit elements in the encapsulated String
  8430. value. Both the code unit data properties and the <code>"length"</code> property are non-writable and
  8431. non-configurable.</p>
  8432. <p>Exotic String objects have the same internal slots as ordinary objects. They also have a [[StringData]] internal
  8433. slot.</p>
  8434. <p>Exotic String objects provide alternative definitions for the following internal methods. All of the other exotic
  8435. String object essential internal methods that are not defined below are as specified in <a
  8436. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
  8437. </div>
  8438. <section id="sec-string-exotic-objects-getownproperty-p">
  8439. <div class="front">
  8440. <h1><span class="secnum" id="sec-9.4.3.1"><a href="#sec-string-exotic-objects-getownproperty-p"
  8441. title="link to this section">9.4.3.1</a></span> [[GetOwnProperty]] ( P )</h1>
  8442. <p>When the [[GetOwnProperty]] internal method of an exotic String object <var>S</var> is called with <a
  8443. href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
  8444. <ol class="proc">
  8445. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  8446. <b>true</b>.</li>
  8447. <li>Let <i>desc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>S</i>, <i>P</i>).</li>
  8448. <li>If <i>desc</i> is not <b>undefined</b> return <i>desc</i>.</li>
  8449. <li>Return <a href="#sec-stringgetindexproperty">StringGetIndexProperty</a>(<i>S</i>, <i>P</i>).</li>
  8450. </ol>
  8451. </div>
  8452. <section id="sec-stringgetindexproperty">
  8453. <h1><span class="secnum" id="sec-9.4.3.1.1"><a href="#sec-stringgetindexproperty"
  8454. title="link to this section">9.4.3.1.1</a></span> StringGetIndexProperty (S, P)</h1>
  8455. <p>When the abstract operation StringGetIndexProperty is called with an exotic String object <var>S</var> and with <a
  8456. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  8457. <ol class="proc">
  8458. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is not String, return <b>undefined</b>.</li>
  8459. <li>Let <i>index</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a> (<i>P</i>).</li>
  8460. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>index</i> is not an <a
  8461. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8462. <li>If <i>index</i> is <b>undefined</b>, return <b>undefined</b>.</li>
  8463. <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>undefined</b>.</li>
  8464. <li>If <i>index</i> = &minus;0, return <b>undefined</b>.</li>
  8465. <li>Let <i>str</i> be the String value of the [[StringData]] <a
  8466. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i>.</li>
  8467. <li>Let <i>len</i> be the number of elements in <i>str</i>.</li>
  8468. <li>If <i>index</i> &lt; 0 or <i>len</i> &le; <i>index</i>, return <b>undefined</b>.</li>
  8469. <li>Let <i>resultStr</i> be a String value of length 1, containing one code unit from <i>str</i>, specifically the
  8470. code unit at index <i>index</i>.</li>
  8471. <li>Return a PropertyDescriptor{ [[Value]]: <i>resultStr</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>,
  8472. [[Configurable]]: <b>false</b> }.</li>
  8473. </ol>
  8474. </section>
  8475. </section>
  8476. <section id="sec-string-exotic-objects-hasproperty-p">
  8477. <h1><span class="secnum" id="sec-9.4.3.2"><a href="#sec-string-exotic-objects-hasproperty-p"
  8478. title="link to this section">9.4.3.2</a></span> [[HasProperty]](P)</h1>
  8479. <p>When the [[HasProperty]] internal method of an exotic String object <var>S</var> is called with <a
  8480. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  8481. <ol class="proc">
  8482. <li>Let <i>elementDesc</i> be <a href="#sec-stringgetindexproperty">StringGetIndexProperty</a>(<i>S</i>, <i>P</i>).</li>
  8483. <li>If <i>elementDesc</i> is not <b>undefined</b>, return <b>true</b>.</li>
  8484. <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>S</i>, <i>P</i>)..</li>
  8485. </ol>
  8486. </section>
  8487. <section id="sec-string-exotic-objects-ownpropertykeys">
  8488. <h1><span class="secnum" id="sec-9.4.3.3"><a href="#sec-string-exotic-objects-ownpropertykeys"
  8489. title="link to this section">9.4.3.3</a></span> [[OwnPropertyKeys]] ( )</h1>
  8490. <p>When the [[OwnPropertyKeys]] internal method of a <a href="#sec-string-exotic-objects">String exotic object</a>
  8491. <var>O</var> is called the following steps are taken:</p>
  8492. <ol class="proc">
  8493. <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  8494. <li>Let <i>str</i> be the String value of the [[StringData]] <a
  8495. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  8496. <li>Let <i>len</i> be the number of elements in <i>str</i>.</li>
  8497. <li>For each integer <i>i</i> starting with 0 such that <i>i</i> &lt; <i>len</i>, in ascending order,
  8498. <ol class="block">
  8499. <li>Add <a href="#sec-tostring">ToString</a>(<i>i</i>) as the last element of <i>keys</i></li>
  8500. </ol>
  8501. </li>
  8502. <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <i>P</i> is an integer index
  8503. and <a href="#sec-tointeger">ToInteger</a>(<i>P</i>) &ge; <i>len</i>, in ascending numeric index order,
  8504. <ol class="block">
  8505. <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
  8506. </ol>
  8507. </li>
  8508. <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
  8509. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and <i>P</i> is not an integer index, in
  8510. property creation order,
  8511. <ol class="block">
  8512. <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
  8513. </ol>
  8514. </li>
  8515. <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
  8516. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, in property creation order,
  8517. <ol class="block">
  8518. <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
  8519. </ol>
  8520. </li>
  8521. <li>Return <i>keys</i>.</li>
  8522. </ol>
  8523. </section>
  8524. <section id="sec-stringcreate">
  8525. <h1><span class="secnum" id="sec-9.4.3.4"><a href="#sec-stringcreate" title="link to this section">9.4.3.4</a></span>
  8526. StringCreate( value, prototype)</h1>
  8527. <p>The abstract operation StringCreate with arguments <var>value</var> and <var>prototype</var> is used to specify the
  8528. creation of new exotic String objects. It performs the following steps:</p>
  8529. <ol class="proc">
  8530. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>prototype</i>).</li>
  8531. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  8532. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>value</i>) is String.</li>
  8533. <li>Let <i>S</i> be a newly created <a href="#sec-string-exotic-objects">String exotic object</a>.</li>
  8534. <li>Set the [[StringData]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
  8535. <i>value</i>.</li>
  8536. <li>Set <i>S</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
  8537. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
  8538. <li>Set the [[GetOwnProperty]] internal method of <i>S</i> as specified in <a
  8539. href="#sec-string-exotic-objects-getownproperty-p">9.4.3.1</a>.</li>
  8540. <li>Set the [[HasProperty]] internal method of <i>S</i> as specified in <a
  8541. href="#sec-string-exotic-objects-hasproperty-p">9.4.3.2</a>.</li>
  8542. <li>Set the [[OwnPropertyKeys]] internal method of <i>S</i> as specified in <a
  8543. href="#sec-string-exotic-objects-ownpropertykeys">9.4.3.3</a>.</li>
  8544. <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
  8545. <i>prototype</i>.</li>
  8546. <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
  8547. <b>true</b>.</li>
  8548. <li>Let <i>length</i> be the number of code unit elements in <i>value.</i></li>
  8549. <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>S</i>, <code>"length"</code>,
  8550. PropertyDescriptor{[[Value]]: <i>length</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>,
  8551. [[Configurable]]: <b>false</b> }).</li>
  8552. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
  8553. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8554. <li>Return <i>S</i>.</li>
  8555. </ol>
  8556. </section>
  8557. </section>
  8558. <section id="sec-arguments-exotic-objects">
  8559. <div class="front">
  8560. <h1><span class="secnum" id="sec-9.4.4"><a href="#sec-arguments-exotic-objects"
  8561. title="link to this section">9.4.4</a></span> Arguments Exotic Objects</h1>
  8562. <p>Most ECMAScript functions make an arguments objects available to their code. Depending upon the characteristics of the
  8563. function definition, its argument object is either an ordinary object or an <i>arguments exotic object</i>. An arguments
  8564. exotic object is an exotic object whose array index properties map to the formal parameters bindings of an invocation of
  8565. its associated ECMAScript function.</p>
  8566. <p>Arguments exotic objects have the same internal slots as ordinary objects. They also have a [[ParameterMap]] internal
  8567. slot. Ordinary arguments objects also have a [[ParameterMap]] internal slot whose value is always undefined. For ordinary
  8568. argument objects the [[ParameterMap]] internal slot is only used by <code><a
  8569. href="#sec-object.prototype.tostring">Object.prototype.toString</a></code> (<a
  8570. href="#sec-object.prototype.tostring">19.1.3.6</a>) to identify them as such.</p>
  8571. <p>Arguments exotic objects provide alternative definitions for the following internal methods. All of the other exotic
  8572. arguments object essential internal methods that are not defined below are as specified in <a
  8573. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a></p>
  8574. <div class="note">
  8575. <p><span class="nh">NOTE 1</span> For non-strict functions the integer indexed data properties of an arguments object
  8576. whose numeric name values are less than the number of formal parameters of the corresponding function object initially
  8577. share their values with the corresponding argument bindings in the function&rsquo;s <a
  8578. href="#sec-execution-contexts">execution context</a>. This means that changing the property changes the corresponding
  8579. value of the argument binding and vice-versa. This correspondence is broken if such a property is deleted and then
  8580. redefined or if the property is changed into an accessor property. For strict mode functions, the values of the
  8581. arguments object&rsquo;s properties are simply a copy of the arguments passed to the function and there is no dynamic
  8582. linkage between the property values and the formal parameter values.</p>
  8583. </div>
  8584. <div class="note">
  8585. <p><span class="nh">NOTE 2</span> The ParameterMap object and its property values are used as a device for specifying
  8586. the arguments object correspondence to argument bindings. The ParameterMap object and the objects that are the values of
  8587. its properties are not directly observable from ECMAScript code. An ECMAScript implementation does not need to actually
  8588. create or use such objects to implement the specified semantics.</p>
  8589. </div>
  8590. <div class="note">
  8591. <p><span class="nh">NOTE 3</span> Arguments objects for strict mode functions define non-configurable accessor
  8592. properties named <code>"caller"</code> and <code>"callee"</code> which throw a <b>TypeError</b> exception on access. The
  8593. <code>"callee"</code> property has a more specific meaning for non-strict functions and a <code>"caller"</code> property
  8594. has historically been provided as an implementation-defined extension by some ECMAScript implementations. The strict
  8595. mode definition of these properties exists to ensure that neither of them is defined in any other manner by conforming
  8596. ECMAScript implementations.</p>
  8597. </div>
  8598. </div>
  8599. <section id="sec-arguments-exotic-objects-getownproperty-p">
  8600. <h1><span class="secnum" id="sec-9.4.4.1"><a href="#sec-arguments-exotic-objects-getownproperty-p"
  8601. title="link to this section">9.4.4.1</a></span> [[GetOwnProperty]] (P)</h1>
  8602. <p>The [[GetOwnProperty]] internal method of an arguments exotic object when called with a <a
  8603. href="#sec-object-type">property key</a> <var>P</var> performs the following steps:</p>
  8604. <ol class="proc">
  8605. <li>Let <i>args</i> be the arguments object.</li>
  8606. <li>Let <i>desc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>args</i>, <i>P</i>).</li>
  8607. <li>If <i>desc</i> is <b>undefined</b>, return <i>desc</i>.</li>
  8608. <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
  8609. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
  8610. <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
  8611. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is never an <a
  8612. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8613. <li>If the value of <i>isMapped</i> is <b>true</b>, then
  8614. <ol class="block">
  8615. <li>Set <i>desc</i>.[[Value]] to <a href="#sec-get-o-p">Get</a>(<i>map</i>, <i>P</i>).</li>
  8616. </ol>
  8617. </li>
  8618. <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>desc</i>) is <b>true</b> and <i>P</i> is
  8619. <code>"caller"</code> and <i>desc</i>.[[Value]] is a strict mode Function object, throw a <b>TypeError</b>
  8620. exception.</li>
  8621. <li>Return <i>desc</i>.</li>
  8622. </ol>
  8623. <p>If an implementation does not provide a built-in <code>caller</code> property for argument exotic objects then step 8
  8624. of this algorithm is must be skipped.</p>
  8625. </section>
  8626. <section id="sec-arguments-exotic-objects-defineownproperty-p-desc">
  8627. <h1><span class="secnum" id="sec-9.4.4.2"><a href="#sec-arguments-exotic-objects-defineownproperty-p-desc"
  8628. title="link to this section">9.4.4.2</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
  8629. <p>The [[DefineOwnProperty]] internal method of an arguments exotic object when called with a <a
  8630. href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
  8631. Descriptor</a> <span class="nt">Desc</span> performs the following steps:</p>
  8632. <ol class="proc">
  8633. <li>Let <i>args</i> be the arguments object.</li>
  8634. <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
  8635. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
  8636. <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
  8637. <li>Let <i>allowed</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>args</i>, <i>P</i>,
  8638. <i>Desc</i>).</li>
  8639. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>allowed</i>).</li>
  8640. <li>If <i>allowed</i> is <b>false</b>, return <b>false</b>.</li>
  8641. <li>If the value of <i>isMapped</i> is <b>true</b>, then
  8642. <ol class="block">
  8643. <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
  8644. <ol class="block">
  8645. <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
  8646. </ol>
  8647. </li>
  8648. <li>Else
  8649. <ol class="block">
  8650. <li>If <i>Desc</i>.[[Value]] is present, then
  8651. <ol class="block">
  8652. <li>Let <i>setStatus</i> be <a href="#sec-set-o-p-v-throw">Set</a>(<i>map</i>, <i>P</i>,
  8653. <i>Desc</i>.[[Value]], <b>false</b>).</li>
  8654. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>setStatus</i> is <b>true</b> because formal
  8655. parameters mapped by argument objects are always writable.</li>
  8656. </ol>
  8657. </li>
  8658. <li>If <i>Desc</i>.[[Writable]] is present and its value is <b>false</b>, then
  8659. <ol class="block">
  8660. <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
  8661. </ol>
  8662. </li>
  8663. </ol>
  8664. </li>
  8665. </ol>
  8666. </li>
  8667. <li>Return <b>true</b>.</li>
  8668. </ol>
  8669. </section>
  8670. <section id="sec-arguments-exotic-objects-get-p-receiver">
  8671. <h1><span class="secnum" id="sec-9.4.4.3"><a href="#sec-arguments-exotic-objects-get-p-receiver"
  8672. title="link to this section">9.4.4.3</a></span> [[Get]] (P, Receiver)</h1>
  8673. <p>The [[Get]] internal method of an arguments exotic object when called with a <a href="#sec-object-type">property
  8674. key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
  8675. class="nt">Receiver</span> performs the following steps:</p>
  8676. <ol class="proc">
  8677. <li>Let <i>args</i> be the arguments object.</li>
  8678. <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
  8679. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
  8680. <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
  8681. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
  8682. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8683. <li>If the value of <i>isMapped</i> is <b>false</b>, then
  8684. <ol class="block">
  8685. <li>Let <i>v</i> be the result of calling the default ordinary object [[Get]] internal method (<a
  8686. href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>args</i> passing
  8687. <i>P</i> and <i>Receiver</i> as the arguments.</li>
  8688. </ol>
  8689. </li>
  8690. <li>Else <i>map</i> contains a formal parameter mapping for <i>P</i>,
  8691. <ol class="block">
  8692. <li>Let <i>v</i> be <a href="#sec-get-o-p">Get</a>(<i>map</i>, <i>P</i>).</li>
  8693. </ol>
  8694. </li>
  8695. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>v</i>).</li>
  8696. <li>Return <i>v</i>.</li>
  8697. </ol>
  8698. </section>
  8699. <section id="sec-arguments-exotic-objects-set-p-v-receiver">
  8700. <h1><span class="secnum" id="sec-9.4.4.4"><a href="#sec-arguments-exotic-objects-set-p-v-receiver"
  8701. title="link to this section">9.4.4.4</a></span> [[Set]] ( P, V, Receiver)</h1>
  8702. <p>The [[Set]] internal method of an arguments exotic object when called with <a href="#sec-object-type">property key</a>
  8703. <var>P</var>, value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
  8704. class="nt">Receiver</span> performs the following steps:</p>
  8705. <ol class="proc">
  8706. <li>Let <i>args</i> be the arguments object.</li>
  8707. <li>If <a href="#sec-samevalue">SameValue</a>(<i>args</i>, <i>Receiver</i>) is <b>false</b>, then
  8708. <ol class="block">
  8709. <li>Let <i>isMapped</i> be <b>false</b>.</li>
  8710. </ol>
  8711. </li>
  8712. <li>Else,
  8713. <ol class="block">
  8714. <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
  8715. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
  8716. <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
  8717. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
  8718. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8719. </ol>
  8720. </li>
  8721. <li>If the value of <i>isMapped</i> is <b>false</b>, then
  8722. <ol class="block">
  8723. <li>Return the result of calling the default ordinary object [[Set]] internal method (<a
  8724. href="#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver">9.1.9</a>) on <i>args</i>
  8725. passing <i>P</i>, <i>V</i> and <i>Receiver</i> as the arguments.</li>
  8726. </ol>
  8727. </li>
  8728. <li>Else <i>map</i> contains a formal parameter mapping for <i>P</i>,
  8729. <ol class="block">
  8730. <li>Return <a href="#sec-set-o-p-v-throw">Set</a>(<i>map</i>, <i>P</i>, <i>V</i>, <b>false</b>).</li>
  8731. </ol>
  8732. </li>
  8733. </ol>
  8734. </section>
  8735. <section id="sec-arguments-exotic-objects-delete-p">
  8736. <h1><span class="secnum" id="sec-9.4.4.5"><a href="#sec-arguments-exotic-objects-delete-p"
  8737. title="link to this section">9.4.4.5</a></span> [[Delete]] (P)</h1>
  8738. <p>The [[Delete]] internal method of an arguments exotic object when called with a <a href="#sec-object-type">property
  8739. key</a> <var>P</var> performs the following steps:</p>
  8740. <ol class="proc">
  8741. <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
  8742. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
  8743. <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
  8744. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
  8745. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8746. <li>Let <i>result</i> be the result of calling the default [[Delete]] internal method for ordinary objects (<a
  8747. href="#sec-ordinary-object-internal-methods-and-internal-slots-delete-p">9.1.10</a>) on the arguments object passing
  8748. <i>P</i> as the argument.</li>
  8749. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
  8750. <li>If <i>result</i> is <b>true</b> and the value of <i>isMapped</i> is <b>true</b>, then
  8751. <ol class="block">
  8752. <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
  8753. </ol>
  8754. </li>
  8755. <li>Return <i>result</i>.</li>
  8756. </ol>
  8757. </section>
  8758. <section id="sec-createunmappedargumentsobject">
  8759. <h1><span class="secnum" id="sec-9.4.4.6"><a href="#sec-createunmappedargumentsobject"
  8760. title="link to this section">9.4.4.6</a></span> CreateUnmappedArgumentsObject(argumentsList)</h1>
  8761. <p>The abstract operation <span style="font-family: Times New Roman">CreateUnmappedArgumentsObject</span> called with an
  8762. argument <var>argumentsList</var> performs the following steps:</p>
  8763. <ol class="proc">
  8764. <li>Let <i>len</i> be the number of elements in <i>argumentsList</i>.</li>
  8765. <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%ObjectPrototype%,
  8766. &laquo;&zwj;[[ParameterMap]]&raquo;).</li>
  8767. <li>Set <i>obj</i>&rsquo;s [[ParameterMap]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
  8768. to <b>undefined</b>.</li>
  8769. <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"length"</code>,
  8770. PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
  8771. <b>true</b>}).</li>
  8772. <li>Let <i>index</i> be 0.</li>
  8773. <li>Repeat while <i>index</i> &lt; <i>len</i>,
  8774. <ol class="block">
  8775. <li>Let <i>val</i> be <i>argumentsList</i>[<i>index</i>].</li>
  8776. <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <a
  8777. href="#sec-tostring">ToString</a>(<i>index</i>), <i>val</i>).</li>
  8778. <li>Let <i>index</i> be <i>index</i> + 1</li>
  8779. </ol>
  8780. </li>
  8781. <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, @@iterator, PropertyDescriptor
  8782. {[[Value]]:%ArrayProto_values%, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
  8783. <b>true</b>}).</li>
  8784. <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"caller"</code>,
  8785. PropertyDescriptor {[[Get]]: <a href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Set]]: <a
  8786. href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
  8787. <b>false</b>}).</li>
  8788. <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"callee"</code>,
  8789. PropertyDescriptor {[[Get]]: <a href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Set]]: <a
  8790. href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
  8791. <b>false</b>}).</li>
  8792. <li><a href="#sec-algorithm-conventions">Assert</a>: the above property definitions will not produce an <a
  8793. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8794. <li>Return <i>obj</i></li>
  8795. </ol>
  8796. </section>
  8797. <section id="sec-createmappedargumentsobject">
  8798. <div class="front">
  8799. <h1><span class="secnum" id="sec-9.4.4.7"><a href="#sec-createmappedargumentsobject"
  8800. title="link to this section">9.4.4.7</a></span> CreateMappedArgumentsObject ( func, formals, argumentsList, env
  8801. )</h1>
  8802. <p>The abstract operation <span style="font-family: Times New Roman">CreateMappedArgumentsObject</span> is called with
  8803. object <var>func</var>, parsed grammar phrase <var>formals</var>, <a
  8804. href="#sec-list-and-record-specification-type">List</a> <var>argumentsList</var>, and <a
  8805. href="#sec-environment-records">Environment Record</a> <span style="font-family: Times New Roman"><i>env</i>.</span> The
  8806. following steps are performed:</p>
  8807. <ol class="proc">
  8808. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>formals</i> does not contain a rest parameter, any binding
  8809. patterns, or any initializers. It may contain duplicate identifiers.</li>
  8810. <li>Let <i>len</i> be the number of elements in <i>argumentsList</i>.</li>
  8811. <li>Let <i>obj</i> be a newly created arguments exotic object with a [[ParameterMap]] <a
  8812. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8813. <li>Set the [[GetOwnProperty]] internal method of <i>obj</i> as specified in <a
  8814. href="#sec-arguments-exotic-objects-getownproperty-p">9.4.4.1</a>.</li>
  8815. <li>Set the [[DefineOwnProperty]] internal method of <i>obj</i> as specified in <a
  8816. href="#sec-arguments-exotic-objects-defineownproperty-p-desc">9.4.4.2</a>.</li>
  8817. <li>Set the [[Get]] internal method of <i>obj</i> as specified in <a
  8818. href="#sec-arguments-exotic-objects-get-p-receiver">9.4.4.3</a>.</li>
  8819. <li>Set the [[Set]] internal method of <i>obj</i> as specified in <a
  8820. href="#sec-arguments-exotic-objects-set-p-v-receiver">9.4.4.4</a>.</li>
  8821. <li>Set the [[Delete]] internal method of <i>obj</i> as specified in <a
  8822. href="#sec-arguments-exotic-objects-delete-p">9.4.4.5</a>.</li>
  8823. <li>Set the remainder of <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions
  8824. specified in <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
  8825. <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
  8826. %ObjectPrototype%.</li>
  8827. <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i>
  8828. to <b>true</b>.</li>
  8829. <li>Let <i>parameterNames</i> be the BoundNames of <i>formals</i>.</li>
  8830. <li>Let <i>numberOfParameters</i> be the number of elements in <i>parameterNames</i></li>
  8831. <li>Let <i>index</i> be 0.</li>
  8832. <li>Repeat while <i>index</i> &lt; <i>len</i> ,
  8833. <ol class="block">
  8834. <li>Let <i>val</i> be <i>argumentsList</i>[<i>index</i>].</li>
  8835. <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <a
  8836. href="#sec-tostring">ToString</a>(<i>index</i>), <i>val</i>).</li>
  8837. <li>Let <i>index</i> be <i>index</i> + 1</li>
  8838. </ol>
  8839. </li>
  8840. <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"length"</code>,
  8841. PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
  8842. [[Configurable]]: <b>true</b>}).</li>
  8843. <li>Let <i>map</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<b>null</b>).</li>
  8844. <li>Let <i>mappedNames</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  8845. <li>Let <i>index</i> be <i>numberOfParameters</i> &minus; 1.</li>
  8846. <li>Repeat while <i>index</i> &ge; 0 ,
  8847. <ol class="block">
  8848. <li>Let <i>name</i> be <i>parameterNames</i>[<i>index</i>].</li>
  8849. <li>If <i>name</i> is not an element of <i>mappedNames</i>, then
  8850. <ol class="block">
  8851. <li>Add <i>name</i> as an element of the list <i>mappedNames</i>.</li>
  8852. <li>If <i>index</i> &lt; <i>len</i>, then
  8853. <ol class="block">
  8854. <li>Let <i>g</i> be <a href="#sec-makearggetter">MakeArgGetter</a>(<i>name</i>, <i>env</i>).</li>
  8855. <li>Let <i>p</i> be <a href="#sec-makeargsetter">MakeArgSetter</a>(<i>name</i>, <i>env</i>).</li>
  8856. <li><a href="#sec-call">Call</a> <i>map</i>.[[DefineOwnProperty]](<a
  8857. href="#sec-tostring">ToString</a>(<i>index</i>), PropertyDescriptor{[[Set]]: <i>p</i>, [[Get]]:
  8858. <i>g,</i> [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>true</b>}).</li>
  8859. </ol>
  8860. </li>
  8861. </ol>
  8862. </li>
  8863. <li>Let <i>index</i> be <i>index</i> &minus; 1</li>
  8864. </ol>
  8865. </li>
  8866. <li>Set the [[ParameterMap]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i>
  8867. to <i>map</i>.</li>
  8868. <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, @@iterator, PropertyDescriptor
  8869. {[[Value]]:%ArrayProto_values%, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
  8870. <b>true</b>}).</li>
  8871. <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"callee"</code>,
  8872. PropertyDescriptor {[[Value]]: <i>func</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
  8873. [[Configurable]]: <b>true</b>}).</li>
  8874. <li><a href="#sec-algorithm-conventions">Assert</a>: the above property definitions will not produce an <a
  8875. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8876. <li>Return <i>obj</i></li>
  8877. </ol>
  8878. </div>
  8879. <section id="sec-makearggetter">
  8880. <h1><span class="secnum" id="sec-9.4.4.7.1"><a href="#sec-makearggetter"
  8881. title="link to this section">9.4.4.7.1</a></span> MakeArgGetter ( name, env)</h1>
  8882. <p>The abstract operation <span style="font-family: Times New Roman">MakeArgGetter</span> called with String
  8883. <var>name</var> and <a href="#sec-environment-records">Environment Record</a> <var>env</var> creates a built-in function
  8884. object that when executed returns the value bound for <var>name</var> in <var>env</var>. It performs the following
  8885. steps:</p>
  8886. <ol class="proc">
  8887. <li>Let <i>realm</i> be <a href="#sec-execution-contexts">the current Realm</a>.</li>
  8888. <li>Let <i>steps</i> be the steps of an ArgGetter function as specified below.</li>
  8889. <li>Let <i>getter</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realm</i>, <i>steps</i>,
  8890. %FunctionPrototype%, &laquo;&zwj;[[name]], [[env]]&raquo; ).</li>
  8891. <li>Set <i>getter&rsquo;s</i> [[name]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
  8892. <i>name</i>.</li>
  8893. <li>Set <i>getter&rsquo;s</i> [[env]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
  8894. <i>env</i>.</li>
  8895. <li>Return <i>getter</i>.</li>
  8896. </ol>
  8897. <p>An ArgGetter function is an anonymous built-in function with [[name]] and [[env]] internal slots. When an ArgGetter
  8898. function <var>f</var> that expects no arguments is called it performs the following steps:</p>
  8899. <ol class="proc">
  8900. <li>Let <i>name</i> be the value of <i>f&rsquo;s</i> [[name]] <a
  8901. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8902. <li>Let <i>env</i> be the value of <i>f&rsquo;s</i> [[env]] <a
  8903. href="#sec-object-internal-methods-and-internal-slots">internal slot</a></li>
  8904. <li>Return <i>env</i>.GetBindingValue(<i>name</i>, <b>false</b>).</li>
  8905. </ol>
  8906. <div class="note">
  8907. <p><span class="nh">NOTE</span> ArgGetter functions are never directly accessible to ECMAScript code.</p>
  8908. </div>
  8909. </section>
  8910. <section id="sec-makeargsetter">
  8911. <h1><span class="secnum" id="sec-9.4.4.7.2"><a href="#sec-makeargsetter"
  8912. title="link to this section">9.4.4.7.2</a></span> MakeArgSetter ( name, env)</h1>
  8913. <p>The abstract operation <span style="font-family: Times New Roman">MakeArgSetter</span> called with String
  8914. <var>name</var> and <a href="#sec-environment-records">Environment Record</a> <var>env</var> creates a built-in function
  8915. object that when executed sets the value bound for <var>name</var> in <var>env</var>. It performs the following
  8916. steps:</p>
  8917. <ol class="proc">
  8918. <li>Let <i>realm</i> be <a href="#sec-execution-contexts">the current Realm</a>.</li>
  8919. <li>Let <i>steps</i> be the steps of an ArgSetter function as specified below.</li>
  8920. <li>Let <i>setter</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realm</i>, <i>steps</i>,
  8921. %FunctionPrototype%, &laquo;&zwj;[[name]], [[env]]&raquo; ).</li>
  8922. <li>Set <i>setter&rsquo;s</i> [[name]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
  8923. <i>name</i>.</li>
  8924. <li>Set <i>setter&rsquo;s</i> [[env]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
  8925. <i>env</i>.</li>
  8926. <li>Return <i>setter</i>.</li>
  8927. </ol>
  8928. <p>An ArgSetter function is an anonymous built-in function with [[name]] and [[env]] internal slots. When an ArgSetter
  8929. function <var>f</var> is called with argument <var>value</var> it performs the following steps:</p>
  8930. <ol class="proc">
  8931. <li>Let <i>name</i> be the value of <i>f&rsquo;s</i> [[name]] <a
  8932. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8933. <li>Let <i>env</i> be the value of <i>f&rsquo;s</i> [[env]] <a
  8934. href="#sec-object-internal-methods-and-internal-slots">internal slot</a></li>
  8935. <li>Return <i>env</i>.SetMutableBinding(<i>name</i>, <i>value</i>, <b>false</b>).</li>
  8936. </ol>
  8937. <div class="note">
  8938. <p><span class="nh">NOTE</span> ArgSetter functions are never directly accessible to ECMAScript code.</p>
  8939. </div>
  8940. </section>
  8941. </section>
  8942. </section>
  8943. <section id="sec-integer-indexed-exotic-objects">
  8944. <div class="front">
  8945. <h1><span class="secnum" id="sec-9.4.5"><a href="#sec-integer-indexed-exotic-objects"
  8946. title="link to this section">9.4.5</a></span> Integer Indexed Exotic Objects</h1>
  8947. <p>An <i>Integer Indexed object</i> is an exotic object that performs special handling of integer index property keys.</p>
  8948. <p>Integer Indexed exotic objects have the same internal slots as ordinary objects additionally [[ViewedArrayBuffer]],
  8949. [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</p>
  8950. <p>Integer Indexed Exotic objects provide alternative definitions for the following internal methods. All of the other
  8951. Integer Indexed exotic object essential internal methods that are not defined below are as specified in <a
  8952. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
  8953. </div>
  8954. <section id="sec-integer-indexed-exotic-objects-getownproperty-p">
  8955. <h1><span class="secnum" id="sec-9.4.5.1"><a href="#sec-integer-indexed-exotic-objects-getownproperty-p"
  8956. title="link to this section">9.4.5.1</a></span> [[GetOwnProperty]] ( P )</h1>
  8957. <p>When the [[GetOwnProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
  8958. href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
  8959. <ol class="proc">
  8960. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  8961. <b>true</b>.</li>
  8962. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
  8963. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8964. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
  8965. <ol class="block">
  8966. <li>Let <i>numericIndex</i> be <a
  8967. href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>(<i>P</i>).</li>
  8968. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
  8969. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  8970. <li>If <i>numericIndex</i> is not <b>undefined</b>, then
  8971. <ol class="block">
  8972. <li>Let <i>value</i> be <a href="#sec-integerindexedelementget">IntegerIndexedElementGet</a> (<i>O</i>,
  8973. <i>numericIndex</i>).</li>
  8974. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
  8975. <li>If <i>value</i> is <b>undefined</b>, return <b>undefined</b>.</li>
  8976. <li>Return a PropertyDescriptor{ [[Value]]: <i>value</i>, [[Enumerable]]: <b>true</b>, [[Writable]]:
  8977. <b>true</b>, [[Configurable]]: <b>false</b> }.</li>
  8978. </ol>
  8979. </li>
  8980. </ol>
  8981. </li>
  8982. <li>Return <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
  8983. </ol>
  8984. </section>
  8985. <section id="sec-integer-indexed-exotic-objects-hasproperty-p">
  8986. <h1><span class="secnum" id="sec-9.4.5.2"><a href="#sec-integer-indexed-exotic-objects-hasproperty-p"
  8987. title="link to this section">9.4.5.2</a></span> [[HasProperty]](P)</h1>
  8988. <p>When the [[HasProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
  8989. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  8990. <ol class="proc">
  8991. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  8992. <b>true</b>.</li>
  8993. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
  8994. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  8995. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
  8996. <ol class="block">
  8997. <li>Let <i>numericIndex</i> be <a
  8998. href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>(<i>P</i>).</li>
  8999. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
  9000. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  9001. <li>If <i>numericIndex</i> is not <b>undefined</b>, then
  9002. <ol class="block">
  9003. <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
  9004. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9005. <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a
  9006. <b>TypeError</b> exception.</li>
  9007. <li>If <a href="#sec-isinteger">IsInteger</a>(<i>numericIndex</i>) is <b>false</b>, return <b>false</b></li>
  9008. <li>If <i>numericIndex</i> = &minus;0, return <b>false</b>.</li>
  9009. <li>If <i>numericIndex</i> &lt; 0, return <b>false</b>.</li>
  9010. <li>If <i>numericIndex</i> &ge; the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
  9011. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, return <b>false</b>.</li>
  9012. <li>Return <b>true</b>.</li>
  9013. </ol>
  9014. </li>
  9015. </ol>
  9016. </li>
  9017. <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
  9018. </ol>
  9019. </section>
  9020. <section id="sec-integer-indexed-exotic-objects-defineownproperty-p-desc">
  9021. <h1><span class="secnum" id="sec-9.4.5.3"><a href="#sec-integer-indexed-exotic-objects-defineownproperty-p-desc"
  9022. title="link to this section">9.4.5.3</a></span> [[DefineOwnProperty]] ( P, Desc)</h1>
  9023. <p>When the [[DefineOwnProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
  9024. href="#sec-object-type">property key</a> <var>P</var>, and <a href="#sec-property-descriptor-specification-type">Property
  9025. Descriptor</a> <span class="nt">Desc</span> the following steps are taken:</p>
  9026. <ol class="proc">
  9027. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9028. <b>true</b>.</li>
  9029. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
  9030. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9031. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
  9032. <ol class="block">
  9033. <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
  9034. (<i>P</i>).</li>
  9035. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
  9036. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  9037. <li>If <i>numericIndex</i> is not <b>undefined</b>, then
  9038. <ol class="block">
  9039. <li>If <a href="#sec-isinteger">IsInteger</a>(<i>numericIndex</i>) is <b>false</b>, return <b>false</b></li>
  9040. <li>Let <i>intIndex</i> be <i>numericIndex</i>.</li>
  9041. <li>If <i>intIndex</i> = &minus;0, return <b>false</b>.</li>
  9042. <li>If <i>intIndex</i> &lt; 0, return <b>false</b>.</li>
  9043. <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
  9044. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9045. <li>If <i>intIndex</i> &ge; <i>length</i>, return <b>false</b>.</li>
  9046. <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) is <b>true</b>, return
  9047. <b>false.</b></li>
  9048. <li>If <i>Desc</i> has a [[Configurable]] field and if <i>Desc</i>.[[Configurable]] is <b>true</b>, return
  9049. <b>false<i>.</i></b></li>
  9050. <li>If <i>Desc</i> has an [[Enumerable]] field and if <i>Desc</i>.[[Enumerable]] is <b>false</b>, return
  9051. <b>false<i>.</i></b></li>
  9052. <li>If <i>Desc</i> has a [[Writable]] field and if <i>Desc</i>.[[Writable]] is <b>false</b>, return
  9053. <b>false</b>.</li>
  9054. <li>If <i>Desc</i> has a [[Value]] field, then
  9055. <ol class="block">
  9056. <li>Let <i>value</i> be <i>Desc</i>.[[Value]].</li>
  9057. <li>Return <a href="#sec-integerindexedelementset">IntegerIndexedElementSet</a> (<i>O</i>, <i>intIndex</i>,
  9058. <i>value</i>).</li>
  9059. </ol>
  9060. </li>
  9061. <li>Return <b>true</b>.</li>
  9062. </ol>
  9063. </li>
  9064. </ol>
  9065. </li>
  9066. <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>O</i>, <i>P</i>, <i>Desc</i>).</li>
  9067. </ol>
  9068. </section>
  9069. <section id="sec-integer-indexed-exotic-objects-get-p-receiver">
  9070. <h1><span class="secnum" id="sec-9.4.5.4"><a href="#sec-integer-indexed-exotic-objects-get-p-receiver"
  9071. title="link to this section">9.4.5.4</a></span> [[Get]] (P, Receiver)</h1>
  9072. <p>When the [[Get]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
  9073. href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language
  9074. value</a> <span class="nt">Receiver</span> the following steps are taken:</p>
  9075. <ol class="proc">
  9076. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9077. <b>true</b>.</li>
  9078. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and if <a
  9079. href="#sec-samevalue">SameValue</a>(<i>O</i>, <i>Receiver</i>) is <b>true</b>, then
  9080. <ol class="block">
  9081. <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
  9082. (<i>P</i>).</li>
  9083. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
  9084. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  9085. <li>If <i>numericIndex</i> is not <b>undefined</b>, then
  9086. <ol class="block">
  9087. <li>Return <a href="#sec-integerindexedelementget">IntegerIndexedElementGet</a> (<i>O</i>,
  9088. <i>numericIndex</i>).</li>
  9089. </ol>
  9090. </li>
  9091. </ol>
  9092. </li>
  9093. <li>Return the result of calling the default ordinary object [[Get]] internal method (<a
  9094. href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
  9095. <i>P</i> and <i>Receiver</i> as arguments.</li>
  9096. </ol>
  9097. </section>
  9098. <section id="sec-integer-indexed-exotic-objects-set-p-v-receiver">
  9099. <h1><span class="secnum" id="sec-9.4.5.5"><a href="#sec-integer-indexed-exotic-objects-set-p-v-receiver"
  9100. title="link to this section">9.4.5.5</a></span> [[Set]] ( P, V, Receiver)</h1>
  9101. <p>When the [[Set]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
  9102. href="#sec-object-type">property key</a> <var>P</var>, value <var>V</var>, and <a
  9103. href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span>, the following steps
  9104. are taken:</p>
  9105. <ol class="proc">
  9106. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9107. <b>true</b>.</li>
  9108. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and if <a
  9109. href="#sec-samevalue">SameValue</a>(<i>O</i>, <i>Receiver</i>) is <b>true</b>, then
  9110. <ol class="block">
  9111. <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
  9112. (<i>P</i>).</li>
  9113. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
  9114. href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
  9115. <li>If <i>numericIndex</i> is not <b>undefined</b>, then
  9116. <ol class="block">
  9117. <li>Return <a href="#sec-integerindexedelementset">IntegerIndexedElementSet</a> (<i>O</i>, <i>numericIndex</i>,
  9118. <i>V</i>).</li>
  9119. </ol>
  9120. </li>
  9121. </ol>
  9122. </li>
  9123. <li>Return the result of calling the default ordinary object [[Set]] internal method (<a
  9124. href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
  9125. <i>P</i>, <i>V</i>, and <i>Receiver</i> as arguments.</li>
  9126. </ol>
  9127. </section>
  9128. <section id="sec-integer-indexed-exotic-objects-ownpropertykeys">
  9129. <h1><span class="secnum" id="sec-9.4.5.6"><a href="#sec-integer-indexed-exotic-objects-ownpropertykeys"
  9130. title="link to this section">9.4.5.6</a></span> [[OwnPropertyKeys]] ()</h1>
  9131. <p>When the [[OwnPropertyKeys]] internal method of an Integer Indexed exotic object <var>O</var> is called the following
  9132. steps are taken:</p>
  9133. <ol class="proc">
  9134. <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  9135. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
  9136. [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
  9137. <li>Let <i>len</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
  9138. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9139. <li>For each integer <i>i</i> starting with 0 such that <i>i</i> &lt; <i>len</i>, in ascending order,
  9140. <ol class="block">
  9141. <li>Add <a href="#sec-tostring">ToString</a>(<i>i</i>) as the last element of <i>keys</i>.</li>
  9142. </ol>
  9143. </li>
  9144. <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
  9145. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and <i>P</i> is not an integer index, in
  9146. property creation order
  9147. <ol class="block">
  9148. <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
  9149. </ol>
  9150. </li>
  9151. <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
  9152. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, in property creation order
  9153. <ol class="block">
  9154. <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
  9155. </ol>
  9156. </li>
  9157. <li>Return <i>keys</i>.</li>
  9158. </ol>
  9159. </section>
  9160. <section id="sec-integerindexedobjectcreate">
  9161. <h1><span class="secnum" id="sec-9.4.5.7"><a href="#sec-integerindexedobjectcreate"
  9162. title="link to this section">9.4.5.7</a></span> IntegerIndexedObjectCreate <span style="font-family:
  9163. sans-serif">(prototype, internalSlotsList)</span></h1>
  9164. <p>The abstract operation IntegerIndexedObjectCreate with arguments <var>prototype</var> and <var>internalSlotsList</var>
  9165. is used to specify the creation of new Integer Indexed exotic objects. The argument <var>internalSlotsList</var> is a <a
  9166. href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
  9167. part of the object. IntegerIndexedObjectCreate performs the following steps:</p>
  9168. <ol class="proc">
  9169. <li>Let <i>A</i> be a newly created object with an <a href="#sec-object-internal-methods-and-internal-slots">internal
  9170. slot</a> for each name in <i>internalSlotsList</i>.</li>
  9171. <li>Set <i>A</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
  9172. href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
  9173. <li>Set the [[GetOwnProperty]] internal method of <i>A</i> as specified in <a
  9174. href="#sec-integer-indexed-exotic-objects-getownproperty-p">9.4.5.1</a>.</li>
  9175. <li>Set the [[HasProperty]] internal method of <i>A</i> as specified in <a
  9176. href="#sec-integer-indexed-exotic-objects-hasproperty-p">9.4.5.2</a>.</li>
  9177. <li>Set the [[DefineOwnProperty]] internal method of <i>A</i> as specified in <a
  9178. href="#sec-integer-indexed-exotic-objects-defineownproperty-p-desc">9.4.5.3</a>.</li>
  9179. <li>Set the [[Get]] internal method of <i>A</i> as specified in <a
  9180. href="#sec-integer-indexed-exotic-objects-get-p-receiver">9.4.5.4</a>.</li>
  9181. <li>Set the [[Set]] internal method of <i>A</i> as specified in <a
  9182. href="#sec-integer-indexed-exotic-objects-set-p-v-receiver">9.4.5.5</a>.</li>
  9183. <li>Set the [[OwnPropertyKeys]] internal method of <i>A</i> as specified in <a
  9184. href="#sec-integer-indexed-exotic-objects-ownpropertykeys">9.4.5.6</a>.</li>
  9185. <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
  9186. <i>prototype</i>.</li>
  9187. <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
  9188. <b>true</b>.</li>
  9189. <li>Return <i>A</i>.</li>
  9190. </ol>
  9191. </section>
  9192. <section id="sec-integerindexedelementget">
  9193. <h1><span class="secnum" id="sec-9.4.5.8"><a href="#sec-integerindexedelementget"
  9194. title="link to this section">9.4.5.8</a></span> IntegerIndexedElementGet ( O, index )</h1>
  9195. <p>The abstract operation IntegerIndexedElementGet with arguments <var>O</var> and <var>index</var> performs the following
  9196. steps:</p>
  9197. <ol class="proc">
  9198. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9199. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>index</i>) is Number.</li>
  9200. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
  9201. [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
  9202. <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
  9203. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9204. <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a <b>TypeError</b>
  9205. exception.</li>
  9206. <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>undefined</b></li>
  9207. <li>If <i>index</i> = &minus;0, return <b>undefined</b>.</li>
  9208. <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
  9209. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9210. <li>If <i>index</i> &lt; 0 or <i>index</i> &ge; <i>length</i>, return <b>undefined</b>.</li>
  9211. <li>Let <i>offset</i> be the value of <i>O</i>&rsquo;s [[ByteOffset]] <a
  9212. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9213. <li>Let <i>arrayTypeName</i> be the string value of <i>O</i>&rsquo;s [[TypedArrayName]] <a
  9214. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9215. <li>Let <i>elementSize</i> be the Number value of the Element Size value specified in <a href="#table-49">Table 49</a>
  9216. for <i>arrayTypeName</i>.</li>
  9217. <li>Let <i>indexedPosition</i> = (<i>index</i> &times; <i>elementSize</i>) + <i>offset</i>.</li>
  9218. <li>Let <i>elementType</i> be the string value of the Element Type value in <a href="#table-49">Table 49</a> for
  9219. <i>arrayTypeName</i>.</li>
  9220. <li>Return <a href="#sec-getvaluefrombuffer">GetValueFromBuffer</a>(<i>buffer</i>, <i>indexedPosition</i>,
  9221. <i>elementType</i>).</li>
  9222. </ol>
  9223. </section>
  9224. <section id="sec-integerindexedelementset">
  9225. <h1><span class="secnum" id="sec-9.4.5.9"><a href="#sec-integerindexedelementset"
  9226. title="link to this section">9.4.5.9</a></span> IntegerIndexedElementSet ( O, index, value )</h1>
  9227. <p>The abstract operation IntegerIndexedElementSet with arguments <var>O</var>, <var>index</var>, and <var>value</var>
  9228. performs the following steps:</p>
  9229. <ol class="proc">
  9230. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9231. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>index</i>) is Number.</li>
  9232. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
  9233. [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
  9234. <li>Let <i>numValue</i> be <a href="#sec-tonumber">ToNumber</a>(<i>value</i>).</li>
  9235. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>numValue</i>).</li>
  9236. <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
  9237. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9238. <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a <b>TypeError</b>
  9239. exception.</li>
  9240. <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>false</b></li>
  9241. <li>If <i>index</i> = &minus;0, return <b>false</b>.</li>
  9242. <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
  9243. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9244. <li>If <i>index</i> &lt; 0 or <i>index</i> &ge; <i>length</i>, return <b>false</b>.</li>
  9245. <li>Let <i>offset</i> be the value of <i>O</i>&rsquo;s [[ByteOffset]] <a
  9246. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9247. <li>Let <i>arrayTypeName</i> be the string value of <i>O</i>&rsquo;s [[TypedArrayName]] <a
  9248. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9249. <li>Let <i>elementSize</i> be the Number value of the Element Size value specified in <a href="#table-49">Table 49</a>
  9250. for <i>arrayTypeName</i>.</li>
  9251. <li>Let <i>indexedPosition</i> = (<i>index</i> &times; <i>elementSize</i>) + <i>offset</i>.</li>
  9252. <li>Let <i>elementType</i> be the string value of the Element Type value in <a href="#table-49">Table 49</a> for
  9253. <i>arrayTypeName</i>.</li>
  9254. <li>Let <i>status</i> be <a href="#sec-setvalueinbuffer">SetValueInBuffer</a>(<i>buffer</i>, <i>indexedPosition</i>,
  9255. <i>elementType</i>, <i>numValue</i>).</li>
  9256. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  9257. <li>Return <b>true</b>.</li>
  9258. </ol>
  9259. </section>
  9260. </section>
  9261. <section id="sec-module-namespace-exotic-objects">
  9262. <div class="front">
  9263. <h1><span class="secnum" id="sec-9.4.6"><a href="#sec-module-namespace-exotic-objects"
  9264. title="link to this section">9.4.6</a></span> Module Namespace Exotic Objects</h1>
  9265. <p>A <i>module namespace object</i> is an exotic object that exposes the bindings exported from an ECMAScript <span
  9266. class="nt">Module</span> <var>(See <a href="#sec-exports">15.2.3</a>)</var>. There is a one-to-one correspondence between
  9267. the String-keyed own properties of a module namespace exotic object and the binding names exported by the <span
  9268. class="nt">Module</span>. The exported bindings include any bindings that are indirectly exported using <code>export
  9269. *</code> export items. Each String-valued own <a href="#sec-object-type">property key</a> is the StringValue of the
  9270. corresponding exported binding name. These are the only String-keyed properties of a module namespace exotic object. Each
  9271. such property has the attributes {[[Configurable]]: <span class="value">false</span>, [[Enumerable]]: <span
  9272. class="value">true</span>}. Module namespace objects are not extensible.</p>
  9273. <p>Module namespace objects have the internal slots defined in <a href="#table-29">Table 29</a>.</p>
  9274. <figure>
  9275. <figcaption><span id="table-29">Table 29</span> &mdash; Internal Slots of Module Namespace Exotic Objects</figcaption>
  9276. <table class="real-table">
  9277. <tr>
  9278. <th>Internal Slot</th>
  9279. <th>Type</th>
  9280. <th>Description</th>
  9281. </tr>
  9282. <tr>
  9283. <td>[[Module]]</td>
  9284. <td>Module Record</td>
  9285. <td>The Module Record whose exports this namespace exposes.</td>
  9286. </tr>
  9287. <tr>
  9288. <td>[[Exports]]</td>
  9289. <td><a href="#sec-list-and-record-specification-type">List</a> of String</td>
  9290. <td>A <a href="#sec-list-and-record-specification-type">List</a> containing the String values of the exported names exposed as own properties of this object. The list is ordered as if an Array of those string values had been sorted using <code><a href="#sec-array.prototype.sort">Array.prototype.sort</a></code> using <a href="#sec-sortcompare">SortCompare</a> as <i><span style="font-family: Times New Roman">comparefn</span>.</i></td>
  9291. </tr>
  9292. </table>
  9293. </figure>
  9294. <p>Module namespace exotic objects provide alternative definitions for all of the internal methods.</p>
  9295. </div>
  9296. <section id="sec-module-namespace-exotic-objects-getprototypeof">
  9297. <h1><span class="secnum" id="sec-9.4.6.1"><a href="#sec-module-namespace-exotic-objects-getprototypeof"
  9298. title="link to this section">9.4.6.1</a></span> [[GetPrototypeOf]] ( )</h1>
  9299. <p>When the [[GetPrototypeOf]] internal method of a module namespace exotic object <var>O</var> is called the following
  9300. steps are taken:</p>
  9301. <ol class="proc">
  9302. <li>Return <b>null</b>.</li>
  9303. </ol>
  9304. </section>
  9305. <section id="sec-module-namespace-exotic-objects-setprototypeof-v">
  9306. <h1><span class="secnum" id="sec-9.4.6.2"><a href="#sec-module-namespace-exotic-objects-setprototypeof-v"
  9307. title="link to this section">9.4.6.2</a></span> [[SetPrototypeOf]] (V)</h1>
  9308. <p>When the [[SetPrototypeOf]] internal method of a module namespace exotic object <var>O</var> is called with argument
  9309. <var>V</var> the following steps are taken:</p>
  9310. <ol class="proc">
  9311. <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
  9312. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
  9313. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
  9314. <li>Return <b>false</b>.</li>
  9315. </ol>
  9316. </section>
  9317. <section id="sec-module-namespace-exotic-objects-isextensible">
  9318. <h1><span class="secnum" id="sec-9.4.6.3"><a href="#sec-module-namespace-exotic-objects-isextensible"
  9319. title="link to this section">9.4.6.3</a></span> [[IsExtensible]] ( )</h1>
  9320. <p>When the [[IsExtensible]] internal method of a module namespace exotic object <var>O</var> is called the following
  9321. steps are taken:</p>
  9322. <ol class="proc">
  9323. <li>Return <b>false</b>.</li>
  9324. </ol>
  9325. </section>
  9326. <section id="sec-module-namespace-exotic-objects-preventextensions">
  9327. <h1><span class="secnum" id="sec-9.4.6.4"><a href="#sec-module-namespace-exotic-objects-preventextensions"
  9328. title="link to this section">9.4.6.4</a></span> [[PreventExtensions]] ( )</h1>
  9329. <p>When the [[PreventExtensions]] internal method of a module namespace exotic object <var>O</var> is called the following
  9330. steps are taken:</p>
  9331. <ol class="proc">
  9332. <li>Return <b>true</b>.</li>
  9333. </ol>
  9334. </section>
  9335. <section id="sec-module-namespace-exotic-objects-getownproperty-p">
  9336. <h1><span class="secnum" id="sec-9.4.6.5"><a href="#sec-module-namespace-exotic-objects-getownproperty-p"
  9337. title="link to this section">9.4.6.5</a></span> [[GetOwnProperty]] (P)</h1>
  9338. <p>When the [[GetOwnProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
  9339. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  9340. <ol class="proc">
  9341. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, return <a
  9342. href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
  9343. <li>Throw a <b>TypeError</b> exception.</li>
  9344. </ol>
  9345. </section>
  9346. <section id="sec-module-namespace-exotic-objects-defineownproperty-p-desc">
  9347. <h1><span class="secnum" id="sec-9.4.6.6"><a href="#sec-module-namespace-exotic-objects-defineownproperty-p-desc"
  9348. title="link to this section">9.4.6.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
  9349. <p>When the [[DefineOwnProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
  9350. href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
  9351. Descriptor</a> <span class="nt">Desc</span>, the following steps are taken:</p>
  9352. <ol class="proc">
  9353. <li>Return <b>false</b>.</li>
  9354. </ol>
  9355. </section>
  9356. <section id="sec-module-namespace-exotic-objects-hasproperty-p">
  9357. <h1><span class="secnum" id="sec-9.4.6.7"><a href="#sec-module-namespace-exotic-objects-hasproperty-p"
  9358. title="link to this section">9.4.6.7</a></span> [[HasProperty]] (P)</h1>
  9359. <p>When the [[HasProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
  9360. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  9361. <ol class="proc">
  9362. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, return <a
  9363. href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
  9364. <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
  9365. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9366. <li>If <i>P</i> is an element of <i>exports</i>, return <b>true</b>.</li>
  9367. <li>Return <b>false</b>.</li>
  9368. </ol>
  9369. </section>
  9370. <section id="sec-module-namespace-exotic-objects-get-p-receiver">
  9371. <h1><span class="secnum" id="sec-9.4.6.8"><a href="#sec-module-namespace-exotic-objects-get-p-receiver"
  9372. title="link to this section">9.4.6.8</a></span> [[Get]] (P, Receiver)</h1>
  9373. <p>When the [[Get]] internal method of a module namespace exotic object <var>O</var> is called with <a
  9374. href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language
  9375. value</a> <span class="nt">Receiver</span> the following steps are taken:</p>
  9376. <ol class="proc">
  9377. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9378. <b>true</b>.</li>
  9379. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, then
  9380. <ol class="block">
  9381. <li>Return the result of calling the default ordinary object [[Get]] internal method (<a
  9382. href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
  9383. <i>P</i> and <i>Receiver</i> as arguments.</li>
  9384. </ol>
  9385. </li>
  9386. <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
  9387. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9388. <li>If <i>P</i> is not an element of <i>exports</i>, return <b>undefined</b>.</li>
  9389. <li>Let <i>m</i> be the value of <i>O</i>&rsquo;s [[Module]] <a
  9390. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9391. <li>Let <i>binding</i> be <i>m</i>.<a href="#sec-resolveexport">ResolveExport</a>(<i>P</i>, &laquo;&raquo;,
  9392. &laquo;&raquo;).</li>
  9393. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>binding</i>).</li>
  9394. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>binding</i> is neither <b>null</b> nor
  9395. <code>"ambiguous"</code>.</li>
  9396. <li>Let <i>targetModule</i> be <i>binding</i>.[[module]],</li>
  9397. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>targetModule</i> is not <b>undefined</b>.</li>
  9398. <li>Let <i>targetEnv</i> be <i>targetModule</i>.[[Environment]].</li>
  9399. <li>If <i>targetEnv</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
  9400. <li>Let <i>targetEnvRec</i> be <i>targetEnv</i>&rsquo;s EnvironmentRecord.</li>
  9401. <li>Return <i>targetEnvRec</i>.GetBindingValue(<i>binding.</i>[[bindingName]], <b>true</b>).</li>
  9402. </ol>
  9403. <div class="note">
  9404. <p><span class="nh">NOTE</span> <a href="#sec-resolveexport">ResolveExport</a> is idempotent and side-effect free. An
  9405. implementation might choose to pre-compute or cache the <a href="#sec-resolveexport">ResolveExport</a> results for the
  9406. [[Exports]] of each module namespace exotic object.</p>
  9407. </div>
  9408. </section>
  9409. <section id="sec-module-namespace-exotic-objects-set-p-v-receiver">
  9410. <h1><span class="secnum" id="sec-9.4.6.9"><a href="#sec-module-namespace-exotic-objects-set-p-v-receiver"
  9411. title="link to this section">9.4.6.9</a></span> [[Set]] ( P, V, Receiver)</h1>
  9412. <p>When the [[Set]] internal method of <span style="font-family: Times New Roman">a</span> module namespace exotic object
  9413. <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>, value <var>V</var>, and <a
  9414. href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span>, the following steps
  9415. are taken:</p>
  9416. <ol class="proc">
  9417. <li>Return <b>false</b>.</li>
  9418. </ol>
  9419. </section>
  9420. <section id="sec-module-namespace-exotic-objects-delete-p">
  9421. <h1><span class="secnum" id="sec-9.4.6.10"><a href="#sec-module-namespace-exotic-objects-delete-p"
  9422. title="link to this section">9.4.6.10</a></span> [[Delete]] (P)</h1>
  9423. <p>When the [[Delete]] internal method of a module namespace exotic object <var>O</var> is called with <a
  9424. href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
  9425. <ol class="proc">
  9426. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9427. <b>true</b>.</li>
  9428. <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
  9429. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9430. <li>If <i>P</i> is an element of <i>exports</i>, return <b>false</b>.</li>
  9431. <li>Return <b>true</b>.</li>
  9432. </ol>
  9433. </section>
  9434. <section id="sec-module-namespace-exotic-objects-enumerate">
  9435. <h1><span class="secnum" id="sec-9.4.6.11"><a href="#sec-module-namespace-exotic-objects-enumerate"
  9436. title="link to this section">9.4.6.11</a></span> [[Enumerate]] ()</h1>
  9437. <p>When the [[Enumerate]] internal method of a module namespace exotic object <var>O</var> is called the following steps
  9438. are taken:</p>
  9439. <ol class="proc">
  9440. <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
  9441. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9442. <li>Return <a href="#sec-createlistiterator">CreateListIterator</a>(<i>exports</i>).</li>
  9443. </ol>
  9444. </section>
  9445. <section id="sec-module-namespace-exotic-objects-ownpropertykeys">
  9446. <h1><span class="secnum" id="sec-9.4.6.12"><a href="#sec-module-namespace-exotic-objects-ownpropertykeys"
  9447. title="link to this section">9.4.6.12</a></span> [[OwnPropertyKeys]] ( )</h1>
  9448. <p>When the [[OwnPropertyKeys]] internal method of a module namespace exotic object <var>O</var> is called the following
  9449. steps are taken:</p>
  9450. <ol class="proc">
  9451. <li>Let <i>exports</i> be a copy of the value of <i>O</i>&rsquo;s [[Exports]] <a
  9452. href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
  9453. <li>Let <i>symbolKeys</i> be the result of calling the default ordinary object [[OwnPropertyKeys]] internal method (<a
  9454. href="#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys">9.1.12</a>) on <i>O</i> passing no
  9455. arguments.</li>
  9456. <li>Append all the entries of <i>symbolKeys</i> to the end of <i>exports</i>.</li>
  9457. <li>Return <i>exports</i>.</li>
  9458. </ol>
  9459. </section>
  9460. <section id="sec-modulenamespacecreate">
  9461. <h1><span class="secnum" id="sec-9.4.6.13"><a href="#sec-modulenamespacecreate"
  9462. title="link to this section">9.4.6.13</a></span> ModuleNamespaceCreate (module, exports)</h1>
  9463. <p>The abstract operation ModuleNamespaceCreate with arguments <var>module</var>, and <var>exports</var> is used to
  9464. specify the creation of new module namespace exotic objects. It performs the following steps:</p>
  9465. <ol class="proc">
  9466. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>module</i> is a Module Record (<a
  9467. href="#sec-abstract-module-records">see 15.2.1.14</a>).</li>
  9468. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>module</i>.[[Namespace]] is <b>undefined</b>.</li>
  9469. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>exports</i> is a <a
  9470. href="#sec-list-and-record-specification-type">List</a> of string values.</li>
  9471. <li>Let <i>M</i> be a newly created object.</li>
  9472. <li>Set <i>M</i>&rsquo;s essential internal methods to the definitions specified in <a
  9473. href="#sec-module-namespace-exotic-objects">9.4.6</a>.</li>
  9474. <li>Set <i>M</i>&rsquo;s [[Module]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
  9475. <i>module</i>.</li>
  9476. <li>Set <i>M</i>&rsquo;s [[Exports]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
  9477. <i>exports</i>.</li>
  9478. <li>Create own properties of <i>M</i> corresponding to the definitions in <a
  9479. href="#sec-module-namespace-objects">26.3</a>.</li>
  9480. <li>Set <i>module</i>.[[Namespace]] to <i>M</i>.</li>
  9481. <li>Return <i>M</i>.</li>
  9482. </ol>
  9483. </section>
  9484. </section>
  9485. </section>
  9486. <section id="sec-proxy-object-internal-methods-and-internal-slots">
  9487. <div class="front">
  9488. <h1><span class="secnum" id="sec-9.5"><a href="#sec-proxy-object-internal-methods-and-internal-slots"
  9489. title="link to this section">9.5</a></span> Proxy Object Internal Methods and Internal Slots</h1>
  9490. <p>A proxy object is an exotic object whose essential internal methods are partially implemented using ECMAScript code.
  9491. Every proxy objects has an <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called
  9492. [[ProxyHandler]]. The value of [[ProxyHandler]] is an object, called the proxy&rsquo;s <i>handler object</i>, or <span
  9493. class="value">null</span>. Methods (see <a href="#table-30">Table 30</a>) of a handler object may be used to augment the
  9494. implementation for one or more of the proxy object&rsquo;s internal methods. Every proxy object also has an <a
  9495. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called [[ProxyTarget]] whose value is either an
  9496. object or the <b>null</b> value. This object is called the proxy&rsquo;s <i>target object</i>.</p>
  9497. <figure>
  9498. <figcaption><span id="table-30">Table 30</span> &mdash; Proxy Handler Methods</figcaption>
  9499. <table class="real-table">
  9500. <tr>
  9501. <th>Internal Method</th>
  9502. <th>Handler Method</th>
  9503. </tr>
  9504. <tr>
  9505. <td>[[GetPrototypeOf]]</td>
  9506. <td><code>getPrototypeOf</code></td>
  9507. </tr>
  9508. <tr>
  9509. <td>[[SetPrototypeOf]]</td>
  9510. <td><code>setPrototypeOf</code></td>
  9511. </tr>
  9512. <tr>
  9513. <td>[[IsExtensible]]</td>
  9514. <td><code>isExtensible</code></td>
  9515. </tr>
  9516. <tr>
  9517. <td>[[PreventExtensions]]</td>
  9518. <td><code>preventExtensions</code></td>
  9519. </tr>
  9520. <tr>
  9521. <td>[[GetOwnProperty]]</td>
  9522. <td><code>getOwnPropertyDescriptor</code></td>
  9523. </tr>
  9524. <tr>
  9525. <td>[[HasProperty]]</td>
  9526. <td><code>has</code></td>
  9527. </tr>
  9528. <tr>
  9529. <td>[[Get]]</td>
  9530. <td><code>get</code></td>
  9531. </tr>
  9532. <tr>
  9533. <td>[[Set]]</td>
  9534. <td><code>set</code></td>
  9535. </tr>
  9536. <tr>
  9537. <td>[[Delete]]</td>
  9538. <td><code>deleteProperty</code></td>
  9539. </tr>
  9540. <tr>
  9541. <td>[[DefineOwnProperty]]</td>
  9542. <td><code>defineProperty</code></td>
  9543. </tr>
  9544. <tr>
  9545. <td>[[Enumerate]]</td>
  9546. <td><code>enumerate</code></td>
  9547. </tr>
  9548. <tr>
  9549. <td>[[OwnPropertyKeys]]</td>
  9550. <td><code>ownKeys</code></td>
  9551. </tr>
  9552. <tr>
  9553. <td>[[Call]]</td>
  9554. <td><code>apply</code></td>
  9555. </tr>
  9556. <tr>
  9557. <td>[[Construct]]</td>
  9558. <td><code>construct</code></td>
  9559. </tr>
  9560. </table>
  9561. </figure>
  9562. <p>When a handler method is called to provide the implementation of a proxy object internal method, the handler method is
  9563. passed the proxy&rsquo;s target object as a parameter. A proxy&rsquo;s handler object does not necessarily have a method
  9564. corresponding to every essential internal method. Invoking an internal method on the proxy results in the invocation of the
  9565. corresponding internal method on the proxy&rsquo;s target object if the handler object does not have a method corresponding
  9566. to the internal trap.</p>
  9567. <p>The [[ProxyHandler]] and [[ProxyTarget]] internal slots of a proxy object are always initialized when the object is
  9568. created and typically may not be modified. Some proxy objects are created in a manner that permits them to be subsequently
  9569. <i>revoked</i>. When a proxy is revoked, its [[ProxyHander]] and [[ProxyTarget]] internal slots are set to <b>null</b>
  9570. causing subsequent invocations of internal methods on that proxy object to throw a <span class="value">TypeError</span>
  9571. exception.</p>
  9572. <p>Because proxy objects permit the implementation of internal methods to be provided by arbitrary ECMAScript code, it is
  9573. possible to define a proxy object whose handler methods violates the invariants defined in <a
  9574. href="#sec-invariants-of-the-essential-internal-methods">6.1.7.3</a>. Some of the internal method invariants defined in <a
  9575. href="#sec-invariants-of-the-essential-internal-methods">6.1.7.3</a> are essential integrity invariants. These invariants
  9576. are explicitly enforced by the proxy object internal methods specified in this section. An ECMAScript implementation must be
  9577. robust in the presence of all possible invariant violations.</p>
  9578. <p>In the following algorithm descriptions, assume <var>O</var> is an ECMAScript proxy object, <var>P</var> is a <a
  9579. href="#sec-object-type">property key value</a>, <var>V</var> is any <a href="#sec-ecmascript-language-types">ECMAScript
  9580. language value</a> and <span style="font-family: Times New Roman">Desc</span> is a <a
  9581. href="#sec-property-descriptor-specification-type">Property Descriptor</a> record.</p>
  9582. </div>
  9583. <section id="sec-proxy-object-internal-methods-and-internal-slots-getprototypeof">
  9584. <h1><span class="secnum" id="sec-9.5.1"><a href="#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof"
  9585. title="link to this section">9.5.1</a></span> [[GetPrototypeOf]] ( )</h1>
  9586. <p>When the [[GetPrototypeOf]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
  9587. taken:</p>
  9588. <ol class="proc">
  9589. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  9590. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9591. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  9592. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9593. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  9594. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  9595. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9596. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"getPrototypeOf"</code>).</li>
  9597. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  9598. <li>If <i>trap</i> is <b>undefined</b>, then
  9599. <ol class="block">
  9600. <li>Return <i>target</i>.[[GetPrototypeOf]]().</li>
  9601. </ol>
  9602. </li>
  9603. <li>Let <i>handlerProto</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>,
  9604. &laquo;<i>target</i>&raquo;).</li>
  9605. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>handlerProto</i>).</li>
  9606. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handlerProto</i>) is neither Object nor Null, throw a
  9607. <b>TypeError</b> exception.</li>
  9608. <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
  9609. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
  9610. <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>handlerProto</i>.</li>
  9611. <li>Let <i>targetProto</i> be <i>target</i>.[[GetPrototypeOf]]().</li>
  9612. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetProto</i>).</li>
  9613. <li>If <a href="#sec-samevalue">SameValue</a>(<i>handlerProto</i>, <i>targetProto</i>) is <b>false</b>, throw a
  9614. <b>TypeError</b> exception.</li>
  9615. <li>Return <i>handlerProto</i>.</li>
  9616. </ol>
  9617. <div class="note">
  9618. <p><span class="nh">NOTE</span> [[GetPrototypeOf]] for proxy objects enforces the following invariant:</p>
  9619. <ul>
  9620. <li>
  9621. <p>The result of [[GetPrototypeOf]] must be either an Object or <b>null</b>.</p>
  9622. </li>
  9623. <li>
  9624. <p>If the target object is not extensible, [[GetPrototypeOf]] applied to the proxy object must return the same value
  9625. as [[GetPrototypeOf]] applied to the proxy object&rsquo;s target object.</p>
  9626. </li>
  9627. </ul>
  9628. </div>
  9629. </section>
  9630. <section id="sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v">
  9631. <h1><span class="secnum" id="sec-9.5.2"><a href="#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v"
  9632. title="link to this section">9.5.2</a></span> [[SetPrototypeOf]] (V)</h1>
  9633. <p>When the [[SetPrototypeOf]] internal method of a Proxy exotic object <var>O</var> is called with argument <var>V</var>
  9634. the following steps are taken:</p>
  9635. <ol class="proc">
  9636. <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
  9637. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
  9638. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
  9639. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  9640. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9641. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  9642. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9643. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  9644. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  9645. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9646. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"setPrototypeOf"</code>).</li>
  9647. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  9648. <li>If <i>trap</i> is <b>undefined</b>, then
  9649. <ol class="block">
  9650. <li>Return <i>target</i>.[[SetPrototypeOf]](<i>V</i>).</li>
  9651. </ol>
  9652. </li>
  9653. <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
  9654. <i>handler</i>, &laquo;<i>target</i>, <i>V</i>&raquo;)).</li>
  9655. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
  9656. <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
  9657. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
  9658. <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>booleanTrapResult</i>.</li>
  9659. <li>Let <i>targetProto</i> be <i>target</i>.[[GetPrototypeOf]]().</li>
  9660. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetProto</i>).</li>
  9661. <li>If <i>booleanTrapResult</i> is <b>true</b> and <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>targetProto</i>) is
  9662. <b>false</b>, throw a <b>TypeError</b> exception.</li>
  9663. <li>Return <i>booleanTrapResult</i>.</li>
  9664. </ol>
  9665. <div class="note">
  9666. <p><span class="nh">NOTE</span> [[SetPrototypeOf]] for proxy objects enforces the following invariant:</p>
  9667. <ul>
  9668. <li>
  9669. <p>The result of [[SetPrototypeOf]] is a Boolean value.</p>
  9670. </li>
  9671. <li>
  9672. <p>If the target object is not extensible, the argument value must be the same as the result of [[GetPrototypeOf]]
  9673. applied to target object.</p>
  9674. </li>
  9675. </ul>
  9676. </div>
  9677. </section>
  9678. <section id="sec-proxy-object-internal-methods-and-internal-slots-isextensible">
  9679. <h1><span class="secnum" id="sec-9.5.3"><a href="#sec-proxy-object-internal-methods-and-internal-slots-isextensible"
  9680. title="link to this section">9.5.3</a></span> [[IsExtensible]] ( )</h1>
  9681. <p>When the [[IsExtensible]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
  9682. taken:</p>
  9683. <ol class="proc">
  9684. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  9685. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9686. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  9687. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9688. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  9689. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  9690. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9691. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"isExtensible"</code>).</li>
  9692. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  9693. <li>If <i>trap</i> is <b>undefined</b>, then
  9694. <ol class="block">
  9695. <li>Return <i>target</i>.[[IsExtensible]]().</li>
  9696. </ol>
  9697. </li>
  9698. <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
  9699. <i>handler</i>, &laquo;<i>target</i>&raquo;)).</li>
  9700. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
  9701. <li>Let <i>targetResult</i> be <i>target</i>.[[IsExtensible]]().</li>
  9702. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetResult</i>).</li>
  9703. <li>If <a href="#sec-samevalue">SameValue</a>(<i>booleanTrapResult</i>, <i>targetResult</i>) is <b>false</b>, throw a
  9704. <b>TypeError</b> exception.</li>
  9705. <li>Return <i>booleanTrapResult</i>.</li>
  9706. </ol>
  9707. <div class="note">
  9708. <p><span class="nh">NOTE</span> [[IsExtensible]] for proxy objects enforces the following invariant:</p>
  9709. <ul>
  9710. <li>
  9711. <p>The result of [[IsExtensible]] is a Boolean value.</p>
  9712. </li>
  9713. <li>
  9714. <p>[[IsExtensible]] applied to the proxy object must return the same value as [[IsExtensible]] applied to the proxy
  9715. object&rsquo;s target object with the same argument.</p>
  9716. </li>
  9717. </ul>
  9718. </div>
  9719. </section>
  9720. <section id="sec-proxy-object-internal-methods-and-internal-slots-preventextensions">
  9721. <h1><span class="secnum" id="sec-9.5.4"><a href="#sec-proxy-object-internal-methods-and-internal-slots-preventextensions"
  9722. title="link to this section">9.5.4</a></span> [[PreventExtensions]] ( )</h1>
  9723. <p>When the [[PreventExtensions]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
  9724. taken:</p>
  9725. <ol class="proc">
  9726. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  9727. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9728. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  9729. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9730. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  9731. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  9732. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9733. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"preventExtensions"</code>).</li>
  9734. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  9735. <li>If <i>trap</i> is <b>undefined</b>, then
  9736. <ol class="block">
  9737. <li>Return <i>target</i>.[[PreventExtensions]]().</li>
  9738. </ol>
  9739. </li>
  9740. <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
  9741. <i>handler</i>, &laquo;<i>target</i>&raquo;)).</li>
  9742. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
  9743. <li>If <i>booleanTrapResult</i> is <b>true</b>, then
  9744. <ol class="block">
  9745. <li>Let <i>targetIsExtensible</i> be <i>target</i>.[[IsExtensible]]().</li>
  9746. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetIsExtensible</i>).</li>
  9747. <li>If <i>targetIsExtensible</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
  9748. </ol>
  9749. </li>
  9750. <li>Return <i>booleanTrapResult</i>.</li>
  9751. </ol>
  9752. <div class="note">
  9753. <p><span class="nh">NOTE</span> [[PreventExtensions]] for proxy objects enforces the following invariant:</p>
  9754. <ul>
  9755. <li>
  9756. <p>The result of [[PreventExtensions]] is a Boolean value.</p>
  9757. </li>
  9758. <li>
  9759. <p>[[PreventExtensions]] applied to the proxy object only returns <b>true</b> if [[IsExtensible]] applied to the proxy
  9760. object&rsquo;s target object is <b>false</b>.</p>
  9761. </li>
  9762. </ul>
  9763. </div>
  9764. </section>
  9765. <section id="sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p">
  9766. <h1><span class="secnum" id="sec-9.5.5"><a href="#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p"
  9767. title="link to this section">9.5.5</a></span> [[GetOwnProperty]] (P)</h1>
  9768. <p>When the [[GetOwnProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
  9769. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  9770. <ol class="proc">
  9771. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9772. <b>true</b>.</li>
  9773. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  9774. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9775. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  9776. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9777. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  9778. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  9779. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9780. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>,
  9781. <code>"getOwnPropertyDescriptor"</code>).</li>
  9782. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  9783. <li>If <i>trap</i> is <b>undefined</b>, then
  9784. <ol class="block">
  9785. <li>Return <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
  9786. </ol>
  9787. </li>
  9788. <li>Let <i>trapResultObj</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>,
  9789. <i>P</i>&raquo;).</li>
  9790. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResultObj</i>).</li>
  9791. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>trapResultObj</i>) is neither Object nor Undefined,
  9792. throw a <b>TypeError</b> exception.</li>
  9793. <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
  9794. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
  9795. <li>If <i>trapResultObj</i> is <b>undefined</b>, then
  9796. <ol class="block">
  9797. <li>If <i>targetDesc</i> is <b>undefined</b>, return <b>undefined</b>.</li>
  9798. <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  9799. <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
  9800. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
  9801. <li>If <a href="#sec-toboolean">ToBoolean</a>(<i>extensibleTarget</i>) is <b>false</b>, throw a <b>TypeError</b>
  9802. exception.</li>
  9803. <li>Return <b>undefined</b>.</li>
  9804. </ol>
  9805. </li>
  9806. <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
  9807. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
  9808. <li>Let <i>resultDesc</i> be <a href="#sec-topropertydescriptor">ToPropertyDescriptor</a>(<i>trapResultObj</i>).</li>
  9809. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>resultDesc</i>).</li>
  9810. <li><a href="#sec-call">Call</a> <a
  9811. href="#sec-completepropertydescriptor">CompletePropertyDescriptor</a>(<i>resultDesc</i>).</li>
  9812. <li>Let <i>valid</i> be <a href="#sec-iscompatiblepropertydescriptor">IsCompatiblePropertyDescriptor</a>
  9813. (<i>extensibleTarget</i>, <i>resultDesc</i>, <i>targetDesc</i>).</li>
  9814. <li>If <i>valid</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  9815. <li>If <i>resultDesc</i>.[[Configurable]] is <b>false</b>, then
  9816. <ol class="block">
  9817. <li>If <i>targetDesc</i> is <b>undefined</b> or <i>targetDesc</i>.[[Configurable]] is <b>true</b><i>,</i> then
  9818. <ol class="block">
  9819. <li>Throw a <b>TypeError</b> exception.</li>
  9820. </ol>
  9821. </li>
  9822. </ol>
  9823. </li>
  9824. <li>Return <i>resultDesc</i>.</li>
  9825. </ol>
  9826. <div class="note">
  9827. <p><span class="nh">NOTE</span> [[GetOwnProperty]] for proxy objects enforces the following invariants:</p>
  9828. <ul>
  9829. <li>
  9830. <p>The result of [[GetOwnProperty]] must be either an Object or <b>undefined</b>.</p>
  9831. </li>
  9832. <li>
  9833. <p>A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target
  9834. object.</p>
  9835. </li>
  9836. <li>
  9837. <p>A property cannot be reported as non-existent, if it exists as an own property of the target object and the target
  9838. object is not extensible.</p>
  9839. </li>
  9840. <li>
  9841. <p>A property cannot be reported as existent, if it does not exists as an own property of the target object and the
  9842. target object is not extensible.</p>
  9843. </li>
  9844. <li>
  9845. <p>A property cannot be reported as non-configurable, if it does not exists as an own property of the target object or
  9846. if it exists as a configurable own property of the target object.</p>
  9847. </li>
  9848. </ul>
  9849. </div>
  9850. </section>
  9851. <section id="sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc">
  9852. <h1><span class="secnum" id="sec-9.5.6"><a
  9853. href="#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc"
  9854. title="link to this section">9.5.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
  9855. <p>When the [[DefineOwnProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
  9856. href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
  9857. Descriptor</a> <span class="nt">Desc</span>, the following steps are taken:</p>
  9858. <ol class="proc">
  9859. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9860. <b>true</b>.</li>
  9861. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  9862. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9863. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  9864. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9865. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  9866. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  9867. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9868. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"defineProperty"</code>).</li>
  9869. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  9870. <li>If <i>trap</i> is <b>undefined</b>, then
  9871. <ol class="block">
  9872. <li>Return <i>target</i>.[[DefineOwnProperty]](<i>P</i>, <i>Desc</i>).</li>
  9873. </ol>
  9874. </li>
  9875. <li>Let <i>descObj</i> be <a href="#sec-frompropertydescriptor">FromPropertyDescriptor</a>(<i>Desc</i>).</li>
  9876. <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
  9877. <i>handler</i>, &laquo;<i>target</i>, <i>P</i>, <i>descObj</i>&raquo;)).</li>
  9878. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
  9879. <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
  9880. <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
  9881. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
  9882. <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
  9883. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
  9884. <li>If <i>Desc</i> has a [[Configurable]] field and if <i>Desc</i>.[[Configurable]] is <b>false,</b> then
  9885. <ol class="block">
  9886. <li>Let <i>settingConfigFalse</i> be <b>true</b>.</li>
  9887. </ol>
  9888. </li>
  9889. <li>Else let <i>settingConfigFalse</i> be <b>false</b>.</li>
  9890. <li>If <i>targetDesc</i> is <b>undefined</b>, then
  9891. <ol class="block">
  9892. <li>If <i>extensibleTarget</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  9893. <li>If <i>settingConfigFalse</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
  9894. </ol>
  9895. </li>
  9896. <li>Else <i>targetDesc</i> is not <b>undefined<i>,</i></b>
  9897. <ol class="block">
  9898. <li>If <a href="#sec-iscompatiblepropertydescriptor">IsCompatiblePropertyDescriptor</a>(<i>extensibleTarget</i>,
  9899. <i>Desc</i> , <i>targetDesc</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  9900. <li>If <i>settingConfigFalse</i> is <b>true</b> and <i>targetDesc</i>.[[Configurable]] is <b>true</b>, throw a
  9901. <b>TypeError</b> exception.</li>
  9902. </ol>
  9903. </li>
  9904. <li>Return <b>true</b>.</li>
  9905. </ol>
  9906. <div class="note">
  9907. <p><span class="nh">NOTE</span> [[DefineOwnProperty]] for proxy objects enforces the following invariants:</p>
  9908. <ul>
  9909. <li>
  9910. <p>The result of [[DefineOwnProperty]] is a Boolean value.</p>
  9911. </li>
  9912. <li>
  9913. <p>A property cannot be added, if the target object is not extensible.</p>
  9914. </li>
  9915. <li>
  9916. <p>A property cannot be non-configurable, unless there exists a corresponding non-configurable own property of the
  9917. target object.</p>
  9918. </li>
  9919. <li>
  9920. <p>If a property has a corresponding target object property then applying the <a
  9921. href="#sec-property-descriptor-specification-type">Property Descriptor</a> of the property to the target object using
  9922. [[DefineOwnProperty]] will not throw an exception.</p>
  9923. </li>
  9924. </ul>
  9925. </div>
  9926. </section>
  9927. <section id="sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p">
  9928. <h1><span class="secnum" id="sec-9.5.7"><a href="#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p"
  9929. title="link to this section">9.5.7</a></span> [[HasProperty]] (P)</h1>
  9930. <p>When the [[HasProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
  9931. href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
  9932. <ol class="proc">
  9933. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9934. <b>true</b>.</li>
  9935. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  9936. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9937. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  9938. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9939. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  9940. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  9941. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9942. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"has"</code>).</li>
  9943. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  9944. <li>If <i>trap</i> is <b>undefined</b>, then
  9945. <ol class="block">
  9946. <li>Return <i>target</i>.[[HasProperty]](<i>P</i>).</li>
  9947. </ol>
  9948. </li>
  9949. <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
  9950. <i>handler</i>, &laquo;<i>target</i>, <i>P</i>&raquo;)).</li>
  9951. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
  9952. <li>If <i>booleanTrapResult</i> is <b>false</b>, then
  9953. <ol class="block">
  9954. <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
  9955. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
  9956. <li>If <i>targetDesc</i> is not <b>undefined</b>, then
  9957. <ol class="block">
  9958. <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  9959. <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
  9960. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
  9961. <li>If <i>extensibleTarget</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  9962. </ol>
  9963. </li>
  9964. </ol>
  9965. </li>
  9966. <li>Return <i>booleanTrapResult</i>.</li>
  9967. </ol>
  9968. <div class="note">
  9969. <p><span class="nh">NOTE</span> [[HasProperty]] for proxy objects enforces the following invariants:</p>
  9970. <ul>
  9971. <li>
  9972. <p>The result of [[HasProperty]] is a Boolean value.</p>
  9973. </li>
  9974. <li>
  9975. <p>A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target
  9976. object.</p>
  9977. </li>
  9978. <li>
  9979. <p>A property cannot be reported as non-existent, if it exists as an own property of the target object and the target
  9980. object is not extensible.</p>
  9981. </li>
  9982. </ul>
  9983. </div>
  9984. </section>
  9985. <section id="sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver">
  9986. <h1><span class="secnum" id="sec-9.5.8"><a href="#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver"
  9987. title="link to this section">9.5.8</a></span> [[Get]] (P, Receiver)</h1>
  9988. <p>When the [[Get]] internal method of a Proxy exotic object <var>O</var> is called with <a href="#sec-object-type">property
  9989. key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
  9990. class="nt">Receiver</span> the following steps are taken:</p>
  9991. <ol class="proc">
  9992. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  9993. <b>true</b>.</li>
  9994. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  9995. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  9996. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  9997. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  9998. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  9999. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  10000. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10001. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"get"</code>).</li>
  10002. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  10003. <li>If <i>trap</i> is <b>undefined</b>, then
  10004. <ol class="block">
  10005. <li>Return <i>target</i>.[[Get]](<i>P</i>, <i>Receiver</i>).</li>
  10006. </ol>
  10007. </li>
  10008. <li>Let <i>trapResult</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>, <i>P</i>,
  10009. <i>Receiver</i>&raquo;).</li>
  10010. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
  10011. <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
  10012. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
  10013. <li>If <i>targetDesc</i> is not <b>undefined</b>, then
  10014. <ol class="block">
  10015. <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>targetDesc</i>) and <i>targetDesc</i>.[[Configurable]]
  10016. is <b>false</b> and <i>targetDesc</i>.[[Writable]] is <b>false</b>, then
  10017. <ol class="block">
  10018. <li>If <a href="#sec-samevalue">SameValue</a>(<i>trapResult</i>, <i>targetDesc</i>.[[Value]]) is <b>false</b>,
  10019. throw a <b>TypeError</b> exception.</li>
  10020. </ol>
  10021. </li>
  10022. <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>targetDesc</i>) and
  10023. <i>targetDesc</i>.[[Configurable]] is <b>false</b> and <i>targetDesc</i>.[[Get]] is <b>undefined</b>, then
  10024. <ol class="block">
  10025. <li>If <i>trapResult</i> is not <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
  10026. </ol>
  10027. </li>
  10028. </ol>
  10029. </li>
  10030. <li>Return <i>trapResult</i>.</li>
  10031. </ol>
  10032. <div class="note">
  10033. <p><span class="nh">NOTE</span> [[Get]] for proxy objects enforces the following invariants:</p>
  10034. <ul>
  10035. <li>
  10036. <p>The value reported for a property must be the same as the value of the corresponding target object property if the
  10037. target object property is a non-writable, non-configurable own data property.</p>
  10038. </li>
  10039. <li>
  10040. <p>The value reported for a property must be <b>undefined</b> if the corresponding target object property is a
  10041. non-configurable own accessor property that has <b>undefined</b> as its [[Get]] attribute.</p>
  10042. </li>
  10043. </ul>
  10044. </div>
  10045. </section>
  10046. <section id="sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver">
  10047. <h1><span class="secnum" id="sec-9.5.9"><a href="#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver"
  10048. title="link to this section">9.5.9</a></span> [[Set]] ( P, V, Receiver)</h1>
  10049. <p>When the [[Set]] internal method of a Proxy exotic object <var>O</var> is called with <a href="#sec-object-type">property
  10050. key</a> <var>P</var>, value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
  10051. class="nt">Receiver</span>, the following steps are taken:</p>
  10052. <ol class="proc">
  10053. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  10054. <b>true</b>.</li>
  10055. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  10056. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10057. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  10058. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  10059. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  10060. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  10061. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10062. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"set"</code>).</li>
  10063. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  10064. <li>If <i>trap</i> is <b>undefined</b>, then
  10065. <ol class="block">
  10066. <li>Return <i>target</i>.[[Set]](<i>P</i>, <i>V</i>, <i>Receiver</i>).</li>
  10067. </ol>
  10068. </li>
  10069. <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
  10070. <i>handler</i>, &laquo;<i>target</i>, <i>P</i>, <i>V</i>, <i>Receiver</i>&raquo;)).</li>
  10071. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
  10072. <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
  10073. <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
  10074. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
  10075. <li>If <i>targetDesc</i> is not <b>undefined</b>, then
  10076. <ol class="block">
  10077. <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>targetDesc</i>) and <i>targetDesc</i>.[[Configurable]]
  10078. is <b>false</b> and <i>targetDesc</i>.[[Writable]] is <b>false</b>, then
  10079. <ol class="block">
  10080. <li>If <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>targetDesc</i>.[[Value]]) is <b>false</b>, throw a
  10081. <b>TypeError</b> exception.</li>
  10082. </ol>
  10083. </li>
  10084. <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>targetDesc</i>) and
  10085. <i>targetDesc</i>.[[Configurable]] is <b>false</b>, then
  10086. <ol class="block">
  10087. <li>If <i>targetDesc</i>.[[Set]] is <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
  10088. </ol>
  10089. </li>
  10090. </ol>
  10091. </li>
  10092. <li>Return <b>true</b>.</li>
  10093. </ol>
  10094. <div class="note">
  10095. <p><span class="nh">NOTE</span> [[Set]] for proxy objects enforces the following invariants:</p>
  10096. <ul>
  10097. <li>
  10098. <p>The result of [[Set]] is a Boolean value.</p>
  10099. </li>
  10100. <li>
  10101. <p>Cannot change the value of a property to be different from the value of the corresponding target object property if
  10102. the corresponding target object property is a non-writable, non-configurable own data property.</p>
  10103. </li>
  10104. <li>
  10105. <p>Cannot set the value of a property if the corresponding target object property is a non-configurable own accessor
  10106. property that has <b>undefined</b> as its [[Set]] attribute.</p>
  10107. </li>
  10108. </ul>
  10109. </div>
  10110. </section>
  10111. <section id="sec-proxy-object-internal-methods-and-internal-slots-delete-p">
  10112. <h1><span class="secnum" id="sec-9.5.10"><a href="#sec-proxy-object-internal-methods-and-internal-slots-delete-p"
  10113. title="link to this section">9.5.10</a></span> [[Delete]] (P)</h1>
  10114. <p>When the [[Delete]] internal method of a Proxy exotic object <var>O</var> is called with <a
  10115. href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
  10116. <ol class="proc">
  10117. <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
  10118. <b>true</b>.</li>
  10119. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  10120. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10121. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  10122. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  10123. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  10124. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  10125. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10126. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"deleteProperty"</code>).</li>
  10127. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  10128. <li>If <i>trap</i> is <b>undefined</b>, then
  10129. <ol class="block">
  10130. <li>Return <i>target</i>.[[Delete]](<i>P</i>).</li>
  10131. </ol>
  10132. </li>
  10133. <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
  10134. <i>handler</i>, &laquo;<i>target</i>, <i>P</i>&raquo;)).</li>
  10135. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
  10136. <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
  10137. <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
  10138. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
  10139. <li>If <i>targetDesc</i> is <b>undefined</b>, return <b>true</b>.</li>
  10140. <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  10141. <li>Return <b>true</b>.</li>
  10142. </ol>
  10143. <div class="note">
  10144. <p><span class="nh">NOTE</span> [[Delete]] for proxy objects enforces the following invariant:</p>
  10145. <ul>
  10146. <li>The result of [[Delete]] is a Boolean value.</li>
  10147. <li>A property cannot be reported as deleted, if it exists as a non-configurable own property of the target object.</li>
  10148. </ul>
  10149. </div>
  10150. </section>
  10151. <section id="sec-proxy-object-internal-methods-and-internal-slots-enumerate">
  10152. <h1><span class="secnum" id="sec-9.5.11"><a href="#sec-proxy-object-internal-methods-and-internal-slots-enumerate"
  10153. title="link to this section">9.5.11</a></span> [[Enumerate]] ()</h1>
  10154. <p>When the [[Enumerate]] internal method of a Proxy exotic object <var>O</var> is called the following steps are taken:</p>
  10155. <ol class="proc">
  10156. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  10157. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10158. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  10159. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  10160. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  10161. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  10162. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10163. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"enumerate"</code>).</li>
  10164. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  10165. <li>If <i>trap</i> is <b>undefined</b>, then
  10166. <ol class="block">
  10167. <li>Return <i>target</i>.[[Enumerate]]().</li>
  10168. </ol>
  10169. </li>
  10170. <li>Let <i>trapResult</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>&raquo;).</li>
  10171. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
  10172. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>trapResult</i>) is not Object, throw a <b>TypeError</b>
  10173. exception.</li>
  10174. <li>Return <i>trapResult</i>.</li>
  10175. </ol>
  10176. <div class="note">
  10177. <p><span class="nh">NOTE</span> [[Enumerate]] for proxy objects enforces the following invariants:</p>
  10178. <ul>
  10179. <li>The result of [[Enumerate]] must be an Object.</li>
  10180. </ul>
  10181. </div>
  10182. </section>
  10183. <section id="sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys">
  10184. <h1><span class="secnum" id="sec-9.5.12"><a href="#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys"
  10185. title="link to this section">9.5.12</a></span> [[OwnPropertyKeys]] ( )</h1>
  10186. <p>When the [[OwnPropertyKeys]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
  10187. taken:</p>
  10188. <ol class="proc">
  10189. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  10190. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10191. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  10192. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  10193. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  10194. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  10195. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10196. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"ownKeys"</code>).</li>
  10197. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  10198. <li>If <i>trap</i> is <b>undefined</b>, then
  10199. <ol class="block">
  10200. <li>Return <i>target</i>.[[OwnPropertyKeys]]().</li>
  10201. </ol>
  10202. </li>
  10203. <li>Let <i>trapResultArray</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>,
  10204. &laquo;<i>target</i>&raquo;).</li>
  10205. <li>Let <i>trapResult</i> be <a href="#sec-createlistfromarraylike">CreateListFromArrayLike</a>(<i>trapResultArray</i>,
  10206. &laquo;&zwj;String, Symbol&raquo;).</li>
  10207. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
  10208. <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
  10209. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
  10210. <li>Let <i>targetKeys</i> be <i>target</i>.[[OwnPropertyKeys]]().</li>
  10211. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetKeys</i>).</li>
  10212. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>targetKeys</i> is a <a
  10213. href="#sec-list-and-record-specification-type">List</a> containing only String and Symbol values.</li>
  10214. <li>Let <i>targetConfigurableKeys</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  10215. <li>Let <i>targetNonconfigurableKeys</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  10216. <li>Repeat, for each element <i>key</i> of <i>targetKeys</i>,
  10217. <ol class="block">
  10218. <li>Let <i>desc</i> be <i>target</i>.[[GetOwnProperty]](<i>key</i>).</li>
  10219. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
  10220. <li>If <i>desc</i> is not <b>undefined</b> and <i>desc.</i>[[Configurable]] is <b>false</b>, then
  10221. <ol class="block">
  10222. <li>Append <i>key</i> as an element of <i>targetNonconfigurableKeys</i>.</li>
  10223. </ol>
  10224. </li>
  10225. <li>Else,
  10226. <ol class="block">
  10227. <li>Append <i>key</i> as an element of <i>targetConfigurableKeys</i>.</li>
  10228. </ol>
  10229. </li>
  10230. </ol>
  10231. </li>
  10232. <li>If <i>extensibleTarget</i> is <b>true</b> and <i>targetNonconfigurableKeys</i> is empty, then
  10233. <ol class="block">
  10234. <li>Return <i>trapResult</i>.</li>
  10235. </ol>
  10236. </li>
  10237. <li>Let <i>uncheckedResultKeys</i> be a new <a href="#sec-list-and-record-specification-type">List</a> which is a copy of
  10238. <i>trapResult</i>.</li>
  10239. <li>Repeat, for each <i>key</i> that is an element of <i>targetNonconfigurableKeys</i>,
  10240. <ol class="block">
  10241. <li>If <i>key</i> is not an element of <i>uncheckedResultKeys</i>, throw a <b>TypeError</b> exception.</li>
  10242. <li>Remove <i>key</i> from <i>uncheckedResultKeys</i></li>
  10243. </ol>
  10244. </li>
  10245. <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>trapResult</i>.</li>
  10246. <li>Repeat, for each <i>key</i> that is an element of <i>targetConfigurableKeys</i>,
  10247. <ol class="block">
  10248. <li>If <i>key</i> is not an element of <i>uncheckedResultKeys</i>, throw a <b>TypeError</b> exception.</li>
  10249. <li>Remove <i>key</i> from <i>uncheckedResultKeys</i></li>
  10250. </ol>
  10251. </li>
  10252. <li>If <i>uncheckedResultKeys</i> is not empty, throw a <b>TypeError</b> exception.</li>
  10253. <li>Return <i>trapResult</i>.</li>
  10254. </ol>
  10255. <div class="note">
  10256. <p><span class="nh">NOTE</span> [[OwnPropertyKeys]] for proxy objects enforces the following invariants:</p>
  10257. <ul>
  10258. <li>
  10259. <p>The result of [[OwnPropertyKeys]] is a <a href="#sec-list-and-record-specification-type">List</a>.</p>
  10260. </li>
  10261. <li>
  10262. <p>The Type of each result <a href="#sec-list-and-record-specification-type">List</a> element is either String or
  10263. Symbol.</p>
  10264. </li>
  10265. <li>
  10266. <p>The result <a href="#sec-list-and-record-specification-type">List</a> must contain the keys of all non-configurable
  10267. own properties of the target object.</p>
  10268. </li>
  10269. <li>
  10270. <p>If the target object is not extensible, then the result <a href="#sec-list-and-record-specification-type">List</a>
  10271. must contain all the keys of the own properties of the target object and no other values.</p>
  10272. </li>
  10273. </ul>
  10274. </div>
  10275. </section>
  10276. <section id="sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist">
  10277. <h1><span class="secnum" id="sec-9.5.13"><a
  10278. href="#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist"
  10279. title="link to this section">9.5.13</a></span> [[Call]] (thisArgument, argumentsList)</h1>
  10280. <p>The [[Call]] internal method of a Proxy exotic object <var>O</var> is called with parameters <var>thisArgument</var> and
  10281. <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
  10282. href="#sec-ecmascript-language-types">ECMAScript language values</a>. The following steps are taken:</p>
  10283. <ol class="proc">
  10284. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  10285. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10286. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  10287. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  10288. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  10289. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  10290. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10291. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"apply"</code>).</li>
  10292. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  10293. <li>If <i>trap</i> is <b>undefined</b>, then
  10294. <ol class="block">
  10295. <li>Return <a href="#sec-call">Call</a>(<i>target</i>, <i>thisArgument</i>, <i>argumentsList</i>).</li>
  10296. </ol>
  10297. </li>
  10298. <li>Let <i>argArray</i> be <a href="#sec-createarrayfromlist">CreateArrayFromList</a>(<i>argumentsList</i>).</li>
  10299. <li>Return <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>, <i>thisArgument</i>,
  10300. <i>argArray</i>&raquo;).</li>
  10301. </ol>
  10302. <div class="note">
  10303. <p><span class="nh">NOTE</span> A Proxy exotic object only has a [[Call]] internal method if the initial value of its
  10304. [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is an object that has a
  10305. [[Call]] internal method.</p>
  10306. </div>
  10307. </section>
  10308. <section id="sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget">
  10309. <h1><span class="secnum" id="sec-9.5.14"><a
  10310. href="#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget"
  10311. title="link to this section">9.5.14</a></span> [[Construct]] ( argumentsList, newTarget)</h1>
  10312. <p>The [[Construct]] internal method of a Proxy exotic object <var>O</var> is called with parameters
  10313. <var>argumentsList</var> which is a possibly empty <a href="#sec-list-and-record-specification-type">List</a> of <a
  10314. href="#sec-ecmascript-language-types">ECMAScript language values</a> and <var>newTarget</var>. The following steps are
  10315. taken:</p>
  10316. <ol class="proc">
  10317. <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
  10318. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10319. <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
  10320. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  10321. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
  10322. <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
  10323. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
  10324. <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"construct"</code>).</li>
  10325. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
  10326. <li>If <i>trap</i> is <b>undefined</b>, then
  10327. <ol class="block">
  10328. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>target</i> has a [[Construct]] internal method.</li>
  10329. <li>Return <a href="#sec-construct">Construct</a>(<i>target</i>, <i>argumentsList</i>, <i>newTarget</i>).</li>
  10330. </ol>
  10331. </li>
  10332. <li>Let <i>argArray</i> be <a href="#sec-createarrayfromlist">CreateArrayFromList</a>(<i>argumentsList</i>).</li>
  10333. <li>Let <i>newObj</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>, <i>argArray</i>,
  10334. <i>newTarget</i> &raquo;).</li>
  10335. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newObj</i>).</li>
  10336. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newObj</i>) is not Object, throw a <b>TypeError</b>
  10337. exception.</li>
  10338. <li>Return <i>newObj</i>.</li>
  10339. </ol>
  10340. <div class="note">
  10341. <p><span class="nh">NOTE 1</span> A Proxy exotic object only has a [[Construct]] internal method if the initial value of
  10342. its [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is an object that has a
  10343. [[Construct]] internal method.</p>
  10344. </div>
  10345. <div class="note">
  10346. <p><span class="nh">NOTE 2</span> [[Construct]] for proxy objects enforces the following invariants:</p>
  10347. <ul>
  10348. <li>The result of [[Construct]] must be an Object.</li>
  10349. </ul>
  10350. </div>
  10351. </section>
  10352. <section id="sec-proxycreate">
  10353. <h1><span class="secnum" id="sec-9.5.15"><a href="#sec-proxycreate" title="link to this section">9.5.15</a></span>
  10354. ProxyCreate(target, handler)</h1>
  10355. <p>The abstract operation ProxyCreate with arguments <var>target</var> and <var>handler</var> is used to specify the
  10356. creation of new Proxy exotic objects. It performs the following steps:</p>
  10357. <ol class="proc">
  10358. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>target</i>) is not Object, throw a <b>TypeError</b>
  10359. Exception.</li>
  10360. <li>If <i>target</i> is a Proxy exotic object and the value of the [[ProxyHandler]] <a
  10361. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>target</i> is <b>null</b>, throw a
  10362. <b>TypeError</b> exception.</li>
  10363. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is not Object, throw a <b>TypeError</b>
  10364. Exception.</li>
  10365. <li>If <i>handler</i> is a Proxy exotic object and the value of the [[ProxyHandler]] <a
  10366. href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>handler</i> is <b>null</b>, throw a
  10367. <b>TypeError</b> exception.</li>
  10368. <li>Let <i>P</i> be a newly created object.</li>
  10369. <li>Set <i>P</i>&rsquo;s essential internal methods (except for [[Call]] and [[Construct]]) to the definitions specified
  10370. in <a href="#sec-proxy-object-internal-methods-and-internal-slots">9.5</a>.</li>
  10371. <li>If <a href="#sec-iscallable">IsCallable</a>(<i>target</i>) is <b>true</b>, then
  10372. <ol class="block">
  10373. <li>Set the [[Call]] internal method of <i>P</i> as specified in <a
  10374. href="#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist">9.5.13</a>.</li>
  10375. <li>If <i>target</i> has a [[Construct]] internal method, then
  10376. <ol class="block">
  10377. <li>Set the [[Construct]] internal method of <i>P</i> as specified in <a
  10378. href="#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget">9.5.14</a>.</li>
  10379. </ol>
  10380. </li>
  10381. </ol>
  10382. </li>
  10383. <li>Set the [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>P</i> to
  10384. <i>target</i>.</li>
  10385. <li>Set the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>P</i> to
  10386. <i>handler</i>.</li>
  10387. <li>Return <i>P</i>.</li>
  10388. </ol>
  10389. </section>
  10390. </section>
  10391. </section>
  10392. <section id="sec-ecmascript-language-source-code">
  10393. <div class="front">
  10394. <h1><span class="secnum" id="sec-10"><a href="#sec-ecmascript-language-source-code" title="link to this section">10</a></span>
  10395. ECMAScript Language: Source Code</h1>
  10396. </div>
  10397. <section id="sec-source-text">
  10398. <div class="front">
  10399. <h1><span class="secnum" id="sec-10.1"><a href="#sec-source-text" title="link to this section">10.1</a></span> Source
  10400. Text</h1>
  10401. <h2>Syntax</h2>
  10402. <div class="gp">
  10403. <div class="lhs"><span class="nt">SourceCharacter</span> <span class="geq">::</span></div>
  10404. <div class="rhs"><span class="gprose">any Unicode code point</span></div>
  10405. </div>
  10406. <p>ECMAScript code is expressed using Unicode, version 5.1 or later. ECMAScript source text is a sequence of code points.
  10407. All Unicode code point values from U+0000 to U+10FFFF, including surrogate code points, may occur in source text where
  10408. permitted by the ECMAScript grammars. The actual encodings used to store and interchange ECMAScript source text is not
  10409. relevant to this specification. Regardless of the external source text encoding, a conforming ECMAScript implementation
  10410. processes the source text as if it was an equivalent sequence of <span class="nt">SourceCharacter</span> values. Each <span
  10411. class="nt">SourceCharacter</span> being a Unicode code point. Conforming ECMAScript implementations are not required to
  10412. perform any normalization of source text, or behave as though they were performing normalization of source text.</p>
  10413. <p>The components of a combining character sequence are treated as individual Unicode code points even though a user might
  10414. think of the whole sequence as a single character.</p>
  10415. <div class="note">
  10416. <p><span class="nh">NOTE</span> In string literals, regular expression literals, template literals and identifiers, any
  10417. Unicode code point may also be expressed using Unicode escape sequences that explicitly express a code point&rsquo;s
  10418. numeric value. Within a comment, such an escape sequence is effectively ignored as part of the comment.</p>
  10419. <p>ECMAScript differs from the Java programming language in the behaviour of Unicode escape sequences. In a Java program,
  10420. if the Unicode escape sequence <code>\u000A</code>, for example, occurs within a single-line comment, it is interpreted as
  10421. a line terminator (Unicode code point U+000A is line feed (lf)) and therefore the next code point is not part of the
  10422. comment. Similarly, if the Unicode escape sequence <code>\u000A</code> occurs within a string literal in a Java program,
  10423. it is likewise interpreted as a line terminator, which is not allowed within a string literal&mdash;one must write
  10424. <code>\n</code> instead of <code>\u000A</code> to cause a line feed (lf) to be part of the string value of a string
  10425. literal. In an ECMAScript program, a Unicode escape sequence occurring within a comment is never interpreted and therefore
  10426. cannot contribute to termination of the comment. Similarly, a Unicode escape sequence occurring within a string literal in
  10427. an ECMAScript program always contributes to the literal and is never interpreted as a line terminator or as a code point
  10428. that might terminate the string literal.</p>
  10429. </div>
  10430. </div>
  10431. <section id="sec-utf16encoding">
  10432. <h1><span class="secnum" id="sec-10.1.1"><a href="#sec-utf16encoding" title="link to this section">10.1.1</a></span> Static
  10433. Semantics: <i>UTF16Encoding ( cp )</i></h1>
  10434. <p>The UTF16Encoding of a numeric code point value, <var>cp</var>, is determined as follows:</p>
  10435. <ol class="proc">
  10436. <li><a href="#sec-algorithm-conventions">Assert</a>: 0 &le; <i>cp</i> &le; 0x10FFFF.</li>
  10437. <li>If <i>cp</i> &le; 65535, return <i>cp</i>.</li>
  10438. <li>Let <i>cu1</i> be <a href="#sec-algorithm-conventions">floor</a>((<i>cp</i> &ndash; 65536) / 1024) + 0xD800.</li>
  10439. <li>Let <i>cu2</i> be ((<i>cp</i> &ndash; 65536) <a href="#sec-algorithm-conventions">modulo</a> 1024) + 0xDC00.</li>
  10440. <li>Return the code unit sequence consisting of <i>cu1</i> followed by <i>cu2</i>.</li>
  10441. </ol>
  10442. </section>
  10443. <section id="sec-utf16decode">
  10444. <h1><span class="secnum" id="sec-10.1.2"><a href="#sec-utf16decode" title="link to this section">10.1.2</a></span> Static
  10445. Semantics: UTF16Decode( lead, trail )</h1>
  10446. <p>Two code units, <var>lead</var> and <var>trail</var>, that form a UTF-16 surrogate pair are converted to a code point by
  10447. performing the following steps:</p>
  10448. <ol class="proc">
  10449. <li><a href="#sec-algorithm-conventions">Assert</a>: 0xD800 &le; <i>lead</i> &le; 0xDBFF and 0xDC00 &le; <i>trail</i> &le;
  10450. 0xDFFF.</li>
  10451. <li>Let <i>cp</i> be (<i>lead</i> &ndash; 0xD800) &times; 1024 + (<i>trail</i> &ndash; 0xDC00) + 0x10000.</li>
  10452. <li>Return the code point <i>cp</i>.</li>
  10453. </ol>
  10454. </section>
  10455. </section>
  10456. <section id="sec-types-of-source-code">
  10457. <div class="front">
  10458. <h1><span class="secnum" id="sec-10.2"><a href="#sec-types-of-source-code" title="link to this section">10.2</a></span>
  10459. Types of Source Code</h1>
  10460. <p>There are four types of ECMAScript code:</p>
  10461. <ul>
  10462. <li>
  10463. <p><i>Global code</i> is source text that is treated as an ECMAScript <i>Script</i>. The global code of a particular
  10464. <i>Script</i> does not include any source text that is parsed as part of a <i>FunctionDeclaration</i>,
  10465. <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>, <i>GeneratorExpression</i>, <i>MethodDefinition</i>,
  10466. <i>ArrowFunction, ClassDeclaration</i>, or <i>ClassExpression</i>.</p>
  10467. </li>
  10468. <li>
  10469. <p><i>Eval code</i> is the source text supplied to the built-in <code>eval</code> function. More precisely, if the
  10470. parameter to the built-in <code>eval</code> function is a String, it is treated as an ECMAScript <i>Script</i>. The eval
  10471. code for a particular invocation of <code>eval</code> is the global code portion of that <i>Script</i>.</p>
  10472. </li>
  10473. <li>
  10474. <p><i>Function code</i> is source text that is parsed to supply the value of the [[ECMAScriptCode]] and
  10475. [[FormalParameters]] internal slots (<a href="#sec-ecmascript-function-objects">see 9.2</a>) of an <a
  10476. href="#sec-ecmascript-function-objects">ECMAScript function object</a>. The function code of a particular ECMAScript
  10477. function does not include any source text that is parsed as the function code of a nested <i>FunctionDeclaration</i>,
  10478. <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>, <i>GeneratorExpression</i>, <i>MethodDefinition</i>,
  10479. <i>ArrowFunction, ClassDeclaration</i>, or <i>ClassExpression</i>.</p>
  10480. </li>
  10481. <li>
  10482. <p><i>Module code</i> is source text that is code that is provided as a <i>ModuleBody</i>. It is the code that is
  10483. directly evaluated when a module is initialized. The module code of a particular module does not include any source text
  10484. that is parsed as part of a nested <i>FunctionDeclaration</i>, <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>,
  10485. <i>GeneratorExpression</i>, <i>MethodDefinition</i>, <i>ArrowFunction, ClassDeclaration</i>, or
  10486. <i>ClassExpression</i>.</p>
  10487. </li>
  10488. </ul>
  10489. <div class="note">
  10490. <p><span class="nh">NOTE</span> Function code is generally provided as the bodies of Function Definitions (<a
  10491. href="#sec-function-definitions">14.1</a>), Arrow Function Definitions (<a
  10492. href="#sec-arrow-function-definitions">14.2</a>), Method Definitions (<a href="#sec-method-definitions">14.3</a>) and
  10493. Generator Definitions (<a href="#sec-generator-function-definitions">14.4</a>). Function code is also derived from the
  10494. arguments to the <code>Function</code> constructor (<a href="#sec-function-p1-p2-pn-body">19.2.1.1</a>) and the
  10495. GeneratorFunction constructor (<a href="#sec-generatorfunction">25.2.1.1</a>).</p>
  10496. </div>
  10497. </div>
  10498. <section id="sec-strict-mode-code">
  10499. <h1><span class="secnum" id="sec-10.2.1"><a href="#sec-strict-mode-code" title="link to this section">10.2.1</a></span>
  10500. Strict Mode Code</h1>
  10501. <p>An ECMAScript <span class="nt">Script</span> syntactic unit may be processed using either unrestricted or strict mode
  10502. syntax and semantics. Code is interpreted as <i>strict mode code</i> in the following situations:</p>
  10503. <ul>
  10504. <li>
  10505. <p>Global code is strict mode code if it begins with a <a
  10506. href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
  10507. href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a> (see <a
  10508. href="#sec-directive-prologues-and-the-use-strict-directive">14.1.1</a>).</p>
  10509. </li>
  10510. <li>
  10511. <p>Module code is always strict mode code.</p>
  10512. </li>
  10513. <li>
  10514. <p>All parts of a <span class="nt">ClassDeclaration</span> or a <span class="nt">ClassExpression</span> are strict mode
  10515. code.</p>
  10516. </li>
  10517. <li>
  10518. <p>Eval code is strict mode code if it begins with a <a
  10519. href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
  10520. href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a> or if the call to eval is a direct
  10521. eval (<a href="#sec-function-calls-runtime-semantics-evaluation">see 12.3.4.1</a>) that is contained in strict mode
  10522. code.</p>
  10523. </li>
  10524. <li>
  10525. <p>Function code is strict mode code if the associated <span class="nt">FunctionDeclaration</span>, <span
  10526. class="nt">FunctionExpression</span>, <span class="nt">GeneratorDeclaration</span>, <span
  10527. class="nt">GeneratorExpression</span>, <span class="nt">MethodDefinition</span>, or <span
  10528. class="nt">ArrowFunction</span> is contained in strict mode code or if the code that produces the value of the
  10529. function&rsquo;s [[ECMAScriptCode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> begins
  10530. with a <a href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
  10531. href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a>.</p>
  10532. </li>
  10533. <li>
  10534. <p>Function code that is supplied as the arguments to the built-in <code>Function</code> and <code>Generator</code>
  10535. constructors is strict mode code if the last argument is a String that when processed has a <span
  10536. class="nt">FunctionBody</span> begins with a <a href="#sec-directive-prologues-and-the-use-strict-directive">Directive
  10537. Prologue</a> that contains a <a href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict
  10538. Directive</a>.</p>
  10539. </li>
  10540. </ul>
  10541. <p>ECMAScript code that is not strict mode code is called <i>non-strict code</i>.</p>
  10542. </section>
  10543. <section id="sec-non-ecmascript-functions">
  10544. <h1><span class="secnum" id="sec-10.2.2"><a href="#sec-non-ecmascript-functions"
  10545. title="link to this section">10.2.2</a></span> Non-ECMAScript Functions</h1>
  10546. <p>An ECMAScript implementation may support the evaluation of exotic function objects whose evaluative behaviour is
  10547. expressed in some implementation defined form of executable code other than via ECMAScript code. Whether a function object
  10548. is an ECMAScript code function or a non-ECMAScript function is not semantically observable from the perspective of an
  10549. ECMAScript code function that calls or is called by such a non-ECMAScript function.</p>
  10550. </section>
  10551. </section>
  10552. </section>
  10553. <section id="sec-ecmascript-language-lexical-grammar">
  10554. <div class="front">
  10555. <h1><span class="secnum" id="sec-11"><a href="#sec-ecmascript-language-lexical-grammar"
  10556. title="link to this section">11</a></span> ECMAScript Language: Lexical Grammar</h1>
  10557. <p>The source text of an ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span> is first converted into a
  10558. sequence of input elements, which are tokens, line terminators, comments, or white space. The source text is scanned from left
  10559. to right, repeatedly taking the longest possible sequence of code points as the next input element.</p>
  10560. <p>There are several situations where the identification of lexical input elements is sensitive to the syntactic grammar
  10561. context that is consuming the input elements. This requires multiple goal symbols for the lexical grammar. The <span
  10562. class="nt">InputElementRegExpOrTemplateTail</span> goal is used in syntactic grammar contexts where a
  10563. <var>RegularExpressionLiteral,</var> a <var>TemplateMiddle,</var> or a <span class="nt">TemplateTail</span> is permitted. The
  10564. <span class="nt">InputElementRegExp</span> goal symbol is used in all syntactic grammar contexts where a <span
  10565. class="nt">RegularExpressionLiteral</span> is permitted but neither a <var>TemplateMiddle,</var> nor a <span
  10566. class="nt">TemplateTail</span> is permitted. The <span class="nt">InputElementTemplateTail</span> goal is used in all
  10567. syntactic grammar contexts where a <span class="nt">TemplateMiddle</span> or a <span class="nt">TemplateTail</span> is
  10568. permitted but a <span class="nt">RegularExpressionLiteral</span> is not permitted. In all other contexts, <span
  10569. class="nt">InputElementDiv</span> is used as the lexical goal symbol.</p>
  10570. <div class="note">
  10571. <p><span class="nh">NOTE</span> The use of multiple lexical goals ensures that there are no lexical ambiguities that would
  10572. affect <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>. For example, there are no syntactic
  10573. grammar contexts where both a leading division or division-assignment, and a leading <i>RegularExpressionLiteral</i> are
  10574. permitted. This is not affected by semicolon insertion (<a href="#sec-automatic-semicolon-insertion">see 11.9</a>); in
  10575. examples such as the following:</p>
  10576. <pre>a = b<br>/hi/g.exec(c).map(d);</pre>
  10577. <p>where the first non-whitespace, non-comment code point after a <i>LineTerminator</i> is U+002F (SOLIDUS) and the
  10578. syntactic context allows division or division-assignment, no semicolon is inserted at the <i>LineTerminator</i>. That is,
  10579. the above example is interpreted in the same way as:</p>
  10580. <pre>a = b / hi / g.exec(c).map(d);</pre>
  10581. </div>
  10582. <h2>Syntax</h2>
  10583. <div class="gp">
  10584. <div class="lhs"><span class="nt">InputElementDiv</span> <span class="geq">::</span></div>
  10585. <div class="rhs"><span class="nt">WhiteSpace</span></div>
  10586. <div class="rhs"><span class="nt">LineTerminator</span></div>
  10587. <div class="rhs"><span class="nt">Comment</span></div>
  10588. <div class="rhs"><span class="nt">CommonToken</span></div>
  10589. <div class="rhs"><span class="nt">DivPunctuator</span></div>
  10590. <div class="rhs"><span class="nt">RightBracePunctuator</span></div>
  10591. </div>
  10592. <div class="gp">
  10593. <div class="lhs"><span class="nt">InputElementRegExp</span> <span class="geq">::</span></div>
  10594. <div class="rhs"><span class="nt">WhiteSpace</span></div>
  10595. <div class="rhs"><span class="nt">LineTerminator</span></div>
  10596. <div class="rhs"><span class="nt">Comment</span></div>
  10597. <div class="rhs"><span class="nt">CommonToken</span></div>
  10598. <div class="rhs"><span class="nt">RightBracePunctuator</span></div>
  10599. <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
  10600. </div>
  10601. <div class="gp">
  10602. <div class="lhs"><span class="nt">InputElementRegExpOrTemplateTail</span> <span class="geq">::</span></div>
  10603. <div class="rhs"><span class="nt">WhiteSpace</span></div>
  10604. <div class="rhs"><span class="nt">LineTerminator</span></div>
  10605. <div class="rhs"><span class="nt">Comment</span></div>
  10606. <div class="rhs"><span class="nt">CommonToken</span></div>
  10607. <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
  10608. <div class="rhs"><span class="nt">TemplateSubstitutionTail</span></div>
  10609. </div>
  10610. <div class="gp">
  10611. <div class="lhs"><span class="nt">InputElementTemplateTail</span> <span class="geq">::</span></div>
  10612. <div class="rhs"><span class="nt">WhiteSpace</span></div>
  10613. <div class="rhs"><span class="nt">LineTerminator</span></div>
  10614. <div class="rhs"><span class="nt">Comment</span></div>
  10615. <div class="rhs"><span class="nt">CommonToken</span></div>
  10616. <div class="rhs"><span class="nt">DivPunctuator</span></div>
  10617. <div class="rhs"><span class="nt">TemplateSubstitutionTail</span></div>
  10618. </div>
  10619. </div>
  10620. <section id="sec-unicode-format-control-characters">
  10621. <h1><span class="secnum" id="sec-11.1"><a href="#sec-unicode-format-control-characters"
  10622. title="link to this section">11.1</a></span> Unicode Format-Control Characters</h1>
  10623. <p>The Unicode format-control characters (i.e., the characters in category &ldquo;Cf&rdquo; in the Unicode Character Database
  10624. such as left-to-right mark or right-to-left mark) are control codes used to control the formatting of a range of text in the
  10625. absence of higher-level protocols for this (such as mark-up languages).</p>
  10626. <p>It is useful to allow format-control characters in source text to facilitate editing and display. All format control
  10627. characters may be used within comments, and within string literals, template literals, and regular expression literals.</p>
  10628. <p>U+200C <span style="font-family: Times New Roman">(</span>Zero width non-joiner<span style="font-family: Times New
  10629. Roman">)</span> and U+200D <span style="font-family: Times New Roman">(</span>Zero width joiner<span style="font-family: Times
  10630. New Roman">)</span> are format-control characters that are used to make necessary distinctions when forming words or phrases
  10631. in certain languages. In ECMAScript source text these code points may also be used in an <span
  10632. class="nt">IdentifierName</span> (<a href="#sec-identifier-names">see 11.6.1</a>) after the first character.</p>
  10633. <p>U+FEFF <span style="font-family: Times New Roman">(</span>Zero Width no-break space<span style="font-family: Times New
  10634. Roman">)</span> is a format-control character used primarily at the start of a text to mark it as Unicode and to allow
  10635. detection of the text's encoding and byte order. <span style="font-family: Times New Roman">&lt;ZWNBSP&gt;</span> characters
  10636. intended for this purpose can sometimes also appear after the start of a text, for example as a result of concatenating files.
  10637. In ECMAScript source text &lt;ZWNBSP&gt; code points are treated as white space characters (<a href="#sec-white-space">see
  10638. 11.2</a>).</p>
  10639. <p>The special treatment of certain format-control characters outside of comments, string literals, and regular expression
  10640. literals is summarized in <a href="#table-31">Table 31</a>.</p>
  10641. <figure>
  10642. <figcaption><span id="table-31">Table 31</span> &mdash; Format-Control Code Point Usage</figcaption>
  10643. <table class="real-table">
  10644. <tr>
  10645. <th>Code Point</th>
  10646. <th>Name</th>
  10647. <th>Abbreviation</th>
  10648. <th>Usage</th>
  10649. </tr>
  10650. <tr>
  10651. <td><code>U+200C</code></td>
  10652. <td>Zero width non-joiner</td>
  10653. <td>&lt;ZWNJ&gt;</td>
  10654. <td><i>IdentifierPart</i></td>
  10655. </tr>
  10656. <tr>
  10657. <td><code>U+200D</code></td>
  10658. <td>Zero width joiner</td>
  10659. <td>&lt;ZWJ&gt;</td>
  10660. <td><i>IdentifierPart</i></td>
  10661. </tr>
  10662. <tr>
  10663. <td><code>U+FEFF</code></td>
  10664. <td>ZERO WIDTH NO-BREAK SPACE</td>
  10665. <td>&lt;ZWNBSP&gt;</td>
  10666. <td><i>WhiteSpace</i></td>
  10667. </tr>
  10668. </table>
  10669. </figure>
  10670. </section>
  10671. <section id="sec-white-space">
  10672. <h1><span class="secnum" id="sec-11.2"><a href="#sec-white-space" title="link to this section">11.2</a></span> White
  10673. Space</h1>
  10674. <p>White space code points are used to improve source text readability and to separate tokens (indivisible lexical units) from
  10675. each other, but are otherwise insignificant. White space code points may occur between any two tokens and at the start or end
  10676. of input. White space code points may occur within a <span class="nt">StringLiteral</span>, a <span
  10677. class="nt">RegularExpressionLiteral</span>, a <span class="nt">Template</span>, or a <span
  10678. class="nt">TemplateSubstitutionTail</span> where they are considered significant code points forming part of a literal value.
  10679. They may also occur within a <span class="nt">Comment</span>, but cannot appear within any other kind of token.</p>
  10680. <p>The ECMAScript white space code points are listed in <a href="#table-32">Table 32</a>.</p>
  10681. <figure>
  10682. <figcaption><span id="table-32">Table 32</span> &mdash; White Space Code Points</figcaption>
  10683. <table class="real-table">
  10684. <tr>
  10685. <th>Code Point</th>
  10686. <th>Name</th>
  10687. <th>Abbreviation</th>
  10688. </tr>
  10689. <tr>
  10690. <td><code>U+0009</code></td>
  10691. <td>Character Tabulation</td>
  10692. <td>&lt;TAB&gt;</td>
  10693. </tr>
  10694. <tr>
  10695. <td><code>U+000B</code></td>
  10696. <td>LINE TABULATION</td>
  10697. <td>&lt;VT&gt;</td>
  10698. </tr>
  10699. <tr>
  10700. <td><code>U+000C</code></td>
  10701. <td>Form Feed (ff)</td>
  10702. <td>&lt;FF&gt;</td>
  10703. </tr>
  10704. <tr>
  10705. <td><code>U+0020</code></td>
  10706. <td>Space</td>
  10707. <td>&lt;SP&gt;</td>
  10708. </tr>
  10709. <tr>
  10710. <td><code>U+00A0</code></td>
  10711. <td>No-break space</td>
  10712. <td>&lt;NBSP&gt;</td>
  10713. </tr>
  10714. <tr>
  10715. <td><code>U+FEFF</code></td>
  10716. <td>ZERO wIDTH nO-bREAK SPACE</td>
  10717. <td>&lt;ZWNBSP&gt;</td>
  10718. </tr>
  10719. <tr>
  10720. <td>Other category &ldquo;Zs&rdquo;</td>
  10721. <td>Any other Unicode &ldquo;Separator, space&rdquo; code point</td>
  10722. <td>&lt;USP&gt;</td>
  10723. </tr>
  10724. </table>
  10725. </figure>
  10726. <p>ECMAScript implementations must recognize as <span class="nt">WhiteSpace</span> code points listed in the &ldquo;Separator,
  10727. space&rdquo; (Zs) category by Unicode 5.1. ECMAScript implementations may also recognize as <span class="nt">WhiteSpace</span>
  10728. additional category Zs code points from subsequent editions of the Unicode Standard.</p>
  10729. <div class="note">
  10730. <p><span class="nh">NOTE</span> Other than for the code points listed in <a href="#table-32">Table 32</a>, ECMAScript
  10731. <i>WhiteSpace</i> intentionally excludes all code points that have the Unicode &ldquo;White_Space&rdquo; property but which
  10732. are not classified in category &ldquo;Zs&rdquo;.</p>
  10733. </div>
  10734. <h2>Syntax</h2>
  10735. <div class="gp">
  10736. <div class="lhs"><span class="nt">WhiteSpace</span> <span class="geq">::</span></div>
  10737. <div class="rhs">&lt;TAB&gt;</div>
  10738. <div class="rhs">&lt;VT&gt;</div>
  10739. <div class="rhs">&lt;FF&gt;</div>
  10740. <div class="rhs">&lt;SP&gt;</div>
  10741. <div class="rhs">&lt;NBSP&gt;</div>
  10742. <div class="rhs">&lt;zwnbsp&gt;</div>
  10743. <div class="rhs">&lt;USP&gt;</div>
  10744. </div>
  10745. </section>
  10746. <section id="sec-line-terminators">
  10747. <h1><span class="secnum" id="sec-11.3"><a href="#sec-line-terminators" title="link to this section">11.3</a></span> Line
  10748. Terminators</h1>
  10749. <p>Like white space code points, line terminator code points are used to improve source text readability and to separate
  10750. tokens (indivisible lexical units) from each other. However, unlike white space code points, line terminators have some
  10751. influence over the behaviour of the syntactic grammar. In general, line terminators may occur between any two tokens, but
  10752. there are a few places where they are forbidden by the syntactic grammar. Line terminators also affect the process of <a
  10753. href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a
  10754. href="#sec-automatic-semicolon-insertion">11.9</a>). A line terminator cannot occur within any token except a <span
  10755. class="nt">StringLiteral</span>, <span class="nt">Template</span>, or <span class="nt">TemplateSubstitutionTail</span>. Line
  10756. terminators may only occur within a <span class="nt">StringLiteral</span> token as part of a <span
  10757. class="nt">LineContinuation</span>.</p>
  10758. <p>A line terminator can occur within a <span class="nt">MultiLineComment</span> (<a href="#sec-comments">11.4</a>) but cannot
  10759. occur within a <span class="nt">SingleLineComment</span>.</p>
  10760. <p>Line terminators are included in the set of white space code points that are matched by the <code>\s</code> class in
  10761. regular expressions.</p>
  10762. <p>The ECMAScript line terminator code points are listed in <a href="#table-33">Table 33</a>.</p>
  10763. <figure>
  10764. <figcaption><span id="table-33">Table 33</span> &mdash; Line Terminator Code Points</figcaption>
  10765. <table class="real-table">
  10766. <tr>
  10767. <th>Code Point</th>
  10768. <th>Unicode Name</th>
  10769. <th>Abbreviation</th>
  10770. </tr>
  10771. <tr>
  10772. <td><code>U+000A</code></td>
  10773. <td>Line Feed (LF)</td>
  10774. <td>&lt;LF&gt;</td>
  10775. </tr>
  10776. <tr>
  10777. <td><code>U+000D</code></td>
  10778. <td>Carriage Return (CR)</td>
  10779. <td>&lt;CR&gt;</td>
  10780. </tr>
  10781. <tr>
  10782. <td><code>U+2028</code></td>
  10783. <td>Line separator</td>
  10784. <td>&lt;LS&gt;</td>
  10785. </tr>
  10786. <tr>
  10787. <td><code>U+2029</code></td>
  10788. <td>Paragraph separator</td>
  10789. <td>&lt;PS&gt;</td>
  10790. </tr>
  10791. </table>
  10792. </figure>
  10793. <p>Only the Unicode code points in <a href="#table-33">Table 33</a> are treated as line terminators. Other new line or line
  10794. breaking Unicode code points are not treated as line terminators but are treated as white space if they meet the requirements
  10795. listed in <a href="#table-32">Table 32</a>. The sequence &lt;CR&gt;&lt;LF&gt; is commonly used as a line terminator. It should
  10796. be considered a single <span class="nt">SourceCharacter</span> for the purpose of reporting line numbers.</p>
  10797. <h2>Syntax</h2>
  10798. <div class="gp">
  10799. <div class="lhs"><span class="nt">LineTerminator</span> <span class="geq">::</span></div>
  10800. <div class="rhs">&lt;LF&gt;</div>
  10801. <div class="rhs">&lt;CR&gt;</div>
  10802. <div class="rhs">&lt;LS&gt;</div>
  10803. <div class="rhs">&lt;PS&gt;</div>
  10804. </div>
  10805. <div class="gp">
  10806. <div class="lhs"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></div>
  10807. <div class="rhs">&lt;LF&gt;</div>
  10808. <div class="rhs">&lt;CR&gt; <span class="grhsannot">[lookahead &ne; &lt;LF&gt; ]</span></div>
  10809. <div class="rhs">&lt;LS&gt;</div>
  10810. <div class="rhs">&lt;PS&gt;</div>
  10811. <div class="rhs">&lt;CR&gt; &lt;LF&gt;</div>
  10812. </div>
  10813. </section>
  10814. <section id="sec-comments">
  10815. <h1><span class="secnum" id="sec-11.4"><a href="#sec-comments" title="link to this section">11.4</a></span> Comments</h1>
  10816. <p>Comments can be either single or multi-line. Multi-line comments cannot nest.</p>
  10817. <p>Because a single-line comment can contain any Unicode code point except a <span class="nt">LineTerminator</span> code
  10818. point, and because of the general rule that a token is always as long as possible, a single-line comment always consists of
  10819. all code points from the <code>//</code> marker to the end of the line. However, the <span class="nt">LineTerminator</span> at
  10820. the end of the line is not considered to be part of the single-line comment; it is recognized separately by the lexical
  10821. grammar and becomes part of the stream of input elements for the syntactic grammar. This point is very important, because it
  10822. implies that the presence or absence of single-line comments does not affect the process of <a
  10823. href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a href="#sec-automatic-semicolon-insertion">see
  10824. 11.9</a>).</p>
  10825. <p>Comments behave like white space and are discarded except that, if a <span class="nt">MultiLineComment</span> contains a
  10826. line terminator code point, then the entire comment is considered to be a <span class="nt">LineTerminator</span> for purposes
  10827. of parsing by the syntactic grammar.</p>
  10828. <h2>Syntax</h2>
  10829. <div class="gp">
  10830. <div class="lhs"><span class="nt">Comment</span> <span class="geq">::</span></div>
  10831. <div class="rhs"><span class="nt">MultiLineComment</span></div>
  10832. <div class="rhs"><span class="nt">SingleLineComment</span></div>
  10833. </div>
  10834. <div class="gp">
  10835. <div class="lhs"><span class="nt">MultiLineComment</span> <span class="geq">::</span></div>
  10836. <div class="rhs"><code class="t">/*</code> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub> <code class="t">*/</code></div>
  10837. </div>
  10838. <div class="gp">
  10839. <div class="lhs"><span class="nt">MultiLineCommentChars</span> <span class="geq">::</span></div>
  10840. <div class="rhs"><span class="nt">MultiLineNotAsteriskChar</span> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub></div>
  10841. <div class="rhs"><code class="t">*</code> <span class="nt">PostAsteriskCommentChars</span><sub class="g-opt">opt</sub></div>
  10842. </div>
  10843. <div class="gp">
  10844. <div class="lhs"><span class="nt">PostAsteriskCommentChars</span> <span class="geq">::</span></div>
  10845. <div class="rhs"><span class="nt">MultiLineNotForwardSlashOrAsteriskChar</span> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub></div>
  10846. <div class="rhs"><code class="t">*</code> <span class="nt">PostAsteriskCommentChars</span><sub class="g-opt">opt</sub></div>
  10847. </div>
  10848. <div class="gp">
  10849. <div class="lhs"><span class="nt">MultiLineNotAsteriskChar</span> <span class="geq">::</span></div>
  10850. <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <code class="t">*</code></div>
  10851. </div>
  10852. <div class="gp">
  10853. <div class="lhs"><span class="nt">MultiLineNotForwardSlashOrAsteriskChar</span> <span class="geq">::</span></div>
  10854. <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">/</code> <span class="grhsmod">or</span> <code class="t">*</code></div>
  10855. </div>
  10856. <div class="gp">
  10857. <div class="lhs"><span class="nt">SingleLineComment</span> <span class="geq">::</span></div>
  10858. <div class="rhs"><code class="t">//</code> <span class="nt">SingleLineCommentChars</span><sub class="g-opt">opt</sub></div>
  10859. </div>
  10860. <div class="gp">
  10861. <div class="lhs"><span class="nt">SingleLineCommentChars</span> <span class="geq">::</span></div>
  10862. <div class="rhs"><span class="nt">SingleLineCommentChar</span> <span class="nt">SingleLineCommentChars</span><sub class="g-opt">opt</sub></div>
  10863. </div>
  10864. <div class="gp">
  10865. <div class="lhs"><span class="nt">SingleLineCommentChar</span> <span class="geq">::</span></div>
  10866. <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <span class="nt">LineTerminator</span></div>
  10867. </div>
  10868. </section>
  10869. <section id="sec-tokens">
  10870. <h1><span class="secnum" id="sec-11.5"><a href="#sec-tokens" title="link to this section">11.5</a></span> Tokens</h1>
  10871. <h2>Syntax</h2>
  10872. <div class="gp">
  10873. <div class="lhs"><span class="nt">CommonToken</span> <span class="geq">::</span></div>
  10874. <div class="rhs"><span class="nt">IdentifierName</span></div>
  10875. <div class="rhs"><span class="nt">Punctuator</span></div>
  10876. <div class="rhs"><span class="nt">NumericLiteral</span></div>
  10877. <div class="rhs"><span class="nt">StringLiteral</span></div>
  10878. <div class="rhs"><span class="nt">Template</span></div>
  10879. </div>
  10880. <div class="note">
  10881. <p><span class="nh">NOTE</span> The <i>DivPunctuator</i>, <i>RegularExpressionLiteral</i>, <i>RightBracePunctuator,</i> and
  10882. <i>TemplateSubstitutionTail</i> productions derive additional tokens that are not included in the <i>CommonToken</i>
  10883. production.</p>
  10884. </div>
  10885. </section>
  10886. <section id="sec-names-and-keywords">
  10887. <div class="front">
  10888. <h1><span class="secnum" id="sec-11.6"><a href="#sec-names-and-keywords" title="link to this section">11.6</a></span> Names
  10889. and Keywords</h1>
  10890. <p><span class="nt">IdentifierName</span> and <span class="nt">ReservedWord</span> are tokens that are interpreted according
  10891. to the Default Identifier Syntax given in Unicode Standard Annex #31, Identifier and Pattern Syntax, with some small
  10892. modifications. <span class="nt">ReservedWord</span> is an enumerated subset of <span style="font-family: Times New
  10893. Roman"><i>IdentifierName</i>.</span> The syntactic grammar defines <span class="nt">Identifier</span> as an <span
  10894. class="nt">IdentifierName</span> that is not a <span class="nt">ReservedWord</span> (<a href="#sec-reserved-words">see
  10895. 11.6.2</a>). The Unicode identifier grammar is based on character properties specified by the Unicode Standard. The Unicode
  10896. code points in the specified categories in version 5.1.0 of the Unicode standard must be treated as in those categories by
  10897. all conforming ECMAScript implementations. ECMAScript implementations may recognize identifier code points defined in later
  10898. editions of the Unicode Standard.</p>
  10899. <div class="note">
  10900. <p><span class="nh">NOTE</span> This standard specifies specific code point additions: <span style="font-family:
  10901. sans-serif">U+0024</span> (dollar sign) and <span style="font-family: sans-serif">U+005F</span> (<span style="font-family:
  10902. sans-serif">LOW LINE</span>) are permitted anywhere in an <i>IdentifierName</i><span style="font-family: sans-serif">, and
  10903. the code points</span> <span style="font-family: sans-serif">U+200C (zero-width non-joiner) and U+200D (zero-width joiner)
  10904. are permitted anywhere after the first code point</span> <span style="font-family: sans-serif">of an</span>
  10905. <i>IdentifierName</i>.</p>
  10906. </div>
  10907. <p>Unicode escape sequences are permitted in an <span class="nt">IdentifierName</span>, where they contribute a single
  10908. Unicode code point to the <span class="nt">IdentifierName</span>. The code point is expressed by the <span
  10909. class="nt">HexDigits</span> of the <span class="nt">UnicodeEscapeSequence</span> (<a
  10910. href="#sec-literals-string-literals">see 11.8.4</a>). The <code>\</code> preceding the <span
  10911. class="nt">UnicodeEscapeSequence</span> and the <code>u</code> and <code>{ }</code> code units, if they appear, do not
  10912. contribute code points to the <span class="nt">IdentifierName</span>. A <span class="nt">UnicodeEscapeSequence</span> cannot
  10913. be used to put a code point into an <span class="nt">IdentifierName</span> that would otherwise be illegal. In other words,
  10914. if a <code>\</code> <span class="nt">UnicodeEscapeSequence</span> sequence were replaced by the <span
  10915. class="nt">SourceCharacter</span> it contributes, the result must still be a valid <span class="nt">IdentifierName</span>
  10916. that has the exact same sequence of <span class="nt">SourceCharacter</span> elements as the original <span
  10917. class="nt">IdentifierName</span>. All interpretations of <span class="nt">IdentifierName</span> within this specification
  10918. are based upon their actual code points regardless of whether or not an escape sequence was used to contribute any
  10919. particular code point.</p>
  10920. <p>Two <span class="nt">IdentifierName</span> that are canonically equivalent according to the Unicode standard are
  10921. <i>not</i> equal unless, after replacement of each <span class="nt">UnicodeEscapeSequence</span>, they are represented by
  10922. the exact same sequence of code points.</p>
  10923. <h2>Syntax</h2>
  10924. <div class="gp">
  10925. <div class="lhs"><span class="nt">IdentifierName</span> <span class="geq">::</span></div>
  10926. <div class="rhs"><span class="nt">IdentifierStart</span></div>
  10927. <div class="rhs"><span class="nt">IdentifierName</span> <span class="nt">IdentifierPart</span></div>
  10928. </div>
  10929. <div class="gp">
  10930. <div class="lhs"><span class="nt">IdentifierStart</span> <span class="geq">::</span></div>
  10931. <div class="rhs"><span class="nt">UnicodeIDStart</span></div>
  10932. <div class="rhs"><code class="t">$</code></div>
  10933. <div class="rhs"><code class="t">_</code></div>
  10934. <div class="rhs"><code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
  10935. </div>
  10936. <div class="gp">
  10937. <div class="lhs"><span class="nt">IdentifierPart</span> <span class="geq">::</span></div>
  10938. <div class="rhs"><span class="nt">UnicodeIDContinue</span></div>
  10939. <div class="rhs"><code class="t">$</code></div>
  10940. <div class="rhs"><code class="t">_</code></div>
  10941. <div class="rhs"><code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
  10942. <div class="rhs">&lt;ZWNJ&gt;</div>
  10943. <div class="rhs">&lt;ZWJ&gt;</div>
  10944. </div>
  10945. <div class="gp">
  10946. <div class="lhs"><span class="nt">UnicodeIDStart</span> <span class="geq">::</span></div>
  10947. <div class="rhs"><span class="gprose">any Unicode code point with the Unicode property &ldquo;ID_Start&rdquo;</span></div>
  10948. </div>
  10949. <div class="gp">
  10950. <div class="lhs"><span class="nt">UnicodeIDContinue</span> <span class="geq">::</span></div>
  10951. <div class="rhs"><span class="gprose">any Unicode code point with the Unicode property &ldquo;ID_Continue&rdquo;</span></div>
  10952. </div>
  10953. <p>The definitions of the nonterminal <span class="nt">UnicodeEscapeSequence</span> is given in <a
  10954. href="#sec-literals-string-literals">11.8.4</a>.</p>
  10955. <div class="note">
  10956. <p><span class="nh">NOTE</span> The sets of code points with Unicode properties &ldquo;ID_Start&rdquo; and
  10957. &ldquo;ID_Continue&rdquo; include, respectively, the code points with Unicode properties &ldquo;Other_ID_Start&rdquo; and
  10958. &ldquo;Other_ID_Continue&rdquo;.</p>
  10959. </div>
  10960. </div>
  10961. <section id="sec-identifier-names">
  10962. <div class="front">
  10963. <h1><span class="secnum" id="sec-11.6.1"><a href="#sec-identifier-names" title="link to this section">11.6.1</a></span>
  10964. Identifier Names</h1>
  10965. </div>
  10966. <section id="sec-identifier-names-static-semantics-early-errors">
  10967. <h1><span class="secnum" id="sec-11.6.1.1"><a href="#sec-identifier-names-static-semantics-early-errors"
  10968. title="link to this section">11.6.1.1</a></span> Static Semantics: Early Errors</h1>
  10969. <div class="gp prod"><span class="nt">IdentifierStart</span> <span class="geq">::</span> <code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
  10970. <ul>
  10971. <li>
  10972. <p>It is a Syntax Error if <span style="font-family: Times New Roman">SV(<i>UnicodeEscapeSequence</i>)</span> is none
  10973. of <code>"$"</code>, or <code>"_"</code>, or the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
  10974. href="#sec-utf16encoding">10.1.1</a>) of a code point that would be matched by the <span
  10975. class="nt">UnicodeIDStart</span> lexical grammar production.</p>
  10976. </li>
  10977. </ul>
  10978. <div class="gp prod"><span class="nt">IdentifierPart</span> <span class="geq">::</span> <code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
  10979. <ul>
  10980. <li>
  10981. <p>It is a Syntax Error if <span style="font-family: Times New Roman">SV(<i>UnicodeEscapeSequence</i>)</span> is none
  10982. of <code>"$"</code>, or <code>"_"</code>, or the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
  10983. href="#sec-utf16encoding">10.1.1</a>) of either &lt;ZWNJ&gt; or &lt;ZWJ&gt;, or the <a
  10984. href="#sec-utf16encoding">UTF16Encoding</a> of a Unicode code point that would be matched by the <span
  10985. class="nt">UnicodeIDContinue</span> lexical grammar production.</p>
  10986. </li>
  10987. </ul>
  10988. </section>
  10989. <section id="sec-identifier-names-static-semantics-stringvalue">
  10990. <h1><span class="secnum" id="sec-11.6.1.2"><a href="#sec-identifier-names-static-semantics-stringvalue"
  10991. title="link to this section">11.6.1.2</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
  10992. <i>StringValue</i></h1>
  10993. <p>See also: <a href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>, <a
  10994. href="#sec-identifiers-static-semantics-stringvalue">12.1.4</a>.</p>
  10995. <div class="gp">
  10996. <div class="lhs"><span class="nt">IdentifierName</span> <span class="geq">::</span></div>
  10997. <div class="rhs"><span class="nt">IdentifierStart</span></div>
  10998. <div class="rhs"><span class="nt">IdentifierName</span> <span class="nt">IdentifierPart</span></div>
  10999. </div>
  11000. <ol class="proc">
  11001. <li>Return the String value consisting of the sequence of code units corresponding to <i>IdentifierName</i>. In
  11002. determining the sequence any occurrences of <code>\</code> <i>UnicodeEscapeSequence</i> are first replaced with the
  11003. code point represented by the <i>UnicodeEscapeSequence</i> and then the code points of the entire
  11004. <i>IdentifierName</i> are converted to code units by <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
  11005. href="#sec-utf16encoding">10.1.1</a>) each code point.</li>
  11006. </ol>
  11007. </section>
  11008. </section>
  11009. <section id="sec-reserved-words">
  11010. <div class="front">
  11011. <h1><span class="secnum" id="sec-11.6.2"><a href="#sec-reserved-words" title="link to this section">11.6.2</a></span>
  11012. Reserved Words</h1>
  11013. <p>A reserved word is an <span class="nt">IdentifierName</span> that cannot be used as an <span
  11014. class="nt">Identifier</span>.</p>
  11015. <h2>Syntax</h2>
  11016. <div class="gp">
  11017. <div class="lhs"><span class="nt">ReservedWord</span> <span class="geq">::</span></div>
  11018. <div class="rhs"><span class="nt">Keyword</span></div>
  11019. <div class="rhs"><span class="nt">FutureReservedWord</span></div>
  11020. <div class="rhs"><span class="nt">NullLiteral</span></div>
  11021. <div class="rhs"><span class="nt">BooleanLiteral</span></div>
  11022. </div>
  11023. <div class="note">
  11024. <p><span class="nh">NOTE</span> The <i>ReservedWord</i> definitions are specified as literal sequences of specific
  11025. <i>SourceCharacter</i> elements. A code point in a <i>ReservedWord</i> cannot be expressed by a <code>\</code>
  11026. <i>UnicodeEscapeSequence</i>.</p>
  11027. </div>
  11028. </div>
  11029. <section id="sec-keywords">
  11030. <h1><span class="secnum" id="sec-11.6.2.1"><a href="#sec-keywords" title="link to this section">11.6.2.1</a></span>
  11031. Keywords</h1>
  11032. <p>The following tokens are ECMAScript keywords and may not be used as <span class="nt">Identifiers</span> in ECMAScript
  11033. programs.</p>
  11034. <h2>Syntax</h2>
  11035. <div class="gp prod"><span class="nt">Keyword</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11036. <figure>
  11037. <table class="lightweight-table">
  11038. <tr>
  11039. <td><code>break</code></td>
  11040. <td><code>do</code></td>
  11041. <td><code>in</code></td>
  11042. <td><code>typeof</code></td>
  11043. </tr>
  11044. <tr>
  11045. <td><code>case</code></td>
  11046. <td><code>else</code></td>
  11047. <td><code>instanceof</code></td>
  11048. <td><code>var</code></td>
  11049. </tr>
  11050. <tr>
  11051. <td><code>catch</code></td>
  11052. <td><code>export</code></td>
  11053. <td><code>new</code></td>
  11054. <td><code>void</code></td>
  11055. </tr>
  11056. <tr>
  11057. <td><code>class</code></td>
  11058. <td><code>extends</code></td>
  11059. <td><code>return</code></td>
  11060. <td><code>while</code></td>
  11061. </tr>
  11062. <tr>
  11063. <td><code>const</code></td>
  11064. <td><code>finally</code></td>
  11065. <td><code>super</code></td>
  11066. <td><code>with</code></td>
  11067. </tr>
  11068. <tr>
  11069. <td><code>continue</code></td>
  11070. <td><code>for</code></td>
  11071. <td><code>switch</code></td>
  11072. <td><code>yield</code></td>
  11073. </tr>
  11074. <tr>
  11075. <td><code>debugger</code></td>
  11076. <td><code>function</code></td>
  11077. <td><code>this</code></td>
  11078. <td></td>
  11079. </tr>
  11080. <tr>
  11081. <td><code>default</code></td>
  11082. <td><code>if</code></td>
  11083. <td><code>throw</code></td>
  11084. <td></td>
  11085. </tr>
  11086. <tr>
  11087. <td><code>delete</code></td>
  11088. <td><code>import</code></td>
  11089. <td><code>try</code></td>
  11090. <td></td>
  11091. </tr>
  11092. </table>
  11093. </figure>
  11094. <div class="note">
  11095. <p><span class="nh">NOTE</span> In some contexts <code>yield</code> is given the semantics of an <i>Identifier</i>. See
  11096. <a href="#sec-identifiers-static-semantics-early-errors">12.1.1</a>. In <a href="#sec-strict-mode-code">strict mode
  11097. code</a>, <code>let</code> and <code>static</code> are treated as reserved keywords through static semantic restrictions
  11098. (see <a href="#sec-identifiers-static-semantics-early-errors">12.1.1</a>, <a
  11099. href="#sec-let-and-const-declarations-static-semantics-early-errors">13.2.1.1</a>, <a
  11100. href="#sec-for-in-and-for-of-statements-static-semantics-early-errors">13.6.4.1</a>, and <a
  11101. href="#sec-class-definitions-static-semantics-early-errors">14.5.1</a>) rather than the lexical grammar.</p>
  11102. </div>
  11103. </section>
  11104. <section id="sec-future-reserved-words">
  11105. <h1><span class="secnum" id="sec-11.6.2.2"><a href="#sec-future-reserved-words"
  11106. title="link to this section">11.6.2.2</a></span> Future Reserved Words</h1>
  11107. <p>The following tokens are reserved for used as keywords in future language extensions.</p>
  11108. <h2>Syntax</h2>
  11109. <div class="gp prod"><span class="nt">FutureReservedWord</span> <span class="geq">::</span></div>
  11110. <figure>
  11111. <table class="lightweight-table">
  11112. <tr>
  11113. <td><code>enum<br>await</code></td>
  11114. <td></td>
  11115. <td></td>
  11116. <td></td>
  11117. </tr>
  11118. </table>
  11119. </figure>
  11120. <p><code>await</code> is only treated as a <span class="nt">FutureReservedWord</span> when <span class="nt">Module</span>
  11121. is the goal symbol of the syntactic grammar.</p>
  11122. <div class="note">
  11123. <p><span class="nh">NOTE</span> Use of the following tokens within <a href="#sec-strict-mode-code">strict mode code</a>
  11124. (<a href="#sec-strict-mode-code">see 10.2.1</a>) is also reserved. That usage is restricted using static semantic
  11125. restrictions (<a href="#sec-identifiers-static-semantics-early-errors">see 12.1.1</a>) rather than the lexical
  11126. grammar:</p>
  11127. </div>
  11128. <figure>
  11129. <table class="lightweight-table">
  11130. <tr>
  11131. <td><code>implements</code></td>
  11132. <td><code>package</code></td>
  11133. <td><code>protected</code></td>
  11134. <td></td>
  11135. </tr>
  11136. <tr>
  11137. <td><code>interface</code></td>
  11138. <td><code>private</code></td>
  11139. <td><code>public</code></td>
  11140. <td></td>
  11141. </tr>
  11142. </table>
  11143. </figure>
  11144. </section>
  11145. </section>
  11146. </section>
  11147. <section id="sec-punctuators">
  11148. <h1><span class="secnum" id="sec-11.7"><a href="#sec-punctuators" title="link to this section">11.7</a></span>
  11149. Punctuators</h1>
  11150. <h2>Syntax</h2>
  11151. <div class="gp prod"><span class="nt">Punctuator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11152. <figure>
  11153. <table class="lightweight-table">
  11154. <tr>
  11155. <td><code>{</code></td>
  11156. <td><code>(</code></td>
  11157. <td><code>)</code></td>
  11158. <td><code>[</code></td>
  11159. <td><code>]</code></td>
  11160. <td><code>.</code></td>
  11161. </tr>
  11162. <tr>
  11163. <td><code>...</code></td>
  11164. <td><code>;</code></td>
  11165. <td><code>,</code></td>
  11166. <td><code>&lt;</code></td>
  11167. <td><code>&gt;</code></td>
  11168. <td><code>&lt;=</code></td>
  11169. </tr>
  11170. <tr>
  11171. <td><code>&gt;=</code></td>
  11172. <td><code>==</code></td>
  11173. <td><code>!=</code></td>
  11174. <td><code>===</code></td>
  11175. <td><code>!==</code></td>
  11176. <td></td>
  11177. </tr>
  11178. <tr>
  11179. <td><code>+</code></td>
  11180. <td><code>-</code></td>
  11181. <td><code>*</code></td>
  11182. <td><code>%</code></td>
  11183. <td><code>++</code></td>
  11184. <td><code>--</code></td>
  11185. </tr>
  11186. <tr>
  11187. <td><code>&lt;&lt;</code></td>
  11188. <td><code>&gt;&gt;</code></td>
  11189. <td><code>&gt;&gt;&gt;</code></td>
  11190. <td><code>&amp;</code></td>
  11191. <td><code>|</code></td>
  11192. <td><code>^</code></td>
  11193. </tr>
  11194. <tr>
  11195. <td><code>!</code></td>
  11196. <td><code>~</code></td>
  11197. <td><code>&amp;&amp;</code></td>
  11198. <td><code>||</code></td>
  11199. <td><code>?</code></td>
  11200. <td><code>:</code></td>
  11201. </tr>
  11202. <tr>
  11203. <td><code>=</code></td>
  11204. <td><code>+=</code></td>
  11205. <td><code>-=</code></td>
  11206. <td><code>*=</code></td>
  11207. <td><code>%=</code></td>
  11208. <td><code>&lt;&lt;=</code></td>
  11209. </tr>
  11210. <tr>
  11211. <td><code>&gt;&gt;=</code></td>
  11212. <td><code>&gt;&gt;&gt;=</code></td>
  11213. <td><code>&amp;=</code></td>
  11214. <td><code>|=</code></td>
  11215. <td><code>^=</code></td>
  11216. <td><code>=&gt;</code></td>
  11217. </tr>
  11218. </table>
  11219. </figure>
  11220. <div class="gp prod"><span class="nt">DivPunctuator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11221. <figure>
  11222. <table class="lightweight-table">
  11223. <tr>
  11224. <td><code>/</code></td>
  11225. <td><code>/=</code></td>
  11226. <td></td>
  11227. <td></td>
  11228. <td></td>
  11229. <td></td>
  11230. </tr>
  11231. </table>
  11232. </figure>
  11233. <div class="gp prod"><span class="nt">RightBracePunctuator</span> <span class="geq">::</span></div>
  11234. <figure>
  11235. <table class="lightweight-table">
  11236. <tr>
  11237. <td><code>}</code></td>
  11238. <td></td>
  11239. <td></td>
  11240. <td></td>
  11241. <td></td>
  11242. <td></td>
  11243. </tr>
  11244. </table>
  11245. </figure>
  11246. </section>
  11247. <section id="sec-ecmascript-language-lexical-grammar-literals">
  11248. <div class="front">
  11249. <h1><span class="secnum" id="sec-11.8"><a href="#sec-ecmascript-language-lexical-grammar-literals"
  11250. title="link to this section">11.8</a></span> Literals</h1>
  11251. </div>
  11252. <section id="sec-null-literals">
  11253. <h1><span class="secnum" id="sec-11.8.1"><a href="#sec-null-literals" title="link to this section">11.8.1</a></span> Null
  11254. Literals</h1>
  11255. <h2>Syntax</h2>
  11256. <div class="gp">
  11257. <div class="lhs"><span class="nt">NullLiteral</span> <span class="geq">::</span></div>
  11258. <div class="rhs"><code class="t">null</code></div>
  11259. </div>
  11260. </section>
  11261. <section id="sec-boolean-literals">
  11262. <h1><span class="secnum" id="sec-11.8.2"><a href="#sec-boolean-literals" title="link to this section">11.8.2</a></span>
  11263. Boolean Literals</h1>
  11264. <h2>Syntax</h2>
  11265. <div class="gp">
  11266. <div class="lhs"><span class="nt">BooleanLiteral</span> <span class="geq">::</span></div>
  11267. <div class="rhs"><code class="t">true</code></div>
  11268. <div class="rhs"><code class="t">false</code></div>
  11269. </div>
  11270. </section>
  11271. <section id="sec-literals-numeric-literals">
  11272. <div class="front">
  11273. <h1><span class="secnum" id="sec-11.8.3"><a href="#sec-literals-numeric-literals"
  11274. title="link to this section">11.8.3</a></span> Numeric Literals</h1>
  11275. <h2>Syntax</h2>
  11276. <div class="gp">
  11277. <div class="lhs"><span class="nt">NumericLiteral</span> <span class="geq">::</span></div>
  11278. <div class="rhs"><span class="nt">DecimalLiteral</span></div>
  11279. <div class="rhs"><span class="nt">BinaryIntegerLiteral</span></div>
  11280. <div class="rhs"><span class="nt">OctalIntegerLiteral</span></div>
  11281. <div class="rhs"><span class="nt">HexIntegerLiteral</span></div>
  11282. </div>
  11283. <div class="gp">
  11284. <div class="lhs"><span class="nt">DecimalLiteral</span> <span class="geq">::</span></div>
  11285. <div class="rhs"><span class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">DecimalDigits</span><sub class="g-opt">opt</sub> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
  11286. <div class="rhs"><code class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
  11287. <div class="rhs"><span class="nt">DecimalIntegerLiteral</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
  11288. </div>
  11289. <div class="gp">
  11290. <div class="lhs"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span></div>
  11291. <div class="rhs"><code class="t">0</code></div>
  11292. <div class="rhs"><span class="nt">NonZeroDigit</span> <span class="nt">DecimalDigits</span><sub class="g-opt">opt</sub></div>
  11293. </div>
  11294. <div class="gp">
  11295. <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">::</span></div>
  11296. <div class="rhs"><span class="nt">DecimalDigit</span></div>
  11297. <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
  11298. </div>
  11299. <div class="gp">
  11300. <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11301. <div class="rhs"><code class="t">0</code> <code class="t">1</code> <code class="t">2</code> <code class="t">3</code> <code class="t">4</code> <code class="t">5</code> <code class="t">6</code> <code class="t">7</code> <code class="t">8</code> <code class="t">9</code></div>
  11302. </div>
  11303. <div class="gp">
  11304. <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11305. <div class="rhs"><code class="t">1</code> <code class="t">2</code> <code class="t">3</code> <code class="t">4</code> <code class="t">5</code> <code class="t">6</code> <code class="t">7</code> <code class="t">8</code> <code class="t">9</code></div>
  11306. </div>
  11307. <div class="gp">
  11308. <div class="lhs"><span class="nt">ExponentPart</span> <span class="geq">::</span></div>
  11309. <div class="rhs"><span class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></div>
  11310. </div>
  11311. <div class="gp">
  11312. <div class="lhs"><span class="nt">ExponentIndicator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11313. <div class="rhs"><code class="t">e</code> <code class="t">E</code></div>
  11314. </div>
  11315. <div class="gp">
  11316. <div class="lhs"><span class="nt">SignedInteger</span> <span class="geq">::</span></div>
  11317. <div class="rhs"><span class="nt">DecimalDigits</span></div>
  11318. <div class="rhs"><code class="t">+</code> <span class="nt">DecimalDigits</span></div>
  11319. <div class="rhs"><code class="t">-</code> <span class="nt">DecimalDigits</span></div>
  11320. </div>
  11321. <div class="gp">
  11322. <div class="lhs"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span></div>
  11323. <div class="rhs"><code class="t">0b</code> <span class="nt">BinaryDigits</span></div>
  11324. <div class="rhs"><code class="t">0B</code> <span class="nt">BinaryDigits</span></div>
  11325. </div>
  11326. <div class="gp">
  11327. <div class="lhs"><span class="nt">BinaryDigits</span> <span class="geq">::</span></div>
  11328. <div class="rhs"><span class="nt">BinaryDigit</span></div>
  11329. <div class="rhs"><span class="nt">BinaryDigits</span> <span class="nt">BinaryDigit</span></div>
  11330. </div>
  11331. <div class="gp">
  11332. <div class="lhs"><span class="nt">BinaryDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11333. <div class="rhs"><code class="t">0</code> <code class="t">1</code></div>
  11334. </div>
  11335. <div class="gp">
  11336. <div class="lhs"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span></div>
  11337. <div class="rhs"><code class="t">0o</code> <span class="nt">OctalDigits</span></div>
  11338. <div class="rhs"><code class="t">0O</code> <span class="nt">OctalDigits</span></div>
  11339. </div>
  11340. <div class="gp">
  11341. <div class="lhs"><span class="nt">OctalDigits</span> <span class="geq">::</span></div>
  11342. <div class="rhs"><span class="nt">OctalDigit</span></div>
  11343. <div class="rhs"><span class="nt">OctalDigits</span> <span class="nt">OctalDigit</span></div>
  11344. </div>
  11345. <div class="gp">
  11346. <div class="lhs"><span class="nt">OctalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11347. <div class="rhs"><code class="t">0</code> <code class="t">1</code> <code class="t">2</code> <code class="t">3</code> <code class="t">4</code> <code class="t">5</code> <code class="t">6</code> <code class="t">7</code></div>
  11348. </div>
  11349. <div class="gp">
  11350. <div class="lhs"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span></div>
  11351. <div class="rhs"><code class="t">0x</code> <span class="nt">HexDigits</span></div>
  11352. <div class="rhs"><code class="t">0X</code> <span class="nt">HexDigits</span></div>
  11353. </div>
  11354. <div class="gp">
  11355. <div class="lhs"><span class="nt">HexDigits</span> <span class="geq">::</span></div>
  11356. <div class="rhs"><span class="nt">HexDigit</span></div>
  11357. <div class="rhs"><span class="nt">HexDigits</span> <span class="nt">HexDigit</span></div>
  11358. </div>
  11359. <div class="gp">
  11360. <div class="lhs"><span class="nt">HexDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11361. <div class="rhs"><code class="t">0</code> <code class="t">1</code> <code class="t">2</code> <code class="t">3</code> <code class="t">4</code> <code class="t">5</code> <code class="t">6</code> <code class="t">7</code> <code class="t">8</code> <code class="t">9</code> <code class="t">a</code> <code class="t">b</code> <code class="t">c</code> <code class="t">d</code> <code class="t">e</code> <code class="t">f</code> <code class="t">A</code> <code class="t">B</code> <code class="t">C</code> <code class="t">D</code> <code class="t">E</code> <code class="t">F</code></div>
  11362. </div>
  11363. <p>The <span class="nt">SourceCharacter</span> immediately following a <span class="nt">NumericLiteral</span> must not be
  11364. an <span class="nt">IdentifierStart</span> or <span class="nt">DecimalDigit</span>.</p>
  11365. <div class="note">
  11366. <p><span class="nh">NOTE</span> For example:</p>
  11367. <pre>3in</pre>
  11368. <p>is an error and not the two input elements <code>3</code> and <code>in</code>.</p>
  11369. </div>
  11370. <p>A conforming implementation, when processing <a href="#sec-strict-mode-code">strict mode code</a> (<a
  11371. href="#sec-strict-mode-code">see 10.2.1</a>), must not extend, as described in <a
  11372. href="#sec-additional-syntax-numeric-literals">B.1.1</a>, the syntax of <span class="nt">NumericLiteral</span> to include
  11373. <i>Legacy<span style="font-family: Times New Roman">OctalIntegerLiteral</span></i>, nor extend the syntax of <span
  11374. class="nt">DecimalIntegerLiteral</span> to include <span class="nt">NonOctalDecimalIntegerLiteral</span>.</p>
  11375. </div>
  11376. <section id="sec-static-semantics-mv-s">
  11377. <h1><span class="secnum" id="sec-11.8.3.1"><a href="#sec-static-semantics-mv-s"
  11378. title="link to this section">11.8.3.1</a></span> Static Semantics: MV&rsquo;s</h1>
  11379. <p>A numeric literal stands for a value of the Number type. This value is determined in two steps: first, a mathematical
  11380. value (MV) is derived from the literal; second, this mathematical value is rounded as described below.</p>
  11381. <ul>
  11382. <li>
  11383. <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
  11384. class="nt">DecimalLiteral</span></span> is the MV of <i>DecimalLiteral</i>.</p>
  11385. </li>
  11386. <li>
  11387. <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
  11388. class="nt">BinaryIntegerLiteral</span></span> is the MV of <i>BinaryIntegerLiteral</i>.</p>
  11389. </li>
  11390. <li>
  11391. <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
  11392. class="nt">OctalIntegerLiteral</span></span> is the MV of <i>OctalIntegerLiteral</i>.</p>
  11393. </li>
  11394. <li>
  11395. <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
  11396. class="nt">HexIntegerLiteral</span></span> is the MV of <i>HexIntegerLiteral</i>.</p>
  11397. </li>
  11398. <li>
  11399. <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
  11400. class="nt">DecimalIntegerLiteral</span> <code class="t">.</code></span> is the MV of <i>DecimalIntegerLiteral</i>.</p>
  11401. </li>
  11402. <li>
  11403. <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
  11404. class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">DecimalDigits</span></span> is the
  11405. MV of <i>DecimalIntegerLiteral</i> plus (the MV of <i>DecimalDigits</i> &times; 10<sup>&ndash;<i>n</i></sup>), where
  11406. <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
  11407. </li>
  11408. <li>
  11409. <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
  11410. class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">ExponentPart</span></span> is the MV
  11411. of <i>DecimalIntegerLiteral</i> &times; 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
  11412. </li>
  11413. <li>
  11414. <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
  11415. class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">DecimalDigits</span> <span
  11416. class="nt">ExponentPart</span></span> is (the MV of <i>DecimalIntegerLiteral</i> plus (the MV of <i>DecimalDigits</i>
  11417. &times; 10<sup>&ndash;<i>n</i></sup>)) &times; 10<sup><i>e</i></sup>, where <i>n</i> is the number of code points in
  11418. <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
  11419. </li>
  11420. <li>
  11421. <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <code
  11422. class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i> &times;
  11423. 10<sup>&ndash;<i>n</i></sup>, where <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
  11424. </li>
  11425. <li>
  11426. <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <code
  11427. class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of
  11428. <i>DecimalDigits</i> &times; 10<sup><i>e</i>&ndash;<i>n</i></sup>, where <i>n</i> is the number of code points in
  11429. <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
  11430. </li>
  11431. <li>
  11432. <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
  11433. class="nt">DecimalIntegerLiteral</span></span> is the MV of <i>DecimalIntegerLiteral</i>.</p>
  11434. </li>
  11435. <li>
  11436. <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
  11437. class="nt">DecimalIntegerLiteral</span> <span class="nt">ExponentPart</span></span> is the MV of
  11438. <i>DecimalIntegerLiteral</i> &times; 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
  11439. </li>
  11440. <li>
  11441. <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <code
  11442. class="t">0</code></span> is 0.</p>
  11443. </li>
  11444. <li>
  11445. <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <span
  11446. class="nt">NonZeroDigit</span></span> is the MV of <i>NonZeroDigit.</i></p>
  11447. </li>
  11448. <li>
  11449. <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <span
  11450. class="nt">NonZeroDigit</span> <span class="nt">DecimalDigits</span></span> is (the MV of <i>NonZeroDigit</i> &times;
  11451. 10<sup><i>n</i></sup>) plus the MV of <i>DecimalDigits</i>, where <i>n</i> is the number of code points in
  11452. <i>DecimalDigits</i>.</p>
  11453. </li>
  11454. <li>
  11455. <p>The MV of <span class="prod"><span class="nt">DecimalDigits</span> <span class="geq">::</span> <span
  11456. class="nt">DecimalDigit</span></span> is the MV of <i>DecimalDigit</i>.</p>
  11457. </li>
  11458. <li>
  11459. <p>The MV of <span class="prod"><span class="nt">DecimalDigits</span> <span class="geq">::</span> <span
  11460. class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></span> is (the MV of <i>DecimalDigits</i> &times;
  11461. 10) plus the MV of <i>DecimalDigit</i>.</p>
  11462. </li>
  11463. <li>
  11464. <p>The MV of <span class="prod"><span class="nt">ExponentPart</span> <span class="geq">::</span> <span
  11465. class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></span> is the MV of
  11466. <i>SignedInteger</i>.</p>
  11467. </li>
  11468. <li>
  11469. <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <span
  11470. class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
  11471. </li>
  11472. <li>
  11473. <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <code
  11474. class="t">+</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
  11475. </li>
  11476. <li>
  11477. <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <code
  11478. class="t">-</code> <span class="nt">DecimalDigits</span></span> is the negative of the MV of <i>DecimalDigits</i>.</p>
  11479. </li>
  11480. <li>
  11481. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11482. class="t">0</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11483. class="t">0</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span class="geq">::</span>
  11484. <code class="t">0</code></span> or of <span class="prod"><span class="nt">BinaryDigit</span> <span
  11485. class="geq">::</span> <code class="t">0</code></span> is 0.</p>
  11486. </li>
  11487. <li>
  11488. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11489. class="t">1</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11490. <code class="t">1</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11491. <code class="t">1</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
  11492. class="geq">::</span> <code class="t">1</code></span> or<br>of <span class="prod"><span class="nt">BinaryDigit</span>
  11493. <span class="geq">::</span> <code class="t">1</code></span> is 1.</p>
  11494. </li>
  11495. <li>
  11496. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11497. class="t">2</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11498. <code class="t">2</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11499. <code class="t">2</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
  11500. class="geq">::</span> <code class="t">2</code></span> is 2.</p>
  11501. </li>
  11502. <li>
  11503. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11504. class="t">3</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11505. <code class="t">3</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11506. <code class="t">3</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
  11507. class="geq">::</span> <code class="t">3</code></span> is 3.</p>
  11508. </li>
  11509. <li>
  11510. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11511. class="t">4</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11512. <code class="t">4</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11513. <code class="t">4</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
  11514. class="geq">::</span> <code class="t">4</code></span> is 4.</p>
  11515. </li>
  11516. <li>
  11517. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11518. class="t">5</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11519. <code class="t">5</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11520. <code class="t">5</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
  11521. class="geq">::</span> <code class="t">5</code></span> is 5.</p>
  11522. </li>
  11523. <li>
  11524. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11525. class="t">6</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11526. <code class="t">6</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11527. <code class="t">6</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
  11528. class="geq">::</span> <code class="t">6</code></span> is 6.</p>
  11529. </li>
  11530. <li>
  11531. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11532. class="t">7</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11533. <code class="t">7</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11534. <code class="t">7</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
  11535. class="geq">::</span> <code class="t">7</code></span> is 7.</p>
  11536. </li>
  11537. <li>
  11538. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11539. class="t">8</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11540. <code class="t">8</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11541. <code class="t">8</code></span> is 8.</p>
  11542. </li>
  11543. <li>
  11544. <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
  11545. class="t">9</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
  11546. <code class="t">9</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
  11547. <code class="t">9</code></span> is 9.</p>
  11548. </li>
  11549. <li>
  11550. <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11551. class="t">a</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11552. class="t">A</code></span> is 10.</p>
  11553. </li>
  11554. <li>
  11555. <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11556. class="t">b</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11557. class="t">B</code></span> is 11.</p>
  11558. </li>
  11559. <li>
  11560. <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11561. class="t">c</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11562. class="t">C</code></span> is 12.</p>
  11563. </li>
  11564. <li>
  11565. <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11566. class="t">d</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11567. class="t">D</code></span> is 13.</p>
  11568. </li>
  11569. <li>
  11570. <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11571. class="t">e</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11572. class="t">E</code></span> is 14.</p>
  11573. </li>
  11574. <li>
  11575. <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11576. class="t">f</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
  11577. class="t">F</code></span> is 15.</p>
  11578. </li>
  11579. <li>
  11580. <p>The MV of <span class="prod"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span> <code
  11581. class="t">0b</code> <span class="nt">BinaryDigits</span></span> is the MV of <i>BinaryDigits</i>.</p>
  11582. </li>
  11583. <li>
  11584. <p>The MV of <span class="prod"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span> <code
  11585. class="t">0B</code> <span class="nt">BinaryDigits</span></span> is the MV of <i>BinaryDigits</i>.</p>
  11586. </li>
  11587. <li>
  11588. <p>The MV of <span class="prod"><span class="nt">BinaryDigits</span> <span class="geq">::</span> <span
  11589. class="nt">BinaryDigit</span></span> is the MV of <i>BinaryDigit</i>.</p>
  11590. </li>
  11591. <li>
  11592. <p>The MV of <span class="prod"><span class="nt">BinaryDigits</span> <span class="geq">::</span> <span
  11593. class="nt">BinaryDigits</span> <span class="nt">BinaryDigit</span></span> is (the MV of <i>BinaryDigits</i> &times; 2)
  11594. plus the MV of <i>BinaryDigit</i>.</p>
  11595. </li>
  11596. <li>
  11597. <p>The MV of <span class="prod"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span> <code
  11598. class="t">0o</code> <span class="nt">OctalDigits</span></span> is the MV of <i>OctalDigits</i>.</p>
  11599. </li>
  11600. <li>
  11601. <p>The MV of <span class="prod"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span> <code
  11602. class="t">0O</code> <span class="nt">OctalDigits</span></span> is the MV of <i>OctalDigits</i>.</p>
  11603. </li>
  11604. <li>
  11605. <p>The MV of <span class="prod"><span class="nt">OctalDigits</span> <span class="geq">::</span> <span
  11606. class="nt">OctalDigit</span></span> is the MV of <i>OctalDigit</i>.</p>
  11607. </li>
  11608. <li>
  11609. <p>The MV of <span class="prod"><span class="nt">OctalDigits</span> <span class="geq">::</span> <span
  11610. class="nt">OctalDigits</span> <span class="nt">OctalDigit</span></span> is (the MV of <i>OctalDigits</i> &times; 8)
  11611. plus the MV of <i>OctalDigit</i>.</p>
  11612. </li>
  11613. <li>
  11614. <p>The MV of <span class="prod"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span> <code
  11615. class="t">0x</code> <span class="nt">HexDigits</span></span> is the MV of <i>HexDigits</i>.</p>
  11616. </li>
  11617. <li>
  11618. <p>The MV of <span class="prod"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span> <code
  11619. class="t">0X</code> <span class="nt">HexDigits</span></span> is the MV of <i>HexDigits</i>.</p>
  11620. </li>
  11621. <li>
  11622. <p>The MV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
  11623. class="nt">HexDigit</span></span> is the MV of <i>HexDigit</i>.</p>
  11624. </li>
  11625. <li>
  11626. <p>The MV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
  11627. class="nt">HexDigits</span> <span class="nt">HexDigit</span></span> is (the MV of <i>HexDigits</i> &times; 16) plus
  11628. the MV of <i>HexDigit</i>.</p>
  11629. </li>
  11630. </ul>
  11631. <p>Once the exact MV for a numeric literal has been determined, it is then rounded to a value of the Number type. If the
  11632. MV is 0, then the rounded value is <span class="value">+0</span>; otherwise, the rounded value must be the Number value
  11633. for the MV (as specified in <a href="#sec-ecmascript-language-types-number-type">6.1.6</a>), unless the literal is a <span
  11634. class="nt">DecimalLiteral</span> and the literal has more than 20 significant digits, in which case the Number value may
  11635. be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a
  11636. <code>0</code> digit or the Number value for the MV of a literal produced by replacing each significant digit after the
  11637. 20th with a <code>0</code> digit and then incrementing the literal at the 20th significant digit position. A digit is
  11638. <i>significant</i> if it is not part of an <span class="nt">ExponentPart</span> and</p>
  11639. <ul>
  11640. <li>it is not <code>0</code>; or</li>
  11641. <li>there is a nonzero digit to its left and there is a nonzero digit, not in the <i>ExponentPart</i>, to its
  11642. right.</li>
  11643. </ul>
  11644. </section>
  11645. </section>
  11646. <section id="sec-literals-string-literals">
  11647. <div class="front">
  11648. <h1><span class="secnum" id="sec-11.8.4"><a href="#sec-literals-string-literals"
  11649. title="link to this section">11.8.4</a></span> String Literals</h1>
  11650. <div class="note">
  11651. <p><span class="nh">NOTE</span> A string literal is zero or more Unicode code points enclosed in single or double
  11652. quotes. Unicode code points may also be represented by an escape sequence. All <span style="font-family:
  11653. sans-serif">code points</span> may appear literally in a string literal except for the closing quote <span
  11654. style="font-family: sans-serif">code points</span>, U+005C (REVERSE SOLIDUS), U+000D (carriage return), U+2028 (line
  11655. separator), U+2029 (paragraph separator), and U+000A (line feed). Any <span style="font-family: sans-serif">code
  11656. points</span> may appear in the form of an escape sequence. String literals evaluate to ECMAScript String values. When
  11657. generating these string values Unicode code points are UTF-16 encoded as defined in <a
  11658. href="#sec-utf16encoding">10.1.1</a>. Code points belonging to the Basic Multilingual Plane are encoded as a single code
  11659. unit element of the string. All other code points are encoded as two code unit elements of the string.</p>
  11660. </div>
  11661. <h2>Syntax</h2>
  11662. <div class="gp">
  11663. <div class="lhs"><span class="nt">StringLiteral</span> <span class="geq">::</span></div>
  11664. <div class="rhs"><code class="t">"</code> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">"</code></div>
  11665. <div class="rhs"><code class="t">'</code> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">'</code></div>
  11666. </div>
  11667. <div class="gp">
  11668. <div class="lhs"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span></div>
  11669. <div class="rhs"><span class="nt">DoubleStringCharacter</span> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub></div>
  11670. </div>
  11671. <div class="gp">
  11672. <div class="lhs"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span></div>
  11673. <div class="rhs"><span class="nt">SingleStringCharacter</span> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub></div>
  11674. </div>
  11675. <div class="gp">
  11676. <div class="lhs"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span></div>
  11677. <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">"</code> <span class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <span class="nt">LineTerminator</span></div>
  11678. <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
  11679. <div class="rhs"><span class="nt">LineContinuation</span></div>
  11680. </div>
  11681. <div class="gp">
  11682. <div class="lhs"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span></div>
  11683. <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">'</code> <span class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <span class="nt">LineTerminator</span></div>
  11684. <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
  11685. <div class="rhs"><span class="nt">LineContinuation</span></div>
  11686. </div>
  11687. <div class="gp">
  11688. <div class="lhs"><span class="nt">LineContinuation</span> <span class="geq">::</span></div>
  11689. <div class="rhs"><code class="t">\</code> <span class="nt">LineTerminatorSequence</span></div>
  11690. </div>
  11691. <div class="gp">
  11692. <div class="lhs"><span class="nt">EscapeSequence</span> <span class="geq">::</span></div>
  11693. <div class="rhs"><span class="nt">CharacterEscapeSequence</span></div>
  11694. <div class="rhs"><code class="t">0</code> <span class="grhsannot">[lookahead &notin; <span class="nt">DecimalDigit</span>]</span></div>
  11695. <div class="rhs"><span class="nt">HexEscapeSequence</span></div>
  11696. <div class="rhs"><span class="nt">UnicodeEscapeSequence</span></div>
  11697. </div>
  11698. <p>A conforming implementation, when processing <a href="#sec-strict-mode-code">strict mode code</a> (<a
  11699. href="#sec-strict-mode-code">see 10.2.1</a>), must not extend the syntax of <span class="nt">EscapeSequence</span> to
  11700. include <i>Legacy<span style="font-family: Times New Roman">OctalEscapeSequence</span></i> as described in <a
  11701. href="#sec-additional-syntax-string-literals">B.1.2</a>.</p>
  11702. <div class="gp">
  11703. <div class="lhs"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span></div>
  11704. <div class="rhs"><span class="nt">SingleEscapeCharacter</span></div>
  11705. <div class="rhs"><span class="nt">NonEscapeCharacter</span></div>
  11706. </div>
  11707. <div class="gp">
  11708. <div class="lhs"><span class="nt">SingleEscapeCharacter</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
  11709. <div class="rhs"><code class="t">'</code> <code class="t">"</code> <code class="t">\</code> <code class="t">b</code> <code class="t">f</code> <code class="t">n</code> <code class="t">r</code> <code class="t">t</code> <code class="t">v</code></div>
  11710. </div>
  11711. <div class="gp">
  11712. <div class="lhs"><span class="nt">NonEscapeCharacter</span> <span class="geq">::</span></div>
  11713. <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <span class="nt">EscapeCharacter</span> <span class="grhsmod">or</span> <span class="nt">LineTerminator</span></div>
  11714. </div>
  11715. <div class="gp">
  11716. <div class="lhs"><span class="nt">EscapeCharacter</span> <span class="geq">::</span></div>
  11717. <div class="rhs"><span class="nt">SingleEscapeCharacter</span></div>
  11718. <div class="rhs"><span class="nt">DecimalDigit</span></div>
  11719. <div class="rhs"><code class="t">x</code></div>
  11720. <div class="rhs"><code class="t">u</code></div>
  11721. </div>
  11722. <div class="gp">
  11723. <div class="lhs"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span></div>
  11724. <div class="rhs"><code class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></div>
  11725. </div>
  11726. <div class="gp">
  11727. <div class="lhs"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span></div>
  11728. <div class="rhs"><code class="t">u</code> <span class="nt">Hex4Digits</span></div>
  11729. <div class="rhs"><code class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></div>
  11730. </div>
  11731. <div class="gp">
  11732. <div class="lhs"><span class="nt">Hex4Digits</span> <span class="geq">::</span></div>
  11733. <div class="rhs"><span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></div>
  11734. </div>
  11735. <p>The definition of the nonterminal <span class="nt">HexDigit</span> is given in <a
  11736. href="#sec-literals-numeric-literals">11.8.3</a>. <span class="nt">SourceCharacter</span> is defined in <a
  11737. href="#sec-source-text">10.1</a>.</p>
  11738. <div class="note">
  11739. <p><span class="nh">NOTE</span> A line terminator <span style="font-family: sans-serif">code point</span> cannot appear
  11740. in a string literal, except as part of a <i>LineContinuation</i> to produce the empty <span style="font-family:
  11741. sans-serif">code points</span> sequence. The proper way to cause a line terminator <span style="font-family:
  11742. sans-serif">code point</span> to be part of the String value of a string literal is to use an escape sequence such as
  11743. <code>\n</code> or <code>\u000A</code>.</p>
  11744. </div>
  11745. </div>
  11746. <section id="sec-string-literals-static-semantics-early-errors">
  11747. <h1><span class="secnum" id="sec-11.8.4.1"><a href="#sec-string-literals-static-semantics-early-errors"
  11748. title="link to this section">11.8.4.1</a></span> Static Semantics: Early Errors</h1>
  11749. <div class="gp prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></div>
  11750. <ul>
  11751. <li>It is a Syntax Error if the MV of <span class="nt">HexDigits</span> &gt; <span style="font-family: Times New
  11752. Roman">1114111<i>.</i></span></li>
  11753. </ul>
  11754. </section>
  11755. <section id="sec-string-literals-static-semantics-stringvalue">
  11756. <h1><span class="secnum" id="sec-11.8.4.2"><a href="#sec-string-literals-static-semantics-stringvalue"
  11757. title="link to this section">11.8.4.2</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
  11758. <i>StringValue</i></h1>
  11759. <p>See also: <a href="#sec-identifier-names-static-semantics-stringvalue">11.6.1.2</a>, <a
  11760. href="#sec-identifiers-static-semantics-stringvalue">12.1.4</a>.</p>
  11761. <div class="gp">
  11762. <div class="lhs"><span class="nt">StringLiteral</span> <span class="geq">::</span></div>
  11763. <div class="rhs"><code class="t">"</code> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">"</code></div>
  11764. <div class="rhs"><code class="t">'</code> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">'</code></div>
  11765. </div>
  11766. <ol class="proc">
  11767. <li>Return the String value whose elements are the SV of this <i>StringLiteral</i>.</li>
  11768. </ol>
  11769. </section>
  11770. <section id="sec-static-semantics-sv-s">
  11771. <h1><span class="secnum" id="sec-11.8.4.3"><a href="#sec-static-semantics-sv-s"
  11772. title="link to this section">11.8.4.3</a></span> Static Semantics: <i>SV&rsquo;s</i></h1>
  11773. <p>A string literal stands for a value of the String type. The String value (SV) of the literal is described in terms of
  11774. code unit values contributed by the various parts of the string literal. As part of this process, some Unicode code points
  11775. within the string literal are interpreted as having a mathematical value (MV), as described below or in <a
  11776. href="#sec-literals-numeric-literals">11.8.3</a>.</p>
  11777. <ul>
  11778. <li>
  11779. <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
  11780. class="t">""</code></span> is the empty code unit sequence.</p>
  11781. </li>
  11782. <li>
  11783. <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
  11784. class="t">''</code></span> is the empty code unit sequence.</p>
  11785. </li>
  11786. <li>
  11787. <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
  11788. class="t">"</code> <span class="nt">DoubleStringCharacters</span> <code class="t">"</code></span> is the SV of
  11789. <i>DoubleStringCharacters</i>.</p>
  11790. </li>
  11791. <li>
  11792. <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
  11793. class="t">'</code> <span class="nt">SingleStringCharacters</span> <code class="t">'</code></span> is the SV of
  11794. <i>SingleStringCharacters</i>.</p>
  11795. </li>
  11796. <li>
  11797. <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span> <span
  11798. class="nt">DoubleStringCharacter</span></span> is a sequence of one or two code units that is the SV of
  11799. <i>DoubleStringCharacter</i>.</p>
  11800. </li>
  11801. <li>
  11802. <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span> <span
  11803. class="nt">DoubleStringCharacter</span> <span class="nt">DoubleStringCharacters</span></span> is a sequence of one or
  11804. two code units that is the SV of <i>DoubleStringCharacter</i> followed by all the code units in the SV of
  11805. <i>DoubleStringCharacters</i> in order.</p>
  11806. </li>
  11807. <li>
  11808. <p>The SV of <span class="prod"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span> <span
  11809. class="nt">SingleStringCharacter</span></span> is a sequence of one or two code units that is the SV of
  11810. <i>SingleStringCharacter</i>.</p>
  11811. </li>
  11812. <li>
  11813. <p>The SV of <span class="prod"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span> <span
  11814. class="nt">SingleStringCharacter</span> <span class="nt">SingleStringCharacters</span></span> is a sequence of one or
  11815. two code units that is the SV of <i>SingleStringCharacter</i> followed by all the code units in the SV of
  11816. <i>SingleStringCharacters</i> in order.</p>
  11817. </li>
  11818. <li>
  11819. <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <span
  11820. class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">"</code> <span
  11821. class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <span
  11822. class="nt">LineTerminator</span></span> is the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
  11823. href="#sec-utf16encoding">10.1.1</a>) of the code point value of <i>SourceCharacter</i>.</p>
  11824. </li>
  11825. <li>
  11826. <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <code
  11827. class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of the <i>EscapeSequence</i>.</p>
  11828. </li>
  11829. <li>
  11830. <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <span
  11831. class="nt">LineContinuation</span></span> is the empty code unit sequence.</p>
  11832. </li>
  11833. <li>
  11834. <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <span
  11835. class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">'</code> <span
  11836. class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <span
  11837. class="nt">LineTerminator</span></span> is the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
  11838. href="#sec-utf16encoding">10.1.1</a>) of the code point value of <i>SourceCharacter</i>.</p>
  11839. </li>
  11840. <li>
  11841. <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <code
  11842. class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of the <i>EscapeSequence</i>.</p>
  11843. </li>
  11844. <li>
  11845. <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <span
  11846. class="nt">LineContinuation</span></span> is the empty code unit sequence.</p>
  11847. </li>
  11848. <li>
  11849. <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
  11850. class="nt">CharacterEscapeSequence</span></span> is the SV of the <i>CharacterEscapeSequence</i>.</p>
  11851. </li>
  11852. <li>
  11853. <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <code
  11854. class="t">0</code></span> is the code unit value 0.</p>
  11855. </li>
  11856. <li>
  11857. <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
  11858. class="nt">HexEscapeSequence</span></span> is the SV of the <i>HexEscapeSequence</i>.</p>
  11859. </li>
  11860. <li>
  11861. <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
  11862. class="nt">UnicodeEscapeSequence</span></span> is the SV of the <i>UnicodeEscapeSequence</i>.</p>
  11863. </li>
  11864. <li>
  11865. <p>The SV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
  11866. class="nt">SingleEscapeCharacter</span></span> is the code unit whose value is determined by the
  11867. <i>SingleEscapeCharacter</i> according to { REF _Ref365803173 \h }<a href="#table-34">Table 34</a>.</p>
  11868. </li>
  11869. </ul>
  11870. <figure>
  11871. <figcaption><span id="table-34">Table 34</span> &mdash; String Single Character Escape Sequences</figcaption>
  11872. <table class="real-table">
  11873. <tr>
  11874. <th>Escape Sequence</th>
  11875. <th>Code Unit Value</th>
  11876. <th>Unicode Character Name</th>
  11877. <th>Symbol</th>
  11878. </tr>
  11879. <tr>
  11880. <td><code>\b</code></td>
  11881. <td><code>0x0008</code></td>
  11882. <td>BACKSPACE</td>
  11883. <td>&lt;BS&gt;</td>
  11884. </tr>
  11885. <tr>
  11886. <td><code>\t</code></td>
  11887. <td><code>0x0009</code></td>
  11888. <td>CHARACTER TABULATION</td>
  11889. <td>&lt;HT&gt;</td>
  11890. </tr>
  11891. <tr>
  11892. <td><code>\n</code></td>
  11893. <td><code>0x000A</code></td>
  11894. <td>line feed (lf)</td>
  11895. <td>&lt;LF&gt;</td>
  11896. </tr>
  11897. <tr>
  11898. <td><code>\v</code></td>
  11899. <td><code>0x000B</code></td>
  11900. <td>LINE TABULATION</td>
  11901. <td>&lt;VT&gt;</td>
  11902. </tr>
  11903. <tr>
  11904. <td><code>\f</code></td>
  11905. <td><code>0x000C</code></td>
  11906. <td>form feed (ff)</td>
  11907. <td>&lt;FF&gt;</td>
  11908. </tr>
  11909. <tr>
  11910. <td><code>\r</code></td>
  11911. <td><code>0x000D</code></td>
  11912. <td>carriage return (cr)</td>
  11913. <td>&lt;CR&gt;</td>
  11914. </tr>
  11915. <tr>
  11916. <td><code>\"</code></td>
  11917. <td><code>0x0022</code></td>
  11918. <td>quotation Mark</td>
  11919. <td><code>"</code></td>
  11920. </tr>
  11921. <tr>
  11922. <td><code>\'</code></td>
  11923. <td><code>0x0027</code></td>
  11924. <td>apostrophe</td>
  11925. <td><code>'</code></td>
  11926. </tr>
  11927. <tr>
  11928. <td><code>\\</code></td>
  11929. <td><code>0x005C</code></td>
  11930. <td>REverse Solidus</td>
  11931. <td><code>\</code></td>
  11932. </tr>
  11933. </table>
  11934. </figure>
  11935. <ul>
  11936. <li>
  11937. <p>The SV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
  11938. class="nt">NonEscapeCharacter</span></span> is the SV of the <i>NonEscapeCharacter</i>.</p>
  11939. </li>
  11940. <li>
  11941. <p>The SV of <span class="prod"><span class="nt">NonEscapeCharacter</span> <span class="geq">::</span> <span
  11942. class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <span class="nt">EscapeCharacter</span>
  11943. <span class="grhsmod">or</span> <span class="nt">LineTerminator</span></span> is the <a
  11944. href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
  11945. <i>SourceCharacter</i>.</p>
  11946. </li>
  11947. <li>
  11948. <p>The SV of <span class="prod"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span> <code
  11949. class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></span> is the code unit value
  11950. that is (16 times the MV of the first <i>HexDigit</i>) plus the MV of the second <i>HexDigit</i>.</p>
  11951. </li>
  11952. <li>
  11953. <p>The SV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
  11954. class="t">u</code> <span class="nt">Hex4Digits</span></span> is the SV of <var>Hex4Digits.</var></p>
  11955. </li>
  11956. <li>
  11957. <p>The SV of <span class="prod"><span class="nt">Hex4Digits</span> <span class="geq">::</span> <span
  11958. class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span
  11959. class="nt">HexDigit</span></span> is the code unit value that is (4096 times the MV of the first <i>HexDigit</i>) plus
  11960. (256 times the MV of the second <i>HexDigit</i>) plus (16 times the MV of the third <i>HexDigit</i>) plus the MV of
  11961. the fourth <i>HexDigit</i>.</p>
  11962. </li>
  11963. <li>
  11964. <p>The SV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
  11965. class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></span> is the <a
  11966. href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the MV of
  11967. <i>HexDigits</i>.</p>
  11968. </li>
  11969. </ul>
  11970. </section>
  11971. </section>
  11972. <section id="sec-literals-regular-expression-literals">
  11973. <div class="front">
  11974. <h1><span class="secnum" id="sec-11.8.5"><a href="#sec-literals-regular-expression-literals"
  11975. title="link to this section">11.8.5</a></span> Regular Expression Literals</h1>
  11976. <div class="note">
  11977. <p><span class="nh">NOTE</span> A regular expression literal is an input element that is converted to a RegExp object
  11978. (<a href="#sec-regexp-regular-expression-objects">see 21.2</a>) each time the literal is evaluated. Two regular
  11979. expression literals in a program evaluate to regular expression objects that never compare as <code>===</code> to each
  11980. other even if the two literals' contents are identical. A RegExp object may also be created at runtime by <code>new
  11981. RegExp</code> or calling the <code>RegExp</code> constructor as a function (<a href="#sec-regexp-constructor">see
  11982. 21.2.3</a>).</p>
  11983. </div>
  11984. <p>The productions below describe the syntax for a regular expression literal and are used by the input element scanner to
  11985. find the end of the regular expression literal. The source text comprising the <span
  11986. class="nt">RegularExpressionBody</span> and the <span class="nt">RegularExpressionFlags</span> are subsequently parsed
  11987. again using the more stringent ECMAScript Regular Expression grammar (<a href="#sec-patterns">21.2.1</a>).</p>
  11988. <p>An implementation may extend the ECMAScript Regular Expression grammar defined in <a href="#sec-patterns">21.2.1</a>,
  11989. but it must not extend the <span class="nt">RegularExpressionBody</span> and <span
  11990. class="nt">RegularExpressionFlags</span> productions defined below or the productions used by these productions.</p>
  11991. <h2>Syntax</h2>
  11992. <div class="gp">
  11993. <div class="lhs"><span class="nt">RegularExpressionLiteral</span> <span class="geq">::</span></div>
  11994. <div class="rhs"><code class="t">/</code> <span class="nt">RegularExpressionBody</span> <code class="t">/</code> <span class="nt">RegularExpressionFlags</span></div>
  11995. </div>
  11996. <div class="gp">
  11997. <div class="lhs"><span class="nt">RegularExpressionBody</span> <span class="geq">::</span></div>
  11998. <div class="rhs"><span class="nt">RegularExpressionFirstChar</span> <span class="nt">RegularExpressionChars</span></div>
  11999. </div>
  12000. <div class="gp">
  12001. <div class="lhs"><span class="nt">RegularExpressionChars</span> <span class="geq">::</span></div>
  12002. <div class="rhs"><span class="grhsannot">[empty]</span></div>
  12003. <div class="rhs"><span class="nt">RegularExpressionChars</span> <span class="nt">RegularExpressionChar</span></div>
  12004. </div>
  12005. <div class="gp">
  12006. <div class="lhs"><span class="nt">RegularExpressionFirstChar</span> <span class="geq">::</span></div>
  12007. <div class="rhs"><span class="nt">RegularExpressionNonTerminator</span> <span class="grhsmod">but not one of</span> <code class="t">*</code> <span class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <code class="t">/</code> <span class="grhsmod">or</span> <code class="t">[</code></div>
  12008. <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
  12009. <div class="rhs"><span class="nt">RegularExpressionClass</span></div>
  12010. </div>
  12011. <div class="gp">
  12012. <div class="lhs"><span class="nt">RegularExpressionChar</span> <span class="geq">::</span></div>
  12013. <div class="rhs"><span class="nt">RegularExpressionNonTerminator</span> <span class="grhsmod">but not one of</span> <code class="t">\</code> <span class="grhsmod">or</span> <code class="t">/</code> <span class="grhsmod">or</span> <code class="t">[</code></div>
  12014. <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
  12015. <div class="rhs"><span class="nt">RegularExpressionClass</span></div>
  12016. </div>
  12017. <div class="gp">
  12018. <div class="lhs"><span class="nt">RegularExpressionBackslashSequence</span> <span class="geq">::</span></div>
  12019. <div class="rhs"><code class="t">\</code> <span class="nt">RegularExpressionNonTerminator</span></div>
  12020. </div>
  12021. <div class="gp">
  12022. <div class="lhs"><span class="nt">RegularExpressionNonTerminator</span> <span class="geq">::</span></div>
  12023. <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <span class="nt">LineTerminator</span></div>
  12024. </div>
  12025. <div class="gp">
  12026. <div class="lhs"><span class="nt">RegularExpressionClass</span> <span class="geq">::</span></div>
  12027. <div class="rhs"><code class="t">[</code> <span class="nt">RegularExpressionClassChars</span> <code class="t">]</code></div>
  12028. </div>
  12029. <div class="gp">
  12030. <div class="lhs"><span class="nt">RegularExpressionClassChars</span> <span class="geq">::</span></div>
  12031. <div class="rhs"><span class="grhsannot">[empty]</span></div>
  12032. <div class="rhs"><span class="nt">RegularExpressionClassChars</span> <span class="nt">RegularExpressionClassChar</span></div>
  12033. </div>
  12034. <div class="gp">
  12035. <div class="lhs"><span class="nt">RegularExpressionClassChar</span> <span class="geq">::</span></div>
  12036. <div class="rhs"><span class="nt">RegularExpressionNonTerminator</span> <span class="grhsmod">but not one of</span> <code class="t">]</code> <span class="grhsmod">or</span> <code class="t">\</code></div>
  12037. <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
  12038. </div>
  12039. <div class="gp">
  12040. <div class="lhs"><span class="nt">RegularExpressionFlags</span> <span class="geq">::</span></div>
  12041. <div class="rhs"><span class="grhsannot">[empty]</span></div>
  12042. <div class="rhs"><span class="nt">RegularExpressionFlags</span> <span class="nt">IdentifierPart</span></div>
  12043. </div>
  12044. <div class="note">
  12045. <p><span class="nh">NOTE</span> Regular expression literals may not be empty; instead of representing an empty regular
  12046. expression literal, the code unit sequence <code>//</code> starts a single-line comment. To specify an empty regular
  12047. expression, use: <code>/(?:)/</code>.</p>
  12048. </div>
  12049. </div>
  12050. <section id="sec-literals-regular-expression-literals-static-semantics-early-errors">
  12051. <h1><span class="secnum" id="sec-11.8.5.1"><a
  12052. href="#sec-literals-regular-expression-literals-static-semantics-early-errors"
  12053. title="link to this section">11.8.5.1</a></span> Static Semantics: Early Errors</h1>
  12054. <div class="gp prod"><span class="nt">RegularExpressionFlags</span> <span class="geq">::</span> <span class="nt">RegularExpressionFlags</span> <span class="nt">IdentifierPart</span></div>
  12055. <ul>
  12056. <li>It is a Syntax Error if <span class="nt">IdentifierPart</span> contains a Unicode escape sequence<var>.</var></li>
  12057. </ul>
  12058. </section>
  12059. <section id="sec-static-semantics-bodytext">
  12060. <h1><span class="secnum" id="sec-11.8.5.2"><a href="#sec-static-semantics-bodytext"
  12061. title="link to this section">11.8.5.2</a></span> Static Semantics: <i>BodyText</i></h1>
  12062. <div class="gp prod"><span class="nt">RegularExpressionLiteral</span> <span class="geq">::</span> <code class="t">/</code> <span class="nt">RegularExpressionBody</span> <code class="t">/</code> <span class="nt">RegularExpressionFlags</span></div>
  12063. <ol class="proc">
  12064. <li>Return the source text that was recognized as <i>RegularExpressionBody</i>.</li>
  12065. </ol>
  12066. </section>
  12067. <section id="sec-static-semantics-flagtext">
  12068. <h1><span class="secnum" id="sec-11.8.5.3"><a href="#sec-static-semantics-flagtext"
  12069. title="link to this section">11.8.5.3</a></span> Static Semantics: <i>FlagText</i></h1>
  12070. <div class="gp prod"><span class="nt">RegularExpressionLiteral</span> <span class="geq">::</span> <code class="t">/</code> <span class="nt">RegularExpressionBody</span> <code class="t">/</code> <span class="nt">RegularExpressionFlags</span></div>
  12071. <ol class="proc">
  12072. <li>Return the source text that was recognized as <i>RegularExpressionFlags</i>.</li>
  12073. </ol>
  12074. </section>
  12075. </section>
  12076. <section id="sec-template-literal-lexical-components">
  12077. <div class="front">
  12078. <h1><span class="secnum" id="sec-11.8.6"><a href="#sec-template-literal-lexical-components"
  12079. title="link to this section">11.8.6</a></span> Template Literal Lexical Components</h1>
  12080. <h2>Syntax</h2>
  12081. <div class="gp">
  12082. <div class="lhs"><span class="nt">Template</span> <span class="geq">::</span></div>
  12083. <div class="rhs"><span class="nt">NoSubstitutionTemplate</span></div>
  12084. <div class="rhs"><span class="nt">TemplateHead</span></div>
  12085. </div>
  12086. <div class="gp">
  12087. <div class="lhs"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span></div>
  12088. <div class="rhs"><code class="t">`</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">`</code></div>
  12089. </div>
  12090. <div class="gp">
  12091. <div class="lhs"><span class="nt">TemplateHead</span> <span class="geq">::</span></div>
  12092. <div class="rhs"><code class="t">`</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">${</code></div>
  12093. </div>
  12094. <div class="gp">
  12095. <div class="lhs"><span class="nt">TemplateSubstitutionTail</span> <span class="geq">::</span></div>
  12096. <div class="rhs"><span class="nt">TemplateMiddle</span></div>
  12097. <div class="rhs"><span class="nt">TemplateTail</span></div>
  12098. </div>
  12099. <div class="gp">
  12100. <div class="lhs"><span class="nt">TemplateMiddle</span> <span class="geq">::</span></div>
  12101. <div class="rhs"><code class="t">}</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">${</code></div>
  12102. </div>
  12103. <div class="gp">
  12104. <div class="lhs"><span class="nt">TemplateTail</span> <span class="geq">::</span></div>
  12105. <div class="rhs"><code class="t">}</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">`</code></div>
  12106. </div>
  12107. <div class="gp">
  12108. <div class="lhs"><span class="nt">TemplateCharacters</span> <span class="geq">::</span></div>
  12109. <div class="rhs"><span class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub></div>
  12110. </div>
  12111. <div class="gp">
  12112. <div class="lhs"><span class="nt">TemplateCharacter</span> <span class="geq">::</span></div>
  12113. <div class="rhs"><code class="t">$</code> <span class="grhsannot">[lookahead &ne; { ]</span></div>
  12114. <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
  12115. <div class="rhs"><span class="nt">LineContinuation</span></div>
  12116. <div class="rhs"><span class="nt">LineTerminatorSequence</span></div>
  12117. <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">`</code> <span class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <code class="t">$</code> <span class="grhsmod">or</span> <span class="nt">LineTerminator</span></div>
  12118. </div>
  12119. <p>A conforming implementation must not use the extended definition of <span class="nt">EscapeSequence</span> described in
  12120. <a href="#sec-additional-syntax-string-literals">B.1.2</a> when parsing a <span class="nt">TemplateCharacter</span>.</p>
  12121. <div class="note">
  12122. <p><span class="nh">NOTE</span> <i>TemplateSubstitutionTail</i> is used by the <i>InputElementTemplateTail</i>
  12123. alternative lexical goal.</p>
  12124. </div>
  12125. </div>
  12126. <section id="sec-static-semantics-tv-s-and-trv-s">
  12127. <h1><span class="secnum" id="sec-11.8.6.1"><a href="#sec-static-semantics-tv-s-and-trv-s"
  12128. title="link to this section">11.8.6.1</a></span> Static Semantics: <i>TV&rsquo;s and TRV&rsquo;s</i></h1>
  12129. <p>A template literal component is interpreted as a sequence of Unicode code points. The Template Value (TV) of a literal
  12130. component is described in terms of code unit values (SV, <a href="#sec-literals-string-literals">11.8.4</a>) contributed
  12131. by the various parts of the template literal component. As part of this process, some Unicode code points within the
  12132. template component are interpreted as having a mathematical value (MV, <a
  12133. href="#sec-literals-numeric-literals">11.8.3</a>). In determining a TV, escape sequences are replaced by the UTF-16 code
  12134. unit(s) of the Unicode code point represented by the escape sequence. The Template Raw Value (TRV) is similar to a
  12135. Template Value with the difference that in TRVs escape sequences are interpreted literally.</p>
  12136. <ul>
  12137. <li>
  12138. <p>The TV and TRV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span>
  12139. <code class="t">``</code></span> is the empty code unit sequence.</p>
  12140. </li>
  12141. <li>
  12142. <p>The TV and TRV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
  12143. class="t">`${</code></span> is the empty code unit sequence.</p>
  12144. </li>
  12145. <li>
  12146. <p>The TV and TRV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
  12147. class="t">}${</code></span> is the empty code unit sequence.</p>
  12148. </li>
  12149. <li>
  12150. <p>The TV and TRV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
  12151. class="t">}`</code></span> is the empty code unit sequence.</p>
  12152. </li>
  12153. <li>
  12154. <p>The TV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span> <code
  12155. class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TV of
  12156. <i>TemplateCharacters</i>.</p>
  12157. </li>
  12158. <li>
  12159. <p>The TV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
  12160. class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TV of
  12161. <i>TemplateCharacters</i>.</p>
  12162. </li>
  12163. <li>
  12164. <p>The TV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
  12165. class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TV of
  12166. <i>TemplateCharacters</i>.</p>
  12167. </li>
  12168. <li>
  12169. <p>The TV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
  12170. class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TV of
  12171. <i>TemplateCharacters</i>.</p>
  12172. </li>
  12173. <li>
  12174. <p>The TV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
  12175. class="nt">TemplateCharacter</span></span> is the TV of <i>TemplateCharacter</i>.</p>
  12176. </li>
  12177. <li>
  12178. <p>The TV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
  12179. class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span></span> is a sequence consisting of the
  12180. code units in the TV of <i>TemplateCharacter</i> followed by all the code units in the TV of <i>TemplateCharacters</i>
  12181. in order.</p>
  12182. </li>
  12183. <li>
  12184. <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
  12185. class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">`</code> <span
  12186. class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <code class="t">$</code> <span
  12187. class="grhsmod">or</span> <span class="nt">LineTerminator</span></span> is the <a
  12188. href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
  12189. <i>SourceCharacter</i>.</p>
  12190. </li>
  12191. <li>
  12192. <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
  12193. class="t">$</code></span> is the code unit value 0x0024.</p>
  12194. </li>
  12195. <li>
  12196. <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
  12197. class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of <i>EscapeSequence</i>.</p>
  12198. </li>
  12199. <li>
  12200. <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
  12201. class="nt">LineContinuation</span></span> is the TV of <i>LineContinuation</i>.</p>
  12202. </li>
  12203. <li>
  12204. <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
  12205. class="nt">LineTerminatorSequence</span></span> is the TRV of <i>LineTerminatorSequence</i>.</p>
  12206. </li>
  12207. <li>
  12208. <p>The TV of <span class="prod"><span class="nt">LineContinuation</span> <span class="geq">::</span> <code
  12209. class="t">\</code> <span class="nt">LineTerminatorSequence</span></span> is the empty code unit sequence.</p>
  12210. </li>
  12211. <li>
  12212. <p>The TRV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span> <code
  12213. class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TRV of
  12214. <i>TemplateCharacters</i>.</p>
  12215. </li>
  12216. <li>
  12217. <p>The TRV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
  12218. class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TRV of
  12219. <i>TemplateCharacters</i>.</p>
  12220. </li>
  12221. <li>
  12222. <p>The TRV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
  12223. class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TRV of
  12224. <i>TemplateCharacters</i>.</p>
  12225. </li>
  12226. <li>
  12227. <p>The TRV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
  12228. class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TRV of
  12229. <i>TemplateCharacters</i>.</p>
  12230. </li>
  12231. <li>
  12232. <p>The TRV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
  12233. class="nt">TemplateCharacter</span></span> is the TRV of <i>TemplateCharacter</i>.</p>
  12234. </li>
  12235. <li>
  12236. <p>The TRV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
  12237. class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span></span> is a sequence consisting of the
  12238. code units in the TRV of <i>TemplateCharacter</i> followed by all the code units in the TRV of
  12239. <i>TemplateCharacters,</i> in order.</p>
  12240. </li>
  12241. <li>
  12242. <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
  12243. class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">`</code> <span
  12244. class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <code class="t">$</code> <span
  12245. class="grhsmod">or</span> <span class="nt">LineTerminator</span></span> is the <a
  12246. href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
  12247. <i>SourceCharacter</i>.</p>
  12248. </li>
  12249. <li>
  12250. <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
  12251. class="t">$</code></span> is the code unit value 0x0024.</p>
  12252. </li>
  12253. <li>
  12254. <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
  12255. class="t">\</code> <span class="nt">EscapeSequence</span></span> is the sequence consisting of the code unit value
  12256. 0x005C followed by the code units of TRV of <i>EscapeSequence</i>.</p>
  12257. </li>
  12258. <li>
  12259. <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
  12260. class="nt">LineContinuation</span></span> is the TRV of <i>LineContinuation</i>.</p>
  12261. </li>
  12262. <li>
  12263. <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
  12264. class="nt">LineTerminatorSequence</span></span> is the TRV of <i>LineTerminatorSequence</i>.</p>
  12265. </li>
  12266. <li>
  12267. <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
  12268. class="nt">CharacterEscapeSequence</span></span> is the TRV of the <i>CharacterEscapeSequence</i>.</p>
  12269. </li>
  12270. <li>
  12271. <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <code
  12272. class="t">0</code></span> is the code unit value 0x0030.</p>
  12273. </li>
  12274. <li>
  12275. <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
  12276. class="nt">HexEscapeSequence</span></span> is the TRV of the <i>HexEscapeSequence</i>.</p>
  12277. </li>
  12278. <li>
  12279. <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
  12280. class="nt">UnicodeEscapeSequence</span></span> is the TRV of the <i>UnicodeEscapeSequence</i>.</p>
  12281. </li>
  12282. <li>
  12283. <p>The TRV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
  12284. class="nt">SingleEscapeCharacter</span></span> is the TRV of the <i>SingleEscapeCharacter</i>.</p>
  12285. </li>
  12286. <li>
  12287. <p>The TRV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
  12288. class="nt">NonEscapeCharacter</span></span> is the SV of the <i>NonEscapeCharacter</i>.</p>
  12289. </li>
  12290. <li>
  12291. <p>The TRV of <span class="prod"><span class="nt">SingleEscapeCharacter</span> <span class="geq">::</span> <span
  12292. class="grhsmod">one of</span> <code class="t">'</code> <code class="t">"</code> <code class="t">\</code> <code
  12293. class="t">b</code> <code class="t">f</code> <code class="t">n</code> <code class="t">r</code> <code class="t">t</code>
  12294. <code class="t">v</code></span> is the SV of the <i>SourceCharacter</i> that is that single code point.</p>
  12295. </li>
  12296. <li>
  12297. <p>The TRV of <span class="prod"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span> <code
  12298. class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></span> is the sequence
  12299. consisting of code unit value 0x0078 followed by TRV of the first <i>HexDigit</i> followed by the TRV of the second
  12300. <i>HexDigit</i>.</p>
  12301. </li>
  12302. <li>
  12303. <p>The TRV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
  12304. class="t">u</code> <span class="nt">Hex4Digits</span></span> is the sequence consisting of code unit value 0x0075
  12305. followed by TRV of <span class="nt">Hex4Digits</span>.</p>
  12306. </li>
  12307. <li>
  12308. <p>The TRV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
  12309. class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></span> is the sequence consisting of
  12310. code unit value 0x0075 followed by code unit value 0x007B followed by TRV of <i>HexDigits</i> followed by code unit
  12311. value 0x007D.</p>
  12312. </li>
  12313. <li>
  12314. <p>The TRV of <span class="prod"><span class="nt">Hex4Digits</span> <span class="geq">::</span> <span
  12315. class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span
  12316. class="nt">HexDigit</span></span> is the sequence consisting of the TRV of the first <i>HexDigit</i> followed by the
  12317. TRV of the second <i>HexDigit</i> followed by the TRV of the third <i>HexDigit</i> followed by the TRV of the fourth
  12318. <span class="nt">HexDigit</span>.</p>
  12319. </li>
  12320. <li>
  12321. <p>The TRV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
  12322. class="nt">HexDigit</span></span> is the TRV of <i>HexDigit</i>.</p>
  12323. </li>
  12324. <li>
  12325. <p>The TRV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
  12326. class="nt">HexDigits</span> <span class="nt">HexDigit</span></span> is the sequence consisting of TRV of
  12327. <i>HexDigits</i> followed by TRV of <i>HexDigit</i>.</p>
  12328. </li>
  12329. <li>
  12330. <p>The TRV of a <i>HexDigit</i> is the SV of the <i>SourceCharacter</i> that is that <i>HexDigit</i>.</p>
  12331. </li>
  12332. <li>
  12333. <p>The TRV of <span class="prod"><span class="nt">LineContinuation</span> <span class="geq">::</span> <code
  12334. class="t">\</code> <span class="nt">LineTerminatorSequence</span></span> is the sequence consisting of the code unit
  12335. value 0x005C followed by the code units of TRV of <i>LineTerminatorSequence</i>.</p>
  12336. </li>
  12337. <li>
  12338. <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
  12339. &lt;LF&gt; is the code unit value 0x000A.</p>
  12340. </li>
  12341. <li>
  12342. <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
  12343. &lt;CR&gt; is the code unit value 0x000A.</p>
  12344. </li>
  12345. <li>
  12346. <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
  12347. &lt;LS&gt; is the code unit value 0x2028.</p>
  12348. </li>
  12349. <li>
  12350. <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
  12351. &lt;PS&gt; is the code unit value 0x2029.</p>
  12352. </li>
  12353. <li>
  12354. <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
  12355. &lt;CR&gt;&lt;LF&gt; is the sequence consisting of the code unit value 0x000A.</p>
  12356. </li>
  12357. </ul>
  12358. <div class="note">
  12359. <p><span class="nh">NOTE</span> TV excludes the code units of <i>LineContinuation</i> while TRV includes them.
  12360. &lt;CR&gt;&lt;LF&gt; and &lt;CR&gt; <i>LineTerminatorSequences</i> are normalized to &lt;LF&gt; for both TV and TRV. An
  12361. explicit <i>EscapeSequence</i> is needed to include a &lt;CR&gt; or &lt;CR&gt;&lt;LF&gt; sequence.</p>
  12362. </div>
  12363. </section>
  12364. </section>
  12365. </section>
  12366. <section id="sec-automatic-semicolon-insertion">
  12367. <div class="front">
  12368. <h1><span class="secnum" id="sec-11.9"><a href="#sec-automatic-semicolon-insertion"
  12369. title="link to this section">11.9</a></span> Automatic Semicolon Insertion</h1>
  12370. <p>Certain ECMAScript statements (empty statement, <code>let</code>, <code>const</code>, <code>import</code>, and
  12371. <code>export</code> declarations, variable statement, expression statement, <code>debugger</code> statement,
  12372. <code>continue</code> statement, <code>break</code> statement, <code>return</code> statement, and <code>throw</code>
  12373. statement) must be terminated with semicolons. Such semicolons may always appear explicitly in the source text. For
  12374. convenience, however, such semicolons may be omitted from the source text in certain situations. These situations are
  12375. described by saying that semicolons are automatically inserted into the source code token stream in those situations.</p>
  12376. </div>
  12377. <section id="sec-rules-of-automatic-semicolon-insertion">
  12378. <h1><span class="secnum" id="sec-11.9.1"><a href="#sec-rules-of-automatic-semicolon-insertion"
  12379. title="link to this section">11.9.1</a></span> Rules of Automatic Semicolon Insertion</h1>
  12380. <p>In the following rules, &ldquo;token&rdquo; means the actual recognized lexical token determined using the current
  12381. lexical goal symbol as described in <a href="#sec-ecmascript-language-lexical-grammar">clause 11</a>.</p>
  12382. <p>There are three basic rules of semicolon insertion:</p>
  12383. <ol class="proc">
  12384. <li>When, as a <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
  12385. right, a token (called the <i>offending token</i>) is encountered that is not allowed by any production of the
  12386. grammar, then a semicolon is automatically inserted before the offending token if one or more of the following
  12387. conditions is true:
  12388. <ul>
  12389. <li>
  12390. <p>The offending token is separated from the previous token by at least one <i>LineTerminator</i>.</p>
  12391. </li>
  12392. <li>
  12393. <p>The offending token is <code>}</code>.</p>
  12394. </li>
  12395. <li>
  12396. <p>The previous token is <code>)</code> and the inserted semicolon would then be parsed as the terminating semicolon
  12397. of a do-while statement (<a href="#sec-do-while-statement">13.6.1</a>).</p>
  12398. </li>
  12399. </ul>
  12400. </li>
  12401. <li>When, as the <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
  12402. right, the end of the input stream of tokens is encountered and the parser is unable to parse the input token stream
  12403. as a single complete ECMAScript <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span>, then
  12404. a semicolon is automatically inserted at the end of the input stream.</li>
  12405. <li>When, as the <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
  12406. right, a token is encountered that is allowed by some production of the grammar, but the production is a <i>restricted
  12407. production</i> and the token would be the first token for a terminal or nonterminal immediately following the
  12408. annotation <span style="font-family: Times New Roman">&ldquo;</span>[no&nbsp;<span style="font-family: Times New
  12409. Roman"><i>LineTerminator</i></span> here]&rdquo; within the restricted production (and therefore such a token is
  12410. called a restricted token), and the restricted token is separated from the previous token by at least one <span
  12411. class="nt">LineTerminator</span>, then a semicolon is automatically inserted before the restricted token.</li>
  12412. </ol>
  12413. <p>However, there is an additional overriding condition on the preceding rules: a semicolon is never inserted automatically
  12414. if the semicolon would then be parsed as an empty statement or if that semicolon would become one of the two semicolons in
  12415. the header of a <code>for</code> statement (<a href="#sec-for-statement">see 13.6.3</a>).</p>
  12416. <div class="note">
  12417. <p><span class="nh">NOTE</span> The following are the only restricted productions in the grammar:</p>
  12418. </div>
  12419. <div class="gp">
  12420. <div class="lhs"><span class="nt">PostfixExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12421. <div class="rhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[?Yield]</sub> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <code class="t">++</code></div>
  12422. <div class="rhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[?Yield]</sub> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <code class="t">--</code></div>
  12423. </div>
  12424. <div class="gp">
  12425. <div class="lhs"><span class="nt">ContinueStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12426. <div class="rhs"><code class="t">continue;</code></div>
  12427. <div class="rhs"><code class="t">continue</code> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <span class="nt">LabelIdentifier</span><sub class="g-params">[?Yield]</sub> <code class="t">;</code></div>
  12428. </div>
  12429. <div class="gp">
  12430. <div class="lhs"><span class="nt">BreakStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12431. <div class="rhs"><code class="t">break</code> <code class="t">;</code></div>
  12432. <div class="rhs"><code class="t">break</code> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <span class="nt">LabelIdentifier</span><sub class="g-params">[?Yield]</sub> <code class="t">;</code></div>
  12433. </div>
  12434. <div class="gp">
  12435. <div class="lhs"><span class="nt">ReturnStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12436. <div class="rhs"><code class="t">return</code> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <span class="nt">Expression</span> <code class="t">;</code></div>
  12437. <div class="rhs"><code class="t">return</code> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">;</code></div>
  12438. </div>
  12439. <div class="gp">
  12440. <div class="lhs"><span class="nt">ThrowStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12441. <div class="rhs"><code class="t">throw</code> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">;</code></div>
  12442. </div>
  12443. <div class="gp">
  12444. <div class="lhs"><span class="nt">ArrowFunction</span><sub class="g-params">[In, Yield]</sub> <span class="geq">:</span></div>
  12445. <div class="rhs"><span class="nt">ArrowParameters</span><sub class="g-params">[?Yield]</sub> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <code class="t">=&gt;</code> <span class="nt">ConciseBody</span><sub class="g-params">[?In]</sub></div>
  12446. </div>
  12447. <div class="gp">
  12448. <div class="lhs"><span class="nt">YieldExpression</span><sub class="g-params">[In]</sub> <span class="geq">:</span></div>
  12449. <div class="rhs"><code class="t">yield</code> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <code class="t">*</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[?In, Yield]</sub></div>
  12450. <div class="rhs"><code class="t">yield</code> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <span class="nt">AssignmentExpression</span><sub class="g-params">[?In, Yield]</sub></div>
  12451. </div>
  12452. <p>The practical effect of these restricted productions is as follows:</p>
  12453. <p>When a <code>++</code> or <code>--</code> token is encountered where the parser would treat it as a postfix operator, and
  12454. at least one <span class="nt">LineTerminator</span> occurred between the preceding token and the <code>++</code> or
  12455. <code>--</code> token, then a semicolon is automatically inserted before the <code>++</code> or <code>--</code> token.</p>
  12456. <p>When a <code>continue</code>, <code>break</code>, <code>return</code>, <code>throw</code>, or <code>yield</code> token is
  12457. encountered and a <span class="nt">LineTerminator</span> is encountered before the next token, a semicolon is automatically
  12458. inserted after the <code>continue</code>, <code>break</code>, <code>return</code>, <code>throw</code>, or <code>yield</code>
  12459. token.</p>
  12460. <p>The resulting practical advice to ECMAScript programmers is:</p>
  12461. <p>A postfix <code>++</code> or <code>--</code> operator should appear on the same line as its operand.</p>
  12462. <p>An <span class="nt">Expression</span> in a <code>return</code> or <code>throw</code> statement or an <span
  12463. class="nt">AssignmentExpression</span> in a <code>yield</code> expression should start on the same line as the
  12464. <code>return</code>, <code>throw</code>, or <code>yield</code> token.</p>
  12465. <p>An <span class="nt">IdentifierReference</span> in a <code>break</code> or <code>continue</code> statement should be on
  12466. the same line as the <code>break</code> or <code>continue</code> token.</p>
  12467. </section>
  12468. <section id="sec-examples-of-automatic-semicolon-insertion">
  12469. <h1><span class="secnum" id="sec-11.9.2"><a href="#sec-examples-of-automatic-semicolon-insertion"
  12470. title="link to this section">11.9.2</a></span> Examples of Automatic Semicolon Insertion</h1>
  12471. <p>The source</p>
  12472. <pre>{ 1 2 } 3</pre>
  12473. <p>is not a valid sentence in the ECMAScript grammar, even with the <a href="#sec-automatic-semicolon-insertion">automatic
  12474. semicolon insertion</a> rules. In contrast, the source</p>
  12475. <pre>{ 1<br>2 } 3</pre>
  12476. <p>is also not a valid ECMAScript sentence, but is transformed by <a href="#sec-automatic-semicolon-insertion">automatic
  12477. semicolon insertion</a> into the following:</p>
  12478. <pre>{ 1<br>;2 ;} 3;</pre>
  12479. <p>which is a valid ECMAScript sentence.</p>
  12480. <p>The source</p>
  12481. <pre>for (a; b<br>)</pre>
  12482. <p>is not a valid ECMAScript sentence and is not altered by <a href="#sec-automatic-semicolon-insertion">automatic semicolon
  12483. insertion</a> because the semicolon is needed for the header of a <code>for</code> statement. Automatic semicolon insertion
  12484. never inserts one of the two semicolons in the header of a <code>for</code> statement.</p>
  12485. <p>The source</p>
  12486. <pre>return<br>a + b</pre>
  12487. <p>is transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> into the following:</p>
  12488. <pre>return;<br>a + b;</pre>
  12489. <div class="note">
  12490. <p><span class="nh">NOTE</span> The expression <code>a + b</code> is not treated as a value to be returned by the
  12491. <code>return</code> statement, because a <i>LineTerminator</i> separates it from the token <code>return</code>.</p>
  12492. </div>
  12493. <p>The source</p>
  12494. <pre>a = b<br>++c</pre>
  12495. <p>is transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> into the following:</p>
  12496. <pre>a = b;<br>++c;</pre>
  12497. <div class="note">
  12498. <p><span class="nh">NOTE</span> The token <code>++</code> is not treated as a postfix operator applying to the variable
  12499. <code>b</code>, because a <i>LineTerminator</i> occurs between <code>b</code> and <code>++</code>.</p>
  12500. </div>
  12501. <p>The source</p>
  12502. <pre>if (a &gt; b)<br>else c = d</pre>
  12503. <p>is not a valid ECMAScript sentence and is not altered by <a href="#sec-automatic-semicolon-insertion">automatic semicolon
  12504. insertion</a> before the <code>else</code> token, even though no production of the grammar applies at that point, because an
  12505. automatically inserted semicolon would then be parsed as an empty statement.</p>
  12506. <p>The source</p>
  12507. <pre>a = b + c<br>(d + e).print()</pre>
  12508. <p>is <i>not</i> transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>, because the
  12509. parenthesized expression that begins the second line can be interpreted as an argument list for a function call:</p>
  12510. <pre>a = b + c(d + e).print()</pre>
  12511. <p>In the circumstance that an assignment statement must begin with a left parenthesis, it is a good idea for the programmer
  12512. to provide an explicit semicolon at the end of the preceding statement rather than to rely on <a
  12513. href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>.</p>
  12514. </section>
  12515. </section>
  12516. </section>
  12517. <section id="sec-ecmascript-language-expressions">
  12518. <div class="front">
  12519. <h1><span class="secnum" id="sec-12"><a href="#sec-ecmascript-language-expressions" title="link to this section">12</a></span>
  12520. ECMAScript Language: Expressions</h1>
  12521. </div>
  12522. <section id="sec-identifiers">
  12523. <div class="front">
  12524. <h1><span class="secnum" id="sec-12.1"><a href="#sec-identifiers" title="link to this section">12.1</a></span>
  12525. Identifiers</h1>
  12526. <p><b>Syntax</b></p>
  12527. <div class="gp">
  12528. <div class="lhs"><span class="nt">IdentifierReference</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12529. <div class="rhs"><span class="nt">Identifier</span></div>
  12530. <div class="rhs"><span class="grhsannot">[~Yield]</span> <code class="t">yield</code></div>
  12531. </div>
  12532. <p><i>BindingIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub></span> <b>:</b></p>
  12533. <p><span style="font-family: Times New Roman"><i>Identifier<br></i></span>[~Yield] <code>yield</code></p>
  12534. <div class="gp">
  12535. <div class="lhs"><span class="nt">LabelIdentifier</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12536. <div class="rhs"><span class="nt">Identifier</span></div>
  12537. <div class="rhs"><span class="grhsannot">[~Yield]</span> <code class="t">yield</code></div>
  12538. </div>
  12539. <div class="gp">
  12540. <div class="lhs"><span class="nt">Identifier</span> <span class="geq">:</span></div>
  12541. <div class="rhs"><span class="nt">IdentifierName</span> <span class="grhsmod">but not</span> <span class="nt">ReservedWord</span></div>
  12542. </div>
  12543. </div>
  12544. <section id="sec-identifiers-static-semantics-early-errors">
  12545. <h1><span class="secnum" id="sec-12.1.1"><a href="#sec-identifiers-static-semantics-early-errors"
  12546. title="link to this section">12.1.1</a></span> Static Semantics: Early Errors</h1>
  12547. <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
  12548. <ul>
  12549. <li>
  12550. <p>It is a Syntax Error if the code matched by this production is contained in <a href="#sec-strict-mode-code">strict
  12551. mode code</a> and the StringValue of <span class="nt">Identifier</span> is <code>"arguments"</code> or
  12552. <code>"eval"</code>.</p>
  12553. </li>
  12554. </ul>
  12555. <p><span class="prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code
  12556. class="t">yield</code></span></p>
  12557. <p><span class="prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code
  12558. class="t">yield</code></span></p>
  12559. <div class="gp prod"><span class="nt">LabelIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
  12560. <ul>
  12561. <li>
  12562. <p>It is a Syntax Error if the code matched by this production is contained in <a href="#sec-strict-mode-code">strict
  12563. code</a><var>.</var></p>
  12564. </li>
  12565. </ul>
  12566. <p><i>IdentifierReference</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
  12567. <p><i>BindingIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
  12568. <p><i>LabelIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
  12569. <ul>
  12570. <li>
  12571. <p>It is a Syntax Error if this production has a <sub>[Yield]</sub> parameter and StringValue of <span
  12572. class="nt">Identifier</span> is <code>"yield"</code>.</p>
  12573. </li>
  12574. </ul>
  12575. <div class="gp prod"><span class="nt">Identifier</span> <span class="geq">:</span> <span class="nt">IdentifierName</span> <span class="grhsmod">but not</span> <span class="nt">ReservedWord</span></div>
  12576. <ul>
  12577. <li>
  12578. <p>It is a Syntax Error if this phrase is contained in <a href="#sec-strict-mode-code">strict mode code</a> and the
  12579. StringValue of <span class="nt">IdentifierName</span> is: <code>"implements"</code>, <code>"interface"</code>,
  12580. <code>"let"</code>, <code>"package"</code>, <code>"private"</code>, <code>"protected"</code>, <code>"public"</code>,
  12581. <code>"static"</code>, or <code>"yield"</code>.</p>
  12582. </li>
  12583. <li>
  12584. <p>It is a Syntax Error if StringValue of <span class="nt">IdentifierName</span> is the same string value as the
  12585. StringValue of any <span class="nt">ReservedWord</span> except for <code>yield</code>.</p>
  12586. </li>
  12587. </ul>
  12588. <div class="note">
  12589. <p><span class="nh">NOTE</span> <span style="font-family: sans-serif">StringValue of</span> <i>IdentifierName</i>
  12590. normalizes any Unicode escape sequences in <i>IdentifierName</i> hence such escapes cannot be used to write an
  12591. <i>Identifier</i> whose code point sequence is the same as a <i>ReservedWord</i>.</p>
  12592. </div>
  12593. </section>
  12594. <section id="sec-identifiers-static-semantics-boundnames">
  12595. <h1><span class="secnum" id="sec-12.1.2"><a href="#sec-identifiers-static-semantics-boundnames"
  12596. title="link to this section">12.1.2</a></span> Static Semantics: BoundNames</h1>
  12597. <p>See also: <a href="#sec-let-and-const-declarations-static-semantics-boundnames">13.2.1.2</a>, <a
  12598. href="#sec-variable-statement-static-semantics-boundnames">13.2.2.1</a>, <a
  12599. href="#sec-destructuring-binding-patterns-static-semantics-boundnames">13.2.3.1</a>, <a
  12600. href="#sec-for-in-and-for-of-statements-static-semantics-boundnames">13.6.4.2</a>, <a
  12601. href="#sec-function-definitions-static-semantics-boundnames">14.1.3</a>, <a
  12602. href="#sec-arrow-function-definitions-static-semantics-boundnames">14.2.2</a>, <a
  12603. href="#sec-generator-function-definitions-static-semantics-boundnames">14.4.2</a>, <a
  12604. href="#sec-class-definitions-static-semantics-boundnames">14.5.2</a>, <a
  12605. href="#sec-imports-static-semantics-boundnames">15.2.2.2</a>, <a
  12606. href="#sec-exports-static-semantics-boundnames">15.2.3.2</a>.</p>
  12607. <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
  12608. <ol class="proc">
  12609. <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing the StringValue of
  12610. <i>Identifier</i>.</li>
  12611. </ol>
  12612. <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
  12613. <ol class="proc">
  12614. <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing <code>"yield"</code>.</li>
  12615. </ol>
  12616. </section>
  12617. <section id="sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">
  12618. <h1><span class="secnum" id="sec-12.1.3"><a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget"
  12619. title="link to this section">12.1.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
  12620. <p>See also: <a href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
  12621. href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
  12622. href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
  12623. href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
  12624. href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
  12625. href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
  12626. href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
  12627. href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
  12628. href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
  12629. href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
  12630. href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
  12631. href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
  12632. href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
  12633. href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
  12634. href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
  12635. <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
  12636. <ol class="proc">
  12637. <li>If this <i>IdentifierReference</i> is contained in <a href="#sec-strict-mode-code">strict mode code</a> and
  12638. StringValue of <i>Identifier</i> is <code>"eval"</code> or <code>"arguments"</code>, return <b>false</b>.</li>
  12639. <li>Return <b>true</b>.</li>
  12640. </ol>
  12641. <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code class="t">yield</code></div>
  12642. <ol class="proc">
  12643. <li>Return <b>true</b>.</li>
  12644. </ol>
  12645. </section>
  12646. <section id="sec-identifiers-static-semantics-stringvalue">
  12647. <h1><span class="secnum" id="sec-12.1.4"><a href="#sec-identifiers-static-semantics-stringvalue"
  12648. title="link to this section">12.1.4</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
  12649. <i>StringValue</i></h1>
  12650. <p>See also: <a href="#sec-identifier-names-static-semantics-stringvalue">11.6.1.2</a>, <a
  12651. href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>.</p>
  12652. <p><span class="prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code
  12653. class="t">yield</code></span></p>
  12654. <p><span class="prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code
  12655. class="t">yield</code></span></p>
  12656. <div class="gp prod"><span class="nt">LabelIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
  12657. <ol class="proc">
  12658. <li>Return <code>"yield"</code>.</li>
  12659. </ol>
  12660. <div class="gp prod"><span class="nt">Identifier</span> <span class="geq">:</span> <span class="nt">IdentifierName</span> <span class="grhsmod">but not</span> <span class="nt">ReservedWord</span></div>
  12661. <ol class="proc">
  12662. <li>Return the StringValue of <i>IdentifierName</i>.</li>
  12663. </ol>
  12664. </section>
  12665. <section id="sec-identifiers-runtime-semantics-bindinginitialization">
  12666. <div class="front">
  12667. <h1><span class="secnum" id="sec-12.1.5"><a href="#sec-identifiers-runtime-semantics-bindinginitialization"
  12668. title="link to this section">12.1.5</a></span> Runtime Semantics: BindingInitialization</h1>
  12669. <p>With arguments <var>value</var> and <var>environment</var>.</p>
  12670. <p>See also: <a href="#sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization">13.2.3.5</a>, <a
  12671. href="#sec-for-in-and-for-of-statements-runtime-semantics-bindinginitialization">13.6.4.9</a>.</p>
  12672. <div class="note">
  12673. <p><span class="nh">NOTE</span> <b>undefined</b> is passed for <var>environment</var> to indicate that a <a
  12674. href="#sec-putvalue">PutValue</a> operation should be used to assign the initialization value. This is the case for
  12675. <code>var</code> statements and formal parameter lists of some non-strict functions (See <a
  12676. href="#sec-functiondeclarationinstantiation">9.2.12</a>). In those cases a lexical binding is hoisted and preinitialized
  12677. prior to evaluation of its initializer.</p>
  12678. </div>
  12679. <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
  12680. <ol class="proc">
  12681. <li>Let <i>name</i> be StringValue of <i>Identifier</i>.</li>
  12682. <li>Return <a href="#sec-initializeboundname">InitializeBoundName</a>( <i>name</i>, <i>value</i>,
  12683. <i>environment</i>).</li>
  12684. </ol>
  12685. <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
  12686. <ol class="proc">
  12687. <li>Return <a href="#sec-initializeboundname">InitializeBoundName</a>(<code>"yield"</code>, <i>value</i>,
  12688. <i>environment</i>).</li>
  12689. </ol>
  12690. </div>
  12691. <section id="sec-initializeboundname">
  12692. <h1><span class="secnum" id="sec-12.1.5.1"><a href="#sec-initializeboundname"
  12693. title="link to this section">12.1.5.1</a></span> Runtime Semantics: InitializeBoundName(name, value, environment)</h1>
  12694. <ol class="proc">
  12695. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  12696. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>) is String.</li>
  12697. <li>If <i>environment</i> is not <b>undefined</b>, then
  12698. <ol class="block">
  12699. <li>Let <i>env</i> be the EnvironmentRecord component of <i>environment</i>.</li>
  12700. <li>Perform <i>env</i>.InitializeBinding(<i>name</i>, <i>value</i>).</li>
  12701. <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
  12702. </ol>
  12703. </li>
  12704. <li>Else
  12705. <ol class="block">
  12706. <li>Let <i>lhs</i> be <a href="#sec-resolvebinding">ResolveBinding</a>(<i>name</i>).</li>
  12707. <li>Return <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>value</i>).</li>
  12708. </ol>
  12709. </li>
  12710. </ol>
  12711. </section>
  12712. </section>
  12713. <section id="sec-identifiers-runtime-semantics-evaluation">
  12714. <h1><span class="secnum" id="sec-12.1.6"><a href="#sec-identifiers-runtime-semantics-evaluation"
  12715. title="link to this section">12.1.6</a></span> Runtime Semantics: Evaluation</h1>
  12716. <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
  12717. <ol class="proc">
  12718. <li>Return <a href="#sec-resolvebinding">ResolveBinding</a>(StringValue of <i>Identifier</i>).</li>
  12719. </ol>
  12720. <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code class="t">yield</code></div>
  12721. <ol class="proc">
  12722. <li>Return <a href="#sec-resolvebinding">ResolveBinding</a>(<code>"yield"</code>).</li>
  12723. </ol>
  12724. <div class="note">
  12725. <p><span class="nh">NOTE 1:</span> The result of evaluating an <i>IdentifierReference</i> is always a value of type <a
  12726. href="#sec-reference-specification-type">Reference</a>.</p>
  12727. </div>
  12728. <div class="note">
  12729. <p><span class="nh">NOTE 2:</span> In non-<a href="#sec-strict-mode-code">strict code</a>, the keyword <code>yield</code>
  12730. may be used as an identifier. Evaluating the <i>IdentifierReference</i> production resolves the binding of
  12731. <code>yield</code> as if it was an <i>Identifier</i>. Early Error restriction ensures that such an evaluation only can
  12732. occur for non-<a href="#sec-strict-mode-code">strict code</a>. See <a href="#sec-let-and-const-declarations">13.2.1</a>
  12733. for the handling of <code>yield</code> in binding creation contexts.</p>
  12734. </div>
  12735. </section>
  12736. </section>
  12737. <section id="sec-primary-expression">
  12738. <div class="front">
  12739. <h1><span class="secnum" id="sec-12.2"><a href="#sec-primary-expression" title="link to this section">12.2</a></span>
  12740. Primary Expression</h1>
  12741. <h2>Syntax</h2>
  12742. <div class="gp">
  12743. <div class="lhs"><span class="nt">PrimaryExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12744. <div class="rhs"><code class="t">this</code></div>
  12745. <div class="rhs"><span class="nt">IdentifierReference</span><sub class="g-params">[?Yield]</sub></div>
  12746. <div class="rhs"><span class="nt">Literal</span></div>
  12747. <div class="rhs"><span class="nt">ArrayLiteral</span><sub class="g-params">[?Yield]</sub></div>
  12748. <div class="rhs"><span class="nt">ObjectLiteral</span><sub class="g-params">[?Yield]</sub></div>
  12749. <div class="rhs"><span class="nt">FunctionExpression</span></div>
  12750. <div class="rhs"><span class="nt">ClassExpression</span></div>
  12751. <div class="rhs"><span class="nt">GeneratorExpression</span></div>
  12752. <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
  12753. <div class="rhs"><span class="nt">TemplateLiteral</span><sub class="g-params">[?Yield]</sub></div>
  12754. <div class="rhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub class="g-params">[?Yield]</sub></div>
  12755. </div>
  12756. <div class="gp">
  12757. <div class="lhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12758. <div class="rhs"><code class="t">(</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">)</code></div>
  12759. <div class="rhs"><code class="t">(</code> <code class="t">)</code></div>
  12760. <div class="rhs"><code class="t">(</code> <code class="t">...</code> <span class="nt">BindingIdentifier</span><sub class="g-params">[?Yield]</sub> <code class="t">)</code></div>
  12761. <div class="rhs"><code class="t">(</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">,</code> <code class="t">...</code> <span class="nt">BindingIdentifier</span><sub class="g-params">[?Yield]</sub> <code class="t">)</code></div>
  12762. </div>
  12763. <h2>Supplemental Syntax</h2>
  12764. <p>When processing the production</p>
  12765. <p><span class="nt">PrimaryExpression</span><sub>[Yield]</sub> <b>:</b> <span
  12766. class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub>[?Yield]</sub><span style="font-family: Times New
  12767. Roman"><i><br></i></span>the interpretation of <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> is
  12768. refined using the following grammar:</p>
  12769. <div class="gp">
  12770. <div class="lhs"><span class="nt">ParenthesizedExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12771. <div class="rhs"><code class="t">(</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">)</code></div>
  12772. </div>
  12773. </div>
  12774. <section id="sec-primary-expression-semantics">
  12775. <div class="front">
  12776. <h1><span class="secnum" id="sec-12.2.0"><a href="#sec-primary-expression-semantics"
  12777. title="link to this section">12.2.0</a></span> Semantics</h1>
  12778. </div>
  12779. <section id="sec-static-semantics-coveredparenthesizedexpression">
  12780. <h1><span class="secnum" id="sec-12.2.0.1"><a href="#sec-static-semantics-coveredparenthesizedexpression"
  12781. title="link to this section">12.2.0.1</a></span> Static Semantics: CoveredParenthesizedExpression</h1>
  12782. <div class="gp prod"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span> <code class="t">(</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">)</code></div>
  12783. <ol class="proc">
  12784. <li>Return the result of parsing the lexical token stream matched by
  12785. <i>CoverParenthesizedExpressionAndArrowParameterList</i><sub>[Yield]</sub> using either
  12786. <i>ParenthesizedExpression</i> or <i>ParenthesizedExpression</i><sub>[Yield]</sub> as the goal symbol depending upon
  12787. whether the <sub>[Yield]</sub> grammar parameter was present when
  12788. <i>CoverParenthesizedExpressionAndArrowParameterList was matched.</i></li>
  12789. </ol>
  12790. </section>
  12791. <section id="sec-semantics-static-semantics-isfunctiondefinition">
  12792. <h1><span class="secnum" id="sec-12.2.0.2"><a href="#sec-semantics-static-semantics-isfunctiondefinition"
  12793. title="link to this section">12.2.0.2</a></span> Static Semantics: IsFunctionDefinition</h1>
  12794. <p>See also: <a href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
  12795. href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
  12796. href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
  12797. href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
  12798. href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
  12799. href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
  12800. href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
  12801. href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
  12802. href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
  12803. href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
  12804. href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
  12805. href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
  12806. href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
  12807. href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
  12808. href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
  12809. href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
  12810. href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
  12811. <div class="gp">
  12812. <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
  12813. <div class="rhs"><code class="t">this</code></div>
  12814. <div class="rhs"><span class="nt">IdentifierReference</span></div>
  12815. <div class="rhs"><span class="nt">Literal</span></div>
  12816. <div class="rhs"><span class="nt">ArrayLiteral</span></div>
  12817. <div class="rhs"><span class="nt">ObjectLiteral</span></div>
  12818. <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
  12819. <div class="rhs"><span class="nt">TemplateLiteral</span></div>
  12820. </div>
  12821. <ol class="proc">
  12822. <li>Return <b>false</b>.</li>
  12823. </ol>
  12824. <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
  12825. <ol class="proc">
  12826. <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
  12827. <li>Return IsFunctionDefinition of <i>expr</i>.</li>
  12828. </ol>
  12829. </section>
  12830. <section id="sec-semantics-static-semantics-isidentifierref">
  12831. <h1><span class="secnum" id="sec-12.2.0.3"><a href="#sec-semantics-static-semantics-isidentifierref"
  12832. title="link to this section">12.2.0.3</a></span> Static Semantics: IsIdentifierRef</h1>
  12833. <p>See also: <a href="#sec-static-semantics-static-semantics-isidentifierref">12.3.1.4</a>.</p>
  12834. <div class="gp">
  12835. <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
  12836. <div class="rhs"><span class="nt">IdentifierReference</span></div>
  12837. </div>
  12838. <ol class="proc">
  12839. <li>Return <b>true</b>.</li>
  12840. </ol>
  12841. <div class="gp">
  12842. <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
  12843. <div class="rhs"><code class="t">this</code></div>
  12844. <div class="rhs"><span class="nt">Literal</span></div>
  12845. <div class="rhs"><span class="nt">ArrayLiteral</span></div>
  12846. <div class="rhs"><span class="nt">ObjectLiteral</span></div>
  12847. <div class="rhs"><span class="nt">FunctionExpression</span></div>
  12848. <div class="rhs"><span class="nt">ClassExpression</span></div>
  12849. <div class="rhs"><span class="nt">GeneratorExpression</span></div>
  12850. <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
  12851. <div class="rhs"><span class="nt">TemplateLiteral</span></div>
  12852. <div class="rhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
  12853. </div>
  12854. <ol class="proc">
  12855. <li>Return <b>false</b>.</li>
  12856. </ol>
  12857. </section>
  12858. <section id="sec-semantics-static-semantics-isvalidsimpleassignmenttarget">
  12859. <h1><span class="secnum" id="sec-12.2.0.4"><a href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget"
  12860. title="link to this section">12.2.0.4</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
  12861. <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
  12862. href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
  12863. href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
  12864. href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
  12865. href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
  12866. href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
  12867. href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
  12868. href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
  12869. href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
  12870. href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
  12871. href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
  12872. href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
  12873. href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
  12874. href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
  12875. href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
  12876. <div class="gp">
  12877. <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
  12878. <div class="rhs"><code class="t">this</code></div>
  12879. <div class="rhs"><span class="nt">Literal</span></div>
  12880. <div class="rhs"><span class="nt">ArrayLiteral</span></div>
  12881. <div class="rhs"><span class="nt">ObjectLiteral</span></div>
  12882. <div class="rhs"><span class="nt">FunctionExpression</span></div>
  12883. <div class="rhs"><span class="nt">ClassExpression</span></div>
  12884. <div class="rhs"><span class="nt">GeneratorExpression</span></div>
  12885. <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
  12886. <div class="rhs"><span class="nt">TemplateLiteral</span></div>
  12887. </div>
  12888. <ol class="proc">
  12889. <li>Return <b>false</b>.</li>
  12890. </ol>
  12891. <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
  12892. <ol class="proc">
  12893. <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
  12894. <li>Return IsValidSimpleAssignmentTarget of <i>expr</i>.</li>
  12895. </ol>
  12896. </section>
  12897. </section>
  12898. <section id="sec-this-keyword">
  12899. <div class="front">
  12900. <h1><span class="secnum" id="sec-12.2.1"><a href="#sec-this-keyword" title="link to this section">12.2.1</a></span> The
  12901. <code>this</code> Keyword</h1>
  12902. </div>
  12903. <section id="sec-this-keyword-runtime-semantics-evaluation">
  12904. <h1><span class="secnum" id="sec-12.2.1.1"><a href="#sec-this-keyword-runtime-semantics-evaluation"
  12905. title="link to this section">12.2.1.1</a></span> Runtime Semantics: Evaluation</h1>
  12906. <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <code class="t">this</code></div>
  12907. <ol class="proc">
  12908. <li>Return <a href="#sec-resolvethisbinding">ResolveThisBinding</a>( ) .</li>
  12909. </ol>
  12910. </section>
  12911. </section>
  12912. <section id="sec-identifier-reference">
  12913. <h1><span class="secnum" id="sec-12.2.2"><a href="#sec-identifier-reference" title="link to this section">12.2.2</a></span>
  12914. Identifier Reference</h1>
  12915. <p>See <a href="#sec-identifiers">12.1</a> for <span class="nt">IdentifierReference</span>.</p>
  12916. </section>
  12917. <section id="sec-primary-expression-literals">
  12918. <div class="front">
  12919. <h1><span class="secnum" id="sec-12.2.3"><a href="#sec-primary-expression-literals"
  12920. title="link to this section">12.2.3</a></span> Literals</h1>
  12921. <h2>Syntax</h2>
  12922. <div class="gp">
  12923. <div class="lhs"><span class="nt">Literal</span> <span class="geq">:</span></div>
  12924. <div class="rhs"><span class="nt">NullLiteral</span></div>
  12925. <div class="rhs"><span class="nt">BooleanLiteral</span></div>
  12926. <div class="rhs"><span class="nt">NumericLiteral</span></div>
  12927. <div class="rhs"><span class="nt">StringLiteral</span></div>
  12928. </div>
  12929. </div>
  12930. <section id="sec-literals-runtime-semantics-evaluation">
  12931. <h1><span class="secnum" id="sec-12.2.3.1"><a href="#sec-literals-runtime-semantics-evaluation"
  12932. title="link to this section">12.2.3.1</a></span> Runtime Semantics: Evaluation</h1>
  12933. <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">NullLiteral</span></div>
  12934. <ol class="proc">
  12935. <li>Return <b>null</b>.</li>
  12936. </ol>
  12937. <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">BooleanLiteral</span></div>
  12938. <ol class="proc">
  12939. <li>Return <b>false</b> if <i>BooleanLiteral</i> is the token <code>false</code>.</li>
  12940. <li>Return <b>true</b> if <i>BooleanLiteral</i> is the token <code>true</code>.</li>
  12941. </ol>
  12942. <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
  12943. <ol class="proc">
  12944. <li>Return the number whose value is MV of <i>NumericLiteral</i> as defined in <a
  12945. href="#sec-literals-numeric-literals">11.8.3</a>.</li>
  12946. </ol>
  12947. <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
  12948. <ol class="proc">
  12949. <li>Return the StringValue of <i>StringLiteral</i> as defined in <a
  12950. href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>.</li>
  12951. </ol>
  12952. </section>
  12953. </section>
  12954. <section id="sec-array-initializer">
  12955. <div class="front">
  12956. <h1><span class="secnum" id="sec-12.2.4"><a href="#sec-array-initializer" title="link to this section">12.2.4</a></span>
  12957. Array Initializer</h1>
  12958. <div class="note">
  12959. <p><span class="nh">NOTE</span> An <i>ArrayLiteral</i> is an expression describing the initialization of an Array
  12960. object, using a list, of zero or more expressions each of which represents an array element, enclosed in square
  12961. brackets. The elements need not be literals; they are evaluated each time the array initializer is evaluated.</p>
  12962. </div>
  12963. <p>Array elements may be elided at the beginning, middle or end of the element list. Whenever a comma in the element list
  12964. is not preceded by an <span class="nt">AssignmentExpression</span> (i.e., a comma at the beginning or after another
  12965. comma), the missing array element contributes to the length of the Array and increases the index of subsequent elements.
  12966. Elided array elements are not defined. If an element is elided at the end of an array, that element does not contribute to
  12967. the length of the Array.</p>
  12968. <h2>Syntax</h2>
  12969. <div class="gp">
  12970. <div class="lhs"><span class="nt">ArrayLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12971. <div class="rhs"><code class="t">[</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <code class="t">]</code></div>
  12972. <div class="rhs"><code class="t">[</code> <span class="nt">ElementList</span><sub class="g-params">[?Yield]</sub> <code class="t">]</code></div>
  12973. <div class="rhs"><code class="t">[</code> <span class="nt">ElementList</span><sub class="g-params">[?Yield]</sub> <code class="t">,</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <code class="t">]</code></div>
  12974. </div>
  12975. <div class="gp">
  12976. <div class="lhs"><span class="nt">ElementList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12977. <div class="rhs"><span class="nt">Elision</span><sub class="g-opt">opt</sub> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
  12978. <div class="rhs"><span class="nt">Elision</span><sub class="g-opt">opt</sub> <span class="nt">SpreadElement</span><sub class="g-params">[?Yield]</sub></div>
  12979. <div class="rhs"><span class="nt">ElementList</span><sub class="g-params">[?Yield]</sub> <code class="t">,</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
  12980. <div class="rhs"><span class="nt">ElementList</span><sub class="g-params">[?Yield]</sub> <code class="t">,</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <span class="nt">SpreadElement</span><sub class="g-params">[?Yield]</sub></div>
  12981. </div>
  12982. <div class="gp">
  12983. <div class="lhs"><span class="nt">Elision</span> <span class="geq">:</span></div>
  12984. <div class="rhs"><code class="t">,</code></div>
  12985. <div class="rhs"><span class="nt">Elision</span> <code class="t">,</code></div>
  12986. </div>
  12987. <div class="gp">
  12988. <div class="lhs"><span class="nt">SpreadElement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  12989. <div class="rhs"><code class="t">...</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
  12990. </div>
  12991. </div>
  12992. <section id="sec-static-semantics-elisionwidth">
  12993. <h1><span class="secnum" id="sec-12.2.4.1"><a href="#sec-static-semantics-elisionwidth"
  12994. title="link to this section">12.2.4.1</a></span> Static Semantics: ElisionWidth</h1>
  12995. <div class="gp prod"><span class="nt">Elision</span> <span class="geq">:</span> <code class="t">,</code></div>
  12996. <ol class="proc">
  12997. <li>Return the numeric value 1.</li>
  12998. </ol>
  12999. <div class="gp prod"><span class="nt">Elision</span> <span class="geq">:</span> <span class="nt">Elision</span> <code class="t">,</code></div>
  13000. <ol class="proc">
  13001. <li>Let <i>preceding</i> be the ElisionWidth of <i>Elision</i>.</li>
  13002. <li>Return <i>preceding</i>+1.</li>
  13003. </ol>
  13004. </section>
  13005. <section id="sec-runtime-semantics-arrayaccumulation">
  13006. <h1><span class="secnum" id="sec-12.2.4.2"><a href="#sec-runtime-semantics-arrayaccumulation"
  13007. title="link to this section">12.2.4.2</a></span> Runtime Semantics: ArrayAccumulation</h1>
  13008. <p>With parameters <var>array</var> and <var>nextIndex</var>.</p>
  13009. <div class="gp prod"><span class="nt">ElementList</span> <span class="geq">:</span> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <span class="nt">AssignmentExpression</span></div>
  13010. <ol class="proc">
  13011. <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
  13012. zero.</li>
  13013. <li>Let <i>initResult</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  13014. <li>Let <i>initValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>initResult</i>).</li>
  13015. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initValue</i>).</li>
  13016. <li>Let <i>created</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
  13017. href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>nextIndex+padding</i>)),
  13018. <i>initValue</i>).</li>
  13019. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>created</i> is <b>true</b><i>.</i></li>
  13020. <li>Return <i>nextIndex+padding+</i>1.</li>
  13021. </ol>
  13022. <div class="gp prod"><span class="nt">ElementList</span> <span class="geq">:</span> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <span class="nt">SpreadElement</span></div>
  13023. <ol class="proc">
  13024. <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
  13025. zero.</li>
  13026. <li>Return the result of performing ArrayAccumulation for <i>SpreadElement</i> with arguments <i>array</i> and
  13027. <i>nextIndex</i>+<i>padding</i>.</li>
  13028. </ol>
  13029. <div class="gp prod"><span class="nt">ElementList</span> <span class="geq">:</span> <span class="nt">ElementList</span> <code class="t">,</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <span class="nt">AssignmentExpression</span></div>
  13030. <ol class="proc">
  13031. <li>Let <i>postIndex</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments
  13032. <i>array</i> and <i>nextIndex</i>.</li>
  13033. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>postIndex</i>).</li>
  13034. <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
  13035. zero.</li>
  13036. <li>Let <i>initResult</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  13037. <li>Let <i>initValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>initResult</i>).</li>
  13038. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initValue</i>).</li>
  13039. <li>Let <i>created</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
  13040. href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>postIndex</i>+<i>padding</i>)),
  13041. <i>initValue</i>).</li>
  13042. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>created</i> is <b>true</b>.</li>
  13043. <li>Return <i>postIndex</i>+<i>padding+</i>1.</li>
  13044. </ol>
  13045. <div class="gp prod"><span class="nt">ElementList</span> <span class="geq">:</span> <span class="nt">ElementList</span> <code class="t">,</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <span class="nt">SpreadElement</span></div>
  13046. <ol class="proc">
  13047. <li>Let <i>postIndex</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments
  13048. <i>array</i> and <i>nextIndex</i>.</li>
  13049. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>postIndex</i>).</li>
  13050. <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
  13051. zero.</li>
  13052. <li>Return the result of performing ArrayAccumulation for <i>SpreadElement</i> with arguments <i>array</i> and
  13053. <i>postIndex</i>+<i>padding</i>.</li>
  13054. </ol>
  13055. <div class="gp prod"><span class="nt">SpreadElement</span> <span class="geq">:</span> <code class="t">...</code> <span class="nt">AssignmentExpression</span></div>
  13056. <ol class="proc">
  13057. <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  13058. <li>Let <i>spreadObj</i> be <a href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>).</li>
  13059. <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<i>spreadObj</i>).</li>
  13060. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
  13061. <li>Repeat
  13062. <ol class="block">
  13063. <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
  13064. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
  13065. <li>If <i>next</i> is <b>false</b>, return <i>nextIndex</i>.</li>
  13066. <li>Let <i>nextValue</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
  13067. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextValue</i>).</li>
  13068. <li>Let <i>status</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
  13069. href="#sec-tostring">ToString</a>(<i>nextIndex</i>), <i>nextValue</i>).</li>
  13070. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is <b>true</b> .</li>
  13071. <li>Let <i>nextIndex</i> be <i>nextIndex</i> + 1.</li>
  13072. </ol>
  13073. </li>
  13074. </ol>
  13075. <div class="note">
  13076. <p><span class="nh">NOTE</span> <a href="#sec-createdataproperty">CreateDataProperty</a> is used to ensure that own
  13077. properties are defined for the array even if the standard built-in Array prototype object has been modified in a manner
  13078. that would preclude the creation of new own properties using [[Set]].</p>
  13079. </div>
  13080. </section>
  13081. <section id="sec-array-initializer-runtime-semantics-evaluation">
  13082. <h1><span class="secnum" id="sec-12.2.4.3"><a href="#sec-array-initializer-runtime-semantics-evaluation"
  13083. title="link to this section">12.2.4.3</a></span> Runtime Semantics: Evaluation</h1>
  13084. <div class="gp prod"><span class="nt">ArrayLiteral</span> <span class="geq">:</span> <code class="t">[</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <code class="t">]</code></div>
  13085. <ol class="proc">
  13086. <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
  13087. <li>Let <i>pad</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
  13088. zero.</li>
  13089. <li>Perform <a href="#sec-set-o-p-v-throw">Set</a>(<i>array</i>, <code>"length"</code>, <i>pad</i>, <b>false</b>).</li>
  13090. <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
  13091. href="#sec-arraycreate">ArrayCreate</a>.</li>
  13092. <li>Return <i>array</i>.</li>
  13093. </ol>
  13094. <div class="gp prod"><span class="nt">ArrayLiteral</span> <span class="geq">:</span> <code class="t">[</code> <span class="nt">ElementList</span> <code class="t">]</code></div>
  13095. <ol class="proc">
  13096. <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
  13097. <li>Let <i>len</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments <i>array</i> and
  13098. 0.</li>
  13099. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
  13100. <li>Perform <a href="#sec-set-o-p-v-throw">Set</a>(<i>array</i>, <code>"length"</code>, <i>len</i>, <b>false</b>).</li>
  13101. <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
  13102. href="#sec-arraycreate">ArrayCreate</a>.</li>
  13103. <li>Return <i>array</i>.</li>
  13104. </ol>
  13105. <div class="gp prod"><span class="nt">ArrayLiteral</span> <span class="geq">:</span> <code class="t">[</code> <span class="nt">ElementList</span> <code class="t">,</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <code class="t">]</code></div>
  13106. <ol class="proc">
  13107. <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
  13108. <li>Let <i>len</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments <i>array</i> and
  13109. 0.</li>
  13110. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
  13111. <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
  13112. zero.</li>
  13113. <li>Perform <a href="#sec-set-o-p-v-throw">Set</a>(<i>array</i>, <code>"length"</code>, <a
  13114. href="#sec-touint32">ToUint32</a>(<i>padding</i>+<i>len</i>), <b>false</b>).</li>
  13115. <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
  13116. href="#sec-arraycreate">ArrayCreate</a>.</li>
  13117. <li>Return <i>array</i>.</li>
  13118. </ol>
  13119. </section>
  13120. </section>
  13121. <section id="sec-object-initializer">
  13122. <div class="front">
  13123. <h1><span class="secnum" id="sec-12.2.5"><a href="#sec-object-initializer" title="link to this section">12.2.5</a></span>
  13124. Object Initializer</h1>
  13125. <div class="note">
  13126. <p><span class="nh">NOTE 1</span> An object initializer is an expression describing the initialization of an Object,
  13127. written in a form resembling a literal. It is a list of zero or more pairs of property keys and associated values,
  13128. enclosed in curly brackets. The values need not be literals; they are evaluated each time the object initializer is
  13129. evaluated.</p>
  13130. </div>
  13131. <h2>Syntax</h2>
  13132. <div class="gp">
  13133. <div class="lhs"><span class="nt">ObjectLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13134. <div class="rhs"><code class="t">{</code> <code class="t">}</code></div>
  13135. <div class="rhs"><code class="t">{</code> <span class="nt">PropertyDefinitionList</span><sub class="g-params">[?Yield]</sub> <code class="t">}</code></div>
  13136. <div class="rhs"><code class="t">{</code> <span class="nt">PropertyDefinitionList</span><sub class="g-params">[?Yield]</sub> <code class="t">,</code> <code class="t">}</code></div>
  13137. </div>
  13138. <div class="gp">
  13139. <div class="lhs"><span class="nt">PropertyDefinitionList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13140. <div class="rhs"><span class="nt">PropertyDefinition</span><sub class="g-params">[?Yield]</sub></div>
  13141. <div class="rhs"><span class="nt">PropertyDefinitionList</span><sub class="g-params">[?Yield]</sub> <code class="t">,</code> <span class="nt">PropertyDefinition</span><sub class="g-params">[?Yield]</sub></div>
  13142. </div>
  13143. <div class="gp">
  13144. <div class="lhs"><span class="nt">PropertyDefinition</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13145. <div class="rhs"><span class="nt">IdentifierReference</span><sub class="g-params">[?Yield]</sub></div>
  13146. <div class="rhs"><span class="nt">CoverInitializedName</span><sub class="g-params">[?Yield]</sub></div>
  13147. <div class="rhs"><span class="nt">PropertyName</span><sub class="g-params">[?Yield]</sub> <code class="t">:</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
  13148. <div class="rhs"><span class="nt">MethodDefinition</span><sub class="g-params">[?Yield]</sub></div>
  13149. </div>
  13150. <div class="gp">
  13151. <div class="lhs"><span class="nt">PropertyName</span><sub class="g-params">[Yield,GeneratorParameter]</sub> <span class="geq">:</span></div>
  13152. <div class="rhs"><span class="nt">LiteralPropertyName</span></div>
  13153. <div class="rhs"><span class="grhsannot">[+GeneratorParameter]</span> <span class="nt">ComputedPropertyName</span></div>
  13154. <div class="rhs"><span class="grhsannot">[~GeneratorParameter]</span> <span class="nt">ComputedPropertyName</span><sub class="g-params">[?Yield]</sub></div>
  13155. </div>
  13156. <div class="gp">
  13157. <div class="lhs"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span></div>
  13158. <div class="rhs"><span class="nt">IdentifierName</span></div>
  13159. <div class="rhs"><span class="nt">StringLiteral</span></div>
  13160. <div class="rhs"><span class="nt">NumericLiteral</span></div>
  13161. </div>
  13162. <div class="gp">
  13163. <div class="lhs"><span class="nt">ComputedPropertyName</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13164. <div class="rhs"><code class="t">[</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">]</code></div>
  13165. </div>
  13166. <div class="gp">
  13167. <div class="lhs"><span class="nt">CoverInitializedName</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13168. <div class="rhs"><span class="nt">IdentifierReference</span><sub class="g-params">[?Yield]</sub> <span class="nt">Initializer</span><sub class="g-params">[In, ?Yield]</sub></div>
  13169. </div>
  13170. <div class="gp">
  13171. <div class="lhs"><span class="nt">Initializer</span><sub class="g-params">[In, Yield]</sub> <span class="geq">:</span></div>
  13172. <div class="rhs"><code class="t">=</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[?In, ?Yield]</sub></div>
  13173. </div>
  13174. <div class="note">
  13175. <p><span class="nh">NOTE 2</span> <i>MethodDefinition</i> is defined in <a href="#sec-method-definitions">14.3</a>.</p>
  13176. </div>
  13177. <div class="note">
  13178. <p><span class="nh">NOTE 3</span> In certain contexts, <i>ObjectLiteral</i> is used as a cover grammar for a more
  13179. restricted secondary grammar. The <i>CoverInitializedName</i> production is necessary to fully cover these secondary
  13180. grammars. However, use of this production results in an early Syntax Error in normal contexts where an actual
  13181. <i>ObjectLiteral</i> is expected.</p>
  13182. </div>
  13183. </div>
  13184. <section id="sec-object-initializer-static-semantics-early-errors">
  13185. <h1><span class="secnum" id="sec-12.2.5.1"><a href="#sec-object-initializer-static-semantics-early-errors"
  13186. title="link to this section">12.2.5.1</a></span> Static Semantics: Early Errors</h1>
  13187. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">MethodDefinition</span></div>
  13188. <ul>
  13189. <li>It is a Syntax Error if HasDirectSuper of <span class="nt">MethodDefinition</span> is <span style="font-family:
  13190. Times New Roman"><b><i>true</i></b></span>.</li>
  13191. </ul>
  13192. <p>In addition to describing an actual object initializer the <span class="nt">ObjectLiteral</span> productions are also
  13193. used as a cover grammar for <span class="nt">ObjectAssignmentPattern</span> (<a
  13194. href="#sec-destructuring-assignment">12.14.5</a>). and may be recognized as part of a <span
  13195. class="nt">CoverParenthesizedExpressionAndArrowParameterList</span>. When <span class="nt">ObjectLiteral</span> appears in
  13196. a context where <span class="nt">ObjectAssignmentPattern</span> is required the following Early Error rules are <b>not</b>
  13197. applied. In addition, they are not applied when initially parsing a
  13198. <var>CoverParenthesizedExpressionAndArrowParameterList.</var></p>
  13199. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">CoverInitializedName</span></div>
  13200. <ul>
  13201. <li>Always throw a Syntax Error if code matches <span style="font-family: Times New Roman">this production.</span></li>
  13202. </ul>
  13203. <div class="note">
  13204. <p><span class="nh">NOTE</span> This production exists so that <i>ObjectLiteral</i> can serve as a cover grammar for
  13205. <i>ObjectAssignmentPattern</i> (<a href="#sec-destructuring-assignment">12.14.5</a>). It cannot occur in an actual
  13206. object initializer.</p>
  13207. </div>
  13208. </section>
  13209. <section id="sec-object-initializer-static-semantics-computedpropertycontains">
  13210. <h1><span class="secnum" id="sec-12.2.5.2"><a href="#sec-object-initializer-static-semantics-computedpropertycontains"
  13211. title="link to this section">12.2.5.2</a></span> Static Semantics: ComputedPropertyContains</h1>
  13212. <p>With parameter <var>symbol</var>.</p>
  13213. <p>See also: <a href="#sec-method-definitions-static-semantics-computedpropertycontains">14.3.2</a>, <a
  13214. href="#sec-generator-function-definitions-static-semantics-computedpropertycontains">14.4.3</a>, <a
  13215. href="#sec-class-definitions-static-semantics-computedpropertycontains">14.5.5</a>.</p>
  13216. <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">LiteralPropertyName</span></div>
  13217. <ol class="proc">
  13218. <li>Return <b>false</b>.</li>
  13219. </ol>
  13220. <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">ComputedPropertyName</span></div>
  13221. <ol class="proc">
  13222. <li>Return the result of <i>ComputedPropertyName</i> Contains <i>symbol</i>.</li>
  13223. </ol>
  13224. </section>
  13225. <section id="sec-object-initializer-static-semantics-contains">
  13226. <h1><span class="secnum" id="sec-12.2.5.3"><a href="#sec-object-initializer-static-semantics-contains"
  13227. title="link to this section">12.2.5.3</a></span> Static Semantics: Contains</h1>
  13228. <p>With parameter <var>symbol</var>.</p>
  13229. <p>See also: <a href="#sec-static-semantic-rules">5.3</a>, <a
  13230. href="#sec-static-semantics-static-semantics-contains">12.3.1.1</a>, <a
  13231. href="#sec-function-definitions-static-semantics-contains">14.1.4</a>, <a
  13232. href="#sec-arrow-function-definitions-static-semantics-contains">14.2.3</a>, <a
  13233. href="#sec-generator-function-definitions-static-semantics-contains">14.4.4</a>, <a
  13234. href="#sec-class-definitions-static-semantics-contains">14.5.4</a>.</p>
  13235. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">MethodDefinition</span></div>
  13236. <ol class="proc">
  13237. <li>If <i>symbol</i> is <i>MethodDefinition</i>, return <b>true</b>.</li>
  13238. <li>Return the result of ComputedPropertyContains for <i>MethodDefinition</i> with argument <i>symbol</i>.</li>
  13239. </ol>
  13240. <div class="note">
  13241. <p><span class="nh">NOTE</span> Static semantic rules that depend upon substructure generally do not look into function
  13242. definitions.</p>
  13243. </div>
  13244. <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
  13245. <ol class="proc">
  13246. <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
  13247. <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
  13248. <i>IdentifierName</i>, return <b>true</b>;</li>
  13249. <li>Return <b>false</b>.</li>
  13250. </ol>
  13251. </section>
  13252. <section id="sec-object-initializer-static-semantics-hascomputedpropertykey">
  13253. <h1><span class="secnum" id="sec-12.2.5.4"><a href="#sec-object-initializer-static-semantics-hascomputedpropertykey"
  13254. title="link to this section">12.2.5.4</a></span> Static Semantics: HasComputedPropertyKey</h1>
  13255. <p>See also: <a href="#sec-method-definitions-static-semantics-hascomputedpropertykey">14.3.4</a>, <a
  13256. href="#sec-generator-function-definitions-static-semantics-hascomputedpropertykey">14.4.5</a></p>
  13257. <div class="gp prod"><span class="nt">PropertyDefinitionList</span> <span class="geq">:</span> <span class="nt">PropertyDefinitionList</span> <code class="t">,</code> <span class="nt">PropertyDefinition</span></div>
  13258. <ol class="proc">
  13259. <li>If HasComputedPropertyKey of <i>PropertyDefinitionList</i> is <b>true</b>, return <b>true</b>.</li>
  13260. <li>Return HasComputedPropertyKey of <i>PropertyDefinition</i>.</li>
  13261. </ol>
  13262. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
  13263. <ol class="proc">
  13264. <li>Return <b>false</b>.</li>
  13265. </ol>
  13266. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">PropertyName</span> <code class="t">:</code> <span class="nt">AssignmentExpression</span></div>
  13267. <ol class="proc">
  13268. <li>Return IsComputedPropertyKey of <i>PropertyName</i>.</li>
  13269. </ol>
  13270. </section>
  13271. <section id="sec-static-semantics-iscomputedpropertykey">
  13272. <h1><span class="secnum" id="sec-12.2.5.5"><a href="#sec-static-semantics-iscomputedpropertykey"
  13273. title="link to this section">12.2.5.5</a></span> Static Semantics: IsComputedPropertyKey</h1>
  13274. <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">LiteralPropertyName</span></div>
  13275. <ol class="proc">
  13276. <li>Return <b>false</b>.</li>
  13277. </ol>
  13278. <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">ComputedPropertyName</span></div>
  13279. <ol class="proc">
  13280. <li>Return <b>true</b>.</li>
  13281. </ol>
  13282. </section>
  13283. <section id="sec-object-initializer-static-semantics-propname">
  13284. <h1><span class="secnum" id="sec-12.2.5.6"><a href="#sec-object-initializer-static-semantics-propname"
  13285. title="link to this section">12.2.5.6</a></span> Static Semantics: <i>PropName</i></h1>
  13286. <p>See also: <a href="#sec-method-definitions-static-semantics-propname">14.3.6</a>, <a
  13287. href="#sec-generator-function-definitions-static-semantics-propname">14.4.10</a>, <a
  13288. href="#sec-class-definitions-static-semantics-propname">14.5.12</a></p>
  13289. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
  13290. <ol class="proc">
  13291. <li>Return StringValue of <i>IdentifierReference</i>.</li>
  13292. </ol>
  13293. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">PropertyName</span> <code class="t">:</code> <span class="nt">AssignmentExpression</span></div>
  13294. <ol class="proc">
  13295. <li>Return PropName of <i>PropertyName</i>.</li>
  13296. </ol>
  13297. <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
  13298. <ol class="proc">
  13299. <li>Return StringValue of <i>IdentifierName</i>.</li>
  13300. </ol>
  13301. <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
  13302. <ol class="proc">
  13303. <li>Return a String value whose code units are the SV of the <i>StringLiteral</i>.</li>
  13304. </ol>
  13305. <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
  13306. <ol class="proc">
  13307. <li>Let <i>nbr</i> be the result of forming the value of the <i>NumericLiteral</i>.</li>
  13308. <li>Return <a href="#sec-tostring">ToString</a>(<i>nbr</i>).</li>
  13309. </ol>
  13310. <div class="gp prod"><span class="nt">ComputedPropertyName</span> <span class="geq">:</span> <code class="t">[</code> <span class="nt">AssignmentExpression</span> <code class="t">]</code></div>
  13311. <ol class="proc">
  13312. <li>Return <span style="font-family: sans-serif">empty</span>.</li>
  13313. </ol>
  13314. </section>
  13315. <section id="sec-static-semantics-propertynamelist">
  13316. <h1><span class="secnum" id="sec-12.2.5.7"><a href="#sec-static-semantics-propertynamelist"
  13317. title="link to this section">12.2.5.7</a></span> Static Semantics: PropertyNameList</h1>
  13318. <div class="gp prod"><span class="nt">PropertyDefinitionList</span> <span class="geq">:</span> <span class="nt">PropertyDefinition</span></div>
  13319. <ol class="proc">
  13320. <li>If PropName of <i>PropertyDefinition</i> is <span style="font-family: sans-serif">empty</span>, return a new empty
  13321. <a href="#sec-list-and-record-specification-type">List</a>.</li>
  13322. <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing PropName of
  13323. <i>PropertyDefinition</i>.</li>
  13324. </ol>
  13325. <div class="gp prod"><span class="nt">PropertyDefinitionList</span> <span class="geq">:</span> <span class="nt">PropertyDefinitionList</span> <code class="t">,</code> <span class="nt">PropertyDefinition</span></div>
  13326. <ol class="proc">
  13327. <li>Let <i>list</i> be PropertyNameList of <i>PropertyDefinitionList.</i></li>
  13328. <li>If PropName of <i>PropertyDefinition</i> is <span style="font-family: sans-serif">empty</span>, return
  13329. <i>list</i>.</li>
  13330. <li>Append PropName of <i>PropertyDefinition</i> to the end of <i>list</i>.</li>
  13331. <li>Return <i>list</i>.</li>
  13332. </ol>
  13333. </section>
  13334. <section id="sec-object-initializer-runtime-semantics-evaluation">
  13335. <h1><span class="secnum" id="sec-12.2.5.8"><a href="#sec-object-initializer-runtime-semantics-evaluation"
  13336. title="link to this section">12.2.5.8</a></span> Runtime Semantics: Evaluation</h1>
  13337. <div class="gp prod"><span class="nt">ObjectLiteral</span> <span class="geq">:</span> <code class="t">{</code> <code class="t">}</code></div>
  13338. <ol class="proc">
  13339. <li>Return <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
  13340. sans-serif">%ObjectPrototype%</span>).</li>
  13341. </ol>
  13342. <p><span class="prod"><span class="nt">ObjectLiteral</span> <span class="geq">:</span></span><br>&#x9;<code>{</code> <span
  13343. class="nt">PropertyDefinitionList</span> <code>}</code><span style="font-family: Times New
  13344. Roman"><i><br></i></span>&#x9;<code>{</code> <span class="nt">PropertyDefinitionList</span> <code>,</code>
  13345. <code>}</code></p>
  13346. <ol class="proc">
  13347. <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%ObjectPrototype%).</li>
  13348. <li>Let <i>status</i> be the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinitionList</i> with
  13349. arguments <i>obj</i> and <b>true</b>.</li>
  13350. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  13351. <li>Return <i>obj</i>.</li>
  13352. </ol>
  13353. <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
  13354. <ol class="proc">
  13355. <li>Return StringValue of <i>IdentifierName</i>.</li>
  13356. </ol>
  13357. <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
  13358. <ol class="proc">
  13359. <li>Return a String value whose code units are the SV of the <i>StringLiteral</i>.</li>
  13360. </ol>
  13361. <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
  13362. <ol class="proc">
  13363. <li>Let <i>nbr</i> be the result of forming the value of the <i>NumericLiteral</i>.</li>
  13364. <li>Return <a href="#sec-tostring">ToString</a>(<i>nbr</i>).</li>
  13365. </ol>
  13366. <div class="gp prod"><span class="nt">ComputedPropertyName</span> <span class="geq">:</span> <code class="t">[</code> <span class="nt">AssignmentExpression</span> <code class="t">]</code></div>
  13367. <ol class="proc">
  13368. <li>Let <i>exprValue</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  13369. <li>Let <i>propName</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValue</i>).</li>
  13370. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propName</i>).</li>
  13371. <li>Return <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propName</i>).</li>
  13372. </ol>
  13373. </section>
  13374. <section id="sec-object-initializer-runtime-semantics-propertydefinitionevaluation">
  13375. <h1><span class="secnum" id="sec-12.2.5.9"><a
  13376. href="#sec-object-initializer-runtime-semantics-propertydefinitionevaluation"
  13377. title="link to this section">12.2.5.9</a></span> Runtime Semantics: PropertyDefinitionEvaluation</h1>
  13378. <p>With parameter <var>object</var> and <span style="font-family: Times New Roman"><i>enumerable</i>.</span></p>
  13379. <p>See also: <a href="#sec-method-definitions-runtime-semantics-propertydefinitionevaluation">14.3.9</a>, <a
  13380. href="#sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation">14.4.13</a>, B.3.1</p>
  13381. <div class="gp prod"><span class="nt">PropertyDefinitionList</span> <span class="geq">:</span> <span class="nt">PropertyDefinitionList</span> <code class="t">,</code> <span class="nt">PropertyDefinition</span></div>
  13382. <ol class="proc">
  13383. <li>Let <i>status</i> be the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinitionList</i> with
  13384. arguments <i>object</i> and <i>enumerable</i>.</li>
  13385. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  13386. <li>Return the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinition</i> with arguments
  13387. <i>object</i> and <i>enumerable</i>.</li>
  13388. </ol>
  13389. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
  13390. <ol class="proc">
  13391. <li>Let <i>propName</i> be StringValue of <i>IdentifierReference</i>.</li>
  13392. <li>Let <i>exprValue</i> be the result of evaluating <i>IdentifierReference</i>.</li>
  13393. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exprValue</i>).</li>
  13394. <li>Let <i>propValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValue</i>).</li>
  13395. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propValue</i>).</li>
  13396. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>enumerable</i> is <b>true</b>.</li>
  13397. <li>Return <a href="#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a>(<i>object</i>, <i>propName</i>,
  13398. <i>propValue</i>).</li>
  13399. </ol>
  13400. <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">PropertyName</span> <code class="t">:</code> <span class="nt">AssignmentExpression</span></div>
  13401. <ol class="proc">
  13402. <li>Let <i>propKey</i> be the result of evaluating <i>PropertyName</i>.</li>
  13403. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propKey</i>).</li>
  13404. <li>Let <i>exprValueRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  13405. <li>Let <i>propValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValueRef</i>).</li>
  13406. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propValue</i>).</li>
  13407. <li>If <a href="#sec-isanonymousfunctiondefinition">IsAnonymousFunctionDefinition</a>(<i>AssignmentExpression)</i> is
  13408. <b>true</b>, then
  13409. <ol class="block">
  13410. <li>Let <i>hasNameProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>propValue</i>,
  13411. <code>"name"</code>).</li>
  13412. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasNameProperty</i>).</li>
  13413. <li>If <i>hasNameProperty</i> is <b>false</b>, perform <a
  13414. href="#sec-setfunctionname">SetFunctionName</a>(<i>propValue</i>, <i>propKey</i>).</li>
  13415. </ol>
  13416. </li>
  13417. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>enumerable</i> is <b>true</b>.</li>
  13418. <li>Return <a href="#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a>(<i>object</i>, <i>propKey</i>,
  13419. <i>propValue</i>).</li>
  13420. </ol>
  13421. <p class="Note"><i>NOTE&#x9;An alternative semantics for this production is given in <a
  13422. href="#sec-__proto__-property-names-in-object-initializers">B.3.1</a>.</i></p>
  13423. </section>
  13424. </section>
  13425. <section id="sec-function-defining-expressions">
  13426. <h1><span class="secnum" id="sec-12.2.6"><a href="#sec-function-defining-expressions"
  13427. title="link to this section">12.2.6</a></span> Function Defining Expressions</h1>
  13428. <p>See <a href="#sec-function-definitions">14.1</a> for <span class="prod"><span class="nt">PrimaryExpression</span> <span
  13429. class="geq">:</span> <span class="nt">FunctionExpression</span></span> .</p>
  13430. <p>See <a href="#sec-generator-function-definitions">14.4</a> for <span class="prod"><span
  13431. class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">GeneratorExpression</span></span> .</p>
  13432. <p>See <a href="#sec-class-definitions">14.5</a> for <span class="prod"><span class="nt">PrimaryExpression</span> <span
  13433. class="geq">:</span> <span class="nt">ClassExpression</span></span> .</p>
  13434. </section>
  13435. <section id="sec-primary-expression-regular-expression-literals">
  13436. <div class="front">
  13437. <h1><span class="secnum" id="sec-12.2.7"><a href="#sec-primary-expression-regular-expression-literals"
  13438. title="link to this section">12.2.7</a></span> Regular Expression Literals</h1>
  13439. <h2>Syntax</h2>
  13440. <p>See <a href="#sec-literals-string-literals">11.8.4</a>.</p>
  13441. </div>
  13442. <section id="sec-primary-expression-regular-expression-literals-static-semantics-early-errors">
  13443. <h1><span class="secnum" id="sec-12.2.7.1"><a
  13444. href="#sec-primary-expression-regular-expression-literals-static-semantics-early-errors"
  13445. title="link to this section">12.2.7.1</a></span> Static Semantics: Early Errors</h1>
  13446. <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">RegularExpressionLiteral</span></div>
  13447. <ul>
  13448. <li>
  13449. <p>It is a Syntax Error if <span style="font-family: Times New Roman">BodyText</span> of <span
  13450. class="nt">RegularExpressionLiteral</span> cannot be recognized using the goal symbol <span class="nt">Pattern</span>
  13451. of the ECMAScript RegExp grammar specified in <a href="#sec-patterns">21.2.1</a><var>.</var></p>
  13452. </li>
  13453. <li>
  13454. <p>It is a Syntax Error if <span style="font-family: Times New Roman">FlagText</span> of <span
  13455. class="nt">RegularExpressionLiteral</span> contains any code points other than <code>"g"</code>, <code>"i"</code>,
  13456. <code>"m"</code>, <code>"u"</code>, or <code>"y"</code>, or if it contains the same code point more than once.</p>
  13457. </li>
  13458. </ul>
  13459. </section>
  13460. <section id="sec-regular-expression-literals-runtime-semantics-evaluation">
  13461. <h1><span class="secnum" id="sec-12.2.7.2"><a href="#sec-regular-expression-literals-runtime-semantics-evaluation"
  13462. title="link to this section">12.2.7.2</a></span> Runtime Semantics: Evaluation</h1>
  13463. <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">RegularExpressionLiteral</span></div>
  13464. <ol class="proc">
  13465. <li>Let <i>pattern</i> be the string value consisting of the <a href="#sec-utf16encoding">UTF16Encoding</a> of each code
  13466. point of BodyText of <i>RegularExpressionLiteral</i>.</li>
  13467. <li>Let <i>flags</i> be the string value consisting of the <a href="#sec-utf16encoding">UTF16Encoding</a> of each code
  13468. point of FlagText of <i>RegularExpressionLiteral</i>.</li>
  13469. <li>Return <a href="#sec-regexpcreate">RegExpCreate</a>(<i>pattern</i>, <i>flags</i>).</li>
  13470. </ol>
  13471. </section>
  13472. </section>
  13473. <section id="sec-template-literals">
  13474. <div class="front">
  13475. <h1><span class="secnum" id="sec-12.2.8"><a href="#sec-template-literals" title="link to this section">12.2.8</a></span>
  13476. Template Literals</h1>
  13477. <h2>Syntax</h2>
  13478. <div class="gp">
  13479. <div class="lhs"><span class="nt">TemplateLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13480. <div class="rhs"><span class="nt">NoSubstitutionTemplate</span></div>
  13481. <div class="rhs"><span class="nt">TemplateHead</span> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <span class="nt">TemplateSpans</span><sub class="g-params">[?Yield]</sub></div>
  13482. </div>
  13483. <div class="gp">
  13484. <div class="lhs"><span class="nt">TemplateSpans</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13485. <div class="rhs"><span class="nt">TemplateTail</span></div>
  13486. <div class="rhs"><span class="nt">TemplateMiddleList</span><sub class="g-params">[?Yield]</sub> <span class="nt">TemplateTail</span></div>
  13487. </div>
  13488. <div class="gp">
  13489. <div class="lhs"><span class="nt">TemplateMiddleList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13490. <div class="rhs"><span class="nt">TemplateMiddle</span> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub></div>
  13491. <div class="rhs"><span class="nt">TemplateMiddleList</span><sub class="g-params">[?Yield]</sub> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub></div>
  13492. </div>
  13493. </div>
  13494. <section id="sec-static-semantics-templatestrings">
  13495. <h1><span class="secnum" id="sec-12.2.8.1"><a href="#sec-static-semantics-templatestrings"
  13496. title="link to this section">12.2.8.1</a></span> Static Semantics: TemplateStrings</h1>
  13497. <p>With parameter <var>raw</var>.</p>
  13498. <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
  13499. <ol class="proc">
  13500. <li>If <i>raw</i> is <b>false</b>, then
  13501. <ol class="block">
  13502. <li>Let <i>string</i> be the TV of <i>NoSubstitutionTemplate</i>.</li>
  13503. </ol>
  13504. </li>
  13505. <li>Else,
  13506. <ol class="block">
  13507. <li>Let <i>string</i> be the TRV of <i>NoSubstitutionTemplate</i>.</li>
  13508. </ol>
  13509. </li>
  13510. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element,
  13511. <i>string</i>.</li>
  13512. </ol>
  13513. <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">TemplateHead</span> <span class="nt">Expression</span> <span class="nt">TemplateSpans</span></div>
  13514. <ol class="proc">
  13515. <li>If <i>raw</i> is <b>false</b>, then
  13516. <ol class="block">
  13517. <li>Let <i>head</i> be the TV of <i>TemplateHead</i>.</li>
  13518. </ol>
  13519. </li>
  13520. <li>Else,
  13521. <ol class="block">
  13522. <li>Let <i>head</i> be the TRV of <i>TemplateHead</i>.</li>
  13523. </ol>
  13524. </li>
  13525. <li>Let <i>tail</i> be TemplateStrings of <i>TemplateSpans</i> with argument <i>raw</i>.</li>
  13526. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing <i>head</i> followed by the element,
  13527. in order of <i>tail</i>.</li>
  13528. </ol>
  13529. <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
  13530. <ol class="proc">
  13531. <li>If <i>raw</i> is <b>false</b>, then
  13532. <ol class="block">
  13533. <li>Let <i>tail</i> be the TV of <i>TemplateTail</i>.</li>
  13534. </ol>
  13535. </li>
  13536. <li>Else,
  13537. <ol class="block">
  13538. <li>Let <i>tail</i> be the TRV of <i>TemplateTail</i>.</li>
  13539. </ol>
  13540. </li>
  13541. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element, <i>tail</i>.</li>
  13542. </ol>
  13543. <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
  13544. <ol class="proc">
  13545. <li>Let <i>middle</i> be TemplateStrings of <i>TemplateMiddleList</i> with argument <i>raw</i>.</li>
  13546. <li>If <i>raw</i> is <b>false</b>, then
  13547. <ol class="block">
  13548. <li>Let <i>tail</i> be the TV of <i>TemplateTail</i>.</li>
  13549. </ol>
  13550. </li>
  13551. <li>Else,
  13552. <ol class="block">
  13553. <li>Let <i>tail</i> be the TRV of <i>TemplateTail</i>.</li>
  13554. </ol>
  13555. </li>
  13556. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the elements, in order, of
  13557. <i>middle</i> followed by <i>tail</i>.</li>
  13558. </ol>
  13559. <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
  13560. <ol class="proc">
  13561. <li>If <i>raw</i> is <b>false</b>, then
  13562. <ol class="block">
  13563. <li>Let <i>string</i> be the TV of <i>TemplateMiddle</i>.</li>
  13564. </ol>
  13565. </li>
  13566. <li>Else,
  13567. <ol class="block">
  13568. <li>Let <i>string</i> be the TRV of <i>TemplateMiddle</i>.</li>
  13569. </ol>
  13570. </li>
  13571. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element,
  13572. <i>string</i>.</li>
  13573. </ol>
  13574. <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
  13575. <ol class="proc">
  13576. <li>Let <i>front</i> be TemplateStrings of <i>TemplateMiddleList</i> with argument <i>raw</i>.</li>
  13577. <li>If <i>raw</i> is <b>false</b>, then
  13578. <ol class="block">
  13579. <li>Let <i>last</i> be the TV of <i>TemplateMiddle</i>.</li>
  13580. </ol>
  13581. </li>
  13582. <li>Else,
  13583. <ol class="block">
  13584. <li>Let <i>last</i> be the TRV of <i>TemplateMiddle</i>.</li>
  13585. </ol>
  13586. </li>
  13587. <li>Append <i>last</i> as the last element of the <a href="#sec-list-and-record-specification-type">List</a>
  13588. <i>front</i>.</li>
  13589. <li>Return <i>front</i>.</li>
  13590. </ol>
  13591. </section>
  13592. <section id="sec-template-literals-runtime-semantics-argumentlistevaluation">
  13593. <h1><span class="secnum" id="sec-12.2.8.2"><a href="#sec-template-literals-runtime-semantics-argumentlistevaluation"
  13594. title="link to this section">12.2.8.2</a></span> <span style="font-family: sans-serif">Runtime Semantics:</span>
  13595. ArgumentListEvaluation</h1>
  13596. <p>See also: <a href="#sec-argument-lists-runtime-semantics-argumentlistevaluation">12.3.6.1</a></p>
  13597. <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
  13598. <ol class="proc">
  13599. <li>Let <i>templateLiteral</i> be this <i>TemplateLiteral.</i></li>
  13600. <li>Let <i>siteObj</i> be <a href="#sec-gettemplateobject">GetTemplateObject</a>(<i>templateLiteral</i>).</li>
  13601. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the one element which is
  13602. <i>siteObj</i>.</li>
  13603. </ol>
  13604. <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">TemplateHead</span> <span class="nt">Expression</span> <span class="nt">TemplateSpans</span></div>
  13605. <ol class="proc">
  13606. <li>Let <i>templateLiteral</i> be this <i>TemplateLiteral.</i></li>
  13607. <li>Let <i>siteObj</i> be <a href="#sec-gettemplateobject">GetTemplateObject</a>(<i>templateLiteral</i>).</li>
  13608. <li>Let <i>firstSub</i> be the result of evaluating <i>Expression</i>.</li>
  13609. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>firstSub</i>).</li>
  13610. <li>Let <i>restSub</i> be SubstitutionEvaluation of <i>TemplateSpans</i>.</li>
  13611. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>restSub</i>).</li>
  13612. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>restSub</i> is a <a
  13613. href="#sec-list-and-record-specification-type">List</a>.</li>
  13614. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> whose first element is <i>siteObj</i>, whose
  13615. second elements is <i>firstSub</i>, and whose subsequent elements are the elements of <i>restSub</i>, in order.
  13616. <i>restSub</i> may contain no elements.</li>
  13617. </ol>
  13618. </section>
  13619. <section id="sec-gettemplateobject">
  13620. <h1><span class="secnum" id="sec-12.2.8.3"><a href="#sec-gettemplateobject"
  13621. title="link to this section">12.2.8.3</a></span> Runtime Semantics: GetTemplateObject ( templateLiteral )</h1>
  13622. <p>The abstract operation <span style="font-family: Times New Roman">GetTemplateObject</span> is called with a grammar
  13623. production, <var>templateLiteral</var>, as an argument. It performs the following steps:</p>
  13624. <ol class="proc">
  13625. <li>Let <i>rawStrings</i> be TemplateStrings of <i>templateLiteral</i> with argument <b>true</b>.</li>
  13626. <li>Let <i>ctx</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
  13627. <li>Let <i>realm</i> be the <i>ctx</i>&rsquo;s <a href="#sec-code-realms">Realm</a>.</li>
  13628. <li>Let <i>templateRegistry</i> be <i>realm</i>.[[templateMap]].</li>
  13629. <li>For each element <i>e</i> of <i>templateRegistry</i>, do
  13630. <ol class="block">
  13631. <li>If <i>e</i>.[[strings]] and <i>rawStrings</i> contain the same values in the same order, then
  13632. <ol class="block">
  13633. <li>Return <i>e.</i>[[array]].</li>
  13634. </ol>
  13635. </li>
  13636. </ol>
  13637. </li>
  13638. <li>Let <i>cookedStrings</i> be TemplateStrings of <i>templateLiteral</i> with argument <b>false</b>.</li>
  13639. <li>Let <i>count</i> be the number of elements in the <a href="#sec-list-and-record-specification-type">List</a>
  13640. <i>cookedStrings</i>.</li>
  13641. <li>Let <i>template</i> be <a href="#sec-arraycreate">ArrayCreate</a>(<i>count</i>).</li>
  13642. <li>Let <i>rawObj</i> be <a href="#sec-arraycreate">ArrayCreate</a>(<i>count</i>).</li>
  13643. <li>Let <i>index</i> be 0.</li>
  13644. <li>Repeat while <i>index</i> &lt; <i>count</i>
  13645. <ol class="block">
  13646. <li>Let <i>prop</i> be <a href="#sec-tostring">ToString</a>(<i>index</i>).</li>
  13647. <li>Let <i>cookedValue</i> be the string value <i>cookedStrings</i>[<i>index</i>].</li>
  13648. <li><a href="#sec-call">Call</a> <i>template</i>.[[DefineOwnProperty]](<i>prop</i>, PropertyDescriptor{[[Value]]:
  13649. <i>cookedValue</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>, [[Configurable]]:
  13650. <b>false</b>})<i>.</i></li>
  13651. <li>Let <i>rawValue</i> be the string value <i>rawStrings</i>[<i>index</i>].</li>
  13652. <li><a href="#sec-call">Call</a> <i>rawObj</i>.[[DefineOwnProperty]](<i>prop</i>, PropertyDescriptor{[[Value]]:
  13653. <i>rawValue</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>, [[Configurable]]:
  13654. <b>false</b>})<i>.</i></li>
  13655. <li>Let <i>index</i> be <i>index</i>+1.</li>
  13656. </ol>
  13657. </li>
  13658. <li>Perform <a href="#sec-setintegritylevel">SetIntegrityLevel</a>(<i>rawObj</i>, <code>"frozen"</code>).</li>
  13659. <li><a href="#sec-call">Call</a> <i>template</i>.[[DefineOwnProperty]](<code>"raw"</code>, PropertyDescriptor{[[Value]]:
  13660. <i>rawObj</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
  13661. <b>false</b>})<i>.</i></li>
  13662. <li>Perform <a href="#sec-setintegritylevel">SetIntegrityLevel</a>(<i>template</i>, <code>"frozen"</code>).</li>
  13663. <li>Append the Record{[[strings]]: <i>rawStrings</i>, [[array]]: <i>template</i>} to <i>templateRegistry</i>.</li>
  13664. <li>Return <i>template</i>.</li>
  13665. </ol>
  13666. <div class="note">
  13667. <p><span class="nh">NOTE 1</span> The creation of a template object cannot result in an <a
  13668. href="#sec-completion-record-specification-type">abrupt completion</a>.</p>
  13669. </div>
  13670. <div class="note">
  13671. <p><span class="nh">NOTE 2</span> Each <i>TemplateLiteral</i> in the program code of a <a
  13672. href="#sec-code-realms">Realm</a> is associated with a unique template object that is used in the evaluation of tagged
  13673. Templates (<a href="#sec-template-literals-runtime-semantics-evaluation">12.2.8.5</a>). The template objects are frozen
  13674. and the same template object is used each time a specific tagged Template is evaluated. Whether template objects are
  13675. created lazily upon first evaluation of the <i>TemplateLiteral</i> or eagerly prior to first evaluation is an
  13676. implementation choice that is not observable to ECMAScript code.</p>
  13677. </div>
  13678. <div class="note">
  13679. <p><span class="nh">NOTE 3</span> Future editions of this specification may define additional non-enumerable properties
  13680. of template objects.</p>
  13681. </div>
  13682. </section>
  13683. <section id="sec-runtime-semantics-substitutionevaluation">
  13684. <h1><span class="secnum" id="sec-12.2.8.4"><a href="#sec-runtime-semantics-substitutionevaluation"
  13685. title="link to this section">12.2.8.4</a></span> Runtime Semantics: SubstitutionEvaluation</h1>
  13686. <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
  13687. <ol class="proc">
  13688. <li>Return an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  13689. </ol>
  13690. <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
  13691. <ol class="proc">
  13692. <li>Return the result of SubstitutionEvaluation of <i>TemplateMiddleList</i>.</li>
  13693. </ol>
  13694. <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
  13695. <ol class="proc">
  13696. <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
  13697. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>sub</i>).</li>
  13698. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing only <i>sub</i>.</li>
  13699. </ol>
  13700. <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
  13701. <ol class="proc">
  13702. <li>Let <i>preceding</i> be the result of SubstitutionEvaluation of <i>TemplateMiddleList</i> .</li>
  13703. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>preceding</i>).</li>
  13704. <li>Let <i>next</i> be the result of evaluating <i>Expression</i>.</li>
  13705. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
  13706. <li>Append <i>next</i> as the last element of the <a href="#sec-list-and-record-specification-type">List</a>
  13707. <i>preceding</i>.</li>
  13708. <li>Return <i>preceding</i>.</li>
  13709. </ol>
  13710. </section>
  13711. <section id="sec-template-literals-runtime-semantics-evaluation">
  13712. <h1><span class="secnum" id="sec-12.2.8.5"><a href="#sec-template-literals-runtime-semantics-evaluation"
  13713. title="link to this section">12.2.8.5</a></span> Runtime Semantics: Evaluation</h1>
  13714. <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
  13715. <ol class="proc">
  13716. <li>Return the string value whose code units are the elements of the TV of <i>NoSubstitutionTemplate</i> as defined in
  13717. <a href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
  13718. </ol>
  13719. <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">TemplateHead</span> <span class="nt">Expression</span> <span class="nt">TemplateSpans</span></div>
  13720. <ol class="proc">
  13721. <li>Let <i>head</i> be the TV of <i>TemplateHead</i> as defined in <a
  13722. href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
  13723. <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
  13724. <li>Let <i>middle</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
  13725. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>middle</i>).</li>
  13726. <li>Let <i>tail</i> be the result of evaluating <i>TemplateSpans</i> .</li>
  13727. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>tail</i>).</li>
  13728. <li>Return the string value whose code units are the elements of <i>head</i> followed by the elements of <i>middle</i>
  13729. followed by the elements of <i>tail</i>.</li>
  13730. </ol>
  13731. <div class="note">
  13732. <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
  13733. href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
  13734. </div>
  13735. <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
  13736. <ol class="proc">
  13737. <li>Let <i>tail</i> be the TV of <i>TemplateTail</i> as defined in <a
  13738. href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
  13739. <li>Return the string consisting of the code units of <i>tail</i>.</li>
  13740. </ol>
  13741. <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
  13742. <ol class="proc">
  13743. <li>Let <i>head</i> be the result of evaluating <i>TemplateMiddleList</i>.</li>
  13744. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>head</i>).</li>
  13745. <li>Let <i>tail</i> be the TV of <i>TemplateTail</i> as defined in <a
  13746. href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
  13747. <li>Return the string whose code units are the elements of <i>head</i> followed by the elements of <i>tail</i>.</li>
  13748. </ol>
  13749. <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
  13750. <ol class="proc">
  13751. <li>Let <i>head</i> be the TV of <i>TemplateMiddle</i> as defined in <a
  13752. href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
  13753. <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
  13754. <li>Let <i>middle</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
  13755. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>middle</i>).</li>
  13756. <li>Return the sequence of code units consisting of the code units of <i>head</i> followed by the elements of
  13757. <i>middle</i>.</li>
  13758. </ol>
  13759. <div class="note">
  13760. <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
  13761. href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
  13762. </div>
  13763. <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
  13764. <ol class="proc">
  13765. <li>Let <i>rest</i> be the result of evaluating <i>TemplateMiddleList</i> .</li>
  13766. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>rest</i>).</li>
  13767. <li>Let <i>middle</i> be the TV of <i>TemplateMiddle</i> as defined in <a
  13768. href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
  13769. <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
  13770. <li>Let <i>last</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
  13771. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>last</i>).</li>
  13772. <li>Return the sequence of code units consisting of the elements of <i>rest</i> followed by the code units of
  13773. <i>middle</i> followed by the elements of <i>last</i>.</li>
  13774. </ol>
  13775. <div class="note">
  13776. <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
  13777. href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
  13778. </div>
  13779. </section>
  13780. </section>
  13781. <section id="sec-grouping-operator">
  13782. <div class="front">
  13783. <h1><span class="secnum" id="sec-12.2.9"><a href="#sec-grouping-operator" title="link to this section">12.2.9</a></span>
  13784. The Grouping Operator</h1>
  13785. </div>
  13786. <section id="sec-grouping-operator-static-semantics-early-errors">
  13787. <h1><span class="secnum" id="sec-12.2.9.1"><a href="#sec-grouping-operator-static-semantics-early-errors"
  13788. title="link to this section">12.2.9.1</a></span> Static Semantics: Early Errors</h1>
  13789. <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
  13790. <ul>
  13791. <li>
  13792. <p>It is a Syntax Error if the lexical token sequence matched by <span
  13793. class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> cannot be parsed with no tokens left over using
  13794. <span class="nt">ParenthesizedExpression</span> as the goal symbol.</p>
  13795. </li>
  13796. <li>
  13797. <p>All Early Errors rules for <span class="nt">ParenthesizedExpression</span> and its derived productions also apply
  13798. to <span style="font-family: Times New Roman">CoveredParenthesizedExpression</span> of <span
  13799. class="nt">CoverParenthesizedExpressionAndArrowParameterList</span>.</p>
  13800. </li>
  13801. </ul>
  13802. </section>
  13803. <section id="sec-grouping-operator-static-semantics-isfunctiondefinition">
  13804. <h1><span class="secnum" id="sec-12.2.9.2"><a href="#sec-grouping-operator-static-semantics-isfunctiondefinition"
  13805. title="link to this section">12.2.9.2</a></span> Static Semantics: IsFunctionDefinition</h1>
  13806. <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
  13807. href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
  13808. href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
  13809. href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
  13810. href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
  13811. href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
  13812. href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
  13813. href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
  13814. href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
  13815. href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
  13816. href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
  13817. href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
  13818. href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
  13819. href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
  13820. href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
  13821. href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
  13822. href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
  13823. <div class="gp prod"><span class="nt">ParenthesizedExpression</span> <span class="geq">:</span> <code class="t">(</code> <span class="nt">Expression</span> <code class="t">)</code></div>
  13824. <ol class="proc">
  13825. <li>Return IsFunctionDefinition of <i>Expression</i>.</li>
  13826. </ol>
  13827. </section>
  13828. <section id="sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">
  13829. <h1><span class="secnum" id="sec-12.2.9.3"><a href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget"
  13830. title="link to this section">12.2.9.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
  13831. <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
  13832. href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
  13833. href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
  13834. href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
  13835. href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
  13836. href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
  13837. href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
  13838. href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
  13839. href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
  13840. href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
  13841. href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
  13842. href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
  13843. href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
  13844. href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
  13845. href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
  13846. <div class="gp prod"><span class="nt">ParenthesizedExpression</span> <span class="geq">:</span> <code class="t">(</code> <span class="nt">Expression</span> <code class="t">)</code></div>
  13847. <ol class="proc">
  13848. <li>Return IsValidSimpleAssignmentTarget of <i>Expression</i>.</li>
  13849. </ol>
  13850. </section>
  13851. <section id="sec-grouping-operator-runtime-semantics-evaluation">
  13852. <h1><span class="secnum" id="sec-12.2.9.4"><a href="#sec-grouping-operator-runtime-semantics-evaluation"
  13853. title="link to this section">12.2.9.4</a></span> Runtime Semantics: Evaluation</h1>
  13854. <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
  13855. <ol class="proc">
  13856. <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
  13857. <li>Return the result of evaluating <i>expr</i>.</li>
  13858. </ol>
  13859. <div class="gp prod"><span class="nt">ParenthesizedExpression</span> <span class="geq">:</span> <code class="t">(</code> <span class="nt">Expression</span> <code class="t">)</code></div>
  13860. <ol class="proc">
  13861. <li>Return the result of evaluating <i>Expression</i>. This may be of type <a
  13862. href="#sec-reference-specification-type">Reference</a>.</li>
  13863. </ol>
  13864. <div class="note">
  13865. <p><span class="nh">NOTE</span> This algorithm does not apply <a href="#sec-getvalue">GetValue</a> to the result of
  13866. evaluating <i>Expression</i>. The principal motivation for this is so that operators such as <code>delete</code> and
  13867. <code>typeof</code> may be applied to parenthesized expressions.</p>
  13868. </div>
  13869. </section>
  13870. </section>
  13871. </section>
  13872. <section id="sec-left-hand-side-expressions">
  13873. <div class="front">
  13874. <h1><span class="secnum" id="sec-12.3"><a href="#sec-left-hand-side-expressions"
  13875. title="link to this section">12.3</a></span> Left-Hand-Side Expressions</h1>
  13876. <h2>Syntax</h2>
  13877. <div class="gp">
  13878. <div class="lhs"><span class="nt">MemberExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13879. <div class="rhs"><span class="nt">PrimaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  13880. <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub> <code class="t">[</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">]</code></div>
  13881. <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  13882. <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub> <span class="nt">TemplateLiteral</span><sub class="g-params">[?Yield]</sub></div>
  13883. <div class="rhs"><span class="nt">SuperProperty</span><sub class="g-params">[?Yield]</sub></div>
  13884. <div class="rhs"><span class="nt">MetaProperty</span></div>
  13885. <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub> <span class="nt">Arguments</span><sub class="g-params">[?Yield]</sub></div>
  13886. </div>
  13887. <div class="gp">
  13888. <div class="lhs"><span class="nt">SuperProperty</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13889. <div class="rhs"><code class="t">super</code> <code class="t">[</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">]</code></div>
  13890. <div class="rhs"><code class="t">super</code> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  13891. </div>
  13892. <div class="gp">
  13893. <div class="lhs"><span class="nt">MetaProperty</span> <span class="geq">:</span></div>
  13894. <div class="rhs"><span class="nt">NewTarget</span></div>
  13895. </div>
  13896. <div class="gp">
  13897. <div class="lhs"><span class="nt">NewTarget</span> <span class="geq">:</span></div>
  13898. <div class="rhs"><code class="t">new</code> <code class="t">.</code> <code class="t">target</code></div>
  13899. </div>
  13900. <div class="gp">
  13901. <div class="lhs"><span class="nt">NewExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13902. <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub></div>
  13903. <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span><sub class="g-params">[?Yield]</sub></div>
  13904. </div>
  13905. <div class="gp">
  13906. <div class="lhs"><span class="nt">CallExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13907. <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub> <span class="nt">Arguments</span><sub class="g-params">[?Yield]</sub></div>
  13908. <div class="rhs"><span class="nt">SuperCall</span><sub class="g-params">[?Yield]</sub></div>
  13909. <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub> <span class="nt">Arguments</span><sub class="g-params">[?Yield]</sub></div>
  13910. <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub> <code class="t">[</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">]</code></div>
  13911. <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  13912. <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub> <span class="nt">TemplateLiteral</span><sub class="g-params">[?Yield]</sub></div>
  13913. </div>
  13914. <div class="gp">
  13915. <div class="lhs"><span class="nt">SuperCall</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13916. <div class="rhs"><code class="t">super</code> <span class="nt">Arguments</span><sub class="g-params">[?Yield]</sub></div>
  13917. </div>
  13918. <div class="gp">
  13919. <div class="lhs"><span class="nt">Arguments</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13920. <div class="rhs"><code class="t">(</code> <code class="t">)</code></div>
  13921. <div class="rhs"><code class="t">(</code> <span class="nt">ArgumentList</span><sub class="g-params">[?Yield]</sub> <code class="t">)</code></div>
  13922. </div>
  13923. <div class="gp">
  13924. <div class="lhs"><span class="nt">ArgumentList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13925. <div class="rhs"><span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
  13926. <div class="rhs"><code class="t">...</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
  13927. <div class="rhs"><span class="nt">ArgumentList</span><sub class="g-params">[?Yield]</sub> <code class="t">,</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
  13928. <div class="rhs"><span class="nt">ArgumentList</span><sub class="g-params">[?Yield]</sub> <code class="t">,</code> <code class="t">...</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
  13929. </div>
  13930. <div class="gp">
  13931. <div class="lhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  13932. <div class="rhs"><span class="nt">NewExpression</span><sub class="g-params">[?Yield]</sub></div>
  13933. <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub></div>
  13934. </div>
  13935. </div>
  13936. <section id="sec-static-semantics">
  13937. <div class="front">
  13938. <h1><span class="secnum" id="sec-12.3.1"><a href="#sec-static-semantics" title="link to this section">12.3.1</a></span>
  13939. Static Semantics</h1>
  13940. </div>
  13941. <section id="sec-static-semantics-static-semantics-contains">
  13942. <h1><span class="secnum" id="sec-12.3.1.1"><a href="#sec-static-semantics-static-semantics-contains"
  13943. title="link to this section">12.3.1.1</a></span> Static Semantics: Contains</h1>
  13944. <p>With parameter <var>symbol</var>.</p>
  13945. <p>See also: <a href="#sec-static-semantic-rules">5.3</a>, <a
  13946. href="#sec-object-initializer-static-semantics-contains">12.2.5.3</a>, <a
  13947. href="#sec-function-definitions-static-semantics-contains">14.1.4</a>, <a
  13948. href="#sec-arrow-function-definitions-static-semantics-contains">14.2.3</a>, <a
  13949. href="#sec-generator-function-definitions-static-semantics-contains">14.4.4</a>, <a
  13950. href="#sec-class-definitions-static-semantics-contains">14.5.4</a></p>
  13951. <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  13952. <ol class="proc">
  13953. <li>If <i>MemberExpression</i> Contains <i>symbol</i> is <b>true</b>, return <b>true</b>.</li>
  13954. <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
  13955. <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
  13956. <i>IdentifierName</i>, return <b>true</b>;</li>
  13957. <li>Return <b>false</b>.</li>
  13958. </ol>
  13959. <div class="gp prod"><span class="nt">SuperProperty</span> <span class="geq">:</span> <code class="t">super</code> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  13960. <ol class="proc">
  13961. <li>If <i>symbol</i> is the <i>ReservedWord</i> <code>super</code>, return <b>true</b>.</li>
  13962. <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
  13963. <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
  13964. <i>IdentifierName</i>, return <b>true</b>;</li>
  13965. <li>Return <b>false</b>.</li>
  13966. </ol>
  13967. <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  13968. <ol class="proc">
  13969. <li>If <i>CallExpression</i> Contains <i>symbol</i> is <b>true</b>, return <b>true</b>.</li>
  13970. <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
  13971. <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
  13972. <i>IdentifierName</i>, return <b>true</b>;</li>
  13973. <li>Return <b>false</b>.</li>
  13974. </ol>
  13975. </section>
  13976. <section id="sec-static-semantics-static-semantics-isfunctiondefinition">
  13977. <h1><span class="secnum" id="sec-12.3.1.2"><a href="#sec-static-semantics-static-semantics-isfunctiondefinition"
  13978. title="link to this section">12.3.1.2</a></span> Static Semantics: IsFunctionDefinition</h1>
  13979. <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
  13980. href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
  13981. href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
  13982. href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
  13983. href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
  13984. href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
  13985. href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
  13986. href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
  13987. href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
  13988. href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
  13989. href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
  13990. href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
  13991. href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
  13992. href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
  13993. href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
  13994. href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
  13995. href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
  13996. <div class="gp">
  13997. <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
  13998. <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  13999. <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14000. <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
  14001. <div class="rhs"><span class="nt">SuperProperty</span></div>
  14002. <div class="rhs"><span class="nt">MetaProperty</span></div>
  14003. <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14004. </div>
  14005. <div class="gp">
  14006. <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
  14007. <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
  14008. </div>
  14009. <div class="gp">
  14010. <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
  14011. <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14012. <div class="rhs"><span class="nt">SuperCall</span></div>
  14013. <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
  14014. <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14015. <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14016. <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
  14017. </div>
  14018. <ol class="proc">
  14019. <li>Return <b>false</b>.</li>
  14020. </ol>
  14021. </section>
  14022. <section id="sec-static-semantics-static-semantics-isdestructuring">
  14023. <h1><span class="secnum" id="sec-12.3.1.3"><a href="#sec-static-semantics-static-semantics-isdestructuring"
  14024. title="link to this section">12.3.1.3</a></span> Static Semantics: IsDestructuring</h1>
  14025. <p>See also: <a href="#sec-for-in-and-for-of-statements-static-semantics-isdestructuring">13.6.4.6</a>.</p>
  14026. <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">PrimaryExpression</span></div>
  14027. <ol class="proc">
  14028. <li>If <i>PrimaryExpression</i> is either an <i>ObjectLiteral</i> or an <i>ArrayLiteral</i>, return <b>true.</b></li>
  14029. <li>Return <b>false</b>.</li>
  14030. </ol>
  14031. <div class="gp">
  14032. <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
  14033. <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14034. <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14035. <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
  14036. <div class="rhs"><span class="nt">SuperProperty</span></div>
  14037. <div class="rhs"><span class="nt">MetaProperty</span></div>
  14038. <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14039. </div>
  14040. <div class="gp">
  14041. <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
  14042. <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
  14043. </div>
  14044. <div class="gp">
  14045. <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
  14046. <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14047. <div class="rhs"><span class="nt">SuperCall</span></div>
  14048. <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
  14049. <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14050. <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14051. <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
  14052. </div>
  14053. <ol class="proc">
  14054. <li>Return <b>false</b>.</li>
  14055. </ol>
  14056. </section>
  14057. <section id="sec-static-semantics-static-semantics-isidentifierref">
  14058. <h1><span class="secnum" id="sec-12.3.1.4"><a href="#sec-static-semantics-static-semantics-isidentifierref"
  14059. title="link to this section">12.3.1.4</a></span> Static Semantics: IsIdentifierRef</h1>
  14060. <p>See also: <a href="#sec-semantics-static-semantics-isidentifierref">12.2.0.3</a>.</p>
  14061. <div class="gp">
  14062. <div class="lhs"><span class="nt">LeftHandSideExpression</span> <span class="geq">:</span></div>
  14063. <div class="rhs"><span class="nt">CallExpression</span></div>
  14064. </div>
  14065. <div class="gp">
  14066. <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
  14067. <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14068. <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14069. <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
  14070. <div class="rhs"><span class="nt">SuperProperty</span></div>
  14071. <div class="rhs"><span class="nt">MetaProperty</span></div>
  14072. <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14073. </div>
  14074. <div class="gp">
  14075. <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
  14076. <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
  14077. </div>
  14078. <ol class="proc">
  14079. <li>Return <b>false</b>.</li>
  14080. </ol>
  14081. </section>
  14082. <section id="sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">
  14083. <h1><span class="secnum" id="sec-12.3.1.5"><a href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget"
  14084. title="link to this section">12.3.1.5</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
  14085. <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
  14086. href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
  14087. href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
  14088. href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
  14089. href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
  14090. href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
  14091. href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
  14092. href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
  14093. href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
  14094. href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
  14095. href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
  14096. href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
  14097. href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
  14098. href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
  14099. href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
  14100. <div class="gp">
  14101. <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
  14102. <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14103. <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14104. </div>
  14105. <div class="gp">
  14106. <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
  14107. <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14108. <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14109. <div class="rhs"><span class="nt">SuperProperty</span></div>
  14110. </div>
  14111. <ol class="proc">
  14112. <li>Return <b>true</b>.</li>
  14113. </ol>
  14114. <div class="gp">
  14115. <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
  14116. <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14117. <div class="rhs"><span class="nt">SuperCall</span></div>
  14118. <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
  14119. <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
  14120. </div>
  14121. <div class="gp">
  14122. <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
  14123. <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
  14124. </div>
  14125. <div class="gp">
  14126. <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
  14127. <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
  14128. <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14129. </div>
  14130. <div class="gp">
  14131. <div class="lhs"><span class="nt">NewTarget</span> <span class="geq">:</span></div>
  14132. <div class="rhs"><code class="t">new</code> <code class="t">.</code> <code class="t">target</code></div>
  14133. </div>
  14134. <ol class="proc">
  14135. <li>Return <b>false</b>.</li>
  14136. </ol>
  14137. </section>
  14138. </section>
  14139. <section id="sec-property-accessors">
  14140. <div class="front">
  14141. <h1><span class="secnum" id="sec-12.3.2"><a href="#sec-property-accessors" title="link to this section">12.3.2</a></span>
  14142. Property Accessors</h1>
  14143. <div class="note">
  14144. <p><span class="nh">NOTE</span> Properties are accessed by name, using either the dot notation:</p>
  14145. </div>
  14146. <div class="lhs">MemberExpression <code>.</code> IdentifierName<br>CallExpression <code>.</code> IdentifierName</div>
  14147. <p>or the bracket notation:</p>
  14148. <div class="lhs">MemberExpression <code>[</code> Expression <code>]</code><br>CallExpression <code>[</code> Expression <code>]</code></div>
  14149. <p>The dot notation is explained by the following syntactic conversion:</p>
  14150. <div class="lhs">MemberExpression <code>.</code> IdentifierName</div>
  14151. <p>is identical in its behaviour to</p>
  14152. <div class="lhs">MemberExpression <code>[</code> &lt;identifier-name-string&gt; <code>]</code></div>
  14153. <p>and similarly</p>
  14154. <div class="lhs">CallExpression <code>.</code> IdentifierName</div>
  14155. <p>is identical in its behaviour to</p>
  14156. <div class="lhs">CallExpression <code>[</code> &lt;identifier-name-string&gt; <code>]</code></div>
  14157. <p>where <var>&lt;identifier-name-string&gt;</var> is the result of evaluating <span style="font-family: Times New
  14158. Roman">StringValue of</span> <span class="nt">IdentifierName</span>.</p>
  14159. </div>
  14160. <section id="sec-property-accessors-runtime-semantics-evaluation">
  14161. <h1><span class="secnum" id="sec-12.3.2.1"><a href="#sec-property-accessors-runtime-semantics-evaluation"
  14162. title="link to this section">12.3.2.1</a></span> Runtime Semantics: Evaluation</h1>
  14163. <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14164. <ol class="proc">
  14165. <li>Let <i>baseReference</i> be the result of evaluating <i>MemberExpression</i>.</li>
  14166. <li>Let <i>baseValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>baseReference</i>).</li>
  14167. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>baseValue</i>).</li>
  14168. <li>Let <i>propertyNameReference</i> be the result of evaluating <i>Expression</i>.</li>
  14169. <li>Let <i>propertyNameValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>propertyNameReference</i>).</li>
  14170. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyNameValue</i>).</li>
  14171. <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
  14172. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
  14173. <li>Let <i>propertyKey</i> be <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propertyNameValue</i>).</li>
  14174. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyKey</i>).</li>
  14175. <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
  14176. mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
  14177. <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i> and
  14178. whose referenced name is <i>propertyKey</i>, and whose strict reference flag is <i>strict</i>.</li>
  14179. </ol>
  14180. <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14181. <ol class="proc">
  14182. <li>Let <i>baseReference</i> be the result of evaluating <i>MemberExpression</i>.</li>
  14183. <li>Let <i>baseValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>baseReference</i>).</li>
  14184. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>baseValue</i>).</li>
  14185. <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
  14186. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
  14187. <li>Let <i>propertyNameString</i> be StringValue of <i>IdentifierName</i></li>
  14188. <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
  14189. mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
  14190. <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i> and
  14191. whose referenced name is <i>propertyNameString</i>, and whose strict reference flag is <i>strict</i>.</li>
  14192. </ol>
  14193. <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14194. <p>Is evaluated in exactly the same manner as <span class="prod"><span class="nt">MemberExpression</span> <span
  14195. class="geq">:</span> <span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span>
  14196. <code class="t">]</code></span> except that the contained <span class="nt">CallExpression</span> is evaluated in step
  14197. 1.</p>
  14198. <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14199. <p>Is evaluated in exactly the same manner as <span class="prod"><span class="nt">MemberExpression</span> <span
  14200. class="geq">:</span> <span class="nt">MemberExpression</span> <code class="t">.</code> <span
  14201. class="nt">IdentifierName</span></span> except that the contained <span class="nt">CallExpression</span> is evaluated in
  14202. step 1.</p>
  14203. </section>
  14204. </section>
  14205. <section id="sec-new-operator">
  14206. <div class="front">
  14207. <h1><span class="secnum" id="sec-12.3.3"><a href="#sec-new-operator" title="link to this section">12.3.3</a></span> The
  14208. <code>new</code> Operator</h1>
  14209. </div>
  14210. <section id="sec-new-operator-runtime-semantics-evaluation">
  14211. <div class="front">
  14212. <h1><span class="secnum" id="sec-12.3.3.1"><a href="#sec-new-operator-runtime-semantics-evaluation"
  14213. title="link to this section">12.3.3.1</a></span> Runtime Semantics: Evaluation</h1>
  14214. <div class="gp prod"><span class="nt">NewExpression</span> <span class="geq">:</span> <code class="t">new</code> <span class="nt">NewExpression</span></div>
  14215. <ol class="proc">
  14216. <li>Return <a href="#sec-evaluatenew">EvaluateNew</a>(<i>NewExpression</i>, <span style="font-family:
  14217. sans-serif">empty</span>).</li>
  14218. </ol>
  14219. <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14220. <ol class="proc">
  14221. <li>Return <a href="#sec-evaluatenew">EvaluateNew</a>(<i>MemberExpression</i>, <i>Arguments</i>).</li>
  14222. </ol>
  14223. </div>
  14224. <section id="sec-evaluatenew">
  14225. <h1><span class="secnum" id="sec-12.3.3.1.1"><a href="#sec-evaluatenew"
  14226. title="link to this section">12.3.3.1.1</a></span> Runtime Semantics: EvaluateNew(constructProduction,
  14227. arguments)</h1>
  14228. <p>The abstract operation EvaluateNew with arguments <span style="font-family: Times New
  14229. Roman"><i>constructProduction</i>,</span> and <var>arguments</var> performs the following steps:</p>
  14230. <ol class="proc">
  14231. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>constructProduction</i> is either a <i>NewExpression</i> or a
  14232. <i>MemberExpression</i>.</li>
  14233. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>arguments</i> is either <span style="font-family:
  14234. sans-serif">empty</span> or an <i>Arguments</i> production.</li>
  14235. <li>Let <i>ref</i> be the result of evaluating <i>constructProduction</i>.</li>
  14236. <li>Let <i>constructor</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
  14237. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>constructor</i>).</li>
  14238. <li>If <i>arguments</i> is <span style="font-family: sans-serif">empty</span>, let <i>argList</i> be an empty <a
  14239. href="#sec-list-and-record-specification-type">List</a>.</li>
  14240. <li>Else,
  14241. <ol class="block">
  14242. <li>Let <i>argList</i> be ArgumentListEvaluation of <i>arguments</i>.</li>
  14243. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
  14244. </ol>
  14245. </li>
  14246. <li>If <a href="#sec-isconstructor">IsConstructor</a> (<i>constructor</i>) is <b>false</b>, throw a <b>TypeError</b>
  14247. exception.</li>
  14248. <li>Return <a href="#sec-construct">Construct</a>(<i>constructor</i>, <i>argList</i>).</li>
  14249. </ol>
  14250. </section>
  14251. </section>
  14252. </section>
  14253. <section id="sec-function-calls">
  14254. <div class="front">
  14255. <h1><span class="secnum" id="sec-12.3.4"><a href="#sec-function-calls" title="link to this section">12.3.4</a></span>
  14256. Function Calls</h1>
  14257. </div>
  14258. <section id="sec-function-calls-runtime-semantics-evaluation">
  14259. <h1><span class="secnum" id="sec-12.3.4.1"><a href="#sec-function-calls-runtime-semantics-evaluation"
  14260. title="link to this section">12.3.4.1</a></span> Runtime Semantics: Evaluation</h1>
  14261. <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
  14262. <ol class="proc">
  14263. <li>Let <i>ref</i> be the result of evaluating <i>MemberExpression</i>.</li>
  14264. <li>Let <i>func</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
  14265. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
  14266. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
  14267. href="#sec-reference-specification-type">Reference</a> and <a
  14268. href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>false</b> and <a
  14269. href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>) <i>is</i> <code>"eval"</code>, then
  14270. <ol class="block">
  14271. <li>If <a href="#sec-samevalue">SameValue</a>(<i>func</i>, %eval%) is <b>true</b>, then
  14272. <ol class="block">
  14273. <li>Let <i>argList</i> be ArgumentListEvaluation(<i>Arguments</i>).</li>
  14274. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
  14275. <li>If <i>argList</i> has no elements, return <b>undefined.</b></li>
  14276. <li>Let <i>evalText</i> be the first element of <i>argList</i>.</li>
  14277. <li>If the source code matching this <i>CallExpression</i> is <a href="#sec-strict-mode-code">strict code</a>,
  14278. let <i>strictCaller</i> be <b>true.</b> Otherwise let <i>strictCaller</i> be <b>false.</b></li>
  14279. <li>Let <i>evalRealm</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
  14280. href="#sec-code-realms">Realm</a>.</li>
  14281. <li>Return <a href="#sec-performeval">PerformEval</a>(<i>evalText</i>, <i>evalRealm</i>, <i>strictCaller</i>,
  14282. <b>true</b>). .</li>
  14283. </ol>
  14284. </li>
  14285. </ol>
  14286. </li>
  14287. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
  14288. href="#sec-reference-specification-type">Reference</a>, then
  14289. <ol class="block">
  14290. <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
  14291. <ol class="block">
  14292. <li>Let <i>thisValue</i> be <a href="#sec-getthisvalue">GetThisValue</a>(<i>ref</i>).</li>
  14293. </ol>
  14294. </li>
  14295. <li>Else, the base of <i>ref</i> is an <a href="#sec-environment-records">Environment Record</a>
  14296. <ol class="block">
  14297. <li>Let <i>refEnv</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
  14298. <li>Let <i>thisValue</i> be <i>refEnv</i>.WithBaseObject().</li>
  14299. </ol>
  14300. </li>
  14301. </ol>
  14302. </li>
  14303. <li>Else <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
  14304. href="#sec-reference-specification-type">Reference</a>,
  14305. <ol class="block">
  14306. <li>Let <i>thisValue</i> be <b>undefined</b>.</li>
  14307. </ol>
  14308. </li>
  14309. <li>Let <i>thisCall</i> be this <i>CallExpression</i>.</li>
  14310. <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
  14311. href="#sec-isintailposition">14.6.1</a>)</li>
  14312. <li>Return <a href="#sec-evaluatedirectcall">EvaluateDirectCall</a>(<i>func</i>, <i>thisValue</i>, <i>Arguments</i>,
  14313. <i>tailCall</i>).</li>
  14314. </ol>
  14315. <p>A <span class="nt">CallExpression</span> whose evaluation executes step 4.a.vii is a <i>direct eval</i>.</p>
  14316. <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
  14317. <ol class="proc">
  14318. <li>Let <i>ref</i> be the result of evaluating <i>CallExpression</i>.</li>
  14319. <li>Let <i>thisCall</i> be this <i>CallExpression</i></li>
  14320. <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
  14321. href="#sec-isintailposition">14.6.1</a>)</li>
  14322. <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>ref</i>, <i>Arguments</i>, <i>tailCall</i>).</li>
  14323. </ol>
  14324. </section>
  14325. <section id="sec-evaluatecall">
  14326. <h1><span class="secnum" id="sec-12.3.4.2"><a href="#sec-evaluatecall" title="link to this section">12.3.4.2</a></span>
  14327. Runtime Semantics: EvaluateCall( ref, arguments, tailPosition )</h1>
  14328. <p>The abstract operation EvaluateCall takes as arguments a value <var>ref</var>, a syntactic grammar production
  14329. <var>arguments</var>, and a Boolean argument <var>tailPosition</var>. It performs the following steps:</p>
  14330. <ol class="proc">
  14331. <li>Let <i>func</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
  14332. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
  14333. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
  14334. href="#sec-reference-specification-type">Reference</a>, then
  14335. <ol class="block">
  14336. <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
  14337. <ol class="block">
  14338. <li>Let <i>thisValue</i> be <a href="#sec-getthisvalue">GetThisValue</a>(<i>ref</i>).</li>
  14339. </ol>
  14340. </li>
  14341. <li>Else, the base of <i>ref</i> is an <a href="#sec-environment-records">Environment Record</a>
  14342. <ol class="block">
  14343. <li>Let <i>refEnv</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
  14344. <li>Let <i>thisValue</i> be <i>refEnv</i>.WithBaseObject().</li>
  14345. </ol>
  14346. </li>
  14347. </ol>
  14348. </li>
  14349. <li>Else <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
  14350. href="#sec-reference-specification-type">Reference</a>,
  14351. <ol class="block">
  14352. <li>Let <i>thisValue</i> be <b>undefined</b>.</li>
  14353. </ol>
  14354. </li>
  14355. <li>Return <a href="#sec-evaluatedirectcall">EvaluateDirectCall</a>(<i>func</i>, <i>thisValue</i>, <i>arguments</i>,
  14356. <i>tailPosition</i>).</li>
  14357. </ol>
  14358. </section>
  14359. <section id="sec-evaluatedirectcall">
  14360. <h1><span class="secnum" id="sec-12.3.4.3"><a href="#sec-evaluatedirectcall"
  14361. title="link to this section">12.3.4.3</a></span> Runtime Semantics: EvaluateDirectCall( func, thisValue, arguments,
  14362. tailPosition )</h1>
  14363. <p>The abstract operation EvaluateDirectCall takes as arguments a value <var>func</var>, a value <var>thisValue</var>, a
  14364. syntactic grammar production <var>arguments</var>, and a Boolean argument <var>tailPosition</var>. It performs the
  14365. following steps:</p>
  14366. <ol class="proc">
  14367. <li>Let <i>argList</i> be ArgumentListEvaluation(<i>arguments</i>).</li>
  14368. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
  14369. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>func</i>) is not Object, throw a <b>TypeError</b>
  14370. exception.</li>
  14371. <li>If <a href="#sec-iscallable">IsCallable</a>(<i>func</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
  14372. <li>If <i>tailPosition</i> is <b>true</b>, perform <a href="#sec-preparefortailcall">PrepareForTailCall</a>().</li>
  14373. <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>func</i>, <i>thisValue</i>, <i>argList</i>).</li>
  14374. <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>tailPosition</i> is <b>true</b>, the above call will not
  14375. return here, but instead evaluation will continue as if the following return has already occurred.</li>
  14376. <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>result</i> is not an <a
  14377. href="#sec-completion-record-specification-type">abrupt completion</a> then <a
  14378. href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is an <a
  14379. href="#sec-ecmascript-language-types">ECMAScript language type</a>.</li>
  14380. <li>Return <i>result</i>.</li>
  14381. </ol>
  14382. </section>
  14383. </section>
  14384. <section id="sec-super-keyword">
  14385. <div class="front">
  14386. <h1><span class="secnum" id="sec-12.3.5"><a href="#sec-super-keyword" title="link to this section">12.3.5</a></span> The
  14387. <code>super</code> Keyword</h1>
  14388. </div>
  14389. <section id="sec-super-keyword-runtime-semantics-evaluation">
  14390. <h1><span class="secnum" id="sec-12.3.5.1"><a href="#sec-super-keyword-runtime-semantics-evaluation"
  14391. title="link to this section">12.3.5.1</a></span> Runtime Semantics: Evaluation</h1>
  14392. <div class="gp prod"><span class="nt">SuperProperty</span> <span class="geq">:</span> <code class="t">super</code> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
  14393. <ol class="proc">
  14394. <li>Let <i>propertyNameReference</i> be the result of evaluating <i>Expression</i>.</li>
  14395. <li>Let <i>propertyNameValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>propertyNameReference</i>).</li>
  14396. <li>Let <i>propertyKey</i> be <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propertyNameValue</i>).</li>
  14397. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyKey</i>).</li>
  14398. <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
  14399. mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
  14400. <li>Return <a href="#sec-makesuperpropertyreference">MakeSuperPropertyReference</a>(<i>propertyKey</i>,
  14401. <i>strict</i>).</li>
  14402. </ol>
  14403. <div class="gp prod"><span class="nt">SuperProperty</span> <span class="geq">:</span> <code class="t">super</code> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
  14404. <ol class="proc">
  14405. <li>Let <i>propertyKey</i> be StringValue of <i>IdentifierName</i>.</li>
  14406. <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
  14407. mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
  14408. <li>Return <a href="#sec-makesuperpropertyreference">MakeSuperPropertyReference</a>(<i>propertyKey</i>,
  14409. <i>strict</i>).</li>
  14410. </ol>
  14411. <div class="gp prod"><span class="nt">SuperCall</span> <span class="geq">:</span> <code class="t">super</code> <span class="nt">Arguments</span></div>
  14412. <ol class="proc">
  14413. <li>Let <i>newTarget</i> be <a href="#sec-getnewtarget">GetNewTarget</a>().</li>
  14414. <li>If <i>newTarget</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
  14415. <li>Let <i>func</i> be <a href="#sec-getsuperconstructor">GetSuperConstructor</a>().</li>
  14416. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
  14417. <li>Let <i>argList</i> be ArgumentListEvaluation of <i>Arguments</i>.</li>
  14418. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
  14419. <li>Let <i>result</i> be <a href="#sec-construct">Construct</a>(<i>func</i>, <i>argList</i>, <i>newTarget</i>).</li>
  14420. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
  14421. <li>Let <i>thisER</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
  14422. <li>Return <i>thisER</i>.<a href="#sec-bindthisvalue">BindThisValue</a>(<i>result</i>).</li>
  14423. </ol>
  14424. </section>
  14425. <section id="sec-getsuperconstructor">
  14426. <h1><span class="secnum" id="sec-12.3.5.2"><a href="#sec-getsuperconstructor"
  14427. title="link to this section">12.3.5.2</a></span> Runtime Semantics: GetSuperConstructor ( )</h1>
  14428. <p>The abstract operation GetSuperConstructor performs the following steps:</p>
  14429. <ol class="proc">
  14430. <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
  14431. <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> is a function <a
  14432. href="#sec-environment-records">Environment Record</a>.</li>
  14433. <li>Let <i>activeFunction</i> be <i>envRec</i>.[[FunctionObject]].</li>
  14434. <li>Let <i>superConstructor</i> be <i>activeFunction</i>.[[GetPrototypeOf]]().</li>
  14435. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>superConstructor</i>).</li>
  14436. <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>superConstructor</i>) is <b>false</b>, throw a <b>TypeError</b>
  14437. exception.</li>
  14438. <li>Return <i>superConstructor</i>.</li>
  14439. </ol>
  14440. </section>
  14441. <section id="sec-makesuperpropertyreference">
  14442. <h1><span class="secnum" id="sec-12.3.5.3"><a href="#sec-makesuperpropertyreference"
  14443. title="link to this section">12.3.5.3</a></span> Runtime Semantics: MakeSuperPropertyReference(propertyKey,
  14444. strict)</h1>
  14445. <p>The abstract operation MakeSuperPropertyReference with arguments <var>propertyKey</var> and <var>strict</var> performs
  14446. the following steps:</p>
  14447. <ol class="proc">
  14448. <li>Let <i>env</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
  14449. <li>If <i>env</i>.HasSuperBinding() is <b>false</b>, throw a <b>ReferenceError</b> exception.</li>
  14450. <li>Let <i>actualThis</i> be <i>env</i>.GetThisBinding().</li>
  14451. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>actualThis</i>).</li>
  14452. <li>Let <i>baseValue</i> be <i>env</i>.<a href="#sec-getsuperbase">GetSuperBase</a>().</li>
  14453. <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
  14454. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
  14455. <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> that is a Super <a
  14456. href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i>, whose referenced name is
  14457. <i>propertyKey</i>, whose thisValue is <i>actualThis</i>, and whose strict reference flag is <i>strict</i>.</li>
  14458. </ol>
  14459. </section>
  14460. </section>
  14461. <section id="sec-argument-lists">
  14462. <div class="front">
  14463. <h1><span class="secnum" id="sec-12.3.6"><a href="#sec-argument-lists" title="link to this section">12.3.6</a></span>
  14464. Argument Lists</h1>
  14465. <div class="note">
  14466. <p><span class="nh">NOTE</span> The evaluation of an argument list produces a <a
  14467. href="#sec-list-and-record-specification-type">List</a> of values (<a href="#sec-list-and-record-specification-type">see
  14468. 6.2.1</a>).</p>
  14469. </div>
  14470. </div>
  14471. <section id="sec-argument-lists-runtime-semantics-argumentlistevaluation">
  14472. <h1><span class="secnum" id="sec-12.3.6.1"><a href="#sec-argument-lists-runtime-semantics-argumentlistevaluation"
  14473. title="link to this section">12.3.6.1</a></span> <span style="font-family: sans-serif">Runtime Semantics:</span>
  14474. ArgumentListEvaluation</h1>
  14475. <p>See also: <a href="#sec-template-literals-runtime-semantics-argumentlistevaluation">12.2.8.2</a></p>
  14476. <div class="gp prod"><span class="nt">Arguments</span> <span class="geq">:</span> <code class="t">(</code> <code class="t">)</code></div>
  14477. <ol class="proc">
  14478. <li>Return an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  14479. </ol>
  14480. <div class="gp prod"><span class="nt">ArgumentList</span> <span class="geq">:</span> <span class="nt">AssignmentExpression</span></div>
  14481. <ol class="proc">
  14482. <li>Let <i>ref</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  14483. <li>Let <i>arg</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
  14484. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>arg</i>).</li>
  14485. <li>Return a <a href="#sec-list-and-record-specification-type">List</a> whose sole item is <i>arg</i>.</li>
  14486. </ol>
  14487. <div class="gp prod"><span class="nt">ArgumentList</span> <span class="geq">:</span> <code class="t">...</code> <span class="nt">AssignmentExpression</span></div>
  14488. <ol class="proc">
  14489. <li>Let <i>list</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
  14490. <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  14491. <li>Let <i>spreadObj</i> be <a href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>).</li>
  14492. <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<i>spreadObj</i>).</li>
  14493. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
  14494. <li>Repeat
  14495. <ol class="block">
  14496. <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
  14497. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
  14498. <li>If <i>next</i> is <b>false</b>, return <i>list</i>.</li>
  14499. <li>Let <i>nextArg</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
  14500. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextArg</i>).</li>
  14501. <li>Append <i>nextArg</i> as the last element of <i>list</i>.</li>
  14502. </ol>
  14503. </li>
  14504. </ol>
  14505. <div class="gp prod"><span class="nt">ArgumentList</span> <span class="geq">:</span> <span class="nt">ArgumentList</span> <code class="t">,</code> <span class="nt">AssignmentExpression</span></div>
  14506. <ol class="proc">
  14507. <li>Let <i>precedingArgs</i> be the result of evaluating <i>ArgumentList</i>.</li>
  14508. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>precedingArgs</i>).</li>
  14509. <li>Let <i>ref</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  14510. <li>Let <i>arg</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
  14511. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>arg</i>).</li>
  14512. <li>Append <i>arg</i> to the end of <i>precedingArgs</i>.</li>
  14513. <li>Return <i>precedingArgs</i>.</li>
  14514. </ol>
  14515. <div class="gp prod"><span class="nt">ArgumentList</span> <span class="geq">:</span> <span class="nt">ArgumentList</span> <code class="t">,</code> <code class="t">...</code> <span class="nt">AssignmentExpression</span></div>
  14516. <ol class="proc">
  14517. <li>Let <i>precedingArgs</i> be the result of evaluating <i>ArgumentList</i>.</li>
  14518. <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
  14519. <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<a
  14520. href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>) ).</li>
  14521. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
  14522. <li>Repeat
  14523. <ol class="block">
  14524. <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
  14525. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
  14526. <li>If <i>next</i> is <b>false</b>, return <i>precedingArgs</i>.</li>
  14527. <li>Let <i>nextArg</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
  14528. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextArg</i>).</li>
  14529. <li>Append <i>nextArg</i> as the last element of <i>precedingArgs</i>.</li>
  14530. </ol>
  14531. </li>
  14532. </ol>
  14533. </section>
  14534. </section>
  14535. <section id="sec-tagged-templates">
  14536. <div class="front">
  14537. <h1><span class="secnum" id="sec-12.3.7"><a href="#sec-tagged-templates" title="link to this section">12.3.7</a></span>
  14538. Tagged Templates</h1>
  14539. <div class="note">
  14540. <p><span class="nh">NOTE</span> A tagged template is a function call where the arguments of the call are derived from a
  14541. <i>TemplateLiteral</i> (<a href="#sec-template-literals">12.2.8</a>). The actual arguments include a template object (<a
  14542. href="#sec-gettemplateobject">12.2.8.3</a>) and the values produced by evaluating the expressions embedded within the
  14543. <i>TemplateLiteral</i>.</p>
  14544. </div>
  14545. </div>
  14546. <section id="sec-tagged-templates-runtime-semantics-evaluation">
  14547. <h1><span class="secnum" id="sec-12.3.7.1"><a href="#sec-tagged-templates-runtime-semantics-evaluation"
  14548. title="link to this section">12.3.7.1</a></span> Runtime Semantics: Evaluation</h1>
  14549. <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
  14550. <ol class="proc">
  14551. <li>Let <i>tagRef</i> be the result of evaluating <i>MemberExpression</i>.</li>
  14552. <li>Let <i>thisCall</i> be this <i>MemberExpression</i>.</li>
  14553. <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
  14554. href="#sec-isintailposition">14.6.1</a>)</li>
  14555. <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>tagRef</i>, <i>TemplateLiteral</i>, <i>tailCall</i>).</li>
  14556. </ol>
  14557. <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
  14558. <ol class="proc">
  14559. <li>Let <i>tagRef</i> be the result of evaluating <i>CallExpression</i>.</li>
  14560. <li>Let <i>thisCall</i> be this <i>CallExpression</i>.</li>
  14561. <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
  14562. href="#sec-isintailposition">14.6.1</a>)</li>
  14563. <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>tagRef</i>, <i>TemplateLiteral</i>, <i>tailCall</i>).</li>
  14564. </ol>
  14565. </section>
  14566. </section>
  14567. <section id="sec-meta-properties">
  14568. <div class="front">
  14569. <h1><span class="secnum" id="sec-12.3.8"><a href="#sec-meta-properties" title="link to this section">12.3.8</a></span>
  14570. Meta Properties</h1>
  14571. </div>
  14572. <section id="sec-meta-properties-runtime-semantics-evaluation">
  14573. <h1><span class="secnum" id="sec-12.3.8.1"><a href="#sec-meta-properties-runtime-semantics-evaluation"
  14574. title="link to this section">12.3.8.1</a></span> Runtime Semantics: Evaluation</h1>
  14575. <div class="gp prod"><span class="nt">NewTarget</span> <span class="geq">:</span> <code class="t">new</code> <code class="t">.</code> <code class="t">target</code></div>
  14576. <ol class="proc">
  14577. <li>Return <a href="#sec-getnewtarget">GetNewTarget</a>().</li>
  14578. </ol>
  14579. </section>
  14580. </section>
  14581. </section>
  14582. <section id="sec-postfix-expressions">
  14583. <div class="front">
  14584. <h1><span class="secnum" id="sec-12.4"><a href="#sec-postfix-expressions" title="link to this section">12.4</a></span>
  14585. Postfix Expressions</h1>
  14586. <h2>Syntax</h2>
  14587. <div class="gp">
  14588. <div class="lhs"><span class="nt">PostfixExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  14589. <div class="rhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[?Yield]</sub></div>
  14590. <div class="rhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[?Yield]</sub> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <code class="t">++</code></div>
  14591. <div class="rhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[?Yield]</sub> <span class="grhsannot">[no <span class="nt">LineTerminator</span> here]</span> <code class="t">--</code></div>
  14592. </div>
  14593. </div>
  14594. <section id="sec-postfix-expressions-static-semantics-early-errors">
  14595. <h1><span class="secnum" id="sec-12.4.1"><a href="#sec-postfix-expressions-static-semantics-early-errors"
  14596. title="link to this section">12.4.1</a></span> Static Semantics: Early Errors</h1>
  14597. <div class="gp">
  14598. <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
  14599. <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
  14600. <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
  14601. </div>
  14602. <ul>
  14603. <li>
  14604. <p>It is an early <a href="#sec-reference-specification-type">Reference</a> Error if <span style="font-family: Times New
  14605. Roman">IsValidSimpleAssignmentTarget</span> of <span class="nt">LeftHandSideExpression</span> is <span
  14606. class="value">false</span>.</p>
  14607. </li>
  14608. </ul>
  14609. </section>
  14610. <section id="sec-postfix-expressions-static-semantics-isfunctiondefinition">
  14611. <h1><span class="secnum" id="sec-12.4.2"><a href="#sec-postfix-expressions-static-semantics-isfunctiondefinition"
  14612. title="link to this section">12.4.2</a></span> Static Semantics: IsFunctionDefinition</h1>
  14613. <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
  14614. href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
  14615. href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
  14616. href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
  14617. href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
  14618. href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
  14619. href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
  14620. href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
  14621. href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
  14622. href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
  14623. href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
  14624. href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
  14625. href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
  14626. href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
  14627. href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
  14628. href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
  14629. href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a></p>
  14630. <div class="gp">
  14631. <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
  14632. <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
  14633. <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
  14634. </div>
  14635. <ol class="proc">
  14636. <li>Return <b>false</b>.</li>
  14637. </ol>
  14638. </section>
  14639. <section id="sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">
  14640. <h1><span class="secnum" id="sec-12.4.3"><a href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget"
  14641. title="link to this section">12.4.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
  14642. <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
  14643. href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
  14644. href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
  14645. href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
  14646. href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
  14647. href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
  14648. href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
  14649. href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
  14650. href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
  14651. href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
  14652. href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
  14653. href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
  14654. href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
  14655. href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
  14656. href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
  14657. <div class="gp">
  14658. <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
  14659. <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
  14660. <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
  14661. </div>
  14662. <ol class="proc">
  14663. <li>Return <b>false</b>.</li>
  14664. </ol>
  14665. </section>
  14666. <section id="sec-postfix-increment-operator">
  14667. <div class="front">
  14668. <h1><span class="secnum" id="sec-12.4.4"><a href="#sec-postfix-increment-operator"
  14669. title="link to this section">12.4.4</a></span> Postfix Increment Operator</h1>
  14670. </div>
  14671. <section id="sec-postfix-increment-operator-runtime-semantics-evaluation">
  14672. <h1><span class="secnum" id="sec-12.4.4.1"><a href="#sec-postfix-increment-operator-runtime-semantics-evaluation"
  14673. title="link to this section">12.4.4.1</a></span> Runtime Semantics: Evaluation</h1>
  14674. <div class="gp prod"><span class="nt">PostfixExpression</span> <span class="geq">:</span> <span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
  14675. <ol class="proc">
  14676. <li>Let <i>lhs</i> be the result of evaluating <i>LeftHandSideExpression</i>.</li>
  14677. <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>lhs</i>)).</li>
  14678. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
  14679. <li>Let <i>newValue</i> be the result of adding the value <code>1</code> to <i>oldValue</i>, using the same rules as for
  14680. the <code>+</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see 12.7.5</a>).</li>
  14681. <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>newValue</i>).</li>
  14682. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  14683. <li>Return <i>oldValue</i>.</li>
  14684. </ol>
  14685. </section>
  14686. </section>
  14687. <section id="sec-postfix-decrement-operator">
  14688. <div class="front">
  14689. <h1><span class="secnum" id="sec-12.4.5"><a href="#sec-postfix-decrement-operator"
  14690. title="link to this section">12.4.5</a></span> Postfix Decrement Operator</h1>
  14691. </div>
  14692. <section id="sec-postfix-decrement-operator-runtime-semantics-evaluation">
  14693. <h1><span class="secnum" id="sec-12.4.5.1"><a href="#sec-postfix-decrement-operator-runtime-semantics-evaluation"
  14694. title="link to this section">12.4.5.1</a></span> Runtime Semantics: Evaluation</h1>
  14695. <div class="gp prod"><span class="nt">PostfixExpression</span> <span class="geq">:</span> <span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
  14696. <ol class="proc">
  14697. <li>Let <i>lhs</i> be the result of evaluating <i>LeftHandSideExpression</i>.</li>
  14698. <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>lhs</i>)).</li>
  14699. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
  14700. <li>Let <i>newValue</i> be the result of subtracting the value <code>1</code> from <i>oldValue</i>, using the same rules
  14701. as for the <code>-</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">12.7.5</a>).</li>
  14702. <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>newValue</i>).</li>
  14703. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  14704. <li>Return <i>oldValue</i>.</li>
  14705. </ol>
  14706. </section>
  14707. </section>
  14708. </section>
  14709. <section id="sec-unary-operators">
  14710. <div class="front">
  14711. <h1><span class="secnum" id="sec-12.5"><a href="#sec-unary-operators" title="link to this section">12.5</a></span> Unary
  14712. Operators</h1>
  14713. <h2>Syntax</h2>
  14714. <div class="gp">
  14715. <div class="lhs"><span class="nt">UnaryExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  14716. <div class="rhs"><span class="nt">PostfixExpression</span><sub class="g-params">[?Yield]</sub></div>
  14717. <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14718. <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14719. <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14720. <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14721. <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14722. <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14723. <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14724. <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14725. <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  14726. </div>
  14727. </div>
  14728. <section id="sec-unary-operators-static-semantics-early-errors">
  14729. <h1><span class="secnum" id="sec-12.5.1"><a href="#sec-unary-operators-static-semantics-early-errors"
  14730. title="link to this section">12.5.1</a></span> Static Semantics: Early Errors</h1>
  14731. <div class="gp">
  14732. <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
  14733. <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
  14734. <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
  14735. </div>
  14736. <ul>
  14737. <li>
  14738. <p>It is an early <a href="#sec-reference-specification-type">Reference</a> Error if <span style="font-family: Times New
  14739. Roman">IsValidSimpleAssignmentTarget</span> of <span class="nt">UnaryExpression</span> is <span
  14740. class="value">false</span>.</p>
  14741. </li>
  14742. </ul>
  14743. </section>
  14744. <section id="sec-unary-operators-static-semantics-isfunctiondefinition">
  14745. <h1><span class="secnum" id="sec-12.5.2"><a href="#sec-unary-operators-static-semantics-isfunctiondefinition"
  14746. title="link to this section">12.5.2</a></span> Static Semantics: IsFunctionDefinition</h1>
  14747. <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
  14748. href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
  14749. href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
  14750. href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
  14751. href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
  14752. href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
  14753. href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
  14754. href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
  14755. href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
  14756. href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
  14757. href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
  14758. href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
  14759. href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
  14760. href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
  14761. href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
  14762. href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
  14763. href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
  14764. <div class="gp">
  14765. <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
  14766. <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
  14767. <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span></div>
  14768. <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
  14769. <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
  14770. <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
  14771. <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span></div>
  14772. <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span></div>
  14773. <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span></div>
  14774. <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span></div>
  14775. </div>
  14776. <ol class="proc">
  14777. <li>Return <b>false</b>.</li>
  14778. </ol>
  14779. </section>
  14780. <section id="sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">
  14781. <h1><span class="secnum" id="sec-12.5.3"><a href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget"
  14782. title="link to this section">12.5.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
  14783. <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
  14784. href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
  14785. href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
  14786. href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
  14787. href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
  14788. href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
  14789. href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
  14790. href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
  14791. href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
  14792. href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
  14793. href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
  14794. href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
  14795. href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
  14796. href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
  14797. href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
  14798. <div class="gp">
  14799. <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
  14800. <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
  14801. <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span></div>
  14802. <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
  14803. <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
  14804. <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
  14805. <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span></div>
  14806. <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span></div>
  14807. <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span></div>
  14808. <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span></div>
  14809. </div>
  14810. <ol class="proc">
  14811. <li>Return <b>false</b>.</li>
  14812. </ol>
  14813. </section>
  14814. <section id="sec-delete-operator">
  14815. <div class="front">
  14816. <h1><span class="secnum" id="sec-12.5.4"><a href="#sec-delete-operator" title="link to this section">12.5.4</a></span> The
  14817. <code>delete</code> Operator</h1>
  14818. </div>
  14819. <section id="sec-delete-operator-static-semantics-early-errors">
  14820. <h1><span class="secnum" id="sec-12.5.4.1"><a href="#sec-delete-operator-static-semantics-early-errors"
  14821. title="link to this section">12.5.4.1</a></span> Static Semantics: Early Errors</h1>
  14822. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
  14823. <ul>
  14824. <li>
  14825. <p>It is a Syntax Error if the <span class="nt">UnaryExpression</span> is contained in <a
  14826. href="#sec-strict-mode-code">strict mode code</a> and the derived <span class="nt">UnaryExpression</span> is <span
  14827. class="prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></span>
  14828. <var>IdentifierReference.</var></p>
  14829. </li>
  14830. <li>
  14831. <p>It is a Syntax Error if the derived <span class="nt">UnaryExpression</span> is<br> <span style="font-family:
  14832. Times New Roman"><i>PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList<br></i></span>and <span
  14833. class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> ultimately derives a phrase that, if used in place
  14834. of <var>UnaryExpression,</var> would produce a Syntax Error according to these rules. This rule is recursively
  14835. applied.</p>
  14836. </li>
  14837. </ul>
  14838. <div class="note">
  14839. <p><span class="nh">NOTE</span> The last rule means that expressions such as<br>&#x9;&#x9;<code>delete
  14840. (((foo)))</code><br>produce early errors because of recursive application of the first rule.</p>
  14841. </div>
  14842. </section>
  14843. <section id="sec-delete-operator-runtime-semantics-evaluation">
  14844. <h1><span class="secnum" id="sec-12.5.4.2"><a href="#sec-delete-operator-runtime-semantics-evaluation"
  14845. title="link to this section">12.5.4.2</a></span> Runtime Semantics: Evaluation</h1>
  14846. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
  14847. <ol class="proc">
  14848. <li>Let <i>ref</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  14849. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ref</i>).</li>
  14850. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
  14851. href="#sec-reference-specification-type">Reference</a>, return <b>true</b>.</li>
  14852. <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>ref</i>) is <b>true</b>, then
  14853. <ol class="block">
  14854. <li><a href="#sec-algorithm-conventions">Assert</a>: <a
  14855. href="#sec-reference-specification-type">IsStrictReference</a>(<i>ref</i>) is <b>false</b>.</li>
  14856. <li>Return <b>true</b>.</li>
  14857. </ol>
  14858. </li>
  14859. <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
  14860. <ol class="block">
  14861. <li>If <a href="#sec-reference-specification-type">IsSuperReference</a>(<i>ref</i>), throw a <b>ReferenceError</b>
  14862. exception.</li>
  14863. <li>Let <i>baseObj</i> be <a href="#sec-toobject">ToObject</a>(<a
  14864. href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>)).</li>
  14865. <li>Let <i>deleteStatus</i> be <i>baseObj</i>.[[Delete]](<a
  14866. href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>)).</li>
  14867. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>deleteStatus</i>).</li>
  14868. <li>If <i>deleteStatus</i> is <b>false</b> and <a
  14869. href="#sec-reference-specification-type">IsStrictReference</a>(<i>ref</i>) is <b>true</b>, throw a
  14870. <b>TypeError</b> exception.</li>
  14871. <li>Return <i>deleteStatus</i>.</li>
  14872. </ol>
  14873. </li>
  14874. <li>Else <i>ref</i> is a <a href="#sec-reference-specification-type">Reference</a> to an <a
  14875. href="#sec-environment-records">Environment Record</a> binding,
  14876. <ol class="block">
  14877. <li>Let <i>bindings</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
  14878. <li>Return <i>bindings</i>.DeleteBinding(<a
  14879. href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>)).</li>
  14880. </ol>
  14881. </li>
  14882. </ol>
  14883. <div class="note">
  14884. <p><span class="nh">NOTE</span> When a <code>delete</code> operator occurs within <a href="#sec-strict-mode-code">strict
  14885. mode code</a>, a <b>SyntaxError</b> exception is thrown if its <i>UnaryExpression</i> is a direct reference to a
  14886. variable, function argument, or function name. In addition, if a <code>delete</code> operator occurs within <a
  14887. href="#sec-strict-mode-code">strict mode code</a> and the property to be deleted has the attribute { [[Configurable]]:
  14888. <b>false</b> }, a <b>TypeError</b> exception is thrown.</p>
  14889. </div>
  14890. </section>
  14891. </section>
  14892. <section id="sec-void-operator">
  14893. <div class="front">
  14894. <h1><span class="secnum" id="sec-12.5.5"><a href="#sec-void-operator" title="link to this section">12.5.5</a></span> The
  14895. <code>void</code> Operator</h1>
  14896. </div>
  14897. <section id="sec-void-operator-runtime-semantics-evaluation">
  14898. <h1><span class="secnum" id="sec-12.5.5.1"><a href="#sec-void-operator-runtime-semantics-evaluation"
  14899. title="link to this section">12.5.5.1</a></span> Runtime Semantics: Evaluation</h1>
  14900. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">void</code> <span class="nt">UnaryExpression</span></div>
  14901. <ol class="proc">
  14902. <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  14903. <li>Let <i>status</i> be <a href="#sec-getvalue">GetValue</a>(<i>expr</i>).</li>
  14904. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  14905. <li>Return <b>undefined</b>.</li>
  14906. </ol>
  14907. <div class="note">
  14908. <p><span class="nh">NOTE</span> <a href="#sec-getvalue">GetValue</a> must be called even though its value is not used
  14909. because it may have observable side-effects.</p>
  14910. </div>
  14911. </section>
  14912. </section>
  14913. <section id="sec-typeof-operator">
  14914. <div class="front">
  14915. <h1><span class="secnum" id="sec-12.5.6"><a href="#sec-typeof-operator" title="link to this section">12.5.6</a></span> The
  14916. <code>typeof</code> Operator</h1>
  14917. </div>
  14918. <section id="sec-typeof-operator-runtime-semantics-evaluation">
  14919. <h1><span class="secnum" id="sec-12.5.6.1"><a href="#sec-typeof-operator-runtime-semantics-evaluation"
  14920. title="link to this section">12.5.6.1</a></span> Runtime Semantics: Evaluation</h1>
  14921. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
  14922. <ol class="proc">
  14923. <li>Let <i>val</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  14924. <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>val</i>) is <a
  14925. href="#sec-reference-specification-type">Reference</a>, then
  14926. <ol class="block">
  14927. <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>val</i>) is <b>true</b>, return
  14928. <code>"undefined"</code>.</li>
  14929. </ol>
  14930. </li>
  14931. <li>Let <i>val</i> be <a href="#sec-getvalue">GetValue</a>(<i>val</i>).</li>
  14932. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>val</i>).</li>
  14933. <li>Return a String according to <a href="#table-35">Table 35</a>.</li>
  14934. </ol>
  14935. <figure>
  14936. <figcaption><span id="table-35">Table 35</span> &mdash; typeof Operator Results</figcaption>
  14937. <table class="real-table">
  14938. <tr>
  14939. <th><b>Type of</b> <span style="font-family: Times New Roman">val</span></th>
  14940. <th>Result</th>
  14941. </tr>
  14942. <tr>
  14943. <td>Undefined</td>
  14944. <td><code>"undefined"</code></td>
  14945. </tr>
  14946. <tr>
  14947. <td>Null</td>
  14948. <td><code>"object"</code></td>
  14949. </tr>
  14950. <tr>
  14951. <td>Boolean</td>
  14952. <td><code>"boolean"</code></td>
  14953. </tr>
  14954. <tr>
  14955. <td>Number</td>
  14956. <td><code>"number"</code></td>
  14957. </tr>
  14958. <tr>
  14959. <td>String</td>
  14960. <td><code>"string"</code></td>
  14961. </tr>
  14962. <tr>
  14963. <td>Symbol</td>
  14964. <td><code>"symbol"</code></td>
  14965. </tr>
  14966. <tr>
  14967. <td>Object (ordinary and does not implement [[Call]])</td>
  14968. <td><code>"object"</code></td>
  14969. </tr>
  14970. <tr>
  14971. <td>Object (standard exotic and does not implement [[Call]])</td>
  14972. <td><code>"object"</code></td>
  14973. </tr>
  14974. <tr>
  14975. <td>Object (implements [[Call]])</td>
  14976. <td><code>"function"</code></td>
  14977. </tr>
  14978. <tr>
  14979. <td>Object (non-standard exotic and does not implement [[Call]])</td>
  14980. <td>Implementation-defined. Must not be <code>"undefined"</code>, <code>"boolean"</code>, <code>"function"</code>, <code>"number"</code>, <code>"symbol"</code>, or <code>"string".</code></td>
  14981. </tr>
  14982. </table>
  14983. </figure>
  14984. <div class="note">
  14985. <p><span class="nh">NOTE</span> Implementations are discouraged from defining new <code>typeof</code> result values for
  14986. non-standard exotic objects. If possible <code>"object"</code>should be used for such objects.</p>
  14987. </div>
  14988. </section>
  14989. </section>
  14990. <section id="sec-prefix-increment-operator">
  14991. <div class="front">
  14992. <h1><span class="secnum" id="sec-12.5.7"><a href="#sec-prefix-increment-operator"
  14993. title="link to this section">12.5.7</a></span> Prefix Increment Operator</h1>
  14994. </div>
  14995. <section id="sec-prefix-increment-operator-runtime-semantics-evaluation">
  14996. <h1><span class="secnum" id="sec-12.5.7.1"><a href="#sec-prefix-increment-operator-runtime-semantics-evaluation"
  14997. title="link to this section">12.5.7.1</a></span> Runtime Semantics: Evaluation</h1>
  14998. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">++</code> <span class="nt">UnaryExpression</span></div>
  14999. <ol class="proc">
  15000. <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  15001. <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
  15002. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
  15003. <li>Let <i>newValue</i> be the result of adding the value <code>1</code> to <i>oldValue</i>, using the same rules as for
  15004. the <code>+</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see 12.7.5</a>).</li>
  15005. <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>expr</i>, <i>newValue</i>).</li>
  15006. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  15007. <li>Return <i>newValue</i>.</li>
  15008. </ol>
  15009. </section>
  15010. </section>
  15011. <section id="sec-prefix-decrement-operator">
  15012. <div class="front">
  15013. <h1><span class="secnum" id="sec-12.5.8"><a href="#sec-prefix-decrement-operator"
  15014. title="link to this section">12.5.8</a></span> Prefix Decrement Operator</h1>
  15015. </div>
  15016. <section id="sec-prefix-decrement-operator-runtime-semantics-evaluation">
  15017. <h1><span class="secnum" id="sec-12.5.8.1"><a href="#sec-prefix-decrement-operator-runtime-semantics-evaluation"
  15018. title="link to this section">12.5.8.1</a></span> Runtime Semantics: Evaluation</h1>
  15019. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">--</code> <span class="nt">UnaryExpression</span></div>
  15020. <ol class="proc">
  15021. <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  15022. <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
  15023. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
  15024. <li>Let <i>newValue</i> be the result of subtracting the value <code>1</code> from <i>oldValue</i>, using the same
  15025. rules as for the <code>-</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see
  15026. 12.7.5</a>).</li>
  15027. <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>expr</i>, <i>newValue</i>).</li>
  15028. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
  15029. <li>Return <i>newValue</i>.</li>
  15030. </ol>
  15031. </section>
  15032. </section>
  15033. <section id="sec-unary-plus-operator">
  15034. <div class="front">
  15035. <h1><span class="secnum" id="sec-12.5.9"><a href="#sec-unary-plus-operator" title="link to this section">12.5.9</a></span>
  15036. Unary <code>+</code> Operator</h1>
  15037. <div class="note">
  15038. <p><span class="nh">NOTE</span> The unary + operator converts its operand to Number type.</p>
  15039. </div>
  15040. </div>
  15041. <section id="sec-unary-plus-operator-runtime-semantics-evaluation">
  15042. <h1><span class="secnum" id="sec-12.5.9.1"><a href="#sec-unary-plus-operator-runtime-semantics-evaluation"
  15043. title="link to this section">12.5.9.1</a></span> Runtime Semantics: Evaluation</h1>
  15044. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">+</code> <span class="nt">UnaryExpression</span></div>
  15045. <ol class="proc">
  15046. <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  15047. <li>Return <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
  15048. </ol>
  15049. </section>
  15050. </section>
  15051. <section id="sec-unary-minus-operator">
  15052. <div class="front">
  15053. <h1><span class="secnum" id="sec-12.5.10"><a href="#sec-unary-minus-operator"
  15054. title="link to this section">12.5.10</a></span> Unary <code>-</code> Operator</h1>
  15055. <div class="note">
  15056. <p><span class="nh">NOTE</span> The unary <code>-</code> operator converts its operand to Number type and then negates
  15057. it. Negating <b>+0</b> produces <b>&minus;0</b>, and negating <b>&minus;0</b> produces <b>+0</b>.</p>
  15058. </div>
  15059. </div>
  15060. <section id="sec-unary-minus-operator-runtime-semantics-evaluation">
  15061. <h1><span class="secnum" id="sec-12.5.10.1"><a href="#sec-unary-minus-operator-runtime-semantics-evaluation"
  15062. title="link to this section">12.5.10.1</a></span> Runtime Semantics: Evaluation</h1>
  15063. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">-</code> <span class="nt">UnaryExpression</span></div>
  15064. <ol class="proc">
  15065. <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  15066. <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
  15067. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
  15068. <li>If <i>oldValue</i> is <b>NaN</b>, return <b>NaN</b>.</li>
  15069. <li>Return the result of negating <i>oldValue</i>; that is, compute a Number with the same magnitude but opposite
  15070. sign.</li>
  15071. </ol>
  15072. </section>
  15073. </section>
  15074. <section id="sec-bitwise-not-operator">
  15075. <div class="front">
  15076. <h1><span class="secnum" id="sec-12.5.11"><a href="#sec-bitwise-not-operator"
  15077. title="link to this section">12.5.11</a></span> Bitwise NOT Operator ( <code>~</code> )</h1>
  15078. </div>
  15079. <section id="sec-bitwise-not-operator-runtime-semantics-evaluation">
  15080. <h1><span class="secnum" id="sec-12.5.11.1"><a href="#sec-bitwise-not-operator-runtime-semantics-evaluation"
  15081. title="link to this section">12.5.11.1</a></span> Runtime Semantics: Evaluation</h1>
  15082. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">~</code> <span class="nt">UnaryExpression</span></div>
  15083. <ol class="proc">
  15084. <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  15085. <li>Let <i>oldValue</i> be <a href="#sec-toint32">ToInt32</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
  15086. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
  15087. <li>Return the result of applying bitwise complement to <i>oldValue</i>. The result is a signed 32-bit integer.</li>
  15088. </ol>
  15089. </section>
  15090. </section>
  15091. <section id="sec-logical-not-operator">
  15092. <div class="front">
  15093. <h1><span class="secnum" id="sec-12.5.12"><a href="#sec-logical-not-operator"
  15094. title="link to this section">12.5.12</a></span> Logical NOT Operator ( <code>!</code> )</h1>
  15095. </div>
  15096. <section id="sec-logical-not-operator-runtime-semantics-evaluation">
  15097. <h1><span class="secnum" id="sec-12.5.12.1"><a href="#sec-logical-not-operator-runtime-semantics-evaluation"
  15098. title="link to this section">12.5.12.1</a></span> Runtime Semantics: Evaluation</h1>
  15099. <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">!</code> <span class="nt">UnaryExpression</span></div>
  15100. <ol class="proc">
  15101. <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  15102. <li>Let <i>oldValue</i> be <a href="#sec-toboolean">ToBoolean</a>(<a
  15103. href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
  15104. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
  15105. <li>If <i>oldValue</i> is <b>true</b>, return <b>false</b>.</li>
  15106. <li>Return <b>true</b>.</li>
  15107. </ol>
  15108. </section>
  15109. </section>
  15110. </section>
  15111. <section id="sec-multiplicative-operators">
  15112. <div class="front">
  15113. <h1><span class="secnum" id="sec-12.6"><a href="#sec-multiplicative-operators" title="link to this section">12.6</a></span>
  15114. Multiplicative Operators</h1>
  15115. <h2>Syntax</h2>
  15116. <div class="gp">
  15117. <div class="lhs"><span class="nt">MultiplicativeExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
  15118. <div class="rhs"><span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  15119. <div class="rhs"><span class="nt">MultiplicativeExpression</span><sub class="g-params">[?Yield]</sub> <span class="nt">MultiplicativeOperator</span> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
  15120. </div>
  15121. <div class="gp">
  15122. <div class="lhs"><span class="nt">MultiplicativeOperator</span> <span class="geq">:</span> <span class="grhsmod">one of</span></div>
  15123. <div class="rhs"><code class="t">*</code> <code class="t">/</code> <code class="t">%</code></div>
  15124. </div>
  15125. </div>
  15126. <section id="sec-multiplicative-operators-static-semantics-isfunctiondefinition">
  15127. <h1><span class="secnum" id="sec-12.6.1"><a href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition"
  15128. title="link to this section">12.6.1</a></span> Static Semantics: IsFunctionDefinition</h1>
  15129. <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
  15130. href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
  15131. href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
  15132. href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
  15133. href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
  15134. href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
  15135. href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
  15136. href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
  15137. href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
  15138. href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
  15139. href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
  15140. href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
  15141. href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
  15142. href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
  15143. href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
  15144. href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
  15145. href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
  15146. <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
  15147. <i>UnaryExpression</i></p>
  15148. <ol class="proc">
  15149. <li>Return <b>false</b>.</li>
  15150. </ol>
  15151. </section>
  15152. <section id="sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">
  15153. <h1><span class="secnum" id="sec-12.6.2"><a
  15154. href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget"
  15155. title="link to this section">12.6.2</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
  15156. <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
  15157. href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
  15158. href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
  15159. href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
  15160. href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
  15161. href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
  15162. href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
  15163. href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
  15164. href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
  15165. href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
  15166. href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
  15167. href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
  15168. href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
  15169. href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
  15170. href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
  15171. <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
  15172. <i>UnaryExpression</i></p>
  15173. <ol class="proc">
  15174. <li>Return <b>false</b>.</li>
  15175. </ol>
  15176. </section>
  15177. <section id="sec-multiplicative-operators-runtime-semantics-evaluation">
  15178. <div class="front">
  15179. <h1><span class="secnum" id="sec-12.6.3"><a href="#sec-multiplicative-operators-runtime-semantics-evaluation"
  15180. title="link to this section">12.6.3</a></span> Runtime Semantics: Evaluation</h1>
  15181. <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
  15182. <i>UnaryExpression</i></p>
  15183. <ol class="proc">
  15184. <li>Let <i>left</i> be the result of evaluating <i>MultiplicativeExpression</i>.</li>
  15185. <li>Let <i>leftValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>left</i>).</li>
  15186. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>leftValue</i>).</li>
  15187. <li>Let <i>right</i> be the result of evaluating <i>UnaryExpression</i>.</li>
  15188. <li>Let <i>rightValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>right</i>).</li>
  15189. <li>Let <i>lnum</i> be <a href="#sec-tonumber">ToNumber</a>(<i>leftValue</i>).</li>
  15190. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>lnum</i>).</li>
  15191. <li>Let <i>rnum</i> be <a href="#sec-tonumber">ToNumber</a>(<i>rightValue</i>).</li>
  15192. <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>rnum</i>).</li>
  15193. <li>Return the result of applying the <i>MultiplicativeOperator</i> (*, /, or %) to <i>lnum</i> and <i>rnum</i> as
  15194. specified in <a href="#sec-applying-the-mul-operator">12.6.3.1</a>, <a
  15195. href="#sec-applying-the-div-operator">12.6.3.2</a>, or <a href="#sec-applying-the-mod-operator">12.6.3.3</a>.</li>
  15196. </ol>
  15197. </div>
  15198. <section id="sec-applying-the-mul-operator">
  15199. <h1><span class="secnum" id="sec-12.6.3.1"><a href="#sec-applying-the-mul-operator"
  15200. title="link to this section">12.6.3.1</a></span> Applying the <code>*</code> Operator</h1>
  15201. <p>The <code>*</code> <span class="nt">MultiplicativeOperator</span> performs multiplication, producing the product of its
  15202. operands. Multiplication is commutative. Multiplication is not always associative in ECMAScript, because of finite
  15203. precision.</p>
  15204. <p>The result of a floating-point multiplication is governed by the rules of IEEE 754 binary double-precision
  15205. arithmetic:</p>
  15206. <ul>
  15207. <li>
  15208. <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
  15209. </li>
  15210. <li>
  15211. <p>The sign of the result is positive if both operands have the same sign, negative if the operands have different
  15212. signs.</p>
  15213. </li>
  15214. <li>
  15215. <p>Multiplication of an infinity by a zero results in <b>NaN</b>.</p>
  15216. </li>
  15217. <li>
  15218. <p>Multiplication of an infinity by an infinity results in an infinity. The sign is determined by the rule already
  15219. stated above.</p>
  15220. </li>
  15221. <li>
  15222. <p>Multiplication of an infinity by a finite nonzero value results in a signed infinity. The sign is determined by the
  15223. rule already stated above.</p>
  15224. </li>
  15225. <li>
  15226. <p>In the remaining cases, where neither an infinity nor NaN is involved, the product is computed and rounded to the
  15227. nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too large to represent, the
  15228. result is then an infinity of appropriate sign. If the magnitude is too small to represent, the result is then a zero
  15229. of appropriate sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754.</p>
  15230. </li>
  15231. </ul>
  15232. </section>
  15233. <section id="sec-applying-the-div-operator">
  15234. <h1><span class="secnum" id="sec-12.6.3.2"><a href="#sec-applying-the-div-operator"
  15235. title="link to this section">12.6.3.2</a></span> Applying the <code>/</code> Operator</h1>
  15236. <p>The <code>/</code> <span class="nt">MultiplicativeOperator</span> performs division, producing the quotient of its
  15237. operands. The left operand is the dividend and the right operand is the divisor. ECMAScript does not perform integer
  15238. division. The operands and result of all division operations are double-precision floating-point numbers. The result of
  15239. division is determined by the specification of IEEE 754 arithmetic:</p>
  15240. <ul>
  15241. <li>
  15242. <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
  15243. </li>
  15244. <li>
  15245. <p>The sign of the result is positive if both operands have the same sign, negative if the operands have different
  15246. signs.</p>
  15247. </li>
  15248. <li>
  15249. <p>Division of an infinity by an infinity results in <b>NaN</b>.</p>
  15250. </li>
  15251. <li>
  15252. <p>Division of an infinity by a zero results in an infinity. The sign is determined by the rule already stated
  15253. above.</p>
  15254. </li>
  15255. <li>
  15256. <p>Division of an infinity by a nonzero finite value results in a signed infinity. The sign is determined by the rule
  15257. already stated above.</p>
  15258. </li>
  15259. <li>
  15260. <p>Division of a finite value by an infinity results in zero. The sign is determined by the rule already stated
  15261. above.</p>
  15262. </li>
  15263. <li>
  15264. <p>Division of a zero by a zero results in <b>NaN</b>; division of zero by any other finite value results in zero,
  15265. with the sign determined by the rule already stated above.</p>
  15266. </li>
  15267. <li>
  15268. <p>Division of a nonzero finite value by a zero results in a signed infinity. The sign is determined by the rule
  15269. already stated above.</p>
  15270. </li>
  15271. <li>
  15272. <p>In the remaining cases, where neither an infinity, nor a zero, nor <b>NaN</b> is involved, the quotient is computed
  15273. and rounded to the nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too large to
  15274. represent, the operation overflows; the result is then an infinity of appropriate sign. If the magnitude is too small
  15275. to represent, the operation underflows and the result is a zero of the appropriate sign. The ECMAScript language
  15276. requires support of gradual underflow as defined by IEEE 754.</p>
  15277. </li>
  15278. </ul>
  15279. </section>
  15280. <section id="sec-applying-the-mod-operator">
  15281. <h1><span class="secnum" id="sec-12.6.3.3"><a href="#sec-applying-the-mod-operator"
  15282. title="link to this section">12.6.3.3</a></span> Applying the <code>%</code> Operator</h1>
  15283. <p>The <code>%</code> <span class="nt">MultiplicativeOperator</span> yields the remainder of its operands from an implied
  15284. division; the left operand is the dividend and the right operand is the divisor.</p>
  15285. <div class="note">
  15286. <p><span class="nh">NOTE</span> In C and C++, the remainder operator accepts only integral operands; in ECMAScript, it
  15287. also accepts floating-point operands.</p>
  15288. </div>
  15289. <p>The result of a floating-point remainder operation as computed by the <code>%</code> operator is not the same as the
  15290. &ldquo;remainder&rdquo; operation defined by IEEE 754. The IEEE 754 &ldquo;remainder&rdquo; operation computes the
  15291. remainder from a rounding division, not a truncating division, and so its behaviour is not analogous to that of the usual
  15292. integer remainder operator. Instead the ECMAScript language defines <code>%</code> on floating-point operations to behave
  15293. in a manner analogous to that of the Java integer remainder operator; this may be compared with the C library function
  15294. fmod.</p>
  15295. <p>The result of an ECMAScript floating-point remainder operation is determined by the rules of IEEE arithmetic:</p>
  15296. <ul>
  15297. <li>
  15298. <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
  15299. </li>
  15300. <li>
  15301. <p>The sign of the result equals the sign of the dividend.</p>
  15302. </li>
  15303. <li>
  15304. <p>If the dividend is an infinity, or the divisor is a zero, or both, the result is <b>NaN</b>.</p>
  15305. </li>
  15306. <li>
  15307. <p>If the dividend is finite and the divisor is an infinity, the result equals the dividend.</p>
  15308. </li>
  15309. <li>
  15310. <p>If the dividend is a zero and the divisor is nonzero and finite, the result is the same as the dividend.</p>
  15311. </li>
  15312. <li>
  15313. <p>In the remaining cases, where neither an infinity, nor a zero, nor <b>NaN</b> is involved, the floating-point
  15314. remainder r from a dividend n and a divisor d is defined by the mathematical relation r = n &minus; (d &times; q)
  15315. where q is an integer that is negative only if n/d is negative and positive only if n/d is positive, and whose
  15316. magnitude is as large as possible without exceeding the magnitude of the true mathematical quotient of n and d. r is
  15317. computed and rounded to the nearest representable value using IEEE 754 round-to-nearest mode.</p>
  15318. </li>
  15319. </ul>
  15320. </section>
  15321. </section>
  15322. </section>
  15323. </section>
  15324. </body>
  15325. </html>