Debian Codegraph @

_benchmarks/sample_es6.html

raw
1
2 <!doctype html>
3 <html lang="en-GB">
4 <head>
5 <meta charset="utf-8">
6 <title>ECMAScript Language Specification ECMA-262 6th Edition &ndash; DRAFT</title>
7 <link href="es6-draft.css" rel="stylesheet">
8 <script src="es6-draft-sections.js"></script>
9 </head>
10 <body>
11 <div id="unofficial">
12 <p><strong>This is <em>not</em> the official ECMAScript Language Specification.</strong></p>
13
14 <p>This is a draft of the next edition of the standard. See also:</p>
15
16 <ul>
17 <li><a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">ECMAScript Language Specification,
18 Edition 5.1 (PDF)</a>, the most recent official, final standard.</li>
19 <li><a href="http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts">The ES specification drafts archive</a> for
20 PDF and Word versions of this document, and older drafts.</li>
21 <li><a href="https://github.com/jorendorff/es-spec-html">The script that produced this web page</a>, and especially the <a
22 href="https://github.com/jorendorff/es-spec-html/issues?state=open">issue tracker &mdash; please file bugs when you find
23 them</a>. Patches are welcome too.</li>
24 </ul>
25
26 <p>For copyright information, see Ecma International&rsquo;s legal disclaimer in the document itself.</p>
27 </div>
28
29 <hgroup>
30 <h1>Draft</h1>
31 <h1>ECMA-262</h1>
32 <h1>6<sup>th</sup> Edition / Draft March 17, 2015</h1>
33 <h1>Ecma/TC39/2015/0XX</h1>
34 </hgroup>
35 <hgroup>
36 <h1>ECMAScript 2015</h1>
37 <h1>Language Specification</h1>
38
39 <p>Draft<br>Release Candidate #3</p>
40
41 <p>Report Errors and Issues at: https://bugs.ecmascript.org</p>
42
43 <p>Product: Draft for 6th Edition</p>
44
45 <p>Component: choose an appropriate one</p>
46
47 <p>Version: Rev 36, March 17, 2015 Draft</p>
48 </hgroup>
49
50 <section id="contents">
51 <h1>Contents</h1>
52 </section>
53
54 <section>
55 <h1>Introduction</h1>
56
57 <p>This is the sixth edition of ECMAScript Language Specification. Since publication of the first edition in 1997, ECMAScript
58 has grown to be one of the world&rsquo;s most widely used general purpose programming languages. It is best known as the
59 language embedded in web browsers but has also been widely adopted for server and embedded applications. The sixth edition is
60 the most extensive update to ECMAScript since the publication of the first edition in 1997.</p>
61
62 <p>Goals for the sixth edition include providing better support for large applications, library creation, and for use of
63 ECMAScript as a compilation target for other languages. Some of its major enhancements include modules, class declarations,
64 lexical block scoping, iterators and generators, promises for asynchronous programming, destructuring patterns, and proper tail
65 calls. The ECMAScript library of built-ins has been expanded to support additional data abstractions including maps, sets, and
66 arrays of binary numeric values as well as additional support for Unicode supplemental characters in strings and regular
67 expressions. The built-ins are now extensible via subclassing.</p>
68
69 <p>Focused development of the sixth edition started in 2009, as the fifth edition was being prepared for publication. However,
70 this was preceded by significant experimentation and language enhancement design efforts dating to the publication of the third
71 edition in 1999. In a very real sense, the completion of the sixth edition is the culmination of a fifteen year effort. Dozens
72 of individuals representing many organizations have made very significant contributions within TC39 to the development of this
73 edition and to the prior editions. In addition, a vibrant informal community has emerged supporting TC39&rsquo;s ECMAScript
74 efforts. This community has reviewed numerous drafts, filed thousands of bug reports, performed implementation experiments,
75 contributed test suites, and educated the world-wide developer community about ECMAScript. Unfortunately, it is impossible to
76 identify and acknowledge every person and organization who has contributed to this effort.</p>
77
78 <p>New uses and requirements for ECMAScript continue to emerge. The sixth edition provides the foundation for regular,
79 incremental language and library enhancements.</p>
80
81 <p>Allen Wirfs-Brock<br>ECMA-262, 6<sup>th</sup> Edition Project Editor</p>
82
83 <p>This Ecma Standard has been adopted by the General Assembly of &lt;month&gt; &lt;year&gt;.</p>
84
85 <p><b>ECMA-262 Edition History</b></p>
86
87 <p>This Ecma Standard is based on several originating technologies, the most well-known being JavaScript (Netscape) and JScript
88 (Microsoft). The language was invented by Brendan Eich at Netscape and first appeared in that company&rsquo;s Navigator 2.0
89 browser. It has appeared in all subsequent browsers from Netscape and in all browsers from Microsoft starting with Internet
90 Explorer 3.0.</p>
91
92 <p>The development of this Standard started in November 1996. The first edition of this Ecma Standard was adopted by the Ecma
93 General Assembly of June 1997.</p>
94
95 <p>That Ecma Standard was submitted to ISO/IEC JTC 1 for adoption under the fast-track procedure, and approved as international
96 standard ISO/IEC 16262, in April 1998. The Ecma General Assembly of June 1998 approved the second edition of ECMA-262 to keep it
97 fully aligned with ISO/IEC 16262. Changes between the first and the second edition are editorial in nature.</p>
98
99 <p>The third edition of the Standard introduced powerful regular expressions, better string handling, new control statements,
100 try/catch exception handling, tighter definition of errors, formatting for numeric output and minor changes in anticipation
101 future language growth. The third edition of the ECMAScript standard was adopted by the Ecma General Assembly of December 1999
102 and published as ISO/IEC 16262:2002 in June 2002.</p>
103
104 <p>After publication of the third edition, ECMAScript achieved massive adoption in conjunction with the World Wide Web where it
105 has become the programming language that is supported by essentially all web browsers. Significant work was done to develop a
106 fourth edition of ECMAScript. However, that work was not completed and not published as the fourth edition of ECMAScript but
107 some of it was incorporated into the development of the sixth edition.</p>
108
109 <p>The fifth edition of ECMAScript (published as ECMA-262 5<sup>th</sup> edition) codified de facto interpretations of the
110 language specification that have become common among browser implementations and added support for new features that had emerged
111 since the publication of the third edition. Such features include accessor properties, reflective creation and inspection of
112 objects, program control of property attributes, additional array manipulation functions, support for the JSON object encoding
113 format, and a strict mode that provides enhanced error checking and program security. The Fifth Edition was adopted by the Ecma
114 General Assembly of December 2009.</p>
115
116 <p>The Fifth Edition was submitted to ISO/IEC JTC 1 for adoption under the fast-track procedure, and approved as international
117 standard ISO/IEC 16262:2011. Edition 5.1 of the ECMAScript Standard incorporated minor corrections and is the same text as
118 ISO/IEC 16262:2011. The 5.1 Edition was adopted by the Ecma General Assembly of June 2011.</p>
119
120 <p><i>"DISCLAIMER</i></p>
121
122 <p><i>This draft document may be copied and furnished to others, and derivative works that comment on or otherwise explain it or
123 assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of
124 any kind, provided that the above copyright notice and this section are included on all such copies and derivative works.
125 However, this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma
126 International, except as needed for the purpose of developing any document or deliverable produced by Ecma
127 International.</i></p>
128
129 <p><i>This disclaimer is valid only prior to final version of this document. After approval all rights on the standard are
130 reserved by Ecma International.</i></p>
131
132 <p><i>The limited permissions are granted through the standardization phase and will not be revoked by Ecma International or its
133 successors or assigns during this time.</i></p>
134
135 <p><i>This document and the information contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL DISCLAIMS ALL
136 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT
137 INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE."</i></p>
138 </section>
139
140 <div class="inner-title">ECMAScript 2015 Language Specification</div>
141
142 <section id="sec-scope">
143 <h1><span class="secnum" id="sec-1"><a href="#sec-scope" title="link to this section">1</a></span> Scope</h1>
144
145 <p>This Standard defines the ECMAScript 2015 general purpose programming language.</p>
146 </section>
147
148 <section id="sec-conformance">
149 <h1><span class="secnum" id="sec-2"><a href="#sec-conformance" title="link to this section">2</a></span> Conformance</h1>
150
151 <p>A conforming implementation of ECMAScript must provide and support all the types, values, objects, properties, functions, and
152 program syntax and semantics described in this specification.</p>
153
154 <p>A conforming implementation of ECMAScript must interpret source text input in conformance with the Unicode Standard, Version
155 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
156 Unicode set, collection 10646.</p>
157
158 <p>A conforming implementation of ECMAScript that provides an application programming interface that supports programs that need
159 to adapt to the linguistic and cultural conventions used by different human languages and countries must implement the interface
160 defined by the most recent edition of ECMA-402 that is compatible with this specification.</p>
161
162 <p>A conforming implementation of ECMAScript may provide additional types, values, objects, properties, and functions beyond
163 those described in this specification. In particular, a conforming implementation of ECMAScript may provide properties not
164 described in this specification, and values for those properties, for objects that are described in this specification.</p>
165
166 <p>A conforming implementation of ECMAScript may support program and regular expression syntax not described in this
167 specification. In particular, a conforming implementation of ECMAScript may support program syntax that makes use of the
168 &ldquo;future reserved words&rdquo; listed in <a href="#sec-future-reserved-words">subclause 11.6.2.2</a> of this
169 specification.</p>
170
171 <p>A conforming implementation of ECMAScript must not implement any extension that is listed as a Forbidden Extension in <a
172 href="#sec-forbidden-extensions">subclause 16.1</a>.</p>
173 </section>
174
175 <section id="sec-normative-references">
176 <h1><span class="secnum" id="sec-3"><a href="#sec-normative-references" title="link to this section">3</a></span> Normative
177 references</h1>
178
179 <p>The following referenced documents are indispensable for the application of this document. For dated references, only the
180 edition cited applies. For undated references, the latest edition of the referenced document (including any amendments)
181 applies.</p>
182
183 <p class="formal-reference">IEEE Std 754-2008: <i>IEEE Standard for Floating-Point Arithmetic</i>. Institute of Electrical and
184 Electronic Engineers, New York (2008)</p>
185
186 <p class="formal-reference">ISO/IEC 10646:2003: <i>Information Technology &ndash; Universal Multiple-Octet Coded Character Set
187 (UCS) plus Amendment 1:2005, Amendment 2:2006, Amendment 3:2008, and Amendment 4:2008</i>, plus additional amendments and
188 corrigenda, or successor</p>
189
190 <p class="formal-reference"><i>The Unicode Standard, Version 5.0</i>, as amended by Unicode 5.1.0, or successor.<br><a
191 href="http://www.unicode.org/versions/latest">http://www.unicode.org/versions/latest</a></p>
192
193 <p class="formal-reference"><i>Unicode Standard Annex #15, Unicode Normalization Forms, version Unicode 5.1.0</i>, or
194 successor.<br><a href="http://www.unicode.org/reports/tr15/">http://www.unicode.org/reports/tr15/</a></p>
195
196 <p class="formal-reference"><i>Unicode Standard Annex #31, Unicode Identifiers and Pattern Syntax, version Unicode 5.1.0</i>, or
197 successor. <a href="http://www.unicode.org/reports/tr31/">http://www.unicode.org/reports/tr31/</a></p>
198
199 <p>ECMA-402, <i>ECMAScript 2015 Internationalization API Specification</i>.<br><a
200 href="http://www.ecma-international.org/publications/standards/Ecma-402.htm">http://www.ecma-international.org/publications/standards/Ecma-402.htm</a></p>
201
202 <p>ECMA-404, <i>The JSON Data Interchange Format</i>.<br><a
203 href="http://www.ecma-international.org/publications/standards/Ecma-404.htm">http://www.ecma-international.org/publications/standards/Ecma-404.htm</a></p>
204 </section>
205
206 <section id="sec-overview">
207 <div class="front">
208 <h1><span class="secnum" id="sec-4"><a href="#sec-overview" title="link to this section">4</a></span> Overview</h1>
209
210 <p>This section contains a non-normative overview of the ECMAScript language.</p>
211
212 <p>ECMAScript is an object-oriented programming language for performing computations and manipulating computational objects
213 within a host environment. ECMAScript as defined here is not intended to be computationally self-sufficient; indeed, there are
214 no provisions in this specification for input of external data or output of computed results. Instead, it is expected that the
215 computational environment of an ECMAScript program will provide not only the objects and other facilities described in this
216 specification but also certain environment-specific objects, whose description and behaviour are beyond the scope of this
217 specification except to indicate that they may provide certain properties that can be accessed and certain functions that can
218 be called from an ECMAScript program.</p>
219
220 <p>ECMAScript was originally designed to be used as a scripting language, but has become widely used as a general purpose
221 programming language. A <b><i>scripting language</i></b> is a programming language that is used to manipulate, customize, and
222 automate the facilities of an existing system. In such systems, useful functionality is already available through a user
223 interface, and the scripting language is a mechanism for exposing that functionality to program control. In this way, the
224 existing system is said to provide a host environment of objects and facilities, which completes the capabilities of the
225 scripting language. A scripting language is intended for use by both professional and non-professional programmers.</p>
226
227 <p>ECMAScript was originally designed to be a <b><i>Web scripting language</i></b>, providing a mechanism to enliven Web pages
228 in browsers and to perform server computation as part of a Web-based client-server architecture. ECMAScript is now used to
229 provide core scripting capabilities for a variety of host environments. Therefore the core language is specified in this
230 document apart from any particular host environment.</p>
231
232 <p>ECMAScript usage has moved beyond simple scripting and it is now used for the full spectrum of programming tasks in many
233 different environments and scales. As the usage of ECMAScript has expanded, so has the features and facilities it provides.
234 ECMAScript is now a fully featured general propose programming language.</p>
235
236 <p>Some of the facilities of ECMAScript are similar to those used in other programming languages; in particular C,
237 Java&trade;, Self, and Scheme as described in:</p>
238
239 <p>ISO/IEC&nbsp;9899:1996, Programming Languages &ndash; C.</p>
240
241 <p class="formal-reference">Gosling, James, Bill Joy and Guy Steele. <span class="book-title">The Java&trade; Language
242 Specification</span>. Addison Wesley Publishing Co., 1996.</p>
243
244 <p class="formal-reference">Ungar, David, and Smith, Randall B. <span class="book-title">Self: The Power of Simplicity</span>.
245 OOPSLA '87 Conference Proceedings, pp. 227&ndash;241, Orlando, FL, October 1987.</p>
246
247 <p class="formal-reference"><span class="book-title">IEEE Standard for the Scheme Programming Language</span>. IEEE Std
248 1178-1990.</p>
249 </div>
250
251 <section id="sec-web-scripting">
252 <h1><span class="secnum" id="sec-4.1"><a href="#sec-web-scripting" title="link to this section">4.1</a></span> Web
253 Scripting</h1>
254
255 <p>A web browser provides an ECMAScript host environment for client-side computation including, for instance, objects that
256 represent windows, menus, pop-ups, dialog boxes, text areas, anchors, frames, history, cookies, and input/output. Further, the
257 host environment provides a means to attach scripting code to events such as change of focus, page and image loading,
258 unloading, error and abort, selection, form submission, and mouse actions. Scripting code appears within the HTML and the
259 displayed page is a combination of user interface elements and fixed and computed text and images. The scripting code is
260 reactive to user interaction and there is no need for a main program.</p>
261
262 <p>A web server provides a different host environment for server-side computation including objects representing requests,
263 clients, and files; and mechanisms to lock and share data. By using browser-side and server-side scripting together, it is
264 possible to distribute computation between the client and server while providing a customized user interface for a Web-based
265 application.</p>
266
267 <p>Each Web browser and server that supports ECMAScript supplies its own host environment, completing the ECMAScript execution
268 environment.</p>
269 </section>
270
271 <section id="sec-ecmascript-overview">
272 <div class="front">
273 <h1><span class="secnum" id="sec-4.2"><a href="#sec-ecmascript-overview" title="link to this section">4.2</a></span>
274 ECMAScript Overview</h1>
275
276 <p>The following is an informal overview of ECMAScript&mdash;not all parts of the language are described. This overview is
277 not part of the standard proper.</p>
278
279 <p>ECMAScript is object-based: basic language and host facilities are provided by objects, and an ECMAScript program is a
280 cluster of communicating objects. In ECMAScript, an <b><i>object</i></b> is a collection of zero or more
281 <b><i>properties</i></b> each with <b><i>attributes</i></b> that determine how each property can be used&mdash;for example,
282 when the Writable attribute for a property is set to <b>false</b>, any attempt by executed ECMAScript code to assign a
283 different value to the property fails. Properties are containers that hold other objects, <b><i>primitive values</i></b>, or
284 <b><i>functions</i></b>. A primitive value is a member of one of the following built-in types: <b>Undefined</b>,
285 <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
286 <b>Object</b>; and a function is a callable object. A function that is associated with an object via a property is called a
287 <b><i>method</i></b>.</p>
288
289 <p>ECMAScript defines a collection of <b><i>built-in objects</i></b> that round out the definition of ECMAScript entities.
290 These built-in objects include the global object; objects that are fundamental to the runtime semantics of the language
291 including <b>Object</b>, <b>Function</b>, <b>Boolean</b>, <b>Symbol</b>, and various <b>Error</b> objects; objects that
292 represent and manipulate numeric values including <b>Math</b>, <b>Number</b>, and <b>Date</b>; the text processing objects
293 <b>String</b> and <b>RegExp</b>; objects that are indexed collections of values including <b>Array</b> and nine different
294 kinds of Typed Arrays whose elements all have a specific numeric data representation; keyed collections including <b>Map</b>
295 and <b>Set</b> objects; objects supporting structured data including the <b>JSON</b> object, <b>ArrayBuffer</b>, and
296 <b>DataView</b>; objects supporting control abstractions including generator functions and <b>Promise</b> objects;
297 and<b>,</b> reflection objects including <b>Proxy</b> and <b>Reflect</b>.</p>
298
299 <p>ECMAScript also defines a set of built-in <b><i>operators</i></b>. ECMAScript operators include various unary operations,
300 multiplicative operators, additive operators, bitwise shift operators, relational operators, equality operators, binary
301 bitwise operators, binary logical operators, assignment operators, and the comma operator.</p>
302
303 <p>Large ECMAScript programs are supported by <b><i>modules</i></b> which allow a program to be divided into multiple
304 sequences of statements and declarations. Each module explicitly identifies declarations it uses that need to be provided by
305 other modules and which of its declarations are available for use by other modules.</p>
306
307 <p>ECMAScript syntax intentionally resembles Java syntax. ECMAScript syntax is relaxed to enable it to serve as an
308 easy-to-use scripting language. For example, a variable is not required to have its type declared nor are types associated
309 with properties, and defined functions are not required to have their declarations appear textually before calls to
310 them.</p>
311 </div>
312
313 <section id="sec-objects">
314 <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>
315
316 <p>Even though ECMAScript includes syntax for class definitions, ECMAScript objects are not fundamentally class-based such
317 as those in C++, Smalltalk, or Java. Instead objects may be created in various ways including via a literal notation or via
318 <b><i>constructors</i></b> which create objects and then execute code that initializes all or part of them by assigning
319 initial values to their properties. Each constructor is a function that has a property named <code>"prototype"</code> that
320 is used to implement <b><i>prototype-based inheritance</i></b> and <b><i>shared properties</i></b>. Objects are created by
321 using constructors in <b>new</b> expressions; for example, <code>new Date(2009,11)</code> creates a new Date object.
322 Invoking a constructor without using <b>new</b> has consequences that depend on the constructor. For example,
323 <code>Date()</code> produces a string representation of the current date and time rather than an object.</p>
324
325 <p>Every object created by a constructor has an implicit reference (called the object&rsquo;s <i>prototype</i>) to the value
326 of its constructor&rsquo;s <code>"prototype"</code> property. Furthermore, a prototype may have a non-null implicit
327 reference to its prototype, and so on; this is called the <i>prototype chain</i>. When a reference is made to a property in
328 an object, that reference is to the property of that name in the first object in the prototype chain that contains a
329 property of that name. In other words, first the object mentioned directly is examined for such a property; if that object
330 contains the named property, that is the property to which the reference refers; if that object does not contain the named
331 property, the prototype for that object is examined next; and so on.</p>
332
333 <figure>
334 <object data="figure-1.svg" height="354" type="image/svg+xml" width="719">
335 <img alt="An image of lots of boxes and arrows." height="354" src="figure-1.png" width="719">
336 </object>
337 <figcaption>Figure 1 &mdash; Object/Prototype Relationships</figcaption>
338 </figure>
339
340 <p>In a class-based object-oriented language, in general, state is carried by instances, methods are carried by classes, and
341 inheritance is only of structure and behaviour. In ECMAScript, the state and methods are carried by objects, while
342 structure, behaviour, and state are all inherited.</p>
343
344 <p>All objects that do not directly contain a particular property that their prototype contains share that property and its
345 value. Figure 1 illustrates this:</p>
346
347 <p><b>CF</b> is a constructor (and also an object). Five objects have been created by using <code>new</code> expressions:
348 <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
349 of these objects contains properties named <code>q1</code> and <code>q2</code>. The dashed lines represent the implicit
350 prototype relationship; so, for example, <b>cf<sub>3</sub></b>&rsquo;s prototype is <b>CF<sub>p</sub></b>. The constructor,
351 <b>CF</b>, has two properties itself, named <code>P1</code> and <code>P2</code>, which are not visible to
352 <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
353 <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>,
354 <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
355 are any properties found in <b>CF<sub>p</sub></b>&rsquo;s implicit prototype chain that are not named <code>q1</code>,
356 <code>q2</code>, or <code>CFP1</code>. Notice that there is no implicit prototype link between <b>CF</b> and
357 <b>CF<sub>p</sub></b>.</p>
358
359 <p>Unlike most class-based object languages, properties can be added to objects dynamically by assigning values to them.
360 That is, constructors are not required to name or assign values to all or any of the constructed object&rsquo;s properties.
361 In the above diagram, one could add a new shared property for <b>cf<sub>1</sub></b>, <b>cf<sub>2</sub></b>,
362 <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
363 <b>CF<sub>p</sub></b>.</p>
364
365 <p>Although ECMAScript objects are not inherently class-based, it is often convenient to define class-like abstractions
366 based upon a common pattern of constructor functions, prototype objects, and methods. The ECMAScript built-in objects
367 themselves follow such a class-like pattern. Beginning with the sixth edition, the ECMAScript language includes syntactic
368 class definitions that permit programmers to concisely define objects that conform to the same class-like abstraction
369 pattern used by the built-in objects.</p>
370 </section>
371
372 <section id="sec-strict-variant-of-ecmascript">
373 <h1><span class="secnum" id="sec-4.2.2"><a href="#sec-strict-variant-of-ecmascript"
374 title="link to this section">4.2.2</a></span> The Strict Variant of ECMAScript</h1>
375
376 <p>The ECMAScript Language recognizes the possibility that some users of the language may wish to restrict their usage of
377 some features available in the language. They might do so in the interests of security, to avoid what they consider to be
378 error-prone features, to get enhanced error checking, or for other reasons of their choosing. In support of this
379 possibility, ECMAScript defines a strict variant of the language. The strict variant of the language excludes some specific
380 syntactic and semantic features of the regular ECMAScript language and modifies the detailed semantics of some features. The
381 strict variant also specifies additional error conditions that must be reported by throwing error exceptions in situations
382 that are not specified as errors by the non-strict form of the language.</p>
383
384 <p>The strict variant of ECMAScript is commonly referred to as the <i>strict mode</i> of the language. Strict mode selection
385 and use of the strict mode syntax and semantics of ECMAScript is explicitly made at the level of individual ECMAScript
386 source text units. Because strict mode is selected at the level of a syntactic source text unit, strict mode only imposes
387 restrictions that have local effect within such a source text unit. Strict mode does not restrict or modify any aspect of
388 the ECMAScript semantics that must operate consistently across multiple source text units. A complete ECMAScript program may
389 be composed of both strict mode and non-strict mode ECMAScript source text units. In this case, strict mode only applies
390 when actually executing code that is defined within a strict mode source text unit.</p>
391
392 <p>In order to conform to this specification, an ECMAScript implementation must implement both the full unrestricted
393 ECMAScript language and the strict variant of the ECMAScript language as defined by this specification. In addition, an
394 implementation must support the combination of unrestricted and strict mode source text units into a single composite
395 program.</p>
396 </section>
397 </section>
398
399 <section id="sec-terms-and-definitions">
400 <div class="front">
401 <h1><span class="secnum" id="sec-4.3"><a href="#sec-terms-and-definitions" title="link to this section">4.3</a></span> Terms
402 and definitions</h1>
403
404 <p>For the purposes of this document, the following terms and definitions apply.</p>
405 </div>
406
407 <section id="sec-type">
408 <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>
409
410 <p>set of data values as defined in <a href="#sec-ecmascript-data-types-and-values">clause 6</a> of this specification</p>
411 </section>
412
413 <section id="sec-primitive-value">
414 <h1><span class="secnum" id="sec-4.3.2"><a href="#sec-primitive-value" title="link to this section">4.3.2</a></span>
415 primitive value</h1>
416
417 <p>member of one of the types Undefined, Null, Boolean, Number, Symbol, or String as defined in <a
418 href="#sec-ecmascript-data-types-and-values">clause 6</a></p>
419
420 <div class="note">
421 <p><span class="nh">NOTE</span> A primitive value is a datum that is represented directly at the lowest level of the
422 language implementation.</p>
423 </div>
424 </section>
425
426 <section id="sec-terms-and-definitions-object">
427 <h1><span class="secnum" id="sec-4.3.3"><a href="#sec-terms-and-definitions-object"
428 title="link to this section">4.3.3</a></span> object</h1>
429
430 <p>member of the type Object</p>
431
432 <div class="note">
433 <p><span class="nh">NOTE</span> An object is a collection of properties and has a single prototype object. The prototype
434 may be the null value.</p>
435 </div>
436 </section>
437
438 <section id="sec-constructor">
439 <h1><span class="secnum" id="sec-4.3.4"><a href="#sec-constructor" title="link to this section">4.3.4</a></span>
440 constructor</h1>
441
442 <p>function object that creates and initializes objects</p>
443
444 <div class="note">
445 <p><span class="nh">NOTE</span> The value of a constructor&rsquo;s <code>prototype</code> property is a prototype object
446 that is used to implement inheritance and shared properties.</p>
447 </div>
448 </section>
449
450 <section id="sec-terms-and-definitions-prototype">
451 <h1><span class="secnum" id="sec-4.3.5"><a href="#sec-terms-and-definitions-prototype"
452 title="link to this section">4.3.5</a></span> prototype</h1>
453
454 <p>object that provides shared properties for other objects</p>
455
456 <div class="note">
457 <p><span class="nh">NOTE</span> When a constructor creates an object, that object implicitly references the
458 constructor&rsquo;s <code>prototype</code> property for the purpose of resolving property references. The
459 constructor&rsquo;s <code>prototype</code> property can be referenced by the program expression
460 <code><i>constructor</i><b>.prototype</b></code>, and properties added to an object&rsquo;s prototype are shared, through
461 inheritance, by all objects sharing the prototype. Alternatively, a new object may be created with an explicitly specified
462 prototype by using the <code><a href="#sec-object.create">Object.create</a></code> built-in function.</p>
463 </div>
464 </section>
465
466 <section id="sec-ordinary-object">
467 <h1><span class="secnum" id="sec-4.3.6"><a href="#sec-ordinary-object" title="link to this section">4.3.6</a></span>
468 ordinary object</h1>
469
470 <p>object that has the default behaviour for the essential internal methods that must be supported by all objects.</p>
471 </section>
472
473 <section id="sec-exotic-object">
474 <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
475 object</h1>
476
477 <p>object that does not have the default behaviour for one or more of the essential internal methods that must be supported
478 by all objects.</p>
479
480 <div class="note">
481 <p><span class="nh">NOTE</span> Any object that is not an ordinary object is an exotic object.</p>
482 </div>
483 </section>
484
485 <section id="sec-standard-object">
486 <h1><span class="secnum" id="sec-4.3.8"><a href="#sec-standard-object" title="link to this section">4.3.8</a></span>
487 standard object</h1>
488
489 <p>object whose semantics are defined by this specification</p>
490 </section>
491
492 <section id="sec-built-in-object">
493 <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>
494 built-in object</h1>
495
496 <p>object specified and supplied by an ECMAScript implementation</p>
497
498 <div class="note">
499 <p><span class="nh">NOTE</span> Standard built-in objects are defined in this specification. An ECMAScript implementation
500 may specify and supply additional kinds of built-in objects. A <i>built-in constructor</i> is a built-in object that is
501 also a constructor.</p>
502 </div>
503 </section>
504
505 <section id="sec-undefined-value">
506 <h1><span class="secnum" id="sec-4.3.10"><a href="#sec-undefined-value" title="link to this section">4.3.10</a></span>
507 undefined value</h1>
508
509 <p>primitive value used when a variable has not been assigned a value</p>
510 </section>
511
512 <section id="sec-terms-and-definitions-undefined-type">
513 <h1><span class="secnum" id="sec-4.3.11"><a href="#sec-terms-and-definitions-undefined-type"
514 title="link to this section">4.3.11</a></span> Undefined type</h1>
515
516 <p>type whose sole value is the <b>undefined</b> value</p>
517 </section>
518
519 <section id="sec-null-value">
520 <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
521 value</h1>
522
523 <p>primitive value that represents the intentional absence of any object value</p>
524 </section>
525
526 <section id="sec-terms-and-definitions-null-type">
527 <h1><span class="secnum" id="sec-4.3.13"><a href="#sec-terms-and-definitions-null-type"
528 title="link to this section">4.3.13</a></span> Null type</h1>
529
530 <p>type whose sole value is the null value</p>
531 </section>
532
533 <section id="sec-terms-and-definitions-boolean-value">
534 <h1><span class="secnum" id="sec-4.3.14"><a href="#sec-terms-and-definitions-boolean-value"
535 title="link to this section">4.3.14</a></span> Boolean value</h1>
536
537 <p>member of the Boolean type</p>
538
539 <div class="note">
540 <p><span class="nh">NOTE</span> There are only two Boolean values, <b>true</b> and <b>false</b></p>
541 </div>
542 </section>
543
544 <section id="sec-terms-and-definitions-boolean-type">
545 <h1><span class="secnum" id="sec-4.3.15"><a href="#sec-terms-and-definitions-boolean-type"
546 title="link to this section">4.3.15</a></span> Boolean type</h1>
547
548 <p>type consisting of the primitive values <b>true</b> and <b>false</b></p>
549 </section>
550
551 <section id="sec-boolean-object">
552 <h1><span class="secnum" id="sec-4.3.16"><a href="#sec-boolean-object" title="link to this section">4.3.16</a></span>
553 Boolean object</h1>
554
555 <p>member of the Object type that is an instance of the standard built-in <code>Boolean</code> constructor</p>
556
557 <div class="note">
558 <p><span class="nh">NOTE</span> A Boolean object is created by using the <code>Boolean</code> constructor in a
559 <code>new</code> expression, supplying a Boolean value as an argument. The resulting object has an <a
560 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the Boolean value. A Boolean
561 object can be coerced to a Boolean value.</p>
562 </div>
563 </section>
564
565 <section id="sec-terms-and-definitions-string-value">
566 <h1><span class="secnum" id="sec-4.3.17"><a href="#sec-terms-and-definitions-string-value"
567 title="link to this section">4.3.17</a></span> String value</h1>
568
569 <p>primitive value that is a finite ordered sequence of zero or more 16-bit unsigned integer</p>
570
571 <div class="note">
572 <p><span class="nh">NOTE</span> A String value is a member of the String type. Each integer value in the sequence usually
573 represents a single 16-bit unit of UTF-16 text. However, ECMAScript does not place any restrictions or requirements on the
574 values except that they must be 16-bit unsigned integers.</p>
575 </div>
576 </section>
577
578 <section id="sec-terms-and-definitions-string-type">
579 <h1><span class="secnum" id="sec-4.3.18"><a href="#sec-terms-and-definitions-string-type"
580 title="link to this section">4.3.18</a></span> String type</h1>
581
582 <p>set of all possible String values</p>
583 </section>
584
585 <section id="sec-string-object">
586 <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
587 object</h1>
588
589 <p>member of the Object type that is an instance of the standard built-in <code>String</code> constructor</p>
590
591 <div class="note">
592 <p><span class="nh">NOTE</span> A String object is created by using the <code>String</code> constructor in a
593 <code>new</code> expression, supplying a String value as an argument. The resulting object has an <a
594 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the String value. A String object
595 can be coerced to a String value by calling the <code>String</code> constructor as a function (<a
596 href="#sec-string-constructor-string-value">21.1.1.1</a>).</p>
597 </div>
598 </section>
599
600 <section id="sec-terms-and-definitions-number-value">
601 <h1><span class="secnum" id="sec-4.3.20"><a href="#sec-terms-and-definitions-number-value"
602 title="link to this section">4.3.20</a></span> Number value</h1>
603
604 <p>primitive value corresponding to a double-precision 64-bit binary format IEEE 754 value</p>
605
606 <div class="note">
607 <p><span class="nh">NOTE</span> A Number value is a member of the Number type and is a direct representation of a
608 number.</p>
609 </div>
610 </section>
611
612 <section id="sec-terms-and-definitions-number-type">
613 <h1><span class="secnum" id="sec-4.3.21"><a href="#sec-terms-and-definitions-number-type"
614 title="link to this section">4.3.21</a></span> Number type</h1>
615
616 <p>set of all possible Number values including the special &ldquo;Not-a-Number&rdquo; (NaN) value, positive infinity, and
617 negative infinity</p>
618 </section>
619
620 <section id="sec-number-object">
621 <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
622 object</h1>
623
624 <p>member of the Object type that is an instance of the standard built-in <code>Number</code> constructor</p>
625
626 <div class="note">
627 <p><span class="nh">NOTE</span> A Number object is created by using the <code>Number</code> constructor in a
628 <code>new</code> expression, supplying a Number value as an argument. The resulting object has an <a
629 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the Number value. A Number object
630 can be coerced to a Number value by calling the <code>Number</code> constructor as a function (<a
631 href="#sec-number-constructor-number-value">20.1.1.1</a>).</p>
632 </div>
633 </section>
634
635 <section id="sec-terms-and-definitions-infinity">
636 <h1><span class="secnum" id="sec-4.3.23"><a href="#sec-terms-and-definitions-infinity"
637 title="link to this section">4.3.23</a></span> Infinity</h1>
638
639 <p>number value that is the positive infinite Number value</p>
640 </section>
641
642 <section id="sec-terms-and-definitions-nan">
643 <h1><span class="secnum" id="sec-4.3.24"><a href="#sec-terms-and-definitions-nan"
644 title="link to this section">4.3.24</a></span> NaN</h1>
645
646 <p>number value that is an IEEE 754 &ldquo;Not-a-Number&rdquo; value</p>
647 </section>
648
649 <section id="sec-symbol-value">
650 <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
651 value</h1>
652
653 <p>primitive value that represents a unique, non-String Object <a href="#sec-object-type">property key</a></p>
654 </section>
655
656 <section id="sec-terms-and-definitions-symbol-type">
657 <h1><span class="secnum" id="sec-4.3.26"><a href="#sec-terms-and-definitions-symbol-type"
658 title="link to this section">4.3.26</a></span> Symbol type</h1>
659
660 <p>set of all possible Symbol values</p>
661 </section>
662
663 <section id="sec-symbol-object">
664 <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
665 object</h1>
666
667 <p>member of the Object type that is an instance of the standard built-in <code>Symbol</code> constructor</p>
668 </section>
669
670 <section id="sec-terms-and-definitions-function">
671 <h1><span class="secnum" id="sec-4.3.28"><a href="#sec-terms-and-definitions-function"
672 title="link to this section">4.3.28</a></span> function</h1>
673
674 <p>member of the Object type that may be invoked as a subroutine</p>
675
676 <div class="note">
677 <p><span class="nh">NOTE</span> In addition to its properties, a function contains executable code and state that
678 determine how it behaves when invoked. A function&rsquo;s code may or may not be written in ECMAScript.</p>
679 </div>
680 </section>
681
682 <section id="sec-built-in-function">
683 <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>
684 built-in function</h1>
685
686 <p>built-in object that is a function</p>
687
688 <div class="note">
689 <p><span class="nh">NOTE</span> Examples of built-in functions include <code>parseInt</code> and <code><a
690 href="#sec-math.exp">Math.exp</a></code>. An implementation may provide implementation-dependent built-in functions that
691 are not described in this specification.</p>
692 </div>
693 </section>
694
695 <section id="sec-property">
696 <h1><span class="secnum" id="sec-4.3.30"><a href="#sec-property" title="link to this section">4.3.30</a></span>
697 property</h1>
698
699 <p>part of an object that associates a key (either a String value or a Symbol value) and a value.</p>
700
701 <div class="note">
702 <p><span class="nh">NOTE</span> Depending upon the form of the property the value may be represented either directly as a
703 data value (a primitive value, an object, or a function object) or indirectly by a pair of accessor functions.</p>
704 </div>
705 </section>
706
707 <section id="sec-method">
708 <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>
709
710 <p>function that is the value of a property</p>
711
712 <div class="note">
713 <p><span class="nh">NOTE</span> When a function is called as a method of an object, the object is passed to the function
714 as its <b>this</b> value.</p>
715 </div>
716 </section>
717
718 <section id="sec-built-in-method">
719 <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>
720 built-in method</h1>
721
722 <p>method that is a built-in function</p>
723
724 <div class="note">
725 <p><span class="nh">NOTE</span> Standard built-in methods are defined in this specification, and an ECMAScript
726 implementation may specify and provide other additional built-in methods.</p>
727 </div>
728 </section>
729
730 <section id="sec-attribute">
731 <h1><span class="secnum" id="sec-4.3.33"><a href="#sec-attribute" title="link to this section">4.3.33</a></span>
732 attribute</h1>
733
734 <p>internal value that defines some characteristic of a property</p>
735 </section>
736
737 <section id="sec-own-property">
738 <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
739 property</h1>
740
741 <p>property that is directly contained by its object</p>
742 </section>
743
744 <section id="sec-inherited-property">
745 <h1><span class="secnum" id="sec-4.3.35"><a href="#sec-inherited-property" title="link to this section">4.3.35</a></span>
746 inherited property</h1>
747
748 <p>property of an object that is not an own property but is a property (either own or inherited) of the object&rsquo;s
749 prototype</p>
750 </section>
751 </section>
752
753 <section id="sec-organization-of-this-specification">
754 <h1><span class="secnum" id="sec-4.4"><a href="#sec-organization-of-this-specification"
755 title="link to this section">4.4</a></span> Organization of This Specification</h1>
756
757 <p>The remainder of this specification is organized as follows:</p>
758
759 <p>Clause 5 defines the notational conventions used throughout the specification.</p>
760
761 <p>Clauses 6&minus;9 define the execution environment within which ECMAScript programs operate.</p>
762
763 <p>Clauses 10&minus;16 define the actual ECMAScript programming language including its syntactic encoding and the execution
764 semantics of all language features.</p>
765
766 <p>Clauses 17&minus;26 define the ECMAScript standard library. It includes the definitions of all of the standard objects that
767 are available for use by ECMAScript programs as they execute.</p>
768 </section>
769 </section>
770
771 <section id="sec-notational-conventions">
772 <div class="front">
773 <h1><span class="secnum" id="sec-5"><a href="#sec-notational-conventions" title="link to this section">5</a></span> Notational
774 Conventions</h1>
775 </div>
776
777 <section id="sec-syntactic-and-lexical-grammars">
778 <div class="front">
779 <h1><span class="secnum" id="sec-5.1"><a href="#sec-syntactic-and-lexical-grammars"
780 title="link to this section">5.1</a></span> Syntactic and Lexical Grammars</h1>
781 </div>
782
783 <section id="sec-context-free-grammars">
784 <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>
785 Context-Free Grammars</h1>
786
787 <p>A <i>context-free grammar</i> consists of a number of <i>productions</i>. Each production has an abstract symbol called a
788 <i>nonterminal</i> as its <i>left-hand side</i>, and a sequence of zero or more nonterminal and <i>terminal</i> symbols as
789 its <i>right-hand side</i>. For each grammar, the terminal symbols are drawn from a specified alphabet.</p>
790
791 <p>A <i>chain production</i> is a production that has exactly one nonterminal symbol on its right-hand side along with zero
792 or more terminal symbols.</p>
793
794 <p>Starting from a sentence consisting of a single distinguished nonterminal, called the <i>goal symbol</i>, a given
795 context-free grammar specifies a <i>language</i>, namely, the (perhaps infinite) set of possible sequences of terminal
796 symbols that can result from repeatedly replacing any nonterminal in the sequence with a right-hand side of a production for
797 which the nonterminal is the left-hand side.</p>
798 </section>
799
800 <section id="sec-lexical-and-regexp-grammars">
801 <h1><span class="secnum" id="sec-5.1.2"><a href="#sec-lexical-and-regexp-grammars"
802 title="link to this section">5.1.2</a></span> The Lexical and RegExp Grammars</h1>
803
804 <p>A <i>lexical grammar</i> for ECMAScript is given in <a href="#sec-ecmascript-language-lexical-grammar">clause 11</a>.
805 This grammar has as its terminal symbols Unicode code points that conform to the rules for <span
806 class="nt">SourceCharacter</span> defined in <a href="#sec-source-text">10.1</a>. It defines a set of productions, starting
807 from the goal symbol <var>InputElementDiv,</var> <var>InputElementTemplateTail,</var> or <span
808 class="nt">InputElementRegExp</span>, or <var>InputElementRegExpOrTemplateTail,</var> that describe how sequences of such
809 code points are translated into a sequence of input elements.</p>
810
811 <p>Input elements other than white space and comments form the terminal symbols for the syntactic grammar for ECMAScript and
812 are called ECMAScript <i>tokens</i>. These tokens are the reserved words, identifiers, literals, and punctuators of the
813 ECMAScript language. Moreover, line terminators, although not considered to be tokens, also become part of the stream of
814 input elements and guide the process of <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a
815 href="#sec-automatic-semicolon-insertion">11.9</a>). Simple white space and single-line comments are discarded and do not
816 appear in the stream of input elements for the syntactic grammar. A <span class="nt">MultiLineComment</span> (that is, a
817 comment of the form <code>/*</code>&hellip;<code>*/</code> regardless of whether it spans more than one line) is likewise
818 simply discarded if it contains no line terminator; but if a <span class="nt">MultiLineComment</span> contains one or more
819 line terminators, then it is replaced by a single line terminator, which becomes part of the stream of input elements for
820 the syntactic grammar.</p>
821
822 <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
823 terminal symbols the code points as defined by <span class="nt">SourceCharacter</span>. It defines a set of productions,
824 starting from the goal symbol <span class="nt">Pattern</span>, that describe how sequences of code points are translated
825 into regular expression patterns.</p>
826
827 <p>Productions of the lexical and RegExp grammars are distinguished by having two colons &ldquo;<b>::</b>&rdquo; as
828 separating punctuation. The lexical and RegExp grammars share some productions.</p>
829 </section>
830
831 <section id="sec-numeric-string-grammar">
832 <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>
833 The Numeric String Grammar</h1>
834
835 <p>Another grammar is used for translating Strings into numeric values. This grammar is similar to the part of the lexical
836 grammar having to do with numeric literals and has as its terminal symbols <span class="nt">SourceCharacter</span>. This
837 grammar appears in <a href="#sec-tonumber-applied-to-the-string-type">7.1.3.1</a>.</p>
838
839 <p>Productions of the numeric string grammar are distinguished by having three colons &ldquo;<b>:::</b>&rdquo; as
840 punctuation.</p>
841 </section>
842
843 <section id="sec-syntactic-grammar">
844 <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
845 Syntactic Grammar</h1>
846
847 <p>The <i>syntactic grammar</i> for ECMAScript is given in clauses 11, 12, 13, 14, and 15. This grammar has ECMAScript
848 tokens defined by the lexical grammar as its terminal symbols (<a href="#sec-lexical-and-regexp-grammars">5.1.2</a>). It
849 defines a set of productions, starting from two alternative goal symbols <span class="nt">Script</span> and <span
850 class="nt">Module</span>, that describe how sequences of tokens form syntactically correct independent components of
851 ECMAScript programs.</p>
852
853 <p>When a stream of code points is to be parsed as an ECMAScript <span class="nt">Script</span> or <span
854 class="nt">Module</span>, it is first converted to a stream of input elements by repeated application of the lexical
855 grammar; this stream of input elements is then parsed by a single application of the syntactic grammar. The input stream is
856 syntactically in error if the tokens in the stream of input elements cannot be parsed as a single instance of the goal
857 nonterminal (<span class="nt">Script</span> or <span class="nt">Module</span>), with no tokens left over.</p>
858
859 <p>Productions of the syntactic grammar are distinguished by having just one colon &ldquo;<b>:</b>&rdquo; as
860 punctuation.</p>
861
862 <p>The syntactic grammar as presented in clauses 12, 13, 14 and 15 is not a complete account of which token sequences are
863 accepted as a correct ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span>. Certain additional token
864 sequences are also accepted, namely, those that would be described by the grammar if only semicolons were added to the
865 sequence in certain places (such as before line terminator characters). Furthermore, certain token sequences that are
866 described by the grammar are not considered acceptable if a line terminator character appears in certain
867 &ldquo;awkward&rdquo; places.</p>
868
869 <p>In certain cases in order to avoid ambiguities the syntactic grammar uses generalized productions that permit token
870 sequences that do not form a valid ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span>. For example,
871 this technique is used for object literals and object destructuring patterns. In such cases a more restrictive
872 <i>supplemental grammar</i> is provided that further restricts the acceptable token sequences. In certain contexts, when
873 explicitly specified, the input elements corresponding to such a production are parsed again using a goal symbol of a
874 supplemental grammar. The input stream is syntactically in error if the tokens in the stream of input elements parsed by a
875 cover grammar cannot be parsed as a single instance of the corresponding supplemental goal symbol, with no tokens left
876 over.</p>
877 </section>
878
879 <section id="sec-grammar-notation">
880 <h1><span class="secnum" id="sec-5.1.5"><a href="#sec-grammar-notation" title="link to this section">5.1.5</a></span>
881 Grammar Notation</h1>
882
883 <p>Terminal symbols of the lexical, RegExp, and numeric string grammars are shown in <code>fixed width</code> font, both in
884 the productions of the grammars and throughout this specification whenever the text directly refers to such a terminal
885 symbol. These are to appear in a script exactly as written. All terminal symbol code points specified in this way are to be
886 understood as the appropriate Unicode code points from the Basic Latin range, as opposed to any similar-looking code points
887 from other Unicode ranges.</p>
888
889 <p>Nonterminal symbols are shown in <var>italic</var> type. The definition of a nonterminal (also called a
890 &ldquo;production&rdquo;) is introduced by the name of the nonterminal being defined followed by one or more colons. (The
891 number of colons indicates to which grammar the production belongs.) One or more alternative right-hand sides for the
892 nonterminal then follow on succeeding lines. For example, the syntactic definition:</p>
893
894 <div class="gp">
895 <div class="lhs"><span class="nt">WhileStatement</span> <span class="geq">:</span></div>
896 <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>
897 </div>
898
899 <p>states that the nonterminal <span class="nt">WhileStatement</span> represents the token <code>while</code>, followed by a
900 left parenthesis token, followed by an <span class="nt">Expression</span>, followed by a right parenthesis token, followed
901 by a <span class="nt">Statement</span>. The occurrences of <span class="nt">Expression</span> and <span
902 class="nt">Statement</span> are themselves nonterminals. As another example, the syntactic definition:</p>
903
904 <div class="gp">
905 <div class="lhs"><span class="nt">ArgumentList</span> <span class="geq">:</span></div>
906 <div class="rhs"><span class="nt">AssignmentExpression</span></div>
907 <div class="rhs"><span class="nt">ArgumentList</span> <code class="t">,</code> <span class="nt">AssignmentExpression</span></div>
908 </div>
909
910 <p>states that an <span class="nt">ArgumentList</span> may represent either a single <span
911 class="nt">AssignmentExpression</span> or an <span class="nt">ArgumentList</span>, followed by a comma, followed by an <span
912 class="nt">AssignmentExpression</span>. This definition of <span class="nt">ArgumentList</span> is recursive, that is, it is
913 defined in terms of itself. The result is that an <span class="nt">ArgumentList</span> may contain any positive number of
914 arguments, separated by commas, where each argument expression is an <span class="nt">AssignmentExpression</span>. Such
915 recursive definitions of nonterminals are common.</p>
916
917 <p>The subscripted suffix &ldquo;<sub>opt</sub>&rdquo;, which may appear after a terminal or nonterminal, indicates an
918 optional symbol. The alternative containing the optional symbol actually specifies two right-hand sides, one that omits the
919 optional element and one that includes it. This means that:</p>
920
921 <div class="gp">
922 <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
923 <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span><sub class="g-opt">opt</sub></div>
924 </div>
925
926 <p>is a convenient abbreviation for:</p>
927
928 <div class="gp">
929 <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
930 <div class="rhs"><span class="nt">BindingIdentifier</span></div>
931 <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span></div>
932 </div>
933
934 <p>and that:</p>
935
936 <div class="gp">
937 <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
938 <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>
939 </div>
940
941 <p>is a convenient abbreviation for:</p>
942
943 <div class="gp">
944 <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
945 <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>
946 <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>
947 </div>
948
949 <p>which in turn is an abbreviation for:</p>
950
951 <div class="gp">
952 <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
953 <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>
954 <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>
955 <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>
956 <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>
957 </div>
958
959 <p>so, in this example, the nonterminal <span class="nt">IterationStatement</span> actually has four alternative right-hand
960 sides.</p>
961
962 <p>A production may be parameterized by a subscripted annotation of the form &ldquo;<sub>[parameters]</sub>&rdquo;, which
963 may appear as a suffix to the nonterminal symbol defined by the production. &ldquo;<sub>parameters</sub>&rdquo; may be
964 either a single name or a comma separated list of names. A parameterized production is shorthand for a set of productions
965 defining all combinations of the parameter names, preceded by an underscore, appended to the parameterized nonterminal
966 symbol. This means that:</p>
967
968 <div class="gp">
969 <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
970 <div class="rhs"><span class="nt">ReturnStatement</span></div>
971 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
972 </div>
973
974 <p>is a convenient abbreviation for:</p>
975
976 <div class="gp">
977 <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
978 <div class="rhs"><span class="nt">ReturnStatement</span></div>
979 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
980 </div>
981
982 <div class="gp">
983 <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
984 <div class="rhs"><span class="nt">ReturnStatement</span></div>
985 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
986 </div>
987
988 <p>and that:</p>
989
990 <div class="gp">
991 <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return, In]</sub> <span class="geq">:</span></div>
992 <div class="rhs"><span class="nt">ReturnStatement</span></div>
993 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
994 </div>
995
996 <p>is an abbreviation for:</p>
997
998 <div class="gp">
999 <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
1000 <div class="rhs"><span class="nt">ReturnStatement</span></div>
1001 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1002 </div>
1003
1004 <div class="gp">
1005 <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
1006 <div class="rhs"><span class="nt">ReturnStatement</span></div>
1007 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1008 </div>
1009
1010 <div class="gp">
1011 <div class="lhs"><span class="nt">StatementList_In</span> <span class="geq">:</span></div>
1012 <div class="rhs"><span class="nt">ReturnStatement</span></div>
1013 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1014 </div>
1015
1016 <div class="gp">
1017 <div class="lhs"><span class="nt">StatementList_Return_In</span> <span class="geq">:</span></div>
1018 <div class="rhs"><span class="nt">ReturnStatement</span></div>
1019 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1020 </div>
1021
1022 <p>Multiple parameters produce a combinatory number of productions, not all of which are necessarily referenced in a
1023 complete grammar.</p>
1024
1025 <p>References to nonterminals on the right-hand side of a production can also be parameterized. For example:</p>
1026
1027 <div class="gp">
1028 <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
1029 <div class="rhs"><span class="nt">ReturnStatement</span></div>
1030 <div class="rhs"><span class="nt">ExpressionStatement</span><sub class="g-params">[In]</sub></div>
1031 </div>
1032
1033 <p>is equivalent to saying:</p>
1034
1035 <div class="gp">
1036 <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
1037 <div class="rhs"><span class="nt">ReturnStatement</span></div>
1038 <div class="rhs"><span class="nt">ExpressionStatement_In</span></div>
1039 </div>
1040
1041 <p>A nonterminal reference may have both a parameter list and an &ldquo;<sub>opt</sub>&rdquo; suffix. For example:</p>
1042
1043 <div class="gp">
1044 <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
1045 <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>
1046 </div>
1047
1048 <p>is an abbreviation for:</p>
1049
1050 <div class="gp">
1051 <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
1052 <div class="rhs"><span class="nt">BindingIdentifier</span></div>
1053 <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer_In</span></div>
1054 </div>
1055
1056 <p>Prefixing a parameter name with &ldquo;<sub>?</sub>&rdquo; on a right-hand side nonterminal reference makes that
1057 parameter value dependent upon the occurrence of the parameter name on the reference to the current production&rsquo;s
1058 left-hand side symbol. For example:</p>
1059
1060 <div class="gp">
1061 <div class="lhs"><span class="nt">VariableDeclaration</span><sub class="g-params">[In]</sub> <span class="geq">:</span></div>
1062 <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span><sub class="g-params">[?In]</sub></div>
1063 </div>
1064
1065 <p>is an abbreviation for:</p>
1066
1067 <div class="gp">
1068 <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
1069 <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span></div>
1070 </div>
1071
1072 <div class="gp">
1073 <div class="lhs"><span class="nt">VariableDeclaration_In</span> <span class="geq">:</span></div>
1074 <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer_In</span></div>
1075 </div>
1076
1077 <p>If a right-hand side alternative is prefixed with &ldquo;[+parameter]&rdquo; that alternative is only available if the
1078 named parameter was used in referencing the production&rsquo;s nonterminal symbol. If a right-hand side alternative is
1079 prefixed with &ldquo;[~parameter]&rdquo; that alternative is only available if the named parameter was <i>not</i> used in
1080 referencing the production&rsquo;s nonterminal symbol. This means that:</p>
1081
1082 <div class="gp">
1083 <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
1084 <div class="rhs"><span class="grhsannot">[+Return]</span> <span class="nt">ReturnStatement</span></div>
1085 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1086 </div>
1087
1088 <p>is an abbreviation for:</p>
1089
1090 <div class="gp">
1091 <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
1092 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1093 </div>
1094
1095 <div class="gp">
1096 <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
1097 <div class="rhs"><span class="nt">ReturnStatement</span></div>
1098 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1099 </div>
1100
1101 <p>and that</p>
1102
1103 <div class="gp">
1104 <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
1105 <div class="rhs"><span class="grhsannot">[~Return]</span> <span class="nt">ReturnStatement</span></div>
1106 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1107 </div>
1108
1109 <p>is an abbreviation for:</p>
1110
1111 <div class="gp">
1112 <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
1113 <div class="rhs"><span class="nt">ReturnStatement</span></div>
1114 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1115 </div>
1116
1117 <div class="gp">
1118 <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
1119 <div class="rhs"><span class="nt">ExpressionStatement</span></div>
1120 </div>
1121
1122 <p>When the words &ldquo;<b>one of</b>&rdquo; follow the colon(s) in a grammar definition, they signify that each of the
1123 terminal symbols on the following line or lines is an alternative definition. For example, the lexical grammar for
1124 ECMAScript contains the production:</p>
1125
1126 <div class="gp">
1127 <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
1128 <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>
1129 </div>
1130
1131 <p>which is merely a convenient abbreviation for:</p>
1132
1133 <div class="gp">
1134 <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span></div>
1135 <div class="rhs"><code class="t">1</code></div>
1136 <div class="rhs"><code class="t">2</code></div>
1137 <div class="rhs"><code class="t">3</code></div>
1138 <div class="rhs"><code class="t">4</code></div>
1139 <div class="rhs"><code class="t">5</code></div>
1140 <div class="rhs"><code class="t">6</code></div>
1141 <div class="rhs"><code class="t">7</code></div>
1142 <div class="rhs"><code class="t">8</code></div>
1143 <div class="rhs"><code class="t">9</code></div>
1144 </div>
1145
1146 <p>If the phrase &ldquo;[empty]&rdquo; appears as the right-hand side of a production, it indicates that the production's
1147 right-hand side contains no terminals or nonterminals.</p>
1148
1149 <p>If the phrase &ldquo;[lookahead &notin; <var>set</var>]&rdquo; appears in the right-hand side of a production, it
1150 indicates that the production may not be used if the immediately following input token is a member of the given
1151 <var>set</var>. The <var>set</var> can be written as a list of terminals enclosed in curly brackets. For convenience, the
1152 set can also be written as a nonterminal, in which case it represents the set of all terminals to which that nonterminal
1153 could expand. If the <var>set</var> consists of a single terminal the phrase &ldquo;[lookahead &ne;
1154 <var>terminal</var>]&rdquo; may be used.</p>
1155
1156 <p>For example, given the definitions</p>
1157
1158 <div class="gp">
1159 <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
1160 <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>
1161 </div>
1162
1163 <div class="gp">
1164 <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">::</span></div>
1165 <div class="rhs"><span class="nt">DecimalDigit</span></div>
1166 <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
1167 </div>
1168
1169 <p>the definition</p>
1170
1171 <div class="gp">
1172 <div class="lhs"><span class="nt">LookaheadExample</span> <span class="geq">::</span></div>
1173 <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>
1174 <div class="rhs"><span class="nt">DecimalDigit</span> <span class="grhsannot">[lookahead &notin; <span class="nt">DecimalDigit</span>]</span></div>
1175 </div>
1176
1177 <p>matches either the letter <code>n</code> followed by one or more decimal digits the first of which is even, or a decimal
1178 digit not followed by another decimal digit.</p>
1179
1180 <p>If the phrase &ldquo;[no <span class="nt">LineTerminator</span> here]&rdquo; appears in the right-hand side of a
1181 production of the syntactic grammar, it indicates that the production is <i>a restricted production</i>: it may not be used
1182 if a <span class="nt">LineTerminator</span> occurs in the input stream at the indicated position. For example, the
1183 production:</p>
1184
1185 <div class="gp">
1186 <div class="lhs"><span class="nt">ThrowStatement</span> <span class="geq">:</span></div>
1187 <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>
1188 </div>
1189
1190 <p>indicates that the production may not be used if a <span class="nt">LineTerminator</span> occurs in the script between
1191 the <code>throw</code> token and the <span class="nt">Expression</span>.</p>
1192
1193 <p>Unless the presence of a <span class="nt">LineTerminator</span> is forbidden by a restricted production, any number of
1194 occurrences of <span class="nt">LineTerminator</span> may appear between any two consecutive tokens in the stream of input
1195 elements without affecting the syntactic acceptability of the script.</p>
1196
1197 <p>When an alternative in a production of the lexical grammar or the numeric string grammar appears to be a multi-code point
1198 token, it represents the sequence of code points that would make up such a token.</p>
1199
1200 <p>The right-hand side of a production may specify that certain expansions are not permitted by using the phrase
1201 &ldquo;<b>but not</b>&rdquo; and then indicating the expansions to be excluded. For example, the production:</p>
1202
1203 <div class="gp">
1204 <div class="lhs"><span class="nt">Identifier</span> <span class="geq">::</span></div>
1205 <div class="rhs"><span class="nt">IdentifierName</span> <span class="grhsmod">but not</span> <span class="nt">ReservedWord</span></div>
1206 </div>
1207
1208 <p>means that the nonterminal <span class="nt">Identifier</span> may be replaced by any sequence of code points that could
1209 replace <span class="nt">IdentifierName</span> provided that the same sequence of code points could not replace <span
1210 class="nt">ReservedWord</span>.</p>
1211
1212 <p>Finally, a few nonterminal symbols are described by a descriptive phrase in sans-serif type in cases where it would be
1213 impractical to list all the alternatives:</p>
1214
1215 <div class="gp">
1216 <div class="lhs"><span class="nt">SourceCharacter</span> <span class="geq">::</span></div>
1217 <div class="rhs"><span class="gprose">any Unicode code point</span></div>
1218 </div>
1219 </section>
1220 </section>
1221
1222 <section id="sec-algorithm-conventions">
1223 <h1><span class="secnum" id="sec-5.2"><a href="#sec-algorithm-conventions" title="link to this section">5.2</a></span>
1224 Algorithm Conventions</h1>
1225
1226 <p>The specification often uses a numbered list to specify steps in an algorithm. These algorithms are used to precisely
1227 specify the required semantics of ECMAScript language constructs. The algorithms are not intended to imply the use of any
1228 specific implementation technique. In practice, there may be more efficient algorithms available to implement a given
1229 feature.</p>
1230
1231 <p>Algorithms may be explicitly parameterized, in which case the names and usage of the parameters must be provided as part of
1232 the algorithm&rsquo;s definition. In order to facilitate their use in multiple parts of this specification, some algorithms,
1233 called <i>abstract</i> <i>operations</i>, are named and written in parameterized functional form so that they may be
1234 referenced by name from within other algorithms. Abstract operations are typically referenced using a functional application
1235 style such as <span style="font-family: Times New Roman">operationName(<i>arg1</i>, <i>arg2</i>)</span>. Some abstract
1236 operations are treated as polymorphically dispatched methods of class-like specification abstractions. Such method-like
1237 abstract operations are typically referenced using a method application style such as <span style="font-family: Times New
1238 Roman"><i>someValue</i>.operationName(<i>arg1</i>, <i>arg2</i>)</span>.</p>
1239
1240 <p>Algorithms may be associated with productions of one of the ECMAScript grammars. A production that has multiple alternative
1241 definitions will typically have a distinct algorithm for each alternative. When an algorithm is associated with a grammar
1242 production, it may reference the terminal and nonterminal symbols of the production alternative as if they were parameters of
1243 the algorithm. When used in this manner, nonterminal symbols refer to the actual alternative definition that is matched when
1244 parsing the source text.</p>
1245
1246 <p>When an algorithm is associated with a production alternative, the alternative is typically shown without any &ldquo;[
1247 ]&rdquo; grammar annotations. Such annotations should only affect the syntactic recognition of the alternative and have no
1248 effect on the associated semantics for the alternative.</p>
1249
1250 <p>Unless explicitly specified otherwise, all <a href="#sec-context-free-grammars">chain productions</a> have an implicit
1251 definition for every algorithm that might be applied to that production&rsquo;s left-hand side nonterminal. The implicit
1252 definition simply reapplies the same algorithm name with the same parameters, if any, to the <a
1253 href="#sec-context-free-grammars">chain production</a>&rsquo;s sole right-hand side nonterminal and then returns the result.
1254 For example, assume there is a production:</p>
1255
1256 <div class="gp">
1257 <div class="lhs"><span class="nt">Block</span> <span class="geq">:</span></div>
1258 <div class="rhs"><code class="t">{</code> <span class="nt">StatementList</span> <code class="t">}</code></div>
1259 </div>
1260
1261 <p>but there is no corresponding Evaluation algorithm that is explicitly specified for that production. If in some algorithm
1262 there is a statement of the form: &ldquo;<span style="font-family: Times New Roman">Return the result of evaluating
1263 <i>Block</i></span>&rdquo; it is implicit that an Evaluation algorithm exists of the form:</p>
1264
1265 <p><b>Runtime Semantics: Evaluation</b></p>
1266
1267 <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>
1268 <ol class="proc">
1269 <li>Return the result of evaluating <i>StatementList</i>.</li>
1270 </ol>
1271
1272 <p>For clarity of expression, algorithm steps may be subdivided into sequential substeps. Substeps are indented and may
1273 themselves be further divided into indented substeps. Outline numbering conventions are used to identify substeps with the
1274 first level of substeps labelled with lower case alphabetic characters and the second level of substeps labelled with lower
1275 case roman numerals. If more than three levels are required these rules repeat with the fourth level using numeric labels. For
1276 example:</p>
1277
1278 <ol class="proc">
1279 <li>Top-level step
1280 <ol class="block">
1281 <li>Substep.</li>
1282 <li>Substep.
1283 <ol class="block">
1284 <li>Subsubstep.
1285 <ol class="block">
1286 <li>Subsubsubstep
1287 <ol class="block">
1288 <li>Subsubsubsubstep
1289 <ol class="block">
1290 <li>Subsubsubsubsubstep</li>
1291 </ol>
1292 </li>
1293 </ol>
1294 </li>
1295 </ol>
1296 </li>
1297 </ol>
1298 </li>
1299 </ol>
1300 </li>
1301 </ol>
1302
1303 <p>A step or substep may be written as an &ldquo;if&rdquo; predicate that conditions its substeps. In this case, the substeps
1304 are only applied if the predicate is true. If a step or substep begins with the word &ldquo;else&rdquo;, it is a predicate
1305 that is the negation of the preceding &ldquo;if&rdquo; predicate step at the same level.</p>
1306
1307 <p>A step may specify the iterative application of its substeps.</p>
1308
1309 <p>A step that begins with &ldquo;Assert:&rdquo; asserts an invariant condition of its algorithm. Such assertions are used to
1310 make explicit algorithmic invariants that would otherwise be implicit. Such assertions add no additional semantic requirements
1311 and hence need not be checked by an implementation. They are used simply to clarify algorithms.</p>
1312
1313 <p>Mathematical operations such as addition, subtraction, negation, multiplication, division, and the mathematical functions
1314 defined later in this clause should always be understood as computing exact mathematical results on mathematical real numbers,
1315 which unless otherwise noted do not include infinities and do not include a negative zero that is distinguished from positive
1316 zero. Algorithms in this standard that model floating-point arithmetic include explicit steps, where necessary, to handle
1317 infinities and signed zero and to perform rounding. If a mathematical operation or function is applied to a floating-point
1318 number, it should be understood as being applied to the exact mathematical value represented by that floating-point number;
1319 such a floating-point number must be finite, and if it is <span class="value">+0</span> or <span class="value">&minus;0</span>
1320 then the corresponding mathematical value is simply <span class="value">0</span>.</p>
1321
1322 <p>The mathematical function <span style="font-family: Times New Roman">abs(<i>x</i>)</span> produces the absolute value of
1323 <var>x</var>, which is <span style="font-family: Times New Roman">&minus;<i>x</i></span> if <var>x</var> is negative (less
1324 than zero) and otherwise is <var>x</var> itself.</p>
1325
1326 <p>The mathematical function <span style="font-family: Times New Roman">sign(<i>x</i>)</span> produces <span
1327 style="font-family: Times New Roman">1</span> if <var>x</var> is positive and <span style="font-family: Times New
1328 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>
1329 is zero.</p>
1330
1331 <p>The mathematical function <span style="font-family: Times New Roman">min(<i>x</i><sub>1</sub>,</span> <span
1332 style="font-family: Times New Roman"><i>x</i><sub>2</sub>, ..., <i>x</i><sub>n</sub>)</span> produces the mathematically
1333 smallest of <span style="font-family: Times New Roman"><i>x</i><sub>1</sub></span> through <span style="font-family: Times New
1334 Roman"><i>x</i><sub>n</sub></span>. The mathematical function <span style="font-family: Times New
1335 Roman">max(<i>x</i><sub>1</sub>,</span> <span style="font-family: Times New Roman"><i>x</i><sub>2</sub>, ...,
1336 <i>x</i><sub>n</sub>)</span> produces the mathematically largest of <span style="font-family: Times New
1337 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
1338 and range of these mathematical functions include +<b>&infin;</b> and <b>&minus;&infin;</b>.</p>
1339
1340 <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
1341 finite and nonzero) computes a value <var>k</var> of the same sign as <var>y</var> (or zero) such that <span
1342 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
1343 style="font-family: Times New Roman">&times;</span> <var>y</var> for some integer <var>q</var>.</p>
1344
1345 <p>The mathematical function <span style="font-family: Times New Roman">floor(<i>x</i>)</span> produces the largest integer
1346 (closest to positive infinity) that is not larger than <var>x</var>.</p>
1347
1348 <div class="note">
1349 <p><span class="nh">NOTE</span> floor(<i>x</i>) = <i>x</i>&minus;(<i>x</i> modulo 1).</p>
1350 </div>
1351 </section>
1352
1353 <section id="sec-static-semantic-rules">
1354 <h1><span class="secnum" id="sec-5.3"><a href="#sec-static-semantic-rules" title="link to this section">5.3</a></span> Static
1355 Semantic Rules</h1>
1356
1357 <p>Context-free grammars are not sufficiently powerful to express all the rules that define whether a stream of input elements
1358 form a valid ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span> that may be evaluated. In some
1359 situations additional rules are needed that may be expressed using either ECMAScript algorithm conventions or prose
1360 requirements. Such rules are always associated with a production of a grammar and are called the <i>static semantics</i> of
1361 the production.</p>
1362
1363 <p>Static Semantic Rules have names and typically are defined using an algorithm. Named Static Semantic Rules are associated
1364 with grammar productions and a production that has multiple alternative definitions will typically have for each alternative a
1365 distinct algorithm for each applicable named static semantic rule.</p>
1366
1367 <p>Unless otherwise specified every grammar production alternative in this specification implicitly has a definition for a
1368 static semantic rule named <span style="font-family: Times New Roman">Contains</span> which takes an argument named
1369 <var>symbol</var> whose value is a terminal or nonterminal of the grammar that includes the associated production. The default
1370 definition of <span style="font-family: Times New Roman">Contains</span> is:</p>
1371
1372 <ol class="proc">
1373 <li>For each terminal and nonterminal grammar symbol, <i>sym</i>, in the definition of this production do
1374 <ol class="block">
1375 <li>If <i>sym</i> is the same grammar symbol as <i>symbol</i>, return <b>true</b>.</li>
1376 <li>If <i>sym</i> is a nonterminal, then
1377 <ol class="block">
1378 <li>Let <i>contained</i> be the result of <i>sym</i> Contains <i>symbol</i>.</li>
1379 <li>If <i>contained</i> is <b>true</b>, return <b>true</b>.</li>
1380 </ol>
1381 </li>
1382 </ol>
1383 </li>
1384 <li>Return <b>false</b>.</li>
1385 </ol>
1386
1387 <p>The above definition is explicitly over-ridden for specific productions.</p>
1388
1389 <p>A special kind of static semantic rule is an Early Error Rule. Early error rules define early error conditions (see <a
1390 href="#sec-error-handling-and-language-extensions">clause 16</a>) that are associated with specific grammar productions.
1391 Evaluation of most early error rules are not explicitly invoked within the algorithms of this specification. A conforming
1392 implementation must, prior to the first evaluation of a <span class="nt">Script</span>, validate all of the early error rules
1393 of the productions used to parse that <span class="nt">Script</span>. If any of the early error rules are violated the <span
1394 class="nt">Script</span> is invalid and cannot be evaluated.</p>
1395 </section>
1396 </section>
1397
1398 <section id="sec-ecmascript-data-types-and-values">
1399 <div class="front">
1400 <h1><span class="secnum" id="sec-6"><a href="#sec-ecmascript-data-types-and-values" title="link to this section">6</a></span>
1401 ECMAScript Data Types and Values</h1>
1402
1403 <p>Algorithms within this specification manipulate values each of which has an associated type. The possible value types are
1404 exactly those defined in this clause. Types are further subclassified into ECMAScript language types and specification
1405 types.</p>
1406
1407 <p>Within this specification, the notation &ldquo;<span style="font-family: Times New Roman">Type(<i>x</i>)</span>&rdquo; is
1408 used as shorthand for &ldquo;<span style="font-family: Times New Roman">the type of <i>x</i></span>&rdquo; where &ldquo;<span
1409 style="font-family: Times New Roman">type</span>&rdquo; refers to the ECMAScript language and specification types defined in
1410 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
1411 of any type&rdquo;.</p>
1412 </div>
1413
1414 <section id="sec-ecmascript-language-types">
1415 <div class="front">
1416 <h1><span class="secnum" id="sec-6.1"><a href="#sec-ecmascript-language-types" title="link to this section">6.1</a></span>
1417 ECMAScript Language Types</h1>
1418
1419 <p>An ECMAScript language type corresponds to values that are directly manipulated by an ECMAScript programmer using the
1420 ECMAScript language. The ECMAScript language types are Undefined, Null, Boolean, String, Symbol, Number, and Object. An
1421 ECMAScript language value is a value that is characterized by an ECMAScript language type.</p>
1422 </div>
1423
1424 <section id="sec-ecmascript-language-types-undefined-type">
1425 <h1><span class="secnum" id="sec-6.1.1"><a href="#sec-ecmascript-language-types-undefined-type"
1426 title="link to this section">6.1.1</a></span> The Undefined Type</h1>
1427
1428 <p>The Undefined type has exactly one value, called <b>undefined</b>. Any variable that has not been assigned a value has
1429 the value <b>undefined</b>.</p>
1430 </section>
1431
1432 <section id="sec-ecmascript-language-types-null-type">
1433 <h1><span class="secnum" id="sec-6.1.2"><a href="#sec-ecmascript-language-types-null-type"
1434 title="link to this section">6.1.2</a></span> The Null Type</h1>
1435
1436 <p>The Null type has exactly one value, called <b>null</b>.</p>
1437 </section>
1438
1439 <section id="sec-ecmascript-language-types-boolean-type">
1440 <h1><span class="secnum" id="sec-6.1.3"><a href="#sec-ecmascript-language-types-boolean-type"
1441 title="link to this section">6.1.3</a></span> The Boolean Type</h1>
1442
1443 <p>The Boolean type represents a logical entity having two values, called <b>true</b> and <b>false</b>.</p>
1444 </section>
1445
1446 <section id="sec-ecmascript-language-types-string-type">
1447 <h1><span class="secnum" id="sec-6.1.4"><a href="#sec-ecmascript-language-types-string-type"
1448 title="link to this section">6.1.4</a></span> The String Type</h1>
1449
1450 <p>The String type is the set of all finite ordered sequences of zero or more 16-bit unsigned integer values
1451 (&ldquo;elements&rdquo;). The String type is generally used to represent textual data in a running ECMAScript program, in
1452 which case each element in the String is treated as a UTF-16 code unit value. Each element is regarded as occupying a
1453 position within the sequence. These positions are indexed with nonnegative integers. The first element (if any) is at index
1454 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)
1455 within it. The empty String has length zero and therefore contains no elements.</p>
1456
1457 <p>Where ECMAScript operations interpret String values, each element is interpreted as a single UTF-16 code unit. However,
1458 ECMAScript does not place any restrictions or requirements on the sequence of code units in a String value, so they may be
1459 ill-formed when interpreted as UTF-16 code unit sequences. Operations that do not interpret String contents treat them as
1460 sequences of undifferentiated 16-bit unsigned integers. The function <code><a
1461 href="#sec-string.prototype.normalize">String.prototype.normalize</a></code> (<a href="#sec-string.prototype.normalize">see
1462 21.1.3.12</a>) can be used to explicitly normalize a string value. <code><a
1463 href="#sec-string.prototype.localecompare">String.prototype.localeCompare</a></code> (<a
1464 href="#sec-string.prototype.localecompare">see 21.1.3.10</a>) internally normalizes strings values, but no other operations
1465 implicitly normalize the strings upon which they operate. Only operations that are explicitly specified to be language or
1466 locale sensitive produce language-sensitive results.</p>
1467
1468 <div class="note">
1469 <p><span class="nh">NOTE</span> The rationale behind this design was to keep the implementation of Strings as simple and
1470 high-performing as possible. If ECMAScript source text is in Normalized Form C, string literals are guaranteed to also be
1471 normalized, as long as they do not contain any Unicode escape sequences.</p>
1472 </div>
1473
1474 <p>Some operations interpret String contents as UTF-16 encoded Unicode code points. In that case the interpretation is:</p>
1475
1476 <ul>
1477 <li>
1478 <p>A code unit in the range <span style="font-family: Times New Roman">0</span> to <span style="font-family: Times New
1479 Roman">0xD7FF</span> or in the range <span style="font-family: Times New Roman">0xE000</span> to <span
1480 style="font-family: Times New Roman">0xFFFF</span> is interpreted as a code point with the same value.</p>
1481 </li>
1482
1483 <li>
1484 <p>A sequence of two code units, where the first code unit <var>c1</var> is in the range <span style="font-family: Times
1485 New Roman">0xD800</span> to <span style="font-family: Times New Roman">0xDBFF</span> and the second code unit
1486 <var>c2</var> is in the range <span style="font-family: Times New Roman">0xDC00</span> to <span style="font-family:
1487 Times New Roman">0xDFFF</span>, is a surrogate pair and is interpreted as a code point with the value (<var>c1</var> -
1488 <span style="font-family: Times New Roman">0xD800</span>) &times; <span style="font-family: Times New
1489 Roman">0x400</span> + (<var>c2</var> &ndash; <span style="font-family: Times New Roman">0xDC00</span>) + <span
1490 style="font-family: Times New Roman">0x10000</span>. (See <a href="#sec-utf16decode">10.1.2</a>)</p>
1491 </li>
1492
1493 <li>
1494 <p>A code unit that is in the range <span style="font-family: Times New Roman">0xD800</span> to <span
1495 style="font-family: Times New Roman">0xDFFF</span>, but is not part of a surrogate pair, is interpreted as a code point
1496 with the same value.</p>
1497 </li>
1498 </ul>
1499 </section>
1500
1501 <section id="sec-ecmascript-language-types-symbol-type">
1502 <div class="front">
1503 <h1><span class="secnum" id="sec-6.1.5"><a href="#sec-ecmascript-language-types-symbol-type"
1504 title="link to this section">6.1.5</a></span> The Symbol Type</h1>
1505
1506 <p>The Symbol type is the set of all non-String values that may be used as the key of an Object property (<a
1507 href="#sec-object-type">6.1.7</a>).</p>
1508
1509 <p>Each possible Symbol value is unique and immutable.</p>
1510
1511 <p>Each Symbol value immutably holds an associated value called [[Description]] that is either <span
1512 class="value">undefined</span> or a String value.</p>
1513 </div>
1514
1515 <section id="sec-well-known-symbols">
1516 <h1><span class="secnum" id="sec-6.1.5.1"><a href="#sec-well-known-symbols"
1517 title="link to this section">6.1.5.1</a></span> Well-Known Symbols</h1>
1518
1519 <p>Well-known symbols are built-in Symbol values that are explicitly referenced by algorithms of this specification. They
1520 are typically used as the keys of properties whose values serve as extension points of a specification algorithm. Unless
1521 otherwise specified, well-known symbols values are shared by all Code Realms (<a href="#sec-code-realms">8.2</a>).</p>
1522
1523 <p>Within this specification a well-known symbol is referred to by using a notation of the form @@name, where
1524 &ldquo;name&rdquo; is one of the values listed in <a href="#table-1">Table 1</a>.</p>
1525
1526 <figure>
1527 <figcaption><span id="table-1">Table 1</span>&mdash; Well-known Symbols</figcaption>
1528 <table class="real-table">
1529 <tr>
1530 <th>Specification Name</th>
1531 <th>[[Description]]</th>
1532 <th>Value and Purpose</th>
1533 </tr>
1534 <tr>
1535 <td>@@hasInstance</td>
1536 <td><code>"Symbol.hasInstance"</code></td>
1537 <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>
1538 </tr>
1539 <tr>
1540 <td>@@isConcatSpreadable</td>
1541 <td><code>"Symbol.isConcatSpreadable"</code></td>
1542 <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>
1543 </tr>
1544 <tr>
1545 <td>@@iterator</td>
1546 <td><code>"Symbol.iterator"</code></td>
1547 <td>A method that returns the default Iterator for an object. Called by the semantics of the for-of statement.</td>
1548 </tr>
1549 <tr>
1550 <td>@@match</td>
1551 <td><code>"Symbol.match"</code></td>
1552 <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>
1553 </tr>
1554 <tr>
1555 <td>@@replace</td>
1556 <td><code>"Symbol.replace"</code></td>
1557 <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>
1558 </tr>
1559 <tr>
1560 <td>@@search</td>
1561 <td><code>"Symbol.search"</code></td>
1562 <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>
1563 </tr>
1564 <tr>
1565 <td>@@species</td>
1566 <td><code>"Symbol.species"</code></td>
1567 <td>A function valued property that is the constructor function that is used to create derived objects.</td>
1568 </tr>
1569 <tr>
1570 <td>@@split</td>
1571 <td><code>"Symbol.split"</code></td>
1572 <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>
1573 </tr>
1574 <tr>
1575 <td>@@toPrimitive</td>
1576 <td><code>"Symbol.toPrimitive"</code></td>
1577 <td>A method that converts an object to a corresponding primitive value. Called by the <a href="#sec-toprimitive">ToPrimitive</a> abstract operation.</td>
1578 </tr>
1579 <tr>
1580 <td>@@toStringTag</td>
1581 <td><code>"Symbol.toStringTag"</code></td>
1582 <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>
1583 </tr>
1584 <tr>
1585 <td>@@unscopables</td>
1586 <td><code>"Symbol.unscopables"</code></td>
1587 <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>
1588 </tr>
1589 </table>
1590 </figure>
1591 </section>
1592 </section>
1593
1594 <section id="sec-ecmascript-language-types-number-type">
1595 <h1><span class="secnum" id="sec-6.1.6"><a href="#sec-ecmascript-language-types-number-type"
1596 title="link to this section">6.1.6</a></span> The Number Type</h1>
1597
1598 <p>The Number type has exactly <span style="font-family: Times New Roman">18437736874454810627</span> (that is, <span
1599 style="font-family: Times New Roman">2<sup>64</sup>&minus;2<sup>53</sup>+3</span>) values, representing the double-precision
1600 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic, except that the <span
1601 style="font-family: Times New Roman">9007199254740990</span> (that is, <span style="font-family: Times New
1602 Roman">2<sup>53</sup>&minus;2</span>) distinct &ldquo;Not-a-Number&rdquo; values of the IEEE Standard are represented in
1603 ECMAScript as a single special <b>NaN</b> value. (Note that the <b>NaN</b> value is produced by the program expression
1604 <code>NaN</code>.) In some implementations, external code might be able to detect a difference between various Not-a-Number
1605 values, but such behaviour is implementation-dependent; to ECMAScript code, all NaN values are indistinguishable from each
1606 other.</p>
1607
1608 <div class="note">
1609 <p><span class="nh">NOTE</span> The bit pattern that might be observed in an ArrayBuffer (<a
1610 href="#sec-arraybuffer-objects">see 24.1</a>) after a Number value has been stored into it is not necessarily the same as
1611 the internal representation of that Number value used by the ECMAScript implementation.</p>
1612 </div>
1613
1614 <p>There are two other special values, called <b>positive Infinity</b> and <b>negative Infinity</b>. For brevity, these
1615 values are also referred to for expository purposes by the symbols <span class="value">+&infin;</span> and <span
1616 class="value">&minus;&infin;</span>, respectively. (Note that these two infinite Number values are produced by the program
1617 expressions <code>+Infinity</code> (or simply <code>Infinity</code>) and <code>-Infinity</code>.)</p>
1618
1619 <p>The other <span style="font-family: Times New Roman">18437736874454810624</span> (that is, <span style="font-family:
1620 Times New Roman">2<sup>64</sup>&minus;2<sup>53</sup></span>) values are called the finite numbers. Half of these are
1621 positive numbers and half are negative numbers; for every finite positive Number value there is a corresponding negative
1622 value having the same magnitude.</p>
1623
1624 <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
1625 for expository purposes by the symbols <span class="value">+0</span> and <span class="value">&minus;0</span>, respectively.
1626 (Note that these two different zero Number values are produced by the program expressions <code>+0</code> (or simply
1627 <code>0</code>) and <code>-0</code>.)</p>
1628
1629 <p>The <span style="font-family: Times New Roman">18437736874454810622</span> (that is, <span style="font-family: Times New
1630 Roman">2<sup>64</sup>&minus;2<sup>53</sup>&minus;2</span>) finite nonzero values are of two kinds:</p>
1631
1632 <p><span style="font-family: Times New Roman">18428729675200069632</span> (that is, <span style="font-family: Times New
1633 Roman">2<sup>64</sup>&minus;2<sup>54</sup></span>) of them are normalized, having the form</p>
1634
1635 <div class="math-display"><i>s</i> &times; <i>m</i> &times; 2<sup><i>e</i></sup></div>
1636
1637 <p>where <var>s</var> is <span style="font-family: Times New Roman">+1</span> or <span style="font-family: Times New
1638 Roman">&minus;1</span>, <var>m</var> is a positive integer less than <span style="font-family: Times New
1639 Roman">2<sup>53</sup></span> but not less than <span style="font-family: Times New Roman">2<sup>52</sup></span>, and
1640 <var>e</var> is an integer ranging from <span style="font-family: Times New Roman">&minus;1074</span> to <span
1641 style="font-family: Times New Roman">971</span>, inclusive.</p>
1642
1643 <p>The remaining <span style="font-family: Times New Roman">9007199254740990</span> (that is, <span style="font-family:
1644 Times New Roman">2<sup>53</sup>&minus;2</span>) values are denormalized, having the form</p>
1645
1646 <div class="math-display"><i>s</i> &times; <i>m</i> &times; 2<sup><i>e</i></sup></div>
1647
1648 <p>where <var>s</var> is <span style="font-family: Times New Roman">+1</span> or <span style="font-family: Times New
1649 Roman">&minus;1</span>, <var>m</var> is a positive integer less than <span style="font-family: Times New
1650 Roman">2<sup>52</sup></span>, and <var>e</var> is <span style="font-family: Times New Roman">&minus;1074</span>.</p>
1651
1652 <p>Note that all the positive and negative integers whose magnitude is no greater than <span style="font-family: Times New
1653 Roman">2<sup>53</sup></span> are representable in the Number type (indeed, the integer <span style="font-family: Times New
1654 Roman">0</span> has two representations, <code>+0</code> and <code>-0</code>).</p>
1655
1656 <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
1657 the two forms shown above) is odd. Otherwise, it has an <i>even significand</i>.</p>
1658
1659 <p>In this specification, the phrase &ldquo;<span style="font-family: Times New Roman">the Number value for
1660 <i>x</i></span>&rdquo; where <var>x</var> represents an exact nonzero real mathematical quantity (which might even be an
1661 irrational number such as <span style="font-family: Times New Roman">&pi;</span>) means a Number value chosen in the
1662 following manner. Consider the set of all finite values of the Number type, with <span class="value">&minus;0</span> removed
1663 and with two additional values added to it that are not representable in the Number type, namely <span style="font-family:
1664 Times New Roman">2<sup>1024</sup></span> (which is <span style="font-family: Times New Roman">+1 &times;
1665 2<sup>53</sup></span> <span style="font-family: Times New Roman">&times; 2<sup>971</sup></span>) and <span
1666 style="font-family: Times New Roman">&minus;2<sup>1024</sup></span> (which is <span style="font-family: Times New
1667 Roman">&minus;1 &times; 2<sup>53</sup></span> <span style="font-family: Times New Roman">&times; 2<sup>971</sup></span>).
1668 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
1669 one with an even significand is chosen; for this purpose, the two extra values <span style="font-family: Times New
1670 Roman">2<sup>1024</sup></span> and <span style="font-family: Times New Roman">&minus;2<sup>1024</sup></span> are considered
1671 to have even significands. Finally, if <span style="font-family: Times New Roman">2<sup>1024</sup></span> was chosen,
1672 replace it with <span class="value">+&infin;</span>; if <span style="font-family: Times New
1673 Roman">&minus;2<sup>1024</sup></span> was chosen, replace it with <span class="value">&minus;&infin;</span>; if <span
1674 class="value">+0</span> was chosen, replace it with <span class="value">&minus;0</span> if and only if <var>x</var> is less
1675 than zero; any other chosen value is used unchanged. The result is the Number value for <var>x</var>. (This procedure
1676 corresponds exactly to the behaviour of the IEEE 754 &ldquo;round to nearest, ties to even&rdquo; mode.)</p>
1677
1678 <p>Some ECMAScript operators deal only with integers in specific ranges such as <span style="font-family: Times New
1679 Roman">&minus;2<sup>31</sup></span> through <span style="font-family: Times New Roman">2<sup>31</sup>&minus;1</span>,
1680 inclusive, or in the range <span style="font-family: Times New Roman">0</span> through <span style="font-family: Times New
1681 Roman">2<sup>16</sup>&minus;1</span>, inclusive. These operators accept any value of the Number type but first convert each
1682 such value to an integer value in the expected range. See the descriptions of the numeric conversion operations in <a
1683 href="#sec-type-conversion">7.1</a>.</p>
1684 </section>
1685
1686 <section id="sec-object-type">
1687 <div class="front">
1688 <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
1689 Object Type</h1>
1690
1691 <p>An Object is logically a collection of properties. Each property is either a data property, or an accessor
1692 property:</p>
1693
1694 <ul>
1695 <li>
1696 <p>A <i>data property</i> associates a key value with an <a href="#sec-ecmascript-language-types">ECMAScript language
1697 value</a> and a set of Boolean attributes.</p>
1698 </li>
1699
1700 <li>
1701 <p>An <i>accessor property</i> associates a key value with one or two accessor functions, and a set of Boolean
1702 attributes. The accessor functions are used to store or retrieve an <a
1703 href="#sec-ecmascript-language-types">ECMAScript language value</a> that is associated with the property.</p>
1704 </li>
1705 </ul>
1706
1707 <p>Properties are identified using key values. A property key value is either an ECMAScript String value or a Symbol
1708 value. All String and Symbol values, including the empty string, are valid as property keys. A <i>property name</i> is a
1709 property key that is a String value.</p>
1710
1711 <p>An <i>integer index</i> is a String-valued property key that is a canonical numeric String (<a
1712 href="#sec-canonicalnumericindexstring">see 7.1.16</a>) and whose numeric value is either <span style="font-family: Times
1713 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
1714 numeric value <var>i</var> is in the range <span style="font-family: Times New Roman">+0 &le; <i>i</i></span> <span
1715 style="font-family: Times New Roman">&lt; 2<sup>32</sup>&minus;1.</span></p>
1716
1717 <p>Property keys are used to access properties and their values. There are two kinds of access for properties: <i>get</i>
1718 and <i>set</i>, corresponding to value retrieval and assignment, respectively. The properties accessible via get and set
1719 access includes both <i>own properties</i> that are a direct part of an object and <i>inherited properties</i> which are
1720 provided by another associated object via a property inheritance relationship. Inherited properties may be either own or
1721 inherited properties of the associated object. Each own property of an object must each have a key value that is distinct
1722 from the key values of the other own properties of that object.</p>
1723
1724 <p>All objects are logically collections of properties, but there are multiple forms of objects that differ in their
1725 semantics for accessing and manipulating their properties. O<i>rdinary objects</i> are the most common form of objects and
1726 have the default object semantics. An <i>exotic object</i> is any form of object whose property semantics differ in any
1727 way from the default semantics.</p>
1728 </div>
1729
1730 <section id="sec-property-attributes">
1731 <h1><span class="secnum" id="sec-6.1.7.1"><a href="#sec-property-attributes"
1732 title="link to this section">6.1.7.1</a></span> Property Attributes</h1>
1733
1734 <p>Attributes are used in this specification to define and explain the state of Object properties. A data property
1735 associates a key value with the attributes listed in <a href="#table-2">Table 2</a>.</p>
1736
1737 <figure>
1738 <figcaption><span id="table-2">Table 2</span> &mdash; Attributes of a Data Property</figcaption>
1739 <table class="real-table">
1740 <tr>
1741 <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>
1742 <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>
1743 <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Description</th>
1744 </tr>
1745 <tr>
1746 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Value]]</td>
1747 <td style="border-bottom: 1px solid black; border-right: 1px solid black">Any <a href="#sec-ecmascript-language-types">ECMAScript language type</a></td>
1748 <td style="border-bottom: 1px solid black; border-right: 1px solid black">The value retrieved by a get access of the property.</td>
1749 </tr>
1750 <tr>
1751 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Writable]]</td>
1752 <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
1753 <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>
1754 </tr>
1755 <tr>
1756 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Enumerable]]</td>
1757 <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
1758 <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>
1759 </tr>
1760 <tr>
1761 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Configurable]]</td>
1762 <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
1763 <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>
1764 </tr>
1765 </table>
1766 </figure>
1767
1768 <p>An accessor property associates a key value with the attributes listed in <a href="#table-3">Table 3</a>.</p>
1769
1770 <figure>
1771 <figcaption><span id="table-3">Table 3</span> &mdash; Attributes of an Accessor Property</figcaption>
1772 <table class="real-table">
1773 <tr>
1774 <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>
1775 <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>
1776 <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Description</th>
1777 </tr>
1778 <tr>
1779 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000">[[Get]]</td>
1780 <td style="border-bottom: 1px solid black; border-right: 1px solid black">Object <i>or</i> Undefined</td>
1781 <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>
1782 </tr>
1783 <tr>
1784 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Set]]</td>
1785 <td style="border-bottom: 1px solid black; border-right: 1px solid black">Object <i>or</i> Undefined</td>
1786 <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>
1787 </tr>
1788 <tr>
1789 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Enumerable]]</td>
1790 <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
1791 <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>
1792 </tr>
1793 <tr>
1794 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Configurable]]</td>
1795 <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
1796 <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>
1797 </tr>
1798 </table>
1799 </figure>
1800
1801 <p>If the initial values of a property&rsquo;s attributes are not explicitly specified by this specification, the default
1802 value defined in <a href="#table-4">Table 4</a> is used.</p>
1803
1804 <figure>
1805 <figcaption><span id="table-4">Table 4</span> &mdash; Default Attribute Values</figcaption>
1806 <table class="real-table">
1807 <tr>
1808 <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>
1809 <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>
1810 </tr>
1811 <tr>
1812 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Value]]</td>
1813 <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>
1814 </tr>
1815 <tr>
1816 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000">[[Get]]</td>
1817 <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>undefined</b></td>
1818 </tr>
1819 <tr>
1820 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Set]]</td>
1821 <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>undefined</b></td>
1822 </tr>
1823 <tr>
1824 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Writable]]</td>
1825 <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
1826 </tr>
1827 <tr>
1828 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Enumerable]]</td>
1829 <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
1830 </tr>
1831 <tr>
1832 <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Configurable]]</td>
1833 <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
1834 </tr>
1835 </table>
1836 </figure>
1837 </section>
1838
1839 <section id="sec-object-internal-methods-and-internal-slots">
1840 <h1><span class="secnum" id="sec-6.1.7.2"><a href="#sec-object-internal-methods-and-internal-slots"
1841 title="link to this section">6.1.7.2</a></span> Object Internal Methods and Internal Slots</h1>
1842
1843 <p>The actual semantics of objects, in ECMAScript, are specified via algorithms called <i>internal methods</i>. Each
1844 object in an ECMAScript engine is associated with a set of internal methods that defines its runtime behaviour. These
1845 internal methods are not part of the ECMAScript language. They are defined by this specification purely for expository
1846 purposes. However, each object within an implementation of ECMAScript must behave as specified by the internal methods
1847 associated with it. The exact manner in which this is accomplished is determined by the implementation.</p>
1848
1849 <p>Internal method names are polymorphic. This means that different object values may perform different algorithms when a
1850 common internal method name is invoked upon them. That actual object upon which an internal method is invoked is the
1851 &ldquo;target&rdquo; of the invocation. If, at runtime, the implementation of an algorithm attempts to use an internal
1852 method of an object that the object does not support, a <b>TypeError</b> exception is thrown.</p>
1853
1854 <p>Internal slots correspond to internal state that is associated with objects and used by various ECMAScript
1855 specification algorithms. Internal slots are not object properties and they are not inherited. Depending upon the specific
1856 internal slot specification, such state may consist of values of any <a href="#sec-ecmascript-language-types">ECMAScript
1857 language type</a> or of specific ECMAScript specification type values. Unless explicitly specified otherwise, internal
1858 slots are allocated as part of the process of creating an object and may not be dynamically added to an object. Unless
1859 specified otherwise, the initial value of an internal slot is the value <span class="value">undefined</span>. Various
1860 algorithms within this specification create objects that have internal slots. However, the ECMAScript language provides no
1861 direct way to associate internal slots with an object.</p>
1862
1863 <p>Internal methods and internal slots are identified within this specification using names enclosed in double square
1864 brackets [[ ]].</p>
1865
1866 <p><a href="#table-5">Table 5</a> summarizes the <i>essential internal methods</i> used by this specification that are
1867 applicable to all objects created or manipulated by ECMAScript code. Every object must have algorithms for all of the
1868 essential internal methods. However, all objects do not necessarily use the same algorithms for those methods.</p>
1869
1870 <p>The &ldquo;Signature&rdquo; column of <a href="#table-5">Table 5</a> and other similar tables describes the invocation
1871 pattern for each internal method. The invocation pattern always includes a parenthesized list of descriptive parameter
1872 names. If a parameter name is the same as an ECMAScript type name then the name describes the required type of the
1873 parameter value. If an internal method explicitly returns a value, its parameter list is followed by the symbol
1874 &ldquo;&rarr;&rdquo; and the type name of the returned value. The type names used in signatures refer to the types defined
1875 in <a href="#sec-ecmascript-data-types-and-values">clause 6</a> augmented by the following additional names.
1876 &ldquo;<i>any</i>&rdquo; means the value may be any <a href="#sec-ecmascript-language-types">ECMAScript language type</a>.
1877 An internal method implicitly returns a <a href="#sec-completion-record-specification-type">Completion Record</a> as
1878 described in <a href="#sec-completion-record-specification-type">6.2.2</a>. In addition to its parameters, an internal
1879 method always has access to the object that is the target of the method invocation.</p>
1880
1881 <figure>
1882 <figcaption><span id="table-5">Table 5</span> &mdash; Essential Internal Methods</figcaption>
1883 <table class="real-table">
1884 <tr>
1885 <th>Internal Method</th>
1886 <th>Signature</th>
1887 <th>Description</th>
1888 </tr>
1889 <tr>
1890 <td>[[GetPrototypeOf]]</td>
1891 <td>() <b><i>&rarr;</i></b> Object or Null</td>
1892 <td>Determine the object that provides inherited properties for this object. A <b>null</b> value indicates that there are no inherited properties.</td>
1893 </tr>
1894 <tr>
1895 <td>[[SetPrototypeOf]]</td>
1896 <td>(<i>Object</i> or Null) <b><i>&rarr;</i></b> Boolean</td>
1897 <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>
1898 </tr>
1899 <tr>
1900 <td>[[IsExtensible]]</td>
1901 <td>( ) <b><i>&rarr;</i></b> Boolean</td>
1902 <td>Determine whether it is permitted to add additional properties to this object.</td>
1903 </tr>
1904 <tr>
1905 <td>[[PreventExtensions]]</td>
1906 <td>( ) <b><i>&rarr;</i></b> Boolean</td>
1907 <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>
1908 </tr>
1909 <tr>
1910 <td>[[GetOwnProperty]]</td>
1911 <td>(<i>propertyKey</i>) &rarr; Undefined or <a href="#sec-property-descriptor-specification-type">Property Descriptor</a></td>
1912 <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>
1913 </tr>
1914 <tr>
1915 <td>[[HasProperty]]</td>
1916 <td>(<i>propertyKey</i>) <b><i>&rarr;</i></b> Boolean</td>
1917 <td>Return a Boolean value indicating whether this object already has either an own or inherited property whose key is <i>propertyKey</i>.</td>
1918 </tr>
1919 <tr>
1920 <td>[[Get]]</td>
1921 <td>(<i>propertyKey</i>, <i>Receiver</i>) <i><b>&rarr;</b> any</i></td>
1922 <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>
1923 </tr>
1924 <tr>
1925 <td>[[Set]]</td>
1926 <td>(<i>propertyKey</i>,<i>value</i>, <i>Receiver</i>) <br><i><b>&rarr;</b> Boolean</i></td>
1927 <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>
1928 </tr>
1929 <tr>
1930 <td>[[Delete]]</td>
1931 <td>(<i>propertyKey</i>) <b><i>&rarr;</i></b> Boolean</td>
1932 <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>
1933 </tr>
1934 <tr>
1935 <td>[[DefineOwnProperty]]</td>
1936 <td>(<i>propertyKey,PropertyDescriptor</i>)<b><i><br>&rarr;</i></b> Boolean</td>
1937 <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>
1938 </tr>
1939 <tr>
1940 <td>[[Enumerate]]</td>
1941 <td>()<b><i>&rarr;</i></b>Object</td>
1942 <td>Return an iterator object that produces the keys of the string-keyed enumerable properties of the object.</td>
1943 </tr>
1944 <tr>
1945 <td>[[OwnPropertyKeys]]</td>
1946 <td>()<b><i>&rarr;</i></b><a href="#sec-list-and-record-specification-type">List</a> of propertyKey</td>
1947 <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>
1948 </tr>
1949 </table>
1950 </figure>
1951
1952 <p><a href="#table-6">Table 6</a> summarizes additional essential internal methods that are supported by objects that may
1953 be called as functions. A <i>function object</i> is an object that supports the [[Call]] internal methods. A
1954 <i>constructor</i> (also referred to as a <i>constructor function</i>) is a function object that supports the
1955 [[Construct]] internal method.</p>
1956
1957 <figure>
1958 <figcaption><span id="table-6">Table 6</span> &mdash; Additional Essential Internal Methods of Function Objects</figcaption>
1959 <table class="real-table">
1960 <tr>
1961 <th>Internal Method</th>
1962 <th>Signature</th>
1963 <th>Description</th>
1964 </tr>
1965 <tr>
1966 <td>[[Call]]</td>
1967 <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>
1968 <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>
1969 </tr>
1970 <tr>
1971 <td>[[Construct]]</td>
1972 <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>
1973 <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>
1974 </tr>
1975 </table>
1976 </figure>
1977
1978 <p>The semantics of the essential internal methods for ordinary objects and standard exotic objects are specified in <a
1979 href="#sec-ordinary-and-exotic-objects-behaviours">clause 9</a>. If any specified use of an internal method of an exotic
1980 object is not supported by an implementation, that usage must throw a <b>TypeError</b> exception when attempted.</p>
1981 </section>
1982
1983 <section id="sec-invariants-of-the-essential-internal-methods">
1984 <h1><span class="secnum" id="sec-6.1.7.3"><a href="#sec-invariants-of-the-essential-internal-methods"
1985 title="link to this section">6.1.7.3</a></span> Invariants of the Essential Internal Methods</h1>
1986
1987 <p>The Internal Methods of Objects of an ECMAScript engine must conform to the list of invariants specified below.
1988 Ordinary ECMAScript Objects as well as all standard exotic objects in this specification maintain these invariants.
1989 ECMAScript Proxy objects maintain these invariants by means of runtime checks on the result of traps invoked on the
1990 [[ProxyHandler]] object.</p>
1991
1992 <p>Any implementation provided exotic objects must also maintain these invariants for those objects. Violation of these
1993 invariants may cause ECMAScript code to have unpredictable behaviour and create security issues. However, violation of
1994 these invariants must never compromise the memory safety of an implementation.</p>
1995
1996 <p>An implementation must not allow these invariants to be circumvented in any manner such as by providing alternative
1997 interfaces that implement the functionality of the essential internal methods without enforcing their invariants.</p>
1998
1999 <p>Definitions:</p>
2000
2001 <p>&#x25cf;&emsp;The <i>target</i> of an internal method is the object upon which the internal method is called.</p>
2002
2003 <p>&#x25cf;&emsp;A target is <i>non-extensible</i> if it has been observed to return false from its [[IsExtensible]]
2004 internal method, or true from its [[PreventExtensions]] internal method.</p>
2005
2006 <p>&#x25cf;&emsp;A <i>non-existent</i> property is a property that does not exist as an own property on a non-extensible
2007 target.</p>
2008
2009 <p>&#x25cf;&emsp;All references to <i><a href="#sec-samevalue">SameValue</a></i> are according to the definition of <a
2010 href="#sec-samevalue">SameValue</a> algorithm specified in <a href="#sec-samevalue">7.2.9</a>.</p>
2011
2012 <p><b>[[GetPrototypeOf]] ( )</b></p>
2013
2014 <p>&#x25cf;&emsp;The Type of the return value must be either Object or Null.</p>
2015
2016 <p>&#x25cf;&emsp;If target is non-extensible, and [[GetPrototypeOf]] returns a value v, then any future calls to
2017 [[GetPrototypeOf]] should return the <a href="#sec-samevalue">SameValue</a> as v.</p>
2018
2019 <div class="note">
2020 <p><span class="nh">NOTE</span> An object&rsquo;s prototype chain should have finite length (that is, starting from any
2021 object, recursively applying the [[GetPrototypeOf]] internal method to its result should eventually lead to the value
2022 null). However, this requirement is not enforceable as an object level invariant if the prototype chain includes any
2023 exotic objects that do not use the ordinary object definition of [[GetPrototypeOf]]. Such a circular prototype chain may
2024 result in infinite loops when accessing object properties.</p>
2025 </div>
2026
2027 <p><b>[[SetPrototypeOf]] (V)</b></p>
2028
2029 <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
2030
2031 <p>&#x25cf;&emsp;If target is non-extensible, [[SetPrototypeOf]] must return false, unless V is the <a
2032 href="#sec-samevalue">SameValue</a> as the target&rsquo;s observed [[GetPrototypeOf]] value.</p>
2033
2034 <p><b>[[PreventExtensions]] ( )</b></p>
2035
2036 <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
2037
2038 <p>&#x25cf;&emsp;If [[PreventExtensions]] returns true, all future calls to [[IsExtensible]] on the target must return
2039 false and the target is now considered non-extensible.</p>
2040
2041 <p><b>[[GetOwnProperty]] (P)</b></p>
2042
2043 <p>&#x25cf;&emsp;The Type of the return value must be either <a
2044 href="#sec-property-descriptor-specification-type">Property Descriptor</a> or Undefined.</p>
2045
2046 <p>&#x25cf;&emsp;If the Type of the return value is <a href="#sec-property-descriptor-specification-type">Property
2047 Descriptor</a>, the return value must be a complete property descriptor (<a href="#sec-completepropertydescriptor">see
2048 6.2.4.6</a>).</p>
2049
2050 <p>&#x25cf;&emsp;If a property P is described as a data property with Desc.[[Value]] equal to v and Desc.[[Writable]] and
2051 Desc.[[Configurable]] are both false, then the <a href="#sec-samevalue">SameValue</a> must be returned for the
2052 Desc.[[Value]] attribute of the property on all future calls to [[GetOwnProperty]] ( P ).</p>
2053
2054 <p>&#x25cf;&emsp;If P&rsquo;s attributes other than [[Writable]] may change over time or if the property might disappear,
2055 then P&rsquo;s [[Configurable]] attribute must be true.</p>
2056
2057 <p>&#x25cf;&emsp;If the [[Writable]] attribute may change from false to true, then the [[Configurable]] attribute must be
2058 true.</p>
2059
2060 <p>&#x25cf;&emsp;If the target is non-extensible and P is non-existent, then all future calls to [[GetOwnProperty]] (P)
2061 on the target must describe P as non-existent (i.e. [[GetOwnProperty]] (P) must return undefined).</p>
2062
2063 <div class="note">
2064 <p><span class="nh">NOTE</span> As a consequence of the third invariant, if a property is described as a data property
2065 and it may return different values over time, then either or both of the Desc.[[Writable]] and Desc.[[Configurable]]
2066 attributes must be true even if no mechanism to change the value is exposed via the other internal methods.</p>
2067 </div>
2068
2069 <p><b>[[DefineOwnProperty]] (P, Desc)</b></p>
2070
2071 <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
2072
2073 <p>&#x25cf;&emsp;[[DefineOwnProperty]] must return false if P has previously been observed as a non-configurable own
2074 property of the target, unless either:</p>
2075
2076 <p>1.&#x9;P is a non-configurable writable own data property. A non-configurable writable data property can be changed
2077 into a non-configurable non-writable data property.</p>
2078
2079 <p>2.&#x9;All attributes in Desc are the <a href="#sec-samevalue">SameValue</a> as P&rsquo;s attributes.</p>
2080
2081 <p>&#x25cf;&emsp;[[DefineOwnProperty]] (P, Desc) must return false if target is non-extensible and P is a non-existent own
2082 property. That is, a non-extensible target object cannot be extended with new properties.</p>
2083
2084 <p><b>[[HasProperty]] ( P )</b></p>
2085
2086 <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
2087
2088 <p>&#x25cf;&emsp;If P was previously observed as a non-configurable data or accessor own property of the target,
2089 [[HasProperty]] must return true.</p>
2090
2091 <p><b>[[Get]] (P, Receiver)</b></p>
2092
2093 <p>&#x25cf;&emsp;If P was previously observed as a non-configurable, non-writable own data property of the target with
2094 value v, then [[Get]] must return the <a href="#sec-samevalue">SameValue</a>.</p>
2095
2096 <p>&#x25cf;&emsp;If P was previously observed as a non-configurable own accessor property of the target whose [[Get]]
2097 attribute is undefined, the [[Get]] operation must return undefined.</p>
2098
2099 <p><b>[[Set]] ( P, V, Receiver)</b></p>
2100
2101 <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
2102
2103 <p>&#x25cf;&emsp;If P was previously observed as a non-configurable, non-writable own data property of the target, then
2104 [[Set]] must return false unless V is the <a href="#sec-samevalue">SameValue</a> as P&rsquo;s [[Value]] attribute.</p>
2105
2106 <p>&#x25cf;&emsp;If P was previously observed as a non-configurable own accessor property of the target whose [[Set]]
2107 attribute is undefined, the [[Set]] operation must return false.</p>
2108
2109 <p><b>[[Delete]] ( P )</b></p>
2110
2111 <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
2112
2113 <p>&#x25cf;&emsp;If P was previously observed to be a non-configurable own data or accessor property of the target,
2114 [[Delete]] must return false.</p>
2115
2116 <p><b>[[Enumerate]] ( )</b></p>
2117
2118 <p>&#x25cf;&emsp;The Type of the return value must be Object.</p>
2119
2120 <p><b>[[OwnPropertyKeys]] ( )</b></p>
2121
2122 <p>&#x25cf;&emsp;The return value must be a <a href="#sec-list-and-record-specification-type">List</a>.</p>
2123
2124 <p>&#x25cf;&emsp; The Type of each element of the returned <a href="#sec-list-and-record-specification-type">List</a> is
2125 either String or Symbol.</p>
2126
2127 <p>&#x25cf;&emsp;The returned <a href="#sec-list-and-record-specification-type">List</a> must contain at least the keys of
2128 all non-configurable own properties that have previously been observed.</p>
2129
2130 <p>&#x25cf;&emsp;If the object is non-extensible, the returned <a href="#sec-list-and-record-specification-type">List</a>
2131 must contain only the keys of all own properties of the object that are observable using [[GetOwnProperty]].</p>
2132
2133 <p><b>[[Construct]] ( )</b></p>
2134
2135 <p>&#x25cf;&emsp;The Type of the return value must be Object.</p>
2136 </section>
2137
2138 <section id="sec-well-known-intrinsic-objects">
2139 <h1><span class="secnum" id="sec-6.1.7.4"><a href="#sec-well-known-intrinsic-objects"
2140 title="link to this section">6.1.7.4</a></span> Well-Known Intrinsic Objects</h1>
2141
2142 <p>Well-known intrinsics are built-in objects that are explicitly referenced by the algorithms of this specification and
2143 which usually have <a href="#sec-code-realms">Realm</a> specific identities. Unless otherwise specified each intrinsic
2144 object actually corresponds to a set of similar objects, one per <a href="#sec-code-realms">Realm</a>.</p>
2145
2146 <p>Within this specification a reference such as %name% means the intrinsic object, associated with <a
2147 href="#sec-execution-contexts">the current Realm</a>, corresponding to the name. Determination of <a
2148 href="#sec-execution-contexts">the current Realm</a> and its intrinsics is described in <a
2149 href="#sec-newglobalenvironment">8.1.2.5</a>. The well-known intrinsics are listed in <a href="#table-7">Table 7</a>.</p>
2150
2151 <figure>
2152 <figcaption><span id="table-7">Table 7</span> &mdash; Well-known Intrinsic Objects</figcaption>
2153 <table class="real-table">
2154 <tr>
2155 <th>Intrinsic Name</th>
2156 <th>Global Name</th>
2157 <th>ECMAScript Language Association</th>
2158 </tr>
2159 <tr>
2160 <td>%Array%</td>
2161 <td><code>Array</code></td>
2162 <td>The <code>Array</code> constructor (<a href="#sec-array-constructor">22.1.1</a>)</td>
2163 </tr>
2164 <tr>
2165 <td>%ArrayBuffer%</td>
2166 <td><code>ArrayBuffer</code></td>
2167 <td>The <code>ArrayBuffer</code> constructor (<a href="#sec-arraybuffer-constructor">24.1.2</a>)</td>
2168 </tr>
2169 <tr>
2170 <td>%ArrayBufferPrototype%</td>
2171 <td><code><a href="#sec-arraybuffer.prototype">ArrayBuffer.prototype</a></code></td>
2172 <td>The initial value of the <code>prototype</code> data property of %ArrayBuffer%.</td>
2173 </tr>
2174 <tr>
2175 <td>%ArrayIteratorPrototype%</td>
2176 <td></td>
2177 <td>The prototype of Array iterator objects (<a href="#sec-array-iterator-objects">22.1.5</a>)</td>
2178 </tr>
2179 <tr>
2180 <td>%ArrayPrototype%</td>
2181 <td><code>Array.prototype</code></td>
2182 <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>
2183 </tr>
2184 <tr>
2185 <td>%ArrayProto_values%</td>
2186 <td><code><a href="#sec-array.prototype.values">Array.prototype.values</a></code></td>
2187 <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>
2188 </tr>
2189 <tr>
2190 <td>%Boolean%</td>
2191 <td><code>Boolean</code></td>
2192 <td>The <code>Boolean</code> constructor (<a href="#sec-boolean-constructor">19.3.1</a>)</td>
2193 </tr>
2194 <tr>
2195 <td>%BooleanPrototype%</td>
2196 <td><code>Boolean.prototype</code></td>
2197 <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>
2198 </tr>
2199 <tr>
2200 <td>%DataView%</td>
2201 <td><code>DataView</code></td>
2202 <td>The <code>DataView</code> constructor (<a href="#sec-dataview-constructor">24.2.2</a>)</td>
2203 </tr>
2204 <tr>
2205 <td>%DataViewPrototype%</td>
2206 <td><code><a href="#sec-dataview.prototype">DataView.prototype</a></code></td>
2207 <td>The initial value of the <code>prototype</code> data property of %DataView%</td>
2208 </tr>
2209 <tr>
2210 <td>%Date%</td>
2211 <td><code>Date</code></td>
2212 <td>The <code>Date</code> constructor (<a href="#sec-date-constructor">20.3.2</a>)</td>
2213 </tr>
2214 <tr>
2215 <td>%DatePrototype%</td>
2216 <td><code>Date.prototype</code></td>
2217 <td>The initial value of the <code>prototype</code> data property of %Date%.</td>
2218 </tr>
2219 <tr>
2220 <td>%decodeURI%</td>
2221 <td><code>decodeURI</code></td>
2222 <td>The <code>decodeURI</code> function (<a href="#sec-decodeuri-encodeduri">18.2.6.2</a>)</td>
2223 </tr>
2224 <tr>
2225 <td>%decodeURIComponent%</td>
2226 <td><code>decodeURIComponent</code></td>
2227 <td>The <code>decodeURIComponent</code> function (<a href="#sec-decodeuricomponent-encodeduricomponent">18.2.6.3</a>)</td>
2228 </tr>
2229 <tr>
2230 <td>%encodeURI%</td>
2231 <td><code>encodeURI</code></td>
2232 <td>The <code>encodeURI</code> function (<a href="#sec-encodeuri-uri">18.2.6.4</a>)</td>
2233 </tr>
2234 <tr>
2235 <td>%encodeURIComponent%</td>
2236 <td><code>encodeURIComponent</code></td>
2237 <td>The <code>encodeURIComponent</code> function (<a href="#sec-encodeuricomponent-uricomponent">18.2.6.5</a>)</td>
2238 </tr>
2239 <tr>
2240 <td>%Error%</td>
2241 <td><code>Error</code></td>
2242 <td>The <code>Error</code> constructor (<a href="#sec-error-constructor">19.5.1</a>)</td>
2243 </tr>
2244 <tr>
2245 <td>%ErrorPrototype%</td>
2246 <td><code>Error.prototype</code></td>
2247 <td>The initial value of the <code>prototype</code> data property of %Error%</td>
2248 </tr>
2249 <tr>
2250 <td>%eval%</td>
2251 <td><code>eval</code></td>
2252 <td>The <code>eval</code> function (<a href="#sec-eval-x">18.2.1</a>)</td>
2253 </tr>
2254 <tr>
2255 <td>%EvalError%</td>
2256 <td><code>EvalError</code></td>
2257 <td>The <code>EvalError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-evalerror">19.5.5.1</a>)</td>
2258 </tr>
2259 <tr>
2260 <td>%EvalErrorPrototype%</td>
2261 <td><code>EvalError.prototype</code></td>
2262 <td>The initial value of the <code>prototype</code> property of %EvalError%</td>
2263 </tr>
2264 <tr>
2265 <td>%Float32Array%</td>
2266 <td><code><a href="#sec-float32array">Float32Array</a></code></td>
2267 <td>The <code><a href="#sec-float32array">Float32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2268 </tr>
2269 <tr>
2270 <td>%Float32ArrayPrototype%</td>
2271 <td><code>Float32Array.prototype</code></td>
2272 <td>The initial value of the <code>prototype</code> data property of %Float32Array%.</td>
2273 </tr>
2274 <tr>
2275 <td>%Float64Array%</td>
2276 <td><code><a href="#sec-float64array">Float64Array</a></code></td>
2277 <td>The <code><a href="#sec-float64array">Float64Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2278 </tr>
2279 <tr>
2280 <td>%Float64ArrayPrototype%</td>
2281 <td><code>Float64Array.prototype</code></td>
2282 <td>The initial value of the <code>prototype</code> data property of %Float64Array%</td>
2283 </tr>
2284 <tr>
2285 <td>%Function%</td>
2286 <td><code>Function</code></td>
2287 <td>The <code>Function</code> constructor (<a href="#sec-function-constructor">19.2.1</a>)</td>
2288 </tr>
2289 <tr>
2290 <td>%FunctionPrototype%</td>
2291 <td><code>Function.prototype</code></td>
2292 <td>The initial value of the <code>prototype</code> data property of %Function%</td>
2293 </tr>
2294 <tr>
2295 <td>%Generator%</td>
2296 <td></td>
2297 <td>The initial value of the <code>prototype</code> property of %GeneratorFunction%</td>
2298 </tr>
2299 <tr>
2300 <td>%GeneratorFunction%</td>
2301 <td></td>
2302 <td>The constructor of generator objects (<a href="#sec-generatorfunction-constructor">25.2.1</a>)</td>
2303 </tr>
2304 <tr>
2305 <td>%GeneratorPrototype%</td>
2306 <td></td>
2307 <td>The initial value of the <code>prototype</code> property of %Generator%</td>
2308 </tr>
2309 <tr>
2310 <td>%Int8Array%</td>
2311 <td><code><a href="#sec-int8array">Int8Array</a></code></td>
2312 <td>The <code><a href="#sec-int8array">Int8Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2313 </tr>
2314 <tr>
2315 <td>%Int8ArrayPrototype%</td>
2316 <td><code>Int8Array.prototype</code></td>
2317 <td>The initial value of the <code>prototype</code> data property of %Int8Array%</td>
2318 </tr>
2319 <tr>
2320 <td>%Int16Array%</td>
2321 <td><code><a href="#sec-int16array">Int16Array</a></code></td>
2322 <td>The <code><a href="#sec-int16array">Int16Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2323 </tr>
2324 <tr>
2325 <td>%Int16ArrayPrototype%</td>
2326 <td><code>Int16Array.prototype</code></td>
2327 <td>The initial value of the <code>prototype</code> data property of %Int16Array%</td>
2328 </tr>
2329 <tr>
2330 <td>%Int32Array%</td>
2331 <td><code><a href="#sec-int32array">Int32Array</a></code></td>
2332 <td>The <code><a href="#sec-int32array">Int32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2333 </tr>
2334 <tr>
2335 <td>%Int32ArrayPrototype%</td>
2336 <td><code>Int32Array.prototype</code></td>
2337 <td>The initial value of the <code>prototype</code> data property of %Int32Array%</td>
2338 </tr>
2339 <tr>
2340 <td>%isFinite%</td>
2341 <td><code>isFinite</code></td>
2342 <td>The <code>isFinite</code> function (<a href="#sec-isfinite-number">18.2.2</a>)</td>
2343 </tr>
2344 <tr>
2345 <td>%isNaN%</td>
2346 <td><code>isNaN</code></td>
2347 <td>The <code>isNaN</code> function (<a href="#sec-isnan-number">18.2.3</a>)</td>
2348 </tr>
2349 <tr>
2350 <td>%IteratorPrototype%</td>
2351 <td></td>
2352 <td>An object that all standard built-in iterator objects indirectly inherit from</td>
2353 </tr>
2354 <tr>
2355 <td>%JSON%</td>
2356 <td><code>JSON</code></td>
2357 <td>The <code>JSON</code> object (<a href="#sec-json-object">24.3</a>)</td>
2358 </tr>
2359 <tr>
2360 <td>%Map%</td>
2361 <td><code>Map</code></td>
2362 <td>The <code>Map</code> constructor (<a href="#sec-map-constructor">23.1.1</a>)</td>
2363 </tr>
2364 <tr>
2365 <td>%MapIteratorPrototype%</td>
2366 <td></td>
2367 <td>The prototype of Map iterator objects (<a href="#sec-map-iterator-objects">23.1.5</a>)</td>
2368 </tr>
2369 <tr>
2370 <td>%MapPrototype%</td>
2371 <td><code>Map.prototype</code></td>
2372 <td>The initial value of the <code>prototype</code> data property of %Map%</td>
2373 </tr>
2374 <tr>
2375 <td>%Math%</td>
2376 <td><code>Math</code></td>
2377 <td>The <code>Math</code> object (<a href="#sec-math-object">20.2</a>)</td>
2378 </tr>
2379 <tr>
2380 <td>%Number%</td>
2381 <td><code>Number</code></td>
2382 <td>The <code>Number</code> constructor (<a href="#sec-number-constructor">20.1.1</a>)</td>
2383 </tr>
2384 <tr>
2385 <td>%NumberPrototype%</td>
2386 <td><code>Number.prototype</code></td>
2387 <td>The initial value of the <code>prototype</code> property of %Number%</td>
2388 </tr>
2389 <tr>
2390 <td>%Object%</td>
2391 <td><code>Object</code></td>
2392 <td>The <code>Object</code> constructor (<a href="#sec-object-constructor">19.1.1</a>)</td>
2393 </tr>
2394 <tr>
2395 <td>%ObjectPrototype%</td>
2396 <td><code>Object.prototype</code></td>
2397 <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>
2398 </tr>
2399 <tr>
2400 <td>%ObjProto_toString%</td>
2401 <td><code>Object.prototype.<br>toString</code></td>
2402 <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>
2403 </tr>
2404 <tr>
2405 <td>%parseFloat%</td>
2406 <td><code>parseFloat</code></td>
2407 <td>The <code>parseFloat</code> function (<a href="#sec-parsefloat-string">18.2.4</a>)</td>
2408 </tr>
2409 <tr>
2410 <td>%parseInt%</td>
2411 <td><code>parseInt</code></td>
2412 <td>The <code>parseInt</code> function (<a href="#sec-parseint-string-radix">18.2.5</a>)</td>
2413 </tr>
2414 <tr>
2415 <td>%Promise%</td>
2416 <td><code>Promise</code></td>
2417 <td>The <code>Promise</code> constructor (<a href="#sec-promise-constructor">25.4.3</a>)</td>
2418 </tr>
2419 <tr>
2420 <td>%PromisePrototype%</td>
2421 <td><code>Promise.prototype</code></td>
2422 <td>The initial value of the <code>prototype</code> data property of %Promise%</td>
2423 </tr>
2424 <tr>
2425 <td>%Proxy%</td>
2426 <td><code>Proxy</code></td>
2427 <td>The <code>Proxy</code> constructor (<a href="#sec-proxy-constructor">26.2.1</a>)</td>
2428 </tr>
2429 <tr>
2430 <td>%RangeError%</td>
2431 <td><code>RangeError</code></td>
2432 <td>The <code>RangeError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-rangeerror">19.5.5.2</a>)</td>
2433 </tr>
2434 <tr>
2435 <td>%RangeErrorPrototype%</td>
2436 <td><code>RangeError.prototype</code></td>
2437 <td>The initial value of the <code>prototype</code> property of %RangeError%</td>
2438 </tr>
2439 <tr>
2440 <td>%ReferenceError%</td>
2441 <td><code>ReferenceError</code></td>
2442 <td>The <code>ReferenceError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-referenceerror">19.5.5.3</a>)</td>
2443 </tr>
2444 <tr>
2445 <td>%ReferenceErrorPrototype%</td>
2446 <td><code>ReferenceError.<br>prototype</code></td>
2447 <td>The initial value of the <code>prototype</code> property of %ReferenceError%</td>
2448 </tr>
2449 <tr>
2450 <td>%Reflect%</td>
2451 <td><code>Reflect</code></td>
2452 <td>The <code>Reflect</code> object (<a href="#sec-reflect-object">26.1</a>)</td>
2453 </tr>
2454 <tr>
2455 <td>%RegExp%</td>
2456 <td><code>RegExp</code></td>
2457 <td>The <code>RegExp</code> constructor (<a href="#sec-regexp-constructor">21.2.3</a>)</td>
2458 </tr>
2459 <tr>
2460 <td>%RegExpPrototype%</td>
2461 <td><code><a href="#sec-regexp.prototype">RegExp.prototype</a></code></td>
2462 <td>The initial value of the <code>prototype</code> data property of %RegExp%</td>
2463 </tr>
2464 <tr>
2465 <td>%Set%</td>
2466 <td><code>Set</code></td>
2467 <td>The <code>Set</code> constructor (<a href="#sec-set-constructor">23.2.1</a>)</td>
2468 </tr>
2469 <tr>
2470 <td>%SetIteratorPrototype%</td>
2471 <td></td>
2472 <td>The prototype of Set iterator objects (<a href="#sec-set-iterator-objects">23.2.5</a>)</td>
2473 </tr>
2474 <tr>
2475 <td>%SetPrototype%</td>
2476 <td><code>Set.prototype</code></td>
2477 <td>The initial value of the <code>prototype</code> data property of %Set%</td>
2478 </tr>
2479 <tr>
2480 <td>%String%</td>
2481 <td><code>String</code></td>
2482 <td>The <code>String</code> constructor (<a href="#sec-string-constructor">21.1.1</a>)</td>
2483 </tr>
2484 <tr>
2485 <td>%StringIteratorPrototype%</td>
2486 <td></td>
2487 <td>The prototype of String iterator objects (<a href="#sec-string-iterator-objects">21.1.5</a>)</td>
2488 </tr>
2489 <tr>
2490 <td>%StringPrototype%</td>
2491 <td><code>String.prototype</code></td>
2492 <td>The initial value of the <code>prototype</code> data property of %String%</td>
2493 </tr>
2494 <tr>
2495 <td>%Symbol%</td>
2496 <td><code>Symbol</code></td>
2497 <td>The <code>Symbol</code> constructor (<a href="#sec-symbol-constructor">19.4.1</a>)</td>
2498 </tr>
2499 <tr>
2500 <td>%SymbolPrototype%</td>
2501 <td><code>Symbol.prototype</code></td>
2502 <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>
2503 </tr>
2504 <tr>
2505 <td>%SyntaxError%</td>
2506 <td><code>SyntaxError</code></td>
2507 <td>The <code>SyntaxError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-syntaxerror">19.5.5.4</a>)</td>
2508 </tr>
2509 <tr>
2510 <td>%SyntaxErrorPrototype%</td>
2511 <td><code>SyntaxError.prototype</code></td>
2512 <td>The initial value of the <code>prototype</code> property of %SyntaxError%</td>
2513 </tr>
2514 <tr>
2515 <td><a href="#sec-%throwtypeerror%">%ThrowTypeError%</a></td>
2516 <td></td>
2517 <td>A function object that unconditionally throws a new instance of %TypeError%</td>
2518 </tr>
2519 <tr>
2520 <td>%TypedArray%</td>
2521 <td></td>
2522 <td>The super class of all typed Array constructors (<a href="#sec-%typedarray%-intrinsic-object">22.2.1</a>)</td>
2523 </tr>
2524 <tr>
2525 <td>%TypedArrayPrototype%</td>
2526 <td></td>
2527 <td>The initial value of the <code>prototype</code> property of %TypedArray%</td>
2528 </tr>
2529 <tr>
2530 <td>%TypeError%</td>
2531 <td><code>TypeError</code></td>
2532 <td>The <code>TypeError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-typeerror">19.5.5.5</a>)</td>
2533 </tr>
2534 <tr>
2535 <td>%TypeErrorPrototype%</td>
2536 <td><code>TypeError.prototype</code></td>
2537 <td>The initial value of the <code>prototype</code> property of %TypeError%</td>
2538 </tr>
2539 <tr>
2540 <td>%Uint8Array%</td>
2541 <td><code><a href="#sec-uint8array">Uint8Array</a></code></td>
2542 <td>The <code><a href="#sec-uint8array">Uint8Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2543 </tr>
2544 <tr>
2545 <td>%Uint8ArrayPrototype%</td>
2546 <td><code>Uint8Array.prototype</code></td>
2547 <td>The initial value of the <code>prototype</code> data property of %Uint8Array%</td>
2548 </tr>
2549 <tr>
2550 <td>%Uint8ClampedArray%</td>
2551 <td><code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a></code></td>
2552 <td>The <code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2553 </tr>
2554 <tr>
2555 <td>%Uint8ClampedArrayPrototype%</td>
2556 <td><code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a>.<br>prototype</code></td>
2557 <td>The initial value of the <code>prototype</code> data property of %Uint8ClampedArray%</td>
2558 </tr>
2559 <tr>
2560 <td>%Uint16Array%</td>
2561 <td><code><a href="#sec-uint16array">Uint16Array</a></code></td>
2562 <td>The <code><a href="#sec-uint16array">Uint16Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2563 </tr>
2564 <tr>
2565 <td>%Uint16ArrayPrototype%</td>
2566 <td><code>Uint16Array.prototype</code></td>
2567 <td>The initial value of the <code>prototype</code> data property of %Uint16Array%</td>
2568 </tr>
2569 <tr>
2570 <td>%Uint32Array%</td>
2571 <td><code><a href="#sec-uint32array">Uint32Array</a></code></td>
2572 <td>The <code><a href="#sec-uint32array">Uint32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
2573 </tr>
2574 <tr>
2575 <td>%Uint32ArrayPrototype%</td>
2576 <td><code>Uint32Array.prototype</code></td>
2577 <td>The initial value of the <code>prototype</code> data property of %Uint32Array%</td>
2578 </tr>
2579 <tr>
2580 <td>%URIError%</td>
2581 <td><code><a href="#sec-constructor-properties-of-the-global-object-urierror">URIError</a></code></td>
2582 <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>
2583 </tr>
2584 <tr>
2585 <td>%URIErrorPrototype%</td>
2586 <td><code>URIError.prototype</code></td>
2587 <td>The initial value of the <code>prototype</code> property of %URIError%</td>
2588 </tr>
2589 <tr>
2590 <td>%WeakMap%</td>
2591 <td><code>WeakMap</code></td>
2592 <td>The <code>WeakMap</code> constructor (<a href="#sec-weakmap-constructor">23.3.1</a>)</td>
2593 </tr>
2594 <tr>
2595 <td>%WeakMapPrototype%</td>
2596 <td><code><a href="#sec-weakmap.prototype">WeakMap.prototype</a></code></td>
2597 <td>The initial value of the <code>prototype</code> data property of %WeakMap%</td>
2598 </tr>
2599 <tr>
2600 <td>%WeakSet%</td>
2601 <td><code>WeakSet</code></td>
2602 <td>The <code>WeakSet</code> constructor (<a href="#sec-weakset-constructor">23.4.1</a>)</td>
2603 </tr>
2604 <tr>
2605 <td>%WeakSetPrototype%</td>
2606 <td><code><a href="#sec-weakset.prototype">WeakSet.prototype</a></code></td>
2607 <td>The initial value of the <code>prototype</code> data property of %WeakSet%</td>
2608 </tr>
2609 </table>
2610 </figure>
2611 </section>
2612 </section>
2613 </section>
2614
2615 <section id="sec-ecmascript-specification-types">
2616 <div class="front">
2617 <h1><span class="secnum" id="sec-6.2"><a href="#sec-ecmascript-specification-types"
2618 title="link to this section">6.2</a></span> ECMAScript Specification Types</h1>
2619
2620 <p>A specification type corresponds to meta-values that are used within algorithms to describe the semantics of ECMAScript
2621 language constructs and ECMAScript language types. The specification types are <a
2622 href="#sec-reference-specification-type">Reference</a>, <a href="#sec-list-and-record-specification-type">List</a>, <a
2623 href="#sec-completion-record-specification-type">Completion</a>, <a
2624 href="#sec-property-descriptor-specification-type">Property Descriptor</a>, <a href="#sec-lexical-environments">Lexical
2625 Environment</a>, <a href="#sec-environment-records">Environment Record</a>, and <a href="#sec-data-blocks">Data Block</a>.
2626 Specification type values are specification artefacts that do not necessarily correspond to any specific entity within an
2627 ECMAScript implementation. Specification type values may be used to describe intermediate results of ECMAScript expression
2628 evaluation but such values cannot be stored as properties of objects or values of ECMAScript language variables.</p>
2629 </div>
2630
2631 <section id="sec-list-and-record-specification-type">
2632 <h1><span class="secnum" id="sec-6.2.1"><a href="#sec-list-and-record-specification-type"
2633 title="link to this section">6.2.1</a></span> The List and Record Specification Type</h1>
2634
2635 <p>The List type is used to explain the evaluation of argument lists (<a href="#sec-argument-lists">see 12.3.6</a>) in
2636 <code>new</code> expressions, in function calls, and in other algorithms where a simple ordered list of values is needed.
2637 Values of the List type are simply ordered sequences of list elements containing the individual values. These sequences may
2638 be of any length. The elements of a list may be randomly accessed using 0-origin indices. For notational convenience an
2639 array-like syntax can be used to access List elements. For example, <i>arguments</i>[2] is shorthand for saying the
2640 3<sup>rd</sup> element of the List <i>arguments</i>.</p>
2641
2642 <p>For notational convenience within this specification, a literal syntax can be used to express a new List value. For
2643 example, &laquo;1, 2&raquo; defines a List value that has two elements each of which is initialized to a specific value. A
2644 new empty List can be expressed as &laquo;&raquo;.</p>
2645
2646 <p>The Record type is used to describe data aggregations within the algorithms of this specification. A Record type value
2647 consists of one or more named fields. The value of each field is either an ECMAScript value or an abstract value represented
2648 by a name associated with the Record type. Field names are always enclosed in double brackets, for example [[value]].</p>
2649
2650 <p>For notational convenience within this specification, an object literal-like syntax can be used to express a Record
2651 value. For example, {[[field1]]: 42, [[field2]]: <b>false</b>, [[field3]]: <b>empty</b>} defines a Record value that has
2652 three fields, each of which is initialized to a specific value. Field name order is not significant. Any fields that are not
2653 explicitly listed are considered to be absent.</p>
2654
2655 <p>In specification text and algorithms, dot notation may be used to refer to a specific field of a Record value. For
2656 example, if R is the record shown in the previous paragraph then R.[[field2]] is shorthand for &ldquo;the field of R named
2657 [[field2]]&rdquo;.</p>
2658
2659 <p>Schema for commonly used Record field combinations may be named, and that name may be used as a prefix to a literal
2660 Record value to identify the specific kind of aggregations that is being described. For example:
2661 PropertyDescriptor{[[Value]]: 42, [[Writable]]: <b>false</b>, [[Configurable]]: <b>true</b>}.</p>
2662 </section>
2663
2664 <section id="sec-completion-record-specification-type">
2665 <div class="front">
2666 <h1><span class="secnum" id="sec-6.2.2"><a href="#sec-completion-record-specification-type"
2667 title="link to this section">6.2.2</a></span> The Completion Record Specification Type</h1>
2668
2669 <p>The Completion type is a Record used to explain the runtime propagation of values and control flow such as the
2670 behaviour of statements (<code>break</code>, <code>continue</code>, <code>return</code> and <code>throw</code>) that
2671 perform nonlocal transfers of control.</p>
2672
2673 <p>Values of the Completion type are Record values whose fields are defined as by <a href="#table-8">Table 8</a>.</p>
2674
2675 <figure>
2676 <figcaption><span id="table-8">Table 8</span> &mdash; Completion Record Fields</figcaption>
2677 <table class="real-table">
2678 <tr>
2679 <th>Field</th>
2680 <th>Value</th>
2681 <th>Meaning</th>
2682 </tr>
2683 <tr>
2684 <td>[[type]]</td>
2685 <td>One of <b>normal</b>, <b>break</b>, <b>continue</b>, <b>return</b>, or <b>throw</b></td>
2686 <td>The type of completion that occurred.</td>
2687 </tr>
2688 <tr>
2689 <td>[[value]]</td>
2690 <td>any <a href="#sec-ecmascript-language-types">ECMAScript language value</a> or <b>empty</b></td>
2691 <td>The value that was produced.</td>
2692 </tr>
2693 <tr>
2694 <td>[[target]]</td>
2695 <td>any ECMAScript string or <b>empty</b></td>
2696 <td>The target label for directed control transfers.</td>
2697 </tr>
2698 </table>
2699 </figure>
2700
2701 <p>The term &ldquo;abrupt completion&rdquo; refers to any completion with a <span style="font-family: Times New
2702 Roman">[[type]]</span> value other than <b>normal</b>.</p>
2703 </div>
2704
2705 <section id="sec-normalcompletion">
2706 <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>
2707 NormalCompletion</h1>
2708
2709 <p>The abstract operation NormalCompletion with a single <i>argument</i>, such as:</p>
2710
2711 <ol class="proc">
2712 <li>Return NormalCompletion(<i>argument</i>).</li>
2713 </ol>
2714
2715 <p>Is a shorthand that is defined as follows:</p>
2716
2717 <ol class="proc">
2718 <li>Return <a href="#sec-completion-record-specification-type">Completion</a>{[[type]]: <span style="font-family:
2719 sans-serif">normal</span>, [[value]]: <i>argument</i>, [[target]]:<span style="font-family:
2720 sans-serif">empty</span>}.</li>
2721 </ol>
2722 </section>
2723
2724 <section id="sec-implicit-completion-values">
2725 <h1><span class="secnum" id="sec-6.2.2.2"><a href="#sec-implicit-completion-values"
2726 title="link to this section">6.2.2.2</a></span> Implicit Completion Values</h1>
2727
2728 <p>The algorithms of this specification often implicitly return <a
2729 href="#sec-completion-record-specification-type">Completion</a> Records whose [[type]] is <b>normal</b>. Unless it is
2730 otherwise obvious from the context, an algorithm statement that returns a value that is not a <a
2731 href="#sec-completion-record-specification-type">Completion Record</a>, such as:</p>
2732
2733 <ol class="proc">
2734 <li>Return <code>"Infinity"</code>.</li>
2735 </ol>
2736
2737 <p>means the same thing as:</p>
2738
2739 <ol class="proc">
2740 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<code>"Infinity"</code>).</li>
2741 </ol>
2742
2743 <p>However, if the value expression of a &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement
2744 is a <a href="#sec-completion-record-specification-type">Completion Record</a> construction literal, the resulting <a
2745 href="#sec-completion-record-specification-type">Completion Record</a> is returned. If the value expression is a call to
2746 an abstract operation, the &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement simply returns
2747 the <a href="#sec-completion-record-specification-type">Completion Record</a> produced by the abstract operation.</p>
2748
2749 <p>The abstract operation <span style="font-family: Times New Roman"><a
2750 href="#sec-completion-record-specification-type">Completion</a>(<i>completionRecord</i>)</span> is used to emphasize that
2751 a previously computed <a href="#sec-completion-record-specification-type">Completion Record</a> is being returned. The <a
2752 href="#sec-completion-record-specification-type">Completion</a> abstract operation takes a single argument,
2753 <var>completionRecord</var>, and performs the following steps: such as</p>
2754
2755 <ol class="proc">
2756 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>completionRecord</i> is a <a
2757 href="#sec-completion-record-specification-type">Completion Record</a>.</li>
2758 <li>Return <i>completionRecord</i> as the <a href="#sec-completion-record-specification-type">Completion Record</a> of
2759 this abstract operation.</li>
2760 </ol>
2761
2762 <p>A &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement without a value in an algorithm step
2763 means the same thing as:</p>
2764
2765 <ol class="proc">
2766 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
2767 </ol>
2768
2769 <p>Any reference to a <a href="#sec-completion-record-specification-type">Completion Record</a> value that is in a context
2770 that does not explicitly require a complete <a href="#sec-completion-record-specification-type">Completion Record</a>
2771 value is equivalent to an explicit reference to the [[value]] field of the <a
2772 href="#sec-completion-record-specification-type">Completion Record</a> value unless the <a
2773 href="#sec-completion-record-specification-type">Completion Record</a> is an <a
2774 href="#sec-completion-record-specification-type">abrupt completion</a>.</p>
2775 </section>
2776
2777 <section id="sec-throw-an-exception">
2778 <h1><span class="secnum" id="sec-6.2.2.3"><a href="#sec-throw-an-exception"
2779 title="link to this section">6.2.2.3</a></span> Throw an Exception</h1>
2780
2781 <p>Algorithms steps that say to throw an exception, such as</p>
2782
2783 <ol class="proc">
2784 <li>Throw a <b>TypeError</b> exception.</li>
2785 </ol>
2786
2787 <p>mean the same things as:</p>
2788
2789 <ol class="proc">
2790 <li>Return <a href="#sec-completion-record-specification-type">Completion</a>{[[type]]: <span style="font-family:
2791 sans-serif">throw</span>, [[value]]: a newly created <b>TypeError</b> object, [[target]]:<span style="font-family:
2792 sans-serif">empty</span>}.</li>
2793 </ol>
2794 </section>
2795
2796 <section id="sec-returnifabrupt">
2797 <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>
2798 ReturnIfAbrupt</h1>
2799
2800 <p>Algorithms steps that say</p>
2801
2802 <ol class="proc">
2803 <li>ReturnIfAbrupt(<i>argument</i>).</li>
2804 </ol>
2805
2806 <p>mean the same thing as:</p>
2807
2808 <ol class="proc">
2809 <li>If <i>argument</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return
2810 <i>argument</i>.</li>
2811 <li>Else if <i>argument</i> is a <a href="#sec-completion-record-specification-type">Completion Record</a>, let
2812 <i>argument</i> be <i>argument</i>.[[value]].</li>
2813 </ol>
2814 </section>
2815 </section>
2816
2817 <section id="sec-reference-specification-type">
2818 <div class="front">
2819 <h1><span class="secnum" id="sec-6.2.3"><a href="#sec-reference-specification-type"
2820 title="link to this section">6.2.3</a></span> The Reference Specification Type</h1>
2821
2822 <div class="note">
2823 <p><span class="nh">NOTE</span> The Reference type is used to explain the behaviour of such operators as
2824 <code>delete</code>, <code>typeof</code>, the assignment operators, the <code>super</code> keyword and other language
2825 features. For example, the left-hand operand of an assignment is expected to produce a reference.</p>
2826 </div>
2827
2828 <p>A <b>Reference</b> is a resolved name or property binding. A Reference consists of three components, the
2829 <var>base</var> value, the <var>referenced name</var> and the Boolean valued <var>strict reference</var> flag. The
2830 <var>base</var> value is either <b>undefined</b>, an Object, a Boolean, a String, a Symbol, a Number, or an <a
2831 href="#sec-environment-records">Environment Record</a> (<a href="#sec-environment-records">8.1.1</a>). A <var>base</var>
2832 value of <b>undefined</b> indicates that the Reference could not be resolved to a binding. The <var>referenced name</var>
2833 is a String or Symbol value.</p>
2834
2835 <p>A Super Reference is a Reference that is used to represents a name binding that was expressed using the super keyword.
2836 A Super Reference has an additional <var>thisValue</var> component and its <var>base</var> value will never be an <a
2837 href="#sec-environment-records">Environment Record</a>.</p>
2838
2839 <p>The following abstract operations are used in this specification to access the components of references:</p>
2840
2841 <ul>
2842 <li>
2843 <p>GetBase(V). Returns the <i>base</i> value component of the reference V.</p>
2844 </li>
2845
2846 <li>
2847 <p>GetReferencedName(V). Returns the <i>referenced name</i> component of the reference V.</p>
2848 </li>
2849
2850 <li>
2851 <p>IsStrictReference(V). Returns the <i>strict reference</i> flag component of the reference V.</p>
2852 </li>
2853
2854 <li>
2855 <p>HasPrimitiveBase(V). Returns <b>true</b> if <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>base</i>)
2856 is Boolean, String, Symbol, or Number.</p>
2857 </li>
2858
2859 <li>
2860 <p>IsPropertyReference(V). Returns <b>true</b> if either the <i>base</i> value is an object or HasPrimitiveBase(V) is
2861 <b>true</b>; otherwise returns <b>false</b>.</p>
2862 </li>
2863
2864 <li>
2865 <p>IsUnresolvableReference(V). Returns <b>true</b> if the <i>base</i> value is <b>undefined</b> and <b>false</b>
2866 otherwise.</p>
2867 </li>
2868
2869 <li>
2870 <p>IsSuperReference(V). Returns <b>true</b> if this reference has a <i>thisValue</i> component.</p>
2871 </li>
2872 </ul>
2873
2874 <p>The following abstract operations are used in this specification to operate on references:</p>
2875 </div>
2876
2877 <section id="sec-getvalue">
2878 <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
2879 (V)</h1>
2880 <ol class="proc">
2881 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
2882 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is not <a
2883 href="#sec-reference-specification-type">Reference</a>, return <i>V</i>.</li>
2884 <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
2885 <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>), throw a <b>ReferenceError</b>
2886 exception.</li>
2887 <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>), then
2888 <ol class="block">
2889 <li>If <a href="#sec-reference-specification-type">HasPrimitiveBase</a>(<i>V</i>) is <b>true</b>, then
2890 <ol class="block">
2891 <li><a href="#sec-algorithm-conventions">Assert</a>: In this case, <i>base</i> will never be <b>null</b> or
2892 <b>undefined</b>.</li>
2893 <li>Let <i>base</i> be <a href="#sec-toobject">ToObject</a>(<i>base</i>).</li>
2894 </ol>
2895 </li>
2896 <li>Return <i>base.</i>[[Get]](<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <a
2897 href="#sec-getthisvalue">GetThisValue</a>(<i>V</i>)).</li>
2898 </ol>
2899 </li>
2900 <li>Else <i>base</i> must be an <a href="#sec-environment-records">Environment Record</a>,
2901 <ol class="block">
2902 <li>Return <i>base.</i>GetBindingValue(<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>),
2903 <a href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>)) (<a
2904 href="#sec-environment-records">see 8.1.1</a>).</li>
2905 </ol>
2906 </li>
2907 </ol>
2908
2909 <div class="note">
2910 <p><span class="nh">NOTE</span> The object that may be created in step 5.a.ii is not accessible outside of the above
2911 abstract operation and the ordinary object [[Get]] internal method. An implementation might choose to avoid the actual
2912 creation of the object.</p>
2913 </div>
2914 </section>
2915
2916 <section id="sec-putvalue">
2917 <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
2918 (V, W)</h1>
2919 <ol class="proc">
2920 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
2921 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>W</i>).</li>
2922 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is not <a
2923 href="#sec-reference-specification-type">Reference</a>, throw a <b>ReferenceError</b> exception.</li>
2924 <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
2925 <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>), then
2926 <ol class="block">
2927 <li>If <a href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>) is <b>true</b>, then
2928 <ol class="block">
2929 <li>Throw <b>ReferenceError</b> exception.</li>
2930 </ol>
2931 </li>
2932 <li>Let <i>globalObj</i> be <a href="#sec-getglobalobject">GetGlobalObject</a>().</li>
2933 <li>Return <a href="#sec-set-o-p-v-throw">Set</a>(<i>globalObj</i>,<a
2934 href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <b>false</b>).</li>
2935 </ol>
2936 </li>
2937 <li>Else if <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>), then
2938 <ol class="block">
2939 <li>If <a href="#sec-reference-specification-type">HasPrimitiveBase</a>(<i>V</i>) is <b>true</b>, then
2940 <ol class="block">
2941 <li><a href="#sec-algorithm-conventions">Assert</a>: In this case, <i>base</i> will never be <b>null</b> or
2942 <b>undefined</b>.</li>
2943 <li>Set <i>base</i> to <a href="#sec-toobject">ToObject</a>(<i>base</i>).</li>
2944 </ol>
2945 </li>
2946 <li>Let <i>succeeded</i> be <i>base.</i>[[Set]](<a
2947 href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <a
2948 href="#sec-getthisvalue">GetThisValue</a>(<i>V</i>)).</li>
2949 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>succeeded</i>).</li>
2950 <li>If <i>succeeded</i> is <b>false</b> and <a
2951 href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>) is <b>true</b>, throw a
2952 <b>TypeError</b> exception.</li>
2953 <li>Return.</li>
2954 </ol>
2955 </li>
2956 <li>Else <i>base</i> must be an <a href="#sec-environment-records">Environment Record</a>.
2957 <ol class="block">
2958 <li>Return <i>base.</i>SetMutableBinding(<a
2959 href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <a
2960 href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>)) (<a
2961 href="#sec-environment-records">see 8.1.1</a>).</li>
2962 </ol>
2963 </li>
2964 </ol>
2965
2966 <div class="note">
2967 <p><span class="nh">NOTE</span> The object that may be created in step 6.a.ii is not accessible outside of the above
2968 algorithm and the ordinary object [[Set]] internal method. An implementation might choose to avoid the actual creation
2969 of that object.</p>
2970 </div>
2971 </section>
2972
2973 <section id="sec-getthisvalue">
2974 <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>
2975 GetThisValue (V)</h1>
2976 <ol class="proc">
2977 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
2978 href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>) is <b>true</b>.</li>
2979 <li>If <a href="#sec-reference-specification-type">IsSuperReference</a>(<i>V</i>), then
2980 <ol class="block">
2981 <li>Return the value of the <i>thisValue</i> component of the reference <i>V</i>.</li>
2982 </ol>
2983 </li>
2984 <li>Return <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
2985 </ol>
2986 </section>
2987
2988 <section id="sec-initializereferencedbinding">
2989 <h1><span class="secnum" id="sec-6.2.3.4"><a href="#sec-initializereferencedbinding"
2990 title="link to this section">6.2.3.4</a></span> InitializeReferencedBinding (V, W)</h1>
2991 <ol class="proc">
2992 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
2993 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>W</i>).</li>
2994 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>)
2995 is <a href="#sec-reference-specification-type">Reference</a>.</li>
2996 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
2997 href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>) is <b>false</b>.</li>
2998 <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
2999 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>base</i> is an <a href="#sec-environment-records">Environment
3000 Record</a>.</li>
3001 <li>Return <i>base.</i>InitializeBinding(<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>),
3002 <i>W</i>).</li>
3003 </ol>
3004 </section>
3005 </section>
3006
3007 <section id="sec-property-descriptor-specification-type">
3008 <div class="front">
3009 <h1><span class="secnum" id="sec-6.2.4"><a href="#sec-property-descriptor-specification-type"
3010 title="link to this section">6.2.4</a></span> The Property Descriptor Specification Type</h1>
3011
3012 <p>The Property Descriptor type is used to explain the manipulation and reification of Object property attributes. Values
3013 of the Property Descriptor type are Records. Each field&rsquo;s name is an attribute name and its value is a corresponding
3014 attribute value as specified in <a href="#sec-property-attributes">6.1.7.1</a>. In addition, any field may be present or
3015 absent. The schema name used within this specification to tag literal descriptions of Property Descriptor records is
3016 &ldquo;PropertyDescriptor&rdquo;.</p>
3017
3018 <p>Property Descriptor values may be further classified as data Property Descriptors and accessor Property Descriptors
3019 based upon the existence or use of certain fields. A data Property Descriptor is one that includes any fields named either
3020 [[Value]] or [[Writable]]. An accessor Property Descriptor is one that includes any fields named either [[Get]] or
3021 [[Set]]. Any Property Descriptor may have fields named [[Enumerable]] and [[Configurable]]. A Property Descriptor value
3022 may not be both a data Property Descriptor and an accessor Property Descriptor; however, it may be neither. A generic
3023 Property Descriptor is a Property Descriptor value that is neither a data Property Descriptor nor an accessor Property
3024 Descriptor. A fully populated Property Descriptor is one that is either an accessor Property Descriptor or a data Property
3025 Descriptor and that has all of the fields that correspond to the property attributes defined in either <a
3026 href="#table-2">Table 2</a> or <a href="#table-3">Table 3</a>.</p>
3027
3028 <p>The following abstract operations are used in this specification to operate upon Property Descriptor values:</p>
3029 </div>
3030
3031 <section id="sec-isaccessordescriptor">
3032 <h1><span class="secnum" id="sec-6.2.4.1"><a href="#sec-isaccessordescriptor"
3033 title="link to this section">6.2.4.1</a></span> IsAccessorDescriptor ( Desc )</h1>
3034
3035 <p>When the abstract operation IsAccessorDescriptor is called with <a
3036 href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
3037 steps are taken:</p>
3038
3039 <ol class="proc">
3040 <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
3041 <li>If both <i>Desc</i>.[[Get]] and <i>Desc</i>.[[Set]] are absent, return <b>false</b>.</li>
3042 <li>Return <b>true</b>.</li>
3043 </ol>
3044 </section>
3045
3046 <section id="sec-isdatadescriptor">
3047 <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>
3048 IsDataDescriptor ( Desc )</h1>
3049
3050 <p>When the abstract operation IsDataDescriptor is called with <a
3051 href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
3052 steps are taken:</p>
3053
3054 <ol class="proc">
3055 <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
3056 <li>If both <i>Desc</i>.[[Value]] and <i>Desc</i>.[[Writable]] are absent, return <b>false</b>.</li>
3057 <li>Return <b>true</b>.</li>
3058 </ol>
3059 </section>
3060
3061 <section id="sec-isgenericdescriptor">
3062 <h1><span class="secnum" id="sec-6.2.4.3"><a href="#sec-isgenericdescriptor"
3063 title="link to this section">6.2.4.3</a></span> IsGenericDescriptor ( Desc )</h1>
3064
3065 <p>When the abstract operation IsGenericDescriptor is called with <a
3066 href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
3067 steps are taken:</p>
3068
3069 <ol class="proc">
3070 <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
3071 <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) and <a
3072 href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) are both <b>false</b>, return <b>true</b>.</li>
3073 <li>Return <b>false</b>.</li>
3074 </ol>
3075 </section>
3076
3077 <section id="sec-frompropertydescriptor">
3078 <h1><span class="secnum" id="sec-6.2.4.4"><a href="#sec-frompropertydescriptor"
3079 title="link to this section">6.2.4.4</a></span> FromPropertyDescriptor ( Desc )</h1>
3080
3081 <p>When the abstract operation FromPropertyDescriptor is called with <a
3082 href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
3083 steps are taken:</p>
3084
3085 <ol class="proc">
3086 <li>If <i>Desc</i> is <b>undefined</b>, return <b>undefined</b>.</li>
3087 <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
3088 sans-serif">%ObjectPrototype%</span>).</li>
3089 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>obj</i> is an extensible ordinary object with no own
3090 properties.</li>
3091 <li>If <i>Desc</i> has a [[Value]] field, then
3092 <ol class="block">
3093 <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
3094 <code>"value"</code>, <i>Desc</i>.[[Value]]).</li>
3095 </ol>
3096 </li>
3097 <li>If <i>Desc</i> has a [[Writable]] field, then
3098 <ol class="block">
3099 <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
3100 <code>"writable"</code>, <i>Desc</i>.[[Writable]]).</li>
3101 </ol>
3102 </li>
3103 <li>If <i>Desc</i> has a [[Get]] field, then
3104 <ol class="block">
3105 <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
3106 <code>"get",</code> <i>Desc</i>.[[Get]]).</li>
3107 </ol>
3108 </li>
3109 <li>If <i>Desc</i> has a [[Set]] field, then
3110 <ol class="block">
3111 <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
3112 <code>"set"</code>, <i>Desc</i>.[[Set]])</li>
3113 </ol>
3114 </li>
3115 <li>If <i>Desc</i> has an [[Enumerable]] field, then
3116 <ol class="block">
3117 <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
3118 <code>"enumerable"</code>, <i>Desc</i>.[[Enumerable]]).</li>
3119 </ol>
3120 </li>
3121 <li>If <i>Desc</i> has a [[Configurable]] field, then
3122 <ol class="block">
3123 <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i> ,
3124 <code>"configurable"</code>, <i>Desc</i>.[[Configurable]]).</li>
3125 </ol>
3126 </li>
3127 <li><a href="#sec-algorithm-conventions">Assert</a>: all of the above <a
3128 href="#sec-createdataproperty">CreateDataProperty</a> operations return <b>true</b>.</li>
3129 <li>Return <i>obj</i>.</li>
3130 </ol>
3131 </section>
3132
3133 <section id="sec-topropertydescriptor">
3134 <h1><span class="secnum" id="sec-6.2.4.5"><a href="#sec-topropertydescriptor"
3135 title="link to this section">6.2.4.5</a></span> ToPropertyDescriptor ( Obj )</h1>
3136
3137 <p>When the abstract operation ToPropertyDescriptor is called with object <span class="nt">Obj</span>, the following steps
3138 are taken:</p>
3139
3140 <ol class="proc">
3141 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>Obj</i>).</li>
3142 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Obj</i>) is not Object throw a <b>TypeError</b>
3143 exception.</li>
3144 <li>Let <i>desc</i> be a new <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> that
3145 initially has no fields.</li>
3146 <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"enumerable"</code>) is <b>true</b>, then
3147 <ol class="block">
3148 <li>Let <i>enum</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
3149 <code>"enumerable"</code>)).</li>
3150 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>enum</i>).</li>
3151 <li>Set the [[Enumerable]] field of <i>desc</i> to <i>enum</i>.</li>
3152 </ol>
3153 </li>
3154 <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"configurable"</code>) is <b>true</b>, then
3155 <ol class="block">
3156 <li>Let <i>conf</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
3157 <code>"configurable"</code>)).</li>
3158 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>conf</i>).</li>
3159 <li>Set the [[Configurable]] field of <i>desc</i> to <i>conf</i>.</li>
3160 </ol>
3161 </li>
3162 <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"value"</code>) is <b>true</b>, then
3163 <ol class="block">
3164 <li>Let <i>value</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"value"</code>).</li>
3165 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
3166 <li>Set the [[Value]] field of <i>desc</i> to <i>value</i>.</li>
3167 </ol>
3168 </li>
3169 <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"writable"</code>) is <b>true</b>, then
3170 <ol class="block">
3171 <li>Let <i>writable</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
3172 <code>"writable"</code>)).</li>
3173 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>writable</i>).</li>
3174 <li>Set the [[Writable]] field of <i>desc</i> to <i>writable</i>.</li>
3175 </ol>
3176 </li>
3177 <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"get"</code>) is <b>true</b>, then
3178 <ol class="block">
3179 <li>Let <i>getter</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"get"</code>).</li>
3180 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>getter</i>).</li>
3181 <li>If <a href="#sec-iscallable">IsCallable</a>(<i>getter</i>) is <b>false</b> and <i>getter</i> is not
3182 <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
3183 <li>Set the [[Get]] field of <i>desc</i> to <i>getter</i>.</li>
3184 </ol>
3185 </li>
3186 <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"set"</code>) is <b>true</b>, then
3187 <ol class="block">
3188 <li>Let <i>setter</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"set"</code>).</li>
3189 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>setter</i>).</li>
3190 <li>If <a href="#sec-iscallable">IsCallable</a>(<i>setter</i>) is <b>false</b> and <i>setter</i> is not
3191 <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
3192 <li>Set the [[Set]] field of <i>desc</i> to <i>setter</i>.</li>
3193 </ol>
3194 </li>
3195 <li>If either <i>desc</i>.[[Get]] or <i>desc</i>.[[Set]] are present, then
3196 <ol class="block">
3197 <li>If either <i>desc</i>.[[Value]] or <i>desc</i>.[[Writable]] are present, throw a <b>TypeError</b>
3198 exception.</li>
3199 </ol>
3200 </li>
3201 <li>Return <i>desc</i>.</li>
3202 </ol>
3203 </section>
3204
3205 <section id="sec-completepropertydescriptor">
3206 <h1><span class="secnum" id="sec-6.2.4.6"><a href="#sec-completepropertydescriptor"
3207 title="link to this section">6.2.4.6</a></span> CompletePropertyDescriptor ( Desc )</h1>
3208
3209 <p>When the abstract operation CompletePropertyDescriptor is called with <a
3210 href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
3211 steps are taken:</p>
3212
3213 <ol class="proc">
3214 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>Desc</i>).</li>
3215 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>Desc</i> is a <a
3216 href="#sec-property-descriptor-specification-type">Property Descriptor</a></li>
3217 <li>Let <i>like</i> be Record{[[Value]]: <b>undefined</b>, [[Writable]]: <b>false</b>, [[Get]]: <b>undefined</b>,
3218 [[Set]]: <b>undefined</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b>}.</li>
3219 <li>If either <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) or <a
3220 href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
3221 <ol class="block">
3222 <li>If <i>Desc</i> does not have a [[Value]] field, set <i>Desc</i>.[[Value]] to <i>like</i>.[[Value]].</li>
3223 <li>If <i>Desc</i> does not have a [[Writable]] field, set <i>Desc</i>.[[Writable]] to
3224 <i>like</i>.[[Writable]].</li>
3225 </ol>
3226 </li>
3227 <li>Else,
3228 <ol class="block">
3229 <li>If <i>Desc</i> does not have a [[Get]] field, set <i>Desc</i>.[[Get]] to <i>like</i>.[[Get]].</li>
3230 <li>If <i>Desc</i> does not have a [[Set]] field, set <i>Desc</i>.[[Set]] to <i>like</i>.[[Set]].</li>
3231 </ol>
3232 </li>
3233 <li>If <i>Desc</i> does not have an [[Enumerable]] field, set <i>Desc</i>.[[Enumerable]] to
3234 <i>like</i>.[[Enumerable]].</li>
3235 <li>If <i>Desc</i> does not have a [[Configurable]] field, set <i>Desc</i>.[[Configurable]] to
3236 <i>like</i>.[[Configurable]].</li>
3237 <li>Return <i>Desc</i>.</li>
3238 </ol>
3239 </section>
3240 </section>
3241
3242 <section id="sec-lexical-environment-and-environment-record-specification-types">
3243 <h1><span class="secnum" id="sec-6.2.5"><a href="#sec-lexical-environment-and-environment-record-specification-types"
3244 title="link to this section">6.2.5</a></span> The Lexical Environment and Environment Record Specification Types</h1>
3245
3246 <p>The <a href="#sec-lexical-environments">Lexical Environment</a> and <a href="#sec-environment-records">Environment
3247 Record</a> types are used to explain the behaviour of name resolution in nested functions and blocks. These types and the
3248 operations upon them are defined in <a href="#sec-lexical-environments">8.1</a>.</p>
3249 </section>
3250
3251 <section id="sec-data-blocks">
3252 <div class="front">
3253 <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
3254 Blocks</h1>
3255
3256 <p>The Data Block specification type is used to describe a distinct and mutable sequence of byte-sized (8 bit) numeric
3257 values. A Data Block value is created with a fixed number of bytes that each have the initial value 0.</p>
3258
3259 <p>For notational convenience within this specification, an array-like syntax can be used to express to the individual
3260 bytes of a Data Block value. This notation presents a Data Block value as a 0-origined integer indexed sequence of bytes.
3261 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
3262 3<sup>rd</sup> byte.</p>
3263
3264 <p>The following abstract operations are used in this specification to operate upon Data Block values:</p>
3265 </div>
3266
3267 <section id="sec-createbytedatablock">
3268 <h1><span class="secnum" id="sec-6.2.6.1"><a href="#sec-createbytedatablock"
3269 title="link to this section">6.2.6.1</a></span> CreateByteDataBlock(size)</h1>
3270
3271 <p>When the abstract operation CreateByteDataBlock is called with integer argument <var>size</var>, the following steps
3272 are taken:</p>
3273
3274 <ol class="proc">
3275 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>size</i>&ge;0.</li>
3276 <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
3277 impossible to create such a <a href="#sec-data-blocks">Data Block</a>, throw a <b>RangeError</b> exception.</li>
3278 <li>Set all of the bytes of <i>db</i> to 0.</li>
3279 <li>Return <i>db</i>.</li>
3280 </ol>
3281 </section>
3282
3283 <section id="sec-copydatablockbytes">
3284 <h1><span class="secnum" id="sec-6.2.6.2"><a href="#sec-copydatablockbytes"
3285 title="link to this section">6.2.6.2</a></span> CopyDataBlockBytes(toBlock, toIndex, fromBlock, fromIndex, count)</h1>
3286
3287 <p>When the abstract operation CopyDataBlockBytes is called the following steps are taken:</p>
3288
3289 <ol class="proc">
3290 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromBlock</i> and <i>toBlock</i> are distinct <a
3291 href="#sec-data-blocks">Data Block</a> values.</li>
3292 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromIndex</i>, <i>toIndex</i>, and <i>count</i> are positive
3293 integer values.</li>
3294 <li>Let <i>fromSize</i> be the number of bytes in <i>fromBlock</i>.</li>
3295 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromIndex</i>+<i>count</i> &le; <i>fromSize</i>.</li>
3296 <li>Let <i>toSize</i> be the number of bytes in <i>toBlock</i>.</li>
3297 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>toIndex</i>+<i>count</i> &le; <i>toSize</i>.</li>
3298 <li>Repeat, while <i>count</i>&gt;0
3299 <ol class="block">
3300 <li>Set <i>toBlock</i>[<i>toIndex</i>] to the value of <i>fromBlock</i>[<i>fromIndex</i>].</li>
3301 <li>Increment <i>toIndex</i> and <i>fromIndex</i> each by 1.</li>
3302 <li>Decrement <i>count</i> by 1.</li>
3303 </ol>
3304 </li>
3305 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>)</li>
3306 </ol>
3307 </section>
3308 </section>
3309 </section>
3310 </section>
3311
3312 <section id="sec-abstract-operations">
3313 <div class="front">
3314 <h1><span class="secnum" id="sec-7"><a href="#sec-abstract-operations" title="link to this section">7</a></span> Abstract
3315 Operations</h1>
3316
3317 <p>These operations are not a part of the ECMAScript language; they are defined here to solely to aid the specification of the
3318 semantics of the ECMAScript language. Other, more specialized abstract operations are defined throughout this
3319 specification.</p>
3320 </div>
3321
3322 <section id="sec-type-conversion">
3323 <div class="front">
3324 <h1><span class="secnum" id="sec-7.1"><a href="#sec-type-conversion" title="link to this section">7.1</a></span> Type
3325 Conversion</h1>
3326
3327 <p>The ECMAScript language implicitly performs automatic type conversion as needed. To clarify the semantics of certain
3328 constructs it is useful to define a set of conversion abstract operations. The conversion abstract operations are
3329 polymorphic; they can accept a value of any <a href="#sec-ecmascript-language-types">ECMAScript language type</a> or of a <a
3330 href="#sec-completion-record-specification-type">Completion Record</a> value. But no other specification types are used with
3331 these operations.</p>
3332 </div>
3333
3334 <section id="sec-toprimitive">
3335 <h1><span class="secnum" id="sec-7.1.1"><a href="#sec-toprimitive" title="link to this section">7.1.1</a></span> ToPrimitive
3336 ( input [, PreferredType] )</h1>
3337
3338 <p>The abstract operation ToPrimitive takes an <var>input</var> argument and an optional argument <span
3339 class="nt">PreferredType</span>. The abstract operation ToPrimitive converts its <var>input</var> argument to a non-Object
3340 type. If an object is capable of converting to more than one primitive type, it may use the optional hint <span
3341 class="nt">PreferredType</span> to favour that type. Conversion occurs according to <a href="#table-9">Table 9</a>:</p>
3342
3343 <figure>
3344 <figcaption><span id="table-9">Table 9</span> &mdash; ToPrimitive Conversions</figcaption>
3345 <table class="real-table">
3346 <tr>
3347 <th>Input Type</th>
3348 <th>Result</th>
3349 </tr>
3350 <tr>
3351 <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
3352 <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>
3353 </tr>
3354 <tr>
3355 <td>Undefined</td>
3356 <td>Return <var>input</var>.</td>
3357 </tr>
3358 <tr>
3359 <td>Null</td>
3360 <td>Return <var>input</var>.</td>
3361 </tr>
3362 <tr>
3363 <td>Boolean</td>
3364 <td>Return <var>input</var>.</td>
3365 </tr>
3366 <tr>
3367 <td>Number</td>
3368 <td>Return <var>input</var>.</td>
3369 </tr>
3370 <tr>
3371 <td>String</td>
3372 <td>Return <var>input</var>.</td>
3373 </tr>
3374 <tr>
3375 <td>Symbol</td>
3376 <td>Return <var>input</var>.</td>
3377 </tr>
3378 <tr>
3379 <td>Object</td>
3380 <td>Perform the steps following this table.</td>
3381 </tr>
3382 </table>
3383 </figure>
3384
3385 <p>When <span style="font-family: Times New Roman"><a
3386 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>input</i>)</span> is Object, the following steps are taken:</p>
3387
3388 <ol class="proc">
3389 <li>If <i>PreferredType</i> was not passed, let <i>hint</i> be <code>"default"</code>.</li>
3390 <li>Else if <i>PreferredType</i> is hint String, let <i>hint</i> be <code>"string"</code>.</li>
3391 <li>Else <i>PreferredType</i> is hint Number, let <i>hint</i> be <code>"number"</code>.</li>
3392 <li>Let <i>exoticToPrim</i> be <a href="#sec-getmethod">GetMethod</a>(<i>input</i>, @@toPrimitive).</li>
3393 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exoticToPrim</i>).</li>
3394 <li>If <i>exoticToPrim</i> is not <b>undefined</b>, then
3395 <ol class="block">
3396 <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>exoticToPrim</i>, <i>input,</i>
3397 &laquo;<i>hint</i>&raquo;).</li>
3398 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
3399 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, return
3400 <i>result</i>.</li>
3401 <li>Throw a <b>TypeError</b> exception.</li>
3402 </ol>
3403 </li>
3404 <li>If <i>hint</i> is <code>"default"</code>, let <i>hint</i> be <code>"number"</code>.</li>
3405 <li>Return OrdinaryToPrimitive(<i>input,hint</i>).</li>
3406 </ol>
3407
3408 <p>When the abstract operation OrdinaryToPrimitive is called with arguments <var>O</var> and <var>hint</var>, the following
3409 steps are taken:</p>
3410
3411 <ol class="proc">
3412 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
3413 Object</li>
3414 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>hint</i>)
3415 is String and its value is either <code>"string"</code> or <code>"number"</code>.</li>
3416 <li>If <i>hint</i> is <code>"string"</code>, then
3417 <ol class="block">
3418 <li>Let <i>methodNames</i> be &laquo;<code>"toString"</code>, <code>"valueOf"</code>&raquo;.</li>
3419 </ol>
3420 </li>
3421 <li>Else,
3422 <ol class="block">
3423 <li>Let <i>methodNames</i> be &laquo;<code>"valueOf"</code>, <code>"toString"</code>&raquo;.</li>
3424 </ol>
3425 </li>
3426 <li>For each <i>name</i> in <i>methodNames</i> in <a href="#sec-list-and-record-specification-type">List</a> order, do
3427 <ol class="block">
3428 <li>Let <i>method</i> be <a href="#sec-get-o-p">Get</a>(<i>O</i>, <i>name</i>).</li>
3429 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>method</i>).</li>
3430 <li>If <a href="#sec-iscallable">IsCallable</a>(<i>method</i>) is <b>true</b>, then
3431 <ol class="block">
3432 <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>method</i>, <i>O</i>).</li>
3433 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
3434 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, return
3435 <i>result</i>.</li>
3436 </ol>
3437 </li>
3438 </ol>
3439 </li>
3440 <li>Throw a <b>TypeError</b> exception.</li>
3441 </ol>
3442
3443 <div class="note">
3444 <p><span class="nh">NOTE</span> When ToPrimitive is called with no hint, then it generally behaves as if the hint were
3445 Number. However, objects may over-ride this behaviour by defining a @@toPrimitive method. Of the objects defined in this
3446 specification only Date objects (<a href="#sec-date.prototype-@@toprimitive">see 20.3.4.45</a>) and Symbol objects (<a
3447 href="#sec-symbol.prototype-@@toprimitive">see 19.4.3.4</a>) over-ride the default ToPrimitive behaviour. Date objects
3448 treat no hint as if the hint were String.</p>
3449 </div>
3450 </section>
3451
3452 <section id="sec-toboolean">
3453 <h1><span class="secnum" id="sec-7.1.2"><a href="#sec-toboolean" title="link to this section">7.1.2</a></span> ToBoolean (
3454 argument )</h1>
3455
3456 <p>The abstract operation ToBoolean converts <var>argument</var> to a value of type Boolean according to <a
3457 href="#table-10">Table 10</a>:</p>
3458
3459 <figure>
3460 <figcaption><span id="table-10">Table 10</span> &mdash; ToBoolean Conversions</figcaption>
3461 <table class="real-table">
3462 <tr>
3463 <th>Argument Type</th>
3464 <th>Result</th>
3465 </tr>
3466 <tr>
3467 <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
3468 <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>
3469 </tr>
3470 <tr>
3471 <td>Undefined</td>
3472 <td>Return <b>false</b>.</td>
3473 </tr>
3474 <tr>
3475 <td>Null</td>
3476 <td>Return <b>false</b>.</td>
3477 </tr>
3478 <tr>
3479 <td>Boolean</td>
3480 <td>Return <var>argument</var>.</td>
3481 </tr>
3482 <tr>
3483 <td>Number</td>
3484 <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>
3485 </tr>
3486 <tr>
3487 <td>String</td>
3488 <td>Return <b>false</b> if <var>argument</var> is the empty String (its length is zero); otherwise return <b>true</b>.</td>
3489 </tr>
3490 <tr>
3491 <td>Symbol</td>
3492 <td>Return <b>true</b>.</td>
3493 </tr>
3494 <tr>
3495 <td>Object</td>
3496 <td>Return <b>true</b>.</td>
3497 </tr>
3498 </table>
3499 </figure>
3500 </section>
3501
3502 <section id="sec-tonumber">
3503 <div class="front">
3504 <h1><span class="secnum" id="sec-7.1.3"><a href="#sec-tonumber" title="link to this section">7.1.3</a></span> ToNumber (
3505 argument )</h1>
3506
3507 <p>The abstract operation ToNumber converts <var>argument</var> to a value of type Number according to <a
3508 href="#table-11">Table 11</a>:</p>
3509
3510 <figure>
3511 <figcaption><span id="table-11">Table 11</span> &mdash; ToNumber Conversions</figcaption>
3512 <table class="real-table">
3513 <tr>
3514 <th>Argument Type</th>
3515 <th>Result</th>
3516 </tr>
3517 <tr>
3518 <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
3519 <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>
3520 </tr>
3521 <tr>
3522 <td>Undefined</td>
3523 <td>Return <b>NaN</b>.</td>
3524 </tr>
3525 <tr>
3526 <td>Null</td>
3527 <td>Return <b>+0</b>.</td>
3528 </tr>
3529 <tr>
3530 <td>Boolean</td>
3531 <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>
3532 </tr>
3533 <tr>
3534 <td>Number</td>
3535 <td>Return <var>argument</var> (no conversion).</td>
3536 </tr>
3537 <tr>
3538 <td>String</td>
3539 <td>See grammar and conversion algorithm below.</td>
3540 </tr>
3541 <tr>
3542 <td>Symbol</td>
3543 <td>Throw a <b>TypeError</b> exception.</td>
3544 </tr>
3545 <tr>
3546 <td>Object</td>
3547
3548 <td>
3549 <p>Apply the following steps:</p>
3550
3551 <ol class="proc">
3552 <li>Let <i>primValue</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint Number).</li>
3553 <li>Return ToNumber(<i>primValue</i>).</li>
3554 </ol>
3555 </td>
3556 </tr>
3557 </table>
3558 </figure>
3559 </div>
3560
3561 <section id="sec-tonumber-applied-to-the-string-type">
3562 <div class="front">
3563 <h1><span class="secnum" id="sec-7.1.3.1"><a href="#sec-tonumber-applied-to-the-string-type"
3564 title="link to this section">7.1.3.1</a></span> ToNumber Applied to the String Type</h1>
3565
3566 <p><a href="#sec-tonumber">ToNumber</a> applied to Strings applies the following grammar to the input String interpreted
3567 as a sequence of UTF-16 encoded code points (<a href="#sec-ecmascript-language-types-string-type">6.1.4</a>). If the
3568 grammar cannot interpret the String as an expansion of <span class="nt">StringNumericLiteral</span>, then the result of
3569 <a href="#sec-tonumber">ToNumber</a> is <b>NaN</b>.</p>
3570
3571 <div class="note">
3572 <p><span class="nh">NOTE</span> The terminal symbols of this grammar are all composed of Unicode BMP code points so
3573 the result will be <b>NaN</b> if the string contains the UTF-16 encoding of any supplementary code points or any
3574 unpaired surrogate code points</p>
3575 </div>
3576
3577 <h2>Syntax</h2>
3578
3579 <div class="gp">
3580 <div class="lhs"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span></div>
3581 <div class="rhs"><span class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></div>
3582 <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>
3583 </div>
3584
3585 <div class="gp">
3586 <div class="lhs"><span class="nt">StrWhiteSpace</span> <span class="geq">:::</span></div>
3587 <div class="rhs"><span class="nt">StrWhiteSpaceChar</span> <span class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></div>
3588 </div>
3589
3590 <div class="gp">
3591 <div class="lhs"><span class="nt">StrWhiteSpaceChar</span> <span class="geq">:::</span></div>
3592 <div class="rhs"><span class="nt">WhiteSpace</span></div>
3593 <div class="rhs"><span class="nt">LineTerminator</span></div>
3594 </div>
3595
3596 <div class="gp">
3597 <div class="lhs"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span></div>
3598 <div class="rhs"><span class="nt">StrDecimalLiteral</span></div>
3599 <div class="rhs"><span class="nt">BinaryIntegerLiteral</span></div>
3600 <div class="rhs"><span class="nt">OctalIntegerLiteral</span></div>
3601 <div class="rhs"><span class="nt">HexIntegerLiteral</span></div>
3602 </div>
3603
3604 <div class="gp">
3605 <div class="lhs"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span></div>
3606 <div class="rhs"><span class="nt">StrUnsignedDecimalLiteral</span></div>
3607 <div class="rhs"><code class="t">+</code> <span class="nt">StrUnsignedDecimalLiteral</span></div>
3608 <div class="rhs"><code class="t">-</code> <span class="nt">StrUnsignedDecimalLiteral</span></div>
3609 </div>
3610
3611 <div class="gp">
3612 <div class="lhs"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span></div>
3613 <div class="rhs"><span class="nt">Infinity</span></div>
3614 <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>
3615 <div class="rhs"><code class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
3616 <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
3617 </div>
3618
3619 <div class="gp">
3620 <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">:::</span></div>
3621 <div class="rhs"><span class="nt">DecimalDigit</span></div>
3622 <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
3623 </div>
3624
3625 <div class="gp">
3626 <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">:::</span> <span class="grhsmod">one of</span></div>
3627 <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>
3628 </div>
3629
3630 <div class="gp">
3631 <div class="lhs"><span class="nt">ExponentPart</span> <span class="geq">:::</span></div>
3632 <div class="rhs"><span class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></div>
3633 </div>
3634
3635 <div class="gp">
3636 <div class="lhs"><span class="nt">ExponentIndicator</span> <span class="geq">:::</span> <span class="grhsmod">one of</span></div>
3637 <div class="rhs"><code class="t">e</code> <code class="t">E</code></div>
3638 </div>
3639
3640 <div class="gp">
3641 <div class="lhs"><span class="nt">SignedInteger</span> <span class="geq">:::</span></div>
3642 <div class="rhs"><span class="nt">DecimalDigits</span></div>
3643 <div class="rhs"><code class="t">+</code> <span class="nt">DecimalDigits</span></div>
3644 <div class="rhs"><code class="t">-</code> <span class="nt">DecimalDigits</span></div>
3645 </div>
3646
3647 <p>All grammar symbols not explicitly defined above have the definitions used in the Lexical Grammar for numeric
3648 literals (<a href="#sec-literals-numeric-literals">11.8.3</a>)</p>
3649
3650 <div class="note">
3651 <p><span class="nh">NOTE</span> Some differences should be noted between the syntax of a <i>StringNumericLiteral</i>
3652 and a <i>NumericLiteral</i> (<a href="#sec-literals-numeric-literals">see 11.8.3</a>):</p>
3653
3654 <ul>
3655 <li>
3656 <p>A <i>StringNumericLiteral</i> may include leading and/or trailing white space and/or line terminators.</p>
3657 </li>
3658
3659 <li>
3660 <p>A <i>StringNumericLiteral</i> that is decimal may have any number of leading <code>0</code> digits.</p>
3661 </li>
3662
3663 <li>
3664 <p>A <i>StringNumericLiteral</i> that is decimal may include a <code>+</code> or <code>-</code> to indicate its
3665 sign.</p>
3666 </li>
3667
3668 <li>
3669 <p>A <i>StringNumericLiteral</i> that is empty or contains only white space is converted to <b>+0</b>.</p>
3670 </li>
3671
3672 <li>
3673 <p><code>Infinity</code> <code>and &ndash;Infinity</code> are recognized as a <i>StringNumericLiteral</i> but not
3674 as a <i>NumericLiteral</i>.</p>
3675 </li>
3676 </ul>
3677 </div>
3678 </div>
3679
3680 <section id="sec-runtime-semantics-mv-s">
3681 <h1><span class="secnum" id="sec-7.1.3.1.1"><a href="#sec-runtime-semantics-mv-s"
3682 title="link to this section">7.1.3.1.1</a></span> Runtime Semantics: MV&rsquo;s</h1>
3683
3684 <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a
3685 numeric literal (<a href="#sec-literals-numeric-literals">see 11.8.3</a>), but some of the details are different, so the
3686 process for converting a String numeric literal to a value of Number type is given here. This value is determined in two
3687 steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is
3688 rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <a
3689 href="#sec-static-semantics-mv-s">11.8.3.1</a>.</p>
3690
3691 <ul>
3692 <li>
3693 <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <span
3694 class="grhsannot">[empty]</span></span> is 0.</p>
3695 </li>
3696
3697 <li>
3698 <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <span
3699 class="nt">StrWhiteSpace</span></span> is 0.</p>
3700 </li>
3701
3702 <li>
3703 <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <span
3704 class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub> <span class="nt">StrNumericLiteral</span> <span
3705 class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></span> is the MV of <span
3706 class="nt">StrNumericLiteral</span>, no matter whether white space is present or not.</p>
3707 </li>
3708
3709 <li>
3710 <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
3711 class="nt">StrDecimalLiteral</span></span> is the MV of <span class="nt">StrDecimalLiteral</span>.</p>
3712 </li>
3713
3714 <li>
3715 <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
3716 class="nt">BinaryIntegerLiteral</span></span> is the MV of <span class="nt">BinaryIntegerLiteral</span>.</p>
3717 </li>
3718
3719 <li>
3720 <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
3721 class="nt">OctalIntegerLiteral</span></span> is the MV of <span class="nt">OctalIntegerLiteral</span>.</p>
3722 </li>
3723
3724 <li>
3725 <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
3726 class="nt">HexIntegerLiteral</span></span> is the MV of <span class="nt">HexIntegerLiteral</span>.</p>
3727 </li>
3728
3729 <li>
3730 <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <span
3731 class="nt">StrUnsignedDecimalLiteral</span></span> is the MV of <span
3732 class="nt">StrUnsignedDecimalLiteral</span>.</p>
3733 </li>
3734
3735 <li>
3736 <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <code
3737 class="t">+</code> <span class="nt">StrUnsignedDecimalLiteral</span></span> is the MV of <span
3738 class="nt">StrUnsignedDecimalLiteral</span>.</p>
3739 </li>
3740
3741 <li>
3742 <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <code
3743 class="t">-</code> <span class="nt">StrUnsignedDecimalLiteral</span></span> is the negative of the MV of <span
3744 class="nt">StrUnsignedDecimalLiteral</span>. (Note that if the MV of <span
3745 class="nt">StrUnsignedDecimalLiteral</span> is 0, the negative of this MV is also 0. The rounding rule described
3746 below handles the conversion of this signless mathematical zero to a floating-point <b>+0</b> or <b>&minus;0</b> as
3747 appropriate.)</p>
3748 </li>
3749
3750 <li>
3751 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
3752 class="nt">Infinity</span></span> is <span style="font-family: Times New Roman">10<sup>10000</sup></span> (a value
3753 so large that it will round to <b>+&infin;</b>).</p>
3754 </li>
3755
3756 <li>
3757 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
3758 class="nt">DecimalDigits</span> <code class="t">.</code></span> is the MV of <span
3759 class="nt">DecimalDigits</span>.</p>
3760 </li>
3761
3762 <li>
3763 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
3764 class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of
3765 the first <span class="nt">DecimalDigits</span> plus (the MV of the second <span class="nt">DecimalDigits</span>
3766 times <span style="font-family: Times New Roman">10<sup>&minus;<i>n</i></sup></span>), where <var>n</var> is the
3767 number of code points in the second <span class="nt">DecimalDigits</span>.</p>
3768 </li>
3769
3770 <li>
3771 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
3772 class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">ExponentPart</span></span> is the MV of
3773 <i>DecimalDigits</i> times 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
3774 </li>
3775
3776 <li>
3777 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
3778 class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">DecimalDigits</span> <span
3779 class="nt">ExponentPart</span></span> is (the MV of the first <i>DecimalDigits</i> plus (the MV of the second
3780 <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
3781 of code points in the second <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
3782 </li>
3783
3784 <li>
3785 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <code
3786 class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i> times
3787 10<sup>&minus;<i>n</i></sup>, where <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
3788 </li>
3789
3790 <li>
3791 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <code
3792 class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of
3793 <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
3794 <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
3795 </li>
3796
3797 <li>
3798 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
3799 class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
3800 </li>
3801
3802 <li>
3803 <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
3804 class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of <i>DecimalDigits</i> times
3805 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
3806 </li>
3807 </ul>
3808
3809 <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type.
3810 If the MV is 0, then the rounded value is +0 unless the first non white space code point in the String numeric literal
3811 is &lsquo;<code>-</code>&rsquo;, in which case the rounded value is &minus;0. Otherwise, the rounded value must be the
3812 Number value for the MV (in the sense defined in <a href="#sec-ecmascript-language-types-number-type">6.1.6</a>), unless
3813 the literal includes a <span class="nt">StrUnsignedDecimalLiteral</span> and the literal has more than 20 significant
3814 digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each
3815 significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each
3816 significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is
3817 significant if it is not part of an <span class="nt">ExponentPart</span> and</p>
3818
3819 <ul>
3820 <li>it is not <code>0</code>; or</li>
3821 <li>there is a nonzero digit to its left and there is a nonzero digit, not in the <span
3822 class="nt">ExponentPart</span>, to its right.</li>
3823 </ul>
3824 </section>
3825 </section>
3826 </section>
3827
3828 <section id="sec-tointeger">
3829 <h1><span class="secnum" id="sec-7.1.4"><a href="#sec-tointeger" title="link to this section">7.1.4</a></span> ToInteger (
3830 argument )</h1>
3831
3832 <p>The abstract operation ToInteger converts <var>argument</var> to an integral numeric value. This abstract operation
3833 functions as follows:</p>
3834
3835 <ol class="proc">
3836 <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
3837 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
3838 <li>If <i>number</i> is <b>NaN</b>, return <b>+0</b>.</li>
3839 <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>
3840 <li>Return the number value that is the same sign as <i>number</i> and whose magnitude is <a
3841 href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
3842 </ol>
3843 </section>
3844
3845 <section id="sec-toint32">
3846 <h1><span class="secnum" id="sec-7.1.5"><a href="#sec-toint32" title="link to this section">7.1.5</a></span> ToInt32 (
3847 argument )</h1>
3848
3849 <p>The abstract operation ToInt32 converts <var>argument</var> to one of <span style="font-family: Times New
3850 Roman">2<sup>32</sup></span> integer values in the range <span style="font-family: Times New
3851 Roman">&minus;2<sup>31</sup></span> through <span style="font-family: Times New Roman">2<sup>31</sup>&minus;1</span>,
3852 inclusive. This abstract operation functions as follows:</p>
3853
3854 <ol class="proc">
3855 <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
3856 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
3857 <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
3858 <b>+0</b>.</li>
3859 <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
3860 href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
3861 <li>Let <i>int32bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>32</sup>.</li>
3862 <li>If <i>int32bit</i> &ge; 2<sup>31</sup>, return <i>int32bit</i> &minus; 2<sup>32</sup>, otherwise return
3863 <i>int32bit</i>.</li>
3864 </ol>
3865
3866 <div class="note">
3867 <p><span class="nh">NOTE</span> Given the above definition of ToInt32:</p>
3868
3869 <ul>
3870 <li>
3871 <p>The ToInt32 abstract operation is idempotent: if applied to a result that it produced, the second application
3872 leaves that value unchanged.</p>
3873 </li>
3874
3875 <li>
3876 <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>.
3877 (It is to preserve this latter property that +<b>&infin;</b> and &minus;<b>&infin;</b> are mapped to <b>+0</b>.)</p>
3878 </li>
3879
3880 <li>
3881 <p>ToInt32 maps <b>&minus;0</b> to <b>+0</b>.</p>
3882 </li>
3883 </ul>
3884 </div>
3885 </section>
3886
3887 <section id="sec-touint32">
3888 <h1><span class="secnum" id="sec-7.1.6"><a href="#sec-touint32" title="link to this section">7.1.6</a></span> ToUint32 (
3889 argument )</h1>
3890
3891 <p>The abstract operation ToUint32 converts <var>argument</var> to one of <span style="font-family: Times New
3892 Roman">2<sup>32</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
3893 style="font-family: Times New Roman">2<sup>32</sup>&minus;1</span>, inclusive. This abstract operation functions as
3894 follows:</p>
3895
3896 <ol class="proc">
3897 <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
3898 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
3899 <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
3900 <b>+0</b>.</li>
3901 <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
3902 href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
3903 <li>Let <i>int32bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>32</sup>.</li>
3904 <li>Return <i>int32bit</i>.</li>
3905 </ol>
3906
3907 <div class="note">
3908 <p><span class="nh">NOTE</span> Given the above definition of ToUint32:</p>
3909
3910 <ul>
3911 <li>
3912 <p>Step 6 is the only difference between ToUint32 and <a href="#sec-toint32">ToInt32</a>.</p>
3913 </li>
3914
3915 <li>
3916 <p>The ToUint32 abstract operation is idempotent: if applied to a result that it produced, the second application
3917 leaves that value unchanged.</p>
3918 </li>
3919
3920 <li>
3921 <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>.
3922 (It is to preserve this latter property that <b>+&infin;</b> and <b>&minus;&infin;</b> are mapped to <b>+0</b>.)</p>
3923 </li>
3924
3925 <li>
3926 <p>ToUint32 maps <b>&minus;0</b> to <b>+0</b>.</p>
3927 </li>
3928 </ul>
3929 </div>
3930 </section>
3931
3932 <section id="sec-toint16">
3933 <h1><span class="secnum" id="sec-7.1.7"><a href="#sec-toint16" title="link to this section">7.1.7</a></span> ToInt16 (
3934 argument )</h1>
3935
3936 <p>The abstract operation ToInt16 converts <var>argument</var> to one of <span style="font-family: Times New
3937 Roman">2<sup>16</sup></span> integer values in the range <span style="font-family: Times New Roman">&minus;32768</span>
3938 through <span style="font-family: Times New Roman">32767</span>, inclusive. This abstract operation functions as
3939 follows:</p>
3940
3941 <ol class="proc">
3942 <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
3943 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
3944 <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
3945 <b>+0</b>.</li>
3946 <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
3947 href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
3948 <li>Let <i>int16bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>16</sup>.</li>
3949 <li>If <i>int16bit</i> &ge; 2<sup>15</sup>, return <i>int16bit</i> &minus; 2<sup>16</sup>, otherwise return
3950 <i>int16bit</i>.</li>
3951 </ol>
3952 </section>
3953
3954 <section id="sec-touint16">
3955 <h1><span class="secnum" id="sec-7.1.8"><a href="#sec-touint16" title="link to this section">7.1.8</a></span> ToUint16 (
3956 argument )</h1>
3957
3958 <p>The abstract operation ToUint16 converts <var>argument</var> to one of <span style="font-family: Times New
3959 Roman">2<sup>16</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
3960 style="font-family: Times New Roman">2<sup>16</sup>&minus;1</span>, inclusive. This abstract operation functions as
3961 follows:</p>
3962
3963 <ol class="proc">
3964 <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
3965 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
3966 <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
3967 <b>+0</b>.</li>
3968 <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
3969 href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
3970 <li>Let <i>int16bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>16</sup>.</li>
3971 <li>Return <i>int16bit</i>.</li>
3972 </ol>
3973
3974 <div class="note">
3975 <p><span class="nh">NOTE</span> Given the above definition of ToUint16:</p>
3976
3977 <ul>
3978 <li>The substitution of 2<sup>16</sup> for 2<sup>32</sup> in step 5 is the only difference between <a
3979 href="#sec-touint32">ToUint32</a> and ToUint16.</li>
3980 <li>ToUint16 maps <b>&minus;0</b> to <span style="font-family: sans-serif"><b>+0</b></span>.</li>
3981 </ul>
3982 </div>
3983 </section>
3984
3985 <section id="sec-toint8">
3986 <h1><span class="secnum" id="sec-7.1.9"><a href="#sec-toint8" title="link to this section">7.1.9</a></span> ToInt8 (
3987 argument )</h1>
3988
3989 <p>The abstract operation ToInt8 converts <var>argument</var> to one of <span style="font-family: Times New
3990 Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">&minus;128</span> through
3991 <span style="font-family: Times New Roman">127</span>, inclusive. This abstract operation functions as follows:</p>
3992
3993 <ol class="proc">
3994 <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
3995 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
3996 <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
3997 <b>+0</b>.</li>
3998 <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
3999 href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
4000 <li>Let <i>int8bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>8</sup>.</li>
4001 <li>If <i>int8bit</i> &ge; 2<sup>7</sup>, return <i>int8bit</i> &minus; 2<sup>8</sup>, otherwise return
4002 <i>int8bit</i>.</li>
4003 </ol>
4004 </section>
4005
4006 <section id="sec-touint8">
4007 <h1><span class="secnum" id="sec-7.1.10"><a href="#sec-touint8" title="link to this section">7.1.10</a></span> ToUint8 (
4008 argument )</h1>
4009
4010 <p>The abstract operation ToUint8 converts <var>argument</var> to one of <span style="font-family: Times New
4011 Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
4012 style="font-family: Times New Roman">255</span>, inclusive. This abstract operation functions as follows:</p>
4013
4014 <ol class="proc">
4015 <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
4016 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
4017 <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
4018 <b>+0</b>.</li>
4019 <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
4020 href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
4021 <li>Let <i>int8bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>8</sup>.</li>
4022 <li>Return <i>int8bit</i>.</li>
4023 </ol>
4024 </section>
4025
4026 <section id="sec-touint8clamp">
4027 <h1><span class="secnum" id="sec-7.1.11"><a href="#sec-touint8clamp" title="link to this section">7.1.11</a></span>
4028 ToUint8Clamp ( argument )</h1>
4029
4030 <p>The abstract operation ToUint8Clamp converts <var>argument</var> to one of <span style="font-family: Times New
4031 Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
4032 style="font-family: Times New Roman">255</span>, inclusive. This abstract operation functions as follows:</p>
4033
4034 <ol class="proc">
4035 <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
4036 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
4037 <li>If <i>number</i> is <b>NaN</b>, return <b>+0</b>.</li>
4038 <li>If <i>number</i> &le; 0, return <b>+0</b>.</li>
4039 <li>If <i>number</i> &ge; 255, return 255.</li>
4040 <li>Let <i>f</i> be <a href="#sec-algorithm-conventions">floor</a>(<i>number</i>).</li>
4041 <li>If <i>f</i> <i>+</i> 0.5 &lt; <i>number</i>, return <i>f</i> + 1.</li>
4042 <li>If <i>number</i> &lt; <i>f +</i> 0.5, return <i>f</i>.</li>
4043 <li>If <i>f</i> is odd, return <i>f</i> + 1.</li>
4044 <li>Return <i>f</i>.</li>
4045 </ol>
4046
4047 <div class="note">
4048 <p><span class="nh">NOTE</span> Note that unlike the other ECMAScript integer conversion abstract operation, ToUint8Clamp
4049 rounds rather than truncates non-integer values and does not convert +<b>&infin;</b> to 0. ToUint8Clamp does &ldquo;round
4050 half to even&rdquo; tie-breaking. This differs from <code><a href="#sec-math.round">Math.round</a></code> which does
4051 &ldquo;round half up&rdquo; tie-breaking.</p>
4052 </div>
4053 </section>
4054
4055 <section id="sec-tostring">
4056 <div class="front">
4057 <h1><span class="secnum" id="sec-7.1.12"><a href="#sec-tostring" title="link to this section">7.1.12</a></span> ToString (
4058 argument )</h1>
4059
4060 <p>The abstract operation ToString converts <var>argument</var> to a value of type String according to <a
4061 href="#table-12">Table 12</a>:</p>
4062
4063 <figure>
4064 <figcaption><span id="table-12">Table 12</span> &mdash; ToString Conversions</figcaption>
4065 <table class="real-table">
4066 <tr>
4067 <th>Argument Type</th>
4068 <th>Result</th>
4069 </tr>
4070 <tr>
4071 <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
4072 <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>
4073 </tr>
4074 <tr>
4075 <td>Undefined</td>
4076 <td>Return <code>"undefined"</code>.</td>
4077 </tr>
4078 <tr>
4079 <td>Null</td>
4080 <td>Return <code>"null"</code>.</td>
4081 </tr>
4082 <tr>
4083 <td>Boolean</td>
4084
4085 <td>
4086 <p>If <var>argument</var> is <b>true</b>, return <code>"true"</code>.</p>
4087
4088 <p>If <var>argument</var> is <b>false</b>, return <b><code>"false"</code>.</b></p>
4089 </td>
4090 </tr>
4091 <tr>
4092 <td>Number</td>
4093 <td>See <a href="#sec-tostring-applied-to-the-number-type">7.1.12.1</a>.</td>
4094 </tr>
4095 <tr>
4096 <td>String</td>
4097 <td>Return <var>argument</var>.</td>
4098 </tr>
4099 <tr>
4100 <td>Symbol</td>
4101 <td>Throw a <b>TypeError</b> exception.</td>
4102 </tr>
4103 <tr>
4104 <td>Object</td>
4105
4106 <td>
4107 <p>Apply the following steps:</p>
4108
4109 <p>1. Let <i>primValue</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint String).</p>
4110
4111 <p>2. Return ToString(<i>primValue</i>).</p>
4112 </td>
4113 </tr>
4114 </table>
4115 </figure>
4116 </div>
4117
4118 <section id="sec-tostring-applied-to-the-number-type">
4119 <h1><span class="secnum" id="sec-7.1.12.1"><a href="#sec-tostring-applied-to-the-number-type"
4120 title="link to this section">7.1.12.1</a></span> ToString Applied to the Number Type</h1>
4121
4122 <p>The abstract operation <a href="#sec-tostring">ToString</a> converts a Number <var>m</var> to String format as
4123 follows:</p>
4124
4125 <ol class="proc">
4126 <li>If <i>m</i> is <b>NaN</b>, return the String <code>"NaN"</code>.</li>
4127 <li>If <i>m</i> is <b>+0</b> or <b>&minus;0</b>, return the String <code>"0"</code>.</li>
4128 <li>If <i>m</i> is less than zero, return the String concatenation of the String <code>"-"</code> and <a
4129 href="#sec-tostring">ToString</a>(&minus;<i>m</i>).</li>
4130 <li>If <i>m</i> is +&infin;, return the String <code>"Infinity"</code>.</li>
4131 <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>
4132 &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
4133 <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
4134 representation of <i>s</i>, that <i>s</i> is not divisible by 10, and that the least significant digit of <i>s</i>
4135 is not necessarily uniquely determined by these criteria.</li>
4136 <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
4137 decimal representation of <i>s</i> (in order, with no leading zeroes), followed by <i>n&minus;k</i> occurrences of
4138 the code unit 0x0030 (DIGIT ZERO).</li>
4139 <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
4140 of the decimal representation of <i>s</i>, followed by the code unit 0x002E (FULL STOP), followed by the code units
4141 of the remaining <i>k&minus;n</i> digits of the decimal representation of <i>s</i>.</li>
4142 <li>If &minus;6 &lt; <i>n</i> &le; 0, return the String consisting of the code unit 0x0030 (DIGIT ZERO), followed by the
4143 code unit 0x002E (FULL STOP), followed by &minus;<i>n</i> occurrences of the code unit 0x0030 (DIGIT ZERO), followed
4144 by the code units of the <i>k</i> digits of the decimal representation of <i>s</i>.</li>
4145 <li>Otherwise, if <i>k</i> = 1, return the String consisting of the code unit of the single digit of <i>s</i>, followed
4146 by code unit 0x0065 (LATIN SMALL LETTER E), followed by the code unit 0x002B (PLUS SIGN) or the code unit 0x002D
4147 (HYPHEN-MINUS) according to whether <i>n</i>&minus;1 is positive or negative, followed by the code units of the
4148 decimal representation of the integer <a href="#sec-algorithm-conventions">abs</a>(<i>n</i>&minus;1) (with no
4149 leading zeroes).</li>
4150 <li>Return the String consisting of the code units of the most significant digit of the decimal representation of
4151 <i>s</i>, followed by code unit 0x002E (FULL STOP), followed by the code units of the remaining <i>k</i>&minus;1
4152 digits of the decimal representation of <i>s</i>, followed by code unit 0x0065 (LATIN SMALL LETTER E), followed by
4153 code unit 0x002B (PLUS SIGN) or the code unit 0x002D (HYPHEN-MINUS) according to whether <i>n</i>&minus;1 is
4154 positive or negative, followed by the code units of the decimal representation of the integer <a
4155 href="#sec-algorithm-conventions">abs</a>(<i>n</i>&minus;1) (with no leading zeroes).</li>
4156 </ol>
4157
4158 <div class="note">
4159 <p><span class="nh">NOTE 1</span> The following observations may be useful as guidelines for implementations, but are
4160 not part of the normative requirements of this Standard:</p>
4161
4162 <ul>
4163 <li>
4164 <p>If x is any Number value other than <b>&minus;0</b>, then <a href="#sec-tonumber">ToNumber</a>(<a
4165 href="#sec-tostring">ToString</a>(x)) is exactly the same Number value as x.</p>
4166 </li>
4167
4168 <li>
4169 <p>The least significant digit of s is not always uniquely determined by the requirements listed in step 5.</p>
4170 </li>
4171 </ul>
4172 </div>
4173
4174 <div class="note">
4175 <p><span class="nh">NOTE 2</span> For implementations that provide more accurate conversions than required by the rules
4176 above, it is recommended that the following alternative version of step 5 be used as a guideline:</p>
4177
4178 <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>
4179 &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
4180 <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
4181 <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
4182 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
4183 decimal representation of <i>s</i> and that <i>s</i> is not divisible by 10.</p>
4184 </div>
4185
4186 <div class="note">
4187 <p><span class="nh">NOTE 3</span> Implementers of ECMAScript may find useful the paper and code written by David M. Gay
4188 for binary-to-decimal conversion of floating-point numbers:</p>
4189
4190 <p>Gay, David M. Correctly Rounded Binary-Decimal and Decimal-Binary Conversions. Numerical Analysis, Manuscript 90-10.
4191 AT&amp;T Bell Laboratories (Murray Hill, New Jersey). November 30, 1990. Available as<br><span style="font-family:
4192 sans-serif"><a
4193 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>.
4194 Associated code available as<br><span style="font-family: sans-serif"><a
4195 href="http://netlib.sandia.gov/fp/dtoa.c">http://netlib.sandia.gov/fp/dtoa.c</a></span>&nbsp;and&nbsp;as<br><span
4196 style="font-family: sans-serif"><a
4197 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
4198 various <code>netlib</code> mirror sites.</p>
4199 </div>
4200 </section>
4201 </section>
4202
4203 <section id="sec-toobject">
4204 <h1><span class="secnum" id="sec-7.1.13"><a href="#sec-toobject" title="link to this section">7.1.13</a></span> ToObject (
4205 argument )</h1>
4206
4207 <p>The abstract operation ToObject converts <var>argument</var> to a value of type Object according to <a
4208 href="#table-13">Table 13</a>:</p>
4209
4210 <figure>
4211 <figcaption><span id="table-13">Table 13</span> &mdash; ToObject Conversions</figcaption>
4212 <table class="real-table">
4213 <tr>
4214 <th>Argument Type</th>
4215 <th>Result</th>
4216 </tr>
4217 <tr>
4218 <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
4219 <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>
4220 </tr>
4221 <tr>
4222 <td>Undefined</td>
4223 <td>Throw a <b>TypeError</b> exception.</td>
4224 </tr>
4225 <tr>
4226 <td>Null</td>
4227 <td>Throw a <b>TypeError</b> exception.</td>
4228 </tr>
4229 <tr>
4230 <td>Boolean</td>
4231 <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>
4232 </tr>
4233 <tr>
4234 <td>Number</td>
4235 <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>
4236 </tr>
4237 <tr>
4238 <td>String</td>
4239 <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>
4240 </tr>
4241 <tr>
4242 <td>Symbol</td>
4243 <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>
4244 </tr>
4245 <tr>
4246 <td>Object</td>
4247 <td>Return <i>argument</i>.</td>
4248 </tr>
4249 </table>
4250 </figure>
4251 </section>
4252
4253 <section id="sec-topropertykey">
4254 <h1><span class="secnum" id="sec-7.1.14"><a href="#sec-topropertykey" title="link to this section">7.1.14</a></span>
4255 ToPropertyKey ( argument )</h1>
4256
4257 <p>The abstract operation ToPropertyKey converts <var>argument</var> to a value that can be used as a <a
4258 href="#sec-object-type">property key</a> by performing the following steps:</p>
4259
4260 <ol class="proc">
4261 <li>Let <i>key</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint String).</li>
4262 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>key</i>).</li>
4263 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>key</i>) is Symbol, then
4264 <ol class="block">
4265 <li>Return <i>key</i>.</li>
4266 </ol>
4267 </li>
4268 <li>Return <a href="#sec-tostring">ToString</a>(<i>key</i>).</li>
4269 </ol>
4270 </section>
4271
4272 <section id="sec-tolength">
4273 <h1><span class="secnum" id="sec-7.1.15"><a href="#sec-tolength" title="link to this section">7.1.15</a></span> ToLength (
4274 argument )</h1>
4275
4276 <p>The abstract operation ToLength converts <var>argument</var> to an integer suitable for use as the length of an
4277 array-like object. It performs the following steps:</p>
4278
4279 <ol class="proc">
4280 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
4281 <li>Let <i>len</i> be <a href="#sec-tointeger">ToInteger</a>(<i>argument</i>).</li>
4282 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
4283 <li>If <i>len</i> &le; +0, return +0.</li>
4284 <li>If <i>len</i> is <b>+&infin;</b>, return 2<sup>53</sup>-1.</li>
4285 <li>Return min(<i>len</i>, 2<sup>53</sup>-1).</li>
4286 </ol>
4287 </section>
4288
4289 <section id="sec-canonicalnumericindexstring">
4290 <h1><span class="secnum" id="sec-7.1.16"><a href="#sec-canonicalnumericindexstring"
4291 title="link to this section">7.1.16</a></span> CanonicalNumericIndexString ( argument )</h1>
4292
4293 <p>The abstract operation CanonicalNumericIndexString returns <var>argument</var> converted to a numeric value if it is a
4294 String representation of a Number that would be produced by <a href="#sec-tostring">ToString</a>, or the string
4295 <code>"-0"</code>. Otherwise, it returns <span class="value">undefined.</span> This abstract operation functions as
4296 follows:</p>
4297
4298 <ol class="proc">
4299 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
4300 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is String.</li>
4301 <li>If <i>argument</i> is <code>"-0"</code>, return &minus;0.</li>
4302 <li>Let <i>n</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
4303 <li>If <a href="#sec-samevalue">SameValue</a>(<a href="#sec-tostring">ToString</a>(<i>n</i>), <i>argument</i>) is
4304 <b>false</b>, return <b>undefined</b>.</li>
4305 <li>Return <i>n</i>.</li>
4306 </ol>
4307
4308 <p>A <i>canonical numeric string</i> is any String value for which the CanonicalNumericIndexString abstract operation does
4309 not return <span class="value">undefined</span>.</p>
4310 </section>
4311 </section>
4312
4313 <section id="sec-testing-and-comparison-operations">
4314 <div class="front">
4315 <h1><span class="secnum" id="sec-7.2"><a href="#sec-testing-and-comparison-operations"
4316 title="link to this section">7.2</a></span> Testing and Comparison Operations</h1>
4317 </div>
4318
4319 <section id="sec-requireobjectcoercible">
4320 <h1><span class="secnum" id="sec-7.2.1"><a href="#sec-requireobjectcoercible" title="link to this section">7.2.1</a></span>
4321 RequireObjectCoercible ( argument )</h1>
4322
4323 <p>The abstract operation RequireObjectCoercible throws an error if <var>argument</var> is a value that cannot be converted
4324 to an Object using <a href="#sec-toobject">ToObject</a>. It is defined by <a href="#table-14">Table 14</a>:</p>
4325
4326 <figure>
4327 <figcaption><span id="table-14">Table 14</span>&nbsp;&mdash; RequireObjectCoercible Results</figcaption>
4328 <table class="real-table">
4329 <tr>
4330 <th>Argument Type</th>
4331 <th>Result</th>
4332 </tr>
4333 <tr>
4334 <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
4335 <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>
4336 </tr>
4337 <tr>
4338 <td>Undefined</td>
4339 <td>Throw a <b>TypeError</b> exception.</td>
4340 </tr>
4341 <tr>
4342 <td>Null</td>
4343 <td>Throw a <b>TypeError</b> exception.</td>
4344 </tr>
4345 <tr>
4346 <td>Boolean</td>
4347 <td>Return <var>argument</var>.</td>
4348 </tr>
4349 <tr>
4350 <td>Number</td>
4351 <td>Return <var>argument</var>.</td>
4352 </tr>
4353 <tr>
4354 <td>String</td>
4355 <td>Return <var>argument</var>.</td>
4356 </tr>
4357 <tr>
4358 <td>Symbol</td>
4359 <td>Return <var>argument</var>.</td>
4360 </tr>
4361 <tr>
4362 <td>Object</td>
4363 <td>Return <var>argument</var>.</td>
4364 </tr>
4365 </table>
4366 </figure>
4367 </section>
4368
4369 <section id="sec-isarray">
4370 <h1><span class="secnum" id="sec-7.2.2"><a href="#sec-isarray" title="link to this section">7.2.2</a></span> IsArray (
4371 argument )</h1>
4372
4373 <p>The abstract operation IsArray takes one argument <var>argument</var>, and performs the following steps:</p>
4374
4375 <ol class="proc">
4376 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
4377 <li>If <i>argument</i> is an <a href="#sec-array-exotic-objects">Array exotic object</a>, return <b>true</b>.</li>
4378 <li>If <i>argument</i> is a Proxy exotic object, then
4379 <ol class="block">
4380 <li>If the value of the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
4381 of <i>argument</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
4382 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
4383 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>argument</i>.</li>
4384 <li>Return IsArray(<i>target</i>).</li>
4385 </ol>
4386 </li>
4387 <li>Return <b>false</b>.</li>
4388 </ol>
4389 </section>
4390
4391 <section id="sec-iscallable">
4392 <h1><span class="secnum" id="sec-7.2.3"><a href="#sec-iscallable" title="link to this section">7.2.3</a></span> IsCallable (
4393 argument )</h1>
4394
4395 <p>The abstract operation IsCallable determines if <var>argument</var>, which must be an <a
4396 href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
4397 href="#sec-completion-record-specification-type">Completion Record</a>, is a callable function with a [[Call]] internal
4398 method.</p>
4399
4400 <ol class="proc">
4401 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
4402 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
4403 <li>If <i>argument</i> has a [[Call]] internal method, return <b>true</b>.</li>
4404 <li>Return <b>false</b>.</li>
4405 </ol>
4406 </section>
4407
4408 <section id="sec-isconstructor">
4409 <h1><span class="secnum" id="sec-7.2.4"><a href="#sec-isconstructor" title="link to this section">7.2.4</a></span>
4410 IsConstructor ( argument )</h1>
4411
4412 <p>The abstract operation IsConstructor determines if <var>argument</var>, which must be an <a
4413 href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
4414 href="#sec-completion-record-specification-type">Completion Record</a>, is a function object with a [[Construct]] internal
4415 method.</p>
4416
4417 <ol class="proc">
4418 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
4419 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
4420 <li>If <i>argument</i> has a [[Construct]] internal method, return <b>true</b>.</li>
4421 <li>Return <b>false</b>.</li>
4422 </ol>
4423 </section>
4424
4425 <section id="sec-isextensible-o">
4426 <h1><span class="secnum" id="sec-7.2.5"><a href="#sec-isextensible-o" title="link to this section">7.2.5</a></span>
4427 IsExtensible (O)</h1>
4428
4429 <p>The abstract operation <span style="font-family: Times New Roman">IsExtensible</span> is used to determine whether
4430 additional properties can be added to the object that is <var>O</var>. A Boolean value is returned. This abstract operation
4431 performs the following steps:</p>
4432
4433 <ol class="proc">
4434 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4435 Object.</li>
4436 <li>Return <i>O</i>.[[IsExtensible]]().</li>
4437 </ol>
4438 </section>
4439
4440 <section id="sec-isinteger">
4441 <h1><span class="secnum" id="sec-7.2.6"><a href="#sec-isinteger" title="link to this section">7.2.6</a></span> IsInteger (
4442 argument )</h1>
4443
4444 <p>The abstract operation IsInteger determines if <var>argument</var> is a finite integer numeric value.</p>
4445
4446 <ol class="proc">
4447 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
4448 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Number, return <b>false</b>.</li>
4449 <li>If <i>argument</i> is <b>NaN</b>, <b>+&infin;</b>, or <b>&minus;&infin;</b>, return <b>false</b>.</li>
4450 <li>If <a href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>argument</i>)) &ne;
4451 <a href="#sec-algorithm-conventions">abs</a>(<i>argument</i>), return <b>false</b>.</li>
4452 <li>Return <b>true</b>.</li>
4453 </ol>
4454 </section>
4455
4456 <section id="sec-ispropertykey">
4457 <h1><span class="secnum" id="sec-7.2.7"><a href="#sec-ispropertykey" title="link to this section">7.2.7</a></span>
4458 IsPropertyKey ( argument )</h1>
4459
4460 <p>The abstract operation IsPropertyKey determines if <var>argument</var>, which must be an <a
4461 href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
4462 href="#sec-completion-record-specification-type">Completion Record</a>, is a value that may be used as a <a
4463 href="#sec-object-type">property key</a>.</p>
4464
4465 <ol class="proc">
4466 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
4467 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is String, return <b>true</b>.</li>
4468 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is Symbol, return <b>true</b>.</li>
4469 <li>Return <b>false</b>.</li>
4470 </ol>
4471 </section>
4472
4473 <section id="sec-isregexp">
4474 <h1><span class="secnum" id="sec-7.2.8"><a href="#sec-isregexp" title="link to this section">7.2.8</a></span> IsRegExp (
4475 argument )</h1>
4476
4477 <p>The abstract operation IsRegExp with argument <var>argument</var> performs the following steps:</p>
4478
4479 <ol class="proc">
4480 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
4481 <li>Let <i>isRegExp</i> be <a href="#sec-get-o-p">Get</a>(<i>argument</i>, @@match).</li>
4482 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>isRegExp</i>).</li>
4483 <li>If <i>isRegExp</i> is not <b>undefined</b>, return <a href="#sec-toboolean">ToBoolean</a>(<i>isRegExp</i>).</li>
4484 <li>If <i>argument</i> has a [[RegExpMatcher]] <a href="#sec-object-internal-methods-and-internal-slots">internal
4485 slot</a>, return <b>true</b>.</li>
4486 <li>Return <b>false</b>.</li>
4487 </ol>
4488 </section>
4489
4490 <section id="sec-samevalue">
4491 <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,
4492 y)</h1>
4493
4494 <p>The internal comparison abstract operation SameValue(<var>x</var>, <var>y</var>), where <var>x</var> and <var>y</var> are
4495 <a href="#sec-ecmascript-language-types">ECMAScript language values</a>, produces <b>true</b> or <b>false</b>. Such a
4496 comparison is performed as follows:</p>
4497
4498 <ol class="proc">
4499 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
4500 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
4501 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
4502 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
4503 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
4504 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
4505 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
4506 <ol class="block">
4507 <li>If <i>x</i> is NaN and <i>y</i> is NaN, return <b>true</b>.</li>
4508 <li>If <i>x</i> is +0 and <i>y</i> is -0, return <b>false</b>.</li>
4509 <li>If <i>x</i> is -0 and <i>y</i> is +0, return <b>false</b>.</li>
4510 <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
4511 <li>Return <b>false</b>.</li>
4512 </ol>
4513 </li>
4514 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
4515 <ol class="block">
4516 <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
4517 corresponding indices) return <b>true</b>; otherwise, return <b>false</b>.</li>
4518 </ol>
4519 </li>
4520 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
4521 <ol class="block">
4522 <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
4523 <b>false</b>.</li>
4524 </ol>
4525 </li>
4526 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Symbol, then
4527 <ol class="block">
4528 <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>
4529 </ol>
4530 </li>
4531 <li>Return <b>true</b> if <i>x</i> and <i>y</i> are the same Object value. Otherwise, return <b>false</b>.</li>
4532 </ol>
4533 </section>
4534
4535 <section id="sec-samevaluezero">
4536 <h1><span class="secnum" id="sec-7.2.10"><a href="#sec-samevaluezero" title="link to this section">7.2.10</a></span>
4537 SameValueZero(x, y)</h1>
4538
4539 <p>The internal comparison abstract operation SameValueZero(<var>x</var>, <var>y</var>), where <var>x</var> and <var>y</var>
4540 are <a href="#sec-ecmascript-language-types">ECMAScript language values</a>, produces <b>true</b> or <b>false</b>. Such a
4541 comparison is performed as follows:</p>
4542
4543 <ol class="proc">
4544 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
4545 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
4546 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
4547 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
4548 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
4549 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
4550 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
4551 <ol class="block">
4552 <li>If <i>x</i> is NaN and <i>y</i> is NaN, return <b>true</b>.</li>
4553 <li>If <i>x</i> is +0 and <i>y</i> is -0, return <b>true</b>.</li>
4554 <li>If <i>x</i> is -0 and <i>y</i> is +0, return <b>true</b>.</li>
4555 <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
4556 <li>Return <b>false</b>.</li>
4557 </ol>
4558 </li>
4559 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
4560 <ol class="block">
4561 <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
4562 corresponding indices) return <b>true</b>; otherwise, return <b>false</b>.</li>
4563 </ol>
4564 </li>
4565 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
4566 <ol class="block">
4567 <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
4568 <b>false</b>.</li>
4569 </ol>
4570 </li>
4571 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Symbol, then
4572 <ol class="block">
4573 <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>
4574 </ol>
4575 </li>
4576 <li>Return <b>true</b> if <i>x</i> and <i>y</i> are the same Object value. Otherwise, return <b>false</b>.</li>
4577 </ol>
4578
4579 <div class="note">
4580 <p><span class="nh">NOTE</span> SameValueZero differs from SameValue only in its treatment of +0 and -0.</p>
4581 </div>
4582 </section>
4583
4584 <section id="sec-abstract-relational-comparison">
4585 <h1><span class="secnum" id="sec-7.2.11"><a href="#sec-abstract-relational-comparison"
4586 title="link to this section">7.2.11</a></span> Abstract Relational Comparison</h1>
4587
4588 <p>The comparison <var>x</var> &lt; <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b>,
4589 <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
4590 <var>y</var> the algorithm takes a Boolean flag named <span class="nt">LeftFirst</span> as a parameter. The flag is used to
4591 control the order in which operations with potentially visible side-effects are performed upon <var>x</var> and
4592 <var>y</var>. It is necessary because ECMAScript specifies left to right evaluation of expressions. The default value of
4593 <span class="nt">LeftFirst</span> is <b>true</b> and indicates that the <var>x</var> parameter corresponds to an expression
4594 that occurs to the left of the <var>y</var> parameter&rsquo;s corresponding expression. If <span class="nt">LeftFirst</span>
4595 is <b>false</b>, the reverse is the case and operations must be performed upon <var>y</var> before <var>x</var>. Such a
4596 comparison is performed as follows:</p>
4597
4598 <ol class="proc">
4599 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
4600 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
4601 <li>If the <i>LeftFirst</i> flag is <b>true</b>, then
4602 <ol class="block">
4603 <li>Let <i>px</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>, hint Number).</li>
4604 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>px</i>).</li>
4605 <li>Let <i>py</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>, hint Number).</li>
4606 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>py</i>).</li>
4607 </ol>
4608 </li>
4609 <li>Else the order of evaluation needs to be reversed to preserve left to right evaluation
4610 <ol class="block">
4611 <li>Let <i>py</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>, hint Number).</li>
4612 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>py</i>).</li>
4613 <li>Let <i>px</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>, hint Number).</li>
4614 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>px</i>).</li>
4615 </ol>
4616 </li>
4617 <li>If both <i>px</i> and <i>py</i> are Strings, then
4618 <ol class="block">
4619 <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
4620 <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
4621 String is a prefix of itself, because <i>r</i> may be the empty String.)</li>
4622 <li>If <i>px</i> is a prefix of <i>py</i>, return <b>true</b>.</li>
4623 <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
4624 different from the code unit at index <i>k</i> within <i>py</i>. (There must be such a <i>k</i>, for neither
4625 String is a prefix of the other.)</li>
4626 <li>Let <i>m</i> be the integer that is the code unit value at index <i>k</i> within <i>px</i>.</li>
4627 <li>Let <i>n</i> be the integer that is the code unit value at index <i>k</i> within <i>py</i>.</li>
4628 <li>If <i>m</i> &lt; <i>n</i>, return <b>true</b>. Otherwise, return <b>false</b>.</li>
4629 </ol>
4630 </li>
4631 <li>Else,
4632 <ol class="block">
4633 <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
4634 values evaluation order is not important.</li>
4635 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nx</i>).</li>
4636 <li>Let <i>ny</i> be <a href="#sec-tonumber">ToNumber</a>(<i>py</i>).</li>
4637 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ny</i>).</li>
4638 <li>If <i>nx</i> is <b>NaN</b>, return <b>undefined</b>.</li>
4639 <li>If <i>ny</i> is <b>NaN</b>, return <b>undefined</b>.</li>
4640 <li>If <i>nx</i> and <i>ny</i> are the same Number value, return <b>false</b>.</li>
4641 <li>If <i>nx</i> is <b>+0</b> and <i>ny</i> is <b>&minus;0</b>, return <b>false</b>.</li>
4642 <li>If <i>nx</i> is <b>&minus;0</b> and <i>ny</i> is <b>+0</b>, return <b>false</b>.</li>
4643 <li>If <i>nx</i> is <b>+&infin;</b>, return <b>false</b>.</li>
4644 <li>If <i>ny</i> is <b>+&infin;</b>, return <b>true</b>.</li>
4645 <li>If <i>ny</i> is <b>&minus;&infin;</b>, return <b>false</b>.</li>
4646 <li>If <i>nx</i> is <b>&minus;&infin;</b>, return <b>true</b>.</li>
4647 <li>If the mathematical value of <i>nx</i> is less than the mathematical value of <i>ny</i> &mdash;note that these
4648 mathematical values are both finite and not both zero&mdash;return <b>true</b>. Otherwise, return
4649 <b>false</b>.</li>
4650 </ol>
4651 </li>
4652 </ol>
4653
4654 <div class="note">
4655 <p><span class="nh">NOTE 1</span> Step 5 differs from step 11 in the algorithm for the addition operator <code>+</code>
4656 (<a href="#sec-addition-operator-plus">12.7.3</a>) in using &ldquo;and&rdquo; instead of &ldquo;or&rdquo;.</p>
4657 </div>
4658
4659 <div class="note">
4660 <p><span class="nh">NOTE 2</span> The comparison of Strings uses a simple lexicographic ordering on sequences of code unit
4661 values. There is no attempt to use the more complex, semantically oriented definitions of character or string equality and
4662 collating order defined in the Unicode specification. Therefore String values that are canonically equal according to the
4663 Unicode standard could test as unequal. In effect this algorithm assumes that both Strings are already in normalized form.
4664 Also, note that for strings containing supplementary characters, lexicographic ordering on sequences of UTF-16 code unit
4665 values differs from that on sequences of code point values.</p>
4666 </div>
4667 </section>
4668
4669 <section id="sec-abstract-equality-comparison">
4670 <h1><span class="secnum" id="sec-7.2.12"><a href="#sec-abstract-equality-comparison"
4671 title="link to this section">7.2.12</a></span> Abstract Equality Comparison</h1>
4672
4673 <p>The comparison <var>x</var> == <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b> or
4674 <b>false</b>. Such a comparison is performed as follows:</p>
4675
4676 <ol class="proc">
4677 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
4678 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
4679 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is the same as <a
4680 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), then
4681 <ol class="block">
4682 <li>Return the result of performing Strict Equality Comparison <i>x</i> === <i>y</i>.</li>
4683 </ol>
4684 </li>
4685 <li>If <i>x</i> is <b>null</b> and <i>y</i> is <b>undefined</b>, return <b>true</b>.</li>
4686 <li>If <i>x</i> is <b>undefined</b> and <i>y</i> is <b>null</b>, return <b>true</b>.</li>
4687 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number and <a
4688 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is String,<br>return the result of the comparison
4689 <i>x</i> == <a href="#sec-tonumber">ToNumber</a>(<i>y</i>).</li>
4690 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String and <a
4691 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Number,<br>return the result of the comparison <a
4692 href="#sec-tonumber">ToNumber</a>(<i>x</i>) == <i>y</i>.</li>
4693 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, return the result of the comparison
4694 <a href="#sec-tonumber">ToNumber</a>(<i>x</i>) == <i>y</i>.</li>
4695 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Boolean, return the result of the comparison
4696 <i>x</i> == <a href="#sec-tonumber">ToNumber</a>(<i>y</i>).</li>
4697 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is either String, Number, or Symbol and <a
4698 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Object, then<br>return the result of the comparison
4699 <i>x</i> == <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>).</li>
4700 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Object and <a
4701 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is either String, Number, or Symbol, then<br>return
4702 the result of the comparison <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>) == <i>y</i>.</li>
4703 <li>Return <b>false</b>.</li>
4704 </ol>
4705 </section>
4706
4707 <section id="sec-strict-equality-comparison">
4708 <h1><span class="secnum" id="sec-7.2.13"><a href="#sec-strict-equality-comparison"
4709 title="link to this section">7.2.13</a></span> Strict Equality Comparison</h1>
4710
4711 <p>The comparison <var>x</var> === <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b> or
4712 <b>false</b>. Such a comparison is performed as follows:</p>
4713
4714 <ol class="proc">
4715 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
4716 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
4717 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
4718 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
4719 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
4720 <ol class="block">
4721 <li>If <i>x</i> is <b>NaN</b>, return <b>false</b>.</li>
4722 <li>If <i>y</i> is <b>NaN</b>, return <b>false</b>.</li>
4723 <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
4724 <li>If <i>x</i> is <b>+0</b> and <i>y</i> is <b>&minus;0</b>, return <b>true</b>.</li>
4725 <li>If <i>x</i> is <b>&minus;0</b> and <i>y</i> is <b>+0</b>, return <b>true</b>.</li>
4726 <li>Return <b>false</b>.</li>
4727 </ol>
4728 </li>
4729 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
4730 <ol class="block">
4731 <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
4732 corresponding indices), return <b>true</b>.</li>
4733 <li>Else, return <b>false</b>.</li>
4734 </ol>
4735 </li>
4736 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
4737 <ol class="block">
4738 <li>If <i>x</i> and <i>y</i> are both <b>true</b> or both <b>false</b>, return <b>true</b>.</li>
4739 <li>Else, return <b>false</b>.</li>
4740 </ol>
4741 </li>
4742 <li>If <i>x</i> and <i>y</i> are the same Symbol value, return <b>true</b>.</li>
4743 <li>If <i>x</i> and <i>y</i> are the same Object value, return <b>true</b>.</li>
4744 <li>Return <b>false</b>.</li>
4745 </ol>
4746
4747 <div class="note">
4748 <p><span class="nh">NOTE</span> This algorithm differs from <a href="#sec-samevalue">the SameValue Algorithm</a> (<a
4749 href="#sec-samevalue">7.2.9</a>) in its treatment of signed zeroes and NaNs.</p>
4750 </div>
4751 </section>
4752 </section>
4753
4754 <section id="sec-operations-on-objects">
4755 <div class="front">
4756 <h1><span class="secnum" id="sec-7.3"><a href="#sec-operations-on-objects" title="link to this section">7.3</a></span>
4757 Operations on Objects</h1>
4758 </div>
4759
4760 <section id="sec-get-o-p">
4761 <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>
4762
4763 <p>The abstract operation <span style="font-family: Times New Roman">Get</span> is used to retrieve the value of a specific
4764 property of an object. The operation is called with arguments <var>O</var> and <var>P</var> where <var>O</var> is the
4765 object and <var>P</var> is the <a href="#sec-object-type">property key</a>. This abstract operation performs the following
4766 steps:</p>
4767
4768 <ol class="proc">
4769 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4770 Object.</li>
4771 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4772 <b>true</b>.</li>
4773 <li>Return <i>O</i>.[[Get]](<i>P</i>, <i>O</i>).</li>
4774 </ol>
4775 </section>
4776
4777 <section id="sec-getv">
4778 <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>
4779
4780 <p>The abstract operation GetV is used to retrieve the value of a specific property of an <a
4781 href="#sec-ecmascript-language-types">ECMAScript language value</a>. If the value is not an object, the property lookup is
4782 performed using a wrapper object appropriate for the type of the value. The operation is called with arguments <var>V</var>
4783 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
4784 abstract operation performs the following steps:</p>
4785
4786 <ol class="proc">
4787 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4788 <b>true</b>.</li>
4789 <li>Let <i>O</i> be <a href="#sec-toobject">ToObject</a>(<i>V</i>).</li>
4790 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>O</i>).</li>
4791 <li>Return <i>O</i>.[[Get]](<i>P</i>, <i>V</i>).</li>
4792 </ol>
4793 </section>
4794
4795 <section id="sec-set-o-p-v-throw">
4796 <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,
4797 P, V, Throw)</h1>
4798
4799 <p>The abstract operation <span style="font-family: Times New Roman">Set</span> is used to set the value of a specific
4800 property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, <var>V</var>, and <span
4801 class="nt">Throw</span> where <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>,
4802 <var>V</var> is the new value for the property and <span class="nt">Throw</span> is a Boolean flag. This abstract operation
4803 performs the following steps:</p>
4804
4805 <ol class="proc">
4806 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4807 Object.</li>
4808 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4809 <b>true</b>.</li>
4810 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
4811 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Throw</i>) is Boolean.</li>
4812 <li>Let <i>success</i> be <i>O</i>.[[Set]](<i>P</i>, <i>V</i>, <i>O</i>).</li>
4813 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
4814 <li>If <i>success</i> is <b>false</b> and <i>Throw</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
4815 <li>Return <i>success</i>.</li>
4816 </ol>
4817 </section>
4818
4819 <section id="sec-createdataproperty">
4820 <h1><span class="secnum" id="sec-7.3.4"><a href="#sec-createdataproperty" title="link to this section">7.3.4</a></span>
4821 CreateDataProperty (O, P, V)</h1>
4822
4823 <p>The abstract operation <span style="font-family: Times New Roman">CreateDataProperty</span> is used to create a new own
4824 property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where
4825 <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
4826 for the property. This abstract operation performs the following steps:</p>
4827
4828 <ol class="proc">
4829 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4830 Object.</li>
4831 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4832 <b>true</b>.</li>
4833 <li>Let <i>newDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
4834 <b>true</b>, [[Configurable]]: <b>true</b>}.</li>
4835 <li>Return <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>newDesc</i>).</li>
4836 </ol>
4837
4838 <div class="note">
4839 <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
4840 used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist.
4841 If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return
4842 <b>false</b>.</p>
4843 </div>
4844 </section>
4845
4846 <section id="sec-createmethodproperty">
4847 <h1><span class="secnum" id="sec-7.3.5"><a href="#sec-createmethodproperty" title="link to this section">7.3.5</a></span>
4848 CreateMethodProperty (O, P, V)</h1>
4849
4850 <p>The abstract operation <span style="font-family: Times New Roman">CreateMethodProperty</span> is used to create a new own
4851 property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where
4852 <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
4853 for the property. This abstract operation performs the following steps:</p>
4854
4855 <ol class="proc">
4856 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4857 Object.</li>
4858 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4859 <b>true</b>.</li>
4860 <li>Let <i>newDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
4861 <b>false</b>, [[Configurable]]: <b>true</b>}.</li>
4862 <li>Return <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>newDesc</i>).</li>
4863 </ol>
4864
4865 <div class="note">
4866 <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
4867 used for built-in methods and methods defined using class declaration syntax. Normally, the property will not already
4868 exist. If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return
4869 <b>false</b>.</p>
4870 </div>
4871 </section>
4872
4873 <section id="sec-createdatapropertyorthrow">
4874 <h1><span class="secnum" id="sec-7.3.6"><a href="#sec-createdatapropertyorthrow"
4875 title="link to this section">7.3.6</a></span> CreateDataPropertyOrThrow (O, P, V)</h1>
4876
4877 <p>The abstract operation <span style="font-family: Times New Roman">CreateDataPropertyOrThrow</span> is used to create a
4878 new own property of an object. It throws a <span class="value">TypeError</span> exception if the requested property update
4879 cannot be performed. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where <var>O</var>
4880 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
4881 property. This abstract operation performs the following steps:</p>
4882
4883 <ol class="proc">
4884 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4885 Object.</li>
4886 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4887 <b>true</b>.</li>
4888 <li>Let <i>success</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>O</i>, <i>P</i>, <i>V</i>).</li>
4889 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
4890 <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
4891 <li>Return <i>success</i>.</li>
4892 </ol>
4893
4894 <div class="note">
4895 <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
4896 used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist.
4897 If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return <b>false</b>
4898 <span style="font-family: sans-serif">causing this operation to throw a</span> <b>TypeError</b> <span style="font-family:
4899 sans-serif">exception</span>.</p>
4900 </div>
4901 </section>
4902
4903 <section id="sec-definepropertyorthrow">
4904 <h1><span class="secnum" id="sec-7.3.7"><a href="#sec-definepropertyorthrow" title="link to this section">7.3.7</a></span>
4905 DefinePropertyOrThrow (O, P, desc)</h1>
4906
4907 <p>The abstract operation <span style="font-family: Times New Roman">DefinePropertyOrThrow</span> is used to call the
4908 [[DefineOwnProperty]] internal method of an object in a manner that will throw a <b>TypeError</b> exception if the requested
4909 property update cannot be performed. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>desc</var>
4910 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
4911 the <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> for the property. This abstract operation
4912 performs the following steps:</p>
4913
4914 <ol class="proc">
4915 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4916 Object.</li>
4917 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4918 <b>true</b>.</li>
4919 <li>Let <i>success</i> be <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>desc</i>).</li>
4920 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
4921 <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
4922 <li>Return <i>success</i>.</li>
4923 </ol>
4924 </section>
4925
4926 <section id="sec-deletepropertyorthrow">
4927 <h1><span class="secnum" id="sec-7.3.8"><a href="#sec-deletepropertyorthrow" title="link to this section">7.3.8</a></span>
4928 DeletePropertyOrThrow (O, P)</h1>
4929
4930 <p>The abstract operation DeletePropertyOrThrow is used to remove a specific own property of an object. It throws an
4931 exception if the property is not configurable. The operation is called with arguments <var>O</var> and <var>P</var> where
4932 <var>O</var> is the object and <var>P</var> is the <a href="#sec-object-type">property key</a>. This abstract operation
4933 performs the following steps:</p>
4934
4935 <ol class="proc">
4936 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4937 Object.</li>
4938 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4939 <b>true</b>.</li>
4940 <li>Let <i>success</i> be <i>O</i>.[[Delete]](<i>P</i>).</li>
4941 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
4942 <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
4943 <li>Return <i>success</i>.</li>
4944 </ol>
4945 </section>
4946
4947 <section id="sec-getmethod">
4948 <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,
4949 P)</h1>
4950
4951 <p>The abstract operation GetMethod is used to get the value of a specific property of an object when the value of the
4952 property is expected to be a function. The operation is called with arguments <var>O</var> and <var>P</var> where
4953 <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>. This abstract operation
4954 performs the following steps:</p>
4955
4956 <ol class="proc">
4957 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4958 <b>true</b>.</li>
4959 <li>Let <i>func</i> be <a href="#sec-getv">GetV</a>(<i>O</i>, <i>P</i>).</li>
4960 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
4961 <li>If <i>func</i> is either <b>undefined</b> or <b>null</b>, return <b>undefined</b>.</li>
4962 <li>If <a href="#sec-iscallable">IsCallable</a>(<i>func</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
4963 <li>Return <i>func</i>.</li>
4964 </ol>
4965 </section>
4966
4967 <section id="sec-hasproperty">
4968 <h1><span class="secnum" id="sec-7.3.10"><a href="#sec-hasproperty" title="link to this section">7.3.10</a></span>
4969 HasProperty (O, P)</h1>
4970
4971 <p>The abstract operation HasProperty is used to determine whether an object has a property with the specified <a
4972 href="#sec-object-type">property key</a>. The property may be either an own or inherited. A Boolean value is returned. The
4973 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
4974 <a href="#sec-object-type">property key</a>. This abstract operation performs the following steps:</p>
4975
4976 <ol class="proc">
4977 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4978 Object.</li>
4979 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4980 <b>true</b>.</li>
4981 <li>Return <i>O</i>.[[HasProperty]](<i>P</i>).</li>
4982 </ol>
4983 </section>
4984
4985 <section id="sec-hasownproperty">
4986 <h1><span class="secnum" id="sec-7.3.11"><a href="#sec-hasownproperty" title="link to this section">7.3.11</a></span>
4987 HasOwnProperty (O, P)</h1>
4988
4989 <p>The abstract operation HasOwnProperty is used to determine whether an object has an own property with the specified <a
4990 href="#sec-object-type">property key</a>. A Boolean value is returned. The operation is called with arguments <var>O</var>
4991 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
4992 abstract operation performs the following steps:</p>
4993
4994 <ol class="proc">
4995 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
4996 Object.</li>
4997 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
4998 <b>true</b>.</li>
4999 <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
5000 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
5001 <li>If <i>desc</i> is <b>undefined</b>, return <b>false</b>.</li>
5002 <li>Return <b>true</b>.</li>
5003 </ol>
5004 </section>
5005
5006 <section id="sec-call">
5007 <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,
5008 [argumentsList])</h1>
5009
5010 <p>The abstract operation Call is used to call the [[Call]] internal method of a function object. The operation is called
5011 with arguments <var>F</var>, <var>V</var> , and optionally <var>argumentsList</var> where <var>F</var> is the function
5012 object, <var>V</var> is an <a href="#sec-ecmascript-language-types">ECMAScript language value</a> that is the <b>this</b>
5013 value of the [[Call]], and <var>argumentsList</var> is the value passed to the corresponding argument of the internal
5014 method. If <var>argumentsList</var> is not present, an empty <a href="#sec-list-and-record-specification-type">List</a> is
5015 used as its value. This abstract operation performs the following steps:</p>
5016
5017 <ol class="proc">
5018 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>F</i>).</li>
5019 <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
5020 href="#sec-list-and-record-specification-type">List</a>.</li>
5021 <li>If <a href="#sec-iscallable">IsCallable</a>(<i>F</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
5022 <li>Return <i>F</i>.[[Call]](<i>V</i>, <i>argumentsList</i>).</li>
5023 </ol>
5024 </section>
5025
5026 <section id="sec-invoke">
5027 <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,
5028 [argumentsList])</h1>
5029
5030 <p>The abstract operation <span style="font-family: Times New Roman">Invoke</span> is used to call a method property of an
5031 object. The operation is called with arguments <var>O</var>, <var>P</var> , and optionally <var>argumentsList</var> where
5032 <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
5033 href="#sec-object-type">property key</a>, and <var>argumentsList</var> is the list of arguments values passed to the method.
5034 If <var>argumentsList</var> is not present, an empty <a href="#sec-list-and-record-specification-type">List</a> is used as
5035 its value. This abstract operation performs the following steps:</p>
5036
5037 <ol class="proc">
5038 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>P</i> is a valid <a href="#sec-object-type">property key</a>.</li>
5039 <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
5040 href="#sec-list-and-record-specification-type">List</a>.</li>
5041 <li>Let <i>func</i> be <a href="#sec-getv">GetV</a>(<i>O</i>, <i>P</i>).</li>
5042 <li>Return <a href="#sec-call">Call</a>(<i>func</i>, <i>O</i>, <i>argumentsList</i>).</li>
5043 </ol>
5044 </section>
5045
5046 <section id="sec-construct">
5047 <h1><span class="secnum" id="sec-7.3.14"><a href="#sec-construct" title="link to this section">7.3.14</a></span> Construct
5048 (F, [argumentsList], [newTarget])</h1>
5049
5050 <p>The abstract operation Construct is used to call the [[Construct]] internal method of a function object. The operation is
5051 called with arguments <var>F</var>, and optionally <span style="font-family: Times New Roman"><i>argumentsList</i>, and
5052 <i>newTarget</i></span> where <var>F</var> is the function object. <var>argumentsList</var> and <var>newTarget</var> are the
5053 values to be passed as the corresponding arguments of the internal method. If <var>argumentsList</var> is not present, an
5054 empty <a href="#sec-list-and-record-specification-type">List</a> is used as its value. If <var>newTarget</var> is not
5055 present, <var>F</var> is used as its value. This abstract operation performs the following steps:</p>
5056
5057 <ol class="proc">
5058 <li>If <i>newTarget</i> was not passed, let <i>newTarget</i> be <i>F</i>.</li>
5059 <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
5060 href="#sec-list-and-record-specification-type">List</a>.</li>
5061 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>F</i>) is
5062 <b>true</b>.</li>
5063 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>newTarget</i>) is
5064 <b>true</b>.</li>
5065 <li>Return <i>F</i>.[[Construct]](<i>argumentsList</i>, <i>newTarget</i>).</li>
5066 </ol>
5067
5068 <div class="note">
5069 <p><span class="nh">NOTE</span> If <i>newTarget</i> is not passed, this operation is equivalent to: <code>new
5070 F(...argumentsList)</code></p>
5071 </div>
5072 </section>
5073
5074 <section id="sec-setintegritylevel">
5075 <h1><span class="secnum" id="sec-7.3.15"><a href="#sec-setintegritylevel" title="link to this section">7.3.15</a></span>
5076 SetIntegrityLevel (O, level)</h1>
5077
5078 <p>The abstract operation <span style="font-family: Times New Roman">SetIntegrityLevel</span> is used to fix the set of own
5079 properties of an object. This abstract operation performs the following steps:</p>
5080
5081 <ol class="proc">
5082 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
5083 Object.</li>
5084 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>level</i> is either <code>"sealed"</code> or
5085 <code>"frozen"</code>.</li>
5086 <li>Let <i>status</i> be <i>O</i>.[[PreventExtensions]]().</li>
5087 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
5088 <li>If <i>status</i> is <b>false</b>, return <b>false</b>.</li>
5089 <li>Let <i>keys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
5090 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>keys</i>).</li>
5091 <li>If <i>level</i> is <code>"sealed"</code>, then
5092 <ol class="block">
5093 <li>Repeat for each element <i>k</i> of <i>keys</i>,
5094 <ol class="block">
5095 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>O</i>, <i>k</i>,
5096 PropertyDescriptor{ [[Configurable]]: <b>false</b>}).</li>
5097 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
5098 </ol>
5099 </li>
5100 </ol>
5101 </li>
5102 <li>Else <i>level</i> is <code>"frozen"</code>,
5103 <ol class="block">
5104 <li>Repeat for each element <i>k</i> of <i>keys</i>,
5105 <ol class="block">
5106 <li>Let <i>currentDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>k</i>).</li>
5107 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>currentDesc</i>).</li>
5108 <li>If <i>currentDesc</i> is not <b>undefined</b>, then
5109 <ol class="block">
5110 <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>currentDesc</i>) is <b>true</b>, then
5111 <ol class="block">
5112 <li>Let <i>desc</i> be the PropertyDescriptor{[[Configurable]]: <b>false</b>}.</li>
5113 </ol>
5114 </li>
5115 <li>Else,
5116 <ol class="block">
5117 <li>Let <i>desc</i> be the PropertyDescriptor { [[Configurable]]: <b>false</b>, [[Writable]]: <b>false</b>
5118 }.</li>
5119 </ol>
5120 </li>
5121 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>O</i>, <i>k</i>,
5122 <i>desc</i>).</li>
5123 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
5124 </ol>
5125 </li>
5126 </ol>
5127 </li>
5128 </ol>
5129 </li>
5130 <li>Return <b>true</b>.</li>
5131 </ol>
5132 </section>
5133
5134 <section id="sec-testintegritylevel">
5135 <h1><span class="secnum" id="sec-7.3.16"><a href="#sec-testintegritylevel" title="link to this section">7.3.16</a></span>
5136 TestIntegrityLevel (O, level)</h1>
5137
5138 <p>The abstract operation <span style="font-family: Times New Roman">TestIntegrityLevel</span> is used to determine if the
5139 set of own properties of an object are fixed. This abstract operation performs the following steps:</p>
5140
5141 <ol class="proc">
5142 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
5143 Object.</li>
5144 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>level</i> is either <code>"sealed"</code> or
5145 <code>"frozen"</code>.</li>
5146 <li>Let <i>status</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>O</i>).</li>
5147 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
5148 <li>If <i>status</i> is <b>true</b>, return <b>false</b></li>
5149 <li>NOTE If the object is extensible, none of its properties are examined.</li>
5150 <li>Let <i>keys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
5151 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>keys</i>).</li>
5152 <li>Repeat for each element <i>k</i> of <i>keys</i>,
5153 <ol class="block">
5154 <li>Let <i>currentDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>k</i>).</li>
5155 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>currentDesc</i>).</li>
5156 <li>If <i>currentDesc</i> is not <b>undefined</b>, then
5157 <ol class="block">
5158 <li>If <i>currentDesc</i>.[[Configurable]] is <b>true</b>, return <b>false</b>.</li>
5159 <li>If <i>level</i> is <code>"frozen"</code> and <a
5160 href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>currentDesc</i>) is <b>true</b>, then
5161 <ol class="block">
5162 <li>If <i>currentDesc</i>.[[Writable]] is <b>true</b>, return <b>false</b>.</li>
5163 </ol>
5164 </li>
5165 </ol>
5166 </li>
5167 </ol>
5168 </li>
5169 <li>Return <b>true</b>.</li>
5170 </ol>
5171 </section>
5172
5173 <section id="sec-createarrayfromlist">
5174 <h1><span class="secnum" id="sec-7.3.17"><a href="#sec-createarrayfromlist" title="link to this section">7.3.17</a></span>
5175 CreateArrayFromList (elements)</h1>
5176
5177 <p>The abstract operation <span style="font-family: Times New Roman">CreateArrayFromList</span> is used to create an Array
5178 object whose elements are provided by a <a href="#sec-list-and-record-specification-type">List</a>. This abstract operation
5179 performs the following steps:</p>
5180
5181 <ol class="proc">
5182 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>elements</i> is a <a
5183 href="#sec-list-and-record-specification-type">List</a> whose elements are all <a
5184 href="#sec-ecmascript-language-types">ECMAScript language values</a>.</li>
5185 <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0) (<a href="#sec-arraycreate">see 9.4.2.2</a>).</li>
5186 <li>Let <i>n</i> be 0.</li>
5187 <li>For each element <i>e</i> of <i>elements</i>
5188 <ol class="block">
5189 <li>Let <i>status</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
5190 href="#sec-tostring">ToString</a>(<i>n</i>), <i>e</i>).</li>
5191 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is <b>true</b>.</li>
5192 <li>Increment <i>n</i> by 1.</li>
5193 </ol>
5194 </li>
5195 <li>Return <i>array</i>.</li>
5196 </ol>
5197 </section>
5198
5199 <section id="sec-createlistfromarraylike">
5200 <h1><span class="secnum" id="sec-7.3.18"><a href="#sec-createlistfromarraylike"
5201 title="link to this section">7.3.18</a></span> CreateListFromArrayLike (obj [, elementTypes] )</h1>
5202
5203 <p>The abstract operation CreateListFromArrayLike is used to create a List value whose elements are provided by the indexed
5204 properties of an array-like object, <var>obj</var>. The optional argument <var>elementTypes</var> is a <a
5205 href="#sec-list-and-record-specification-type">List</a> containing the names of ECMAScript Language Types that are allowed
5206 for element values of the <a href="#sec-list-and-record-specification-type">List</a> that is created. This abstract
5207 operation performs the following steps:</p>
5208
5209 <ol class="proc">
5210 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>obj</i>).</li>
5211 <li>If <i>elementTypes</i> was not passed, let <i>elementTypes</i> be (Undefined, Null, Boolean, String, Symbol, Number,
5212 Object).</li>
5213 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>obj</i>) is not Object, throw a <b>TypeError</b>
5214 exception.</li>
5215 <li>Let <i>len</i> be <a href="#sec-tolength">ToLength</a>(<a href="#sec-get-o-p">Get</a>(<i>obj</i>,
5216 <code>"length"</code>)).</li>
5217 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
5218 <li>Let <i>list</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
5219 <li>Let <i>index</i> be 0.</li>
5220 <li>Repeat while <i>index</i> &lt; <i>len</i>
5221 <ol class="block">
5222 <li>Let <i>indexName</i> be <a href="#sec-tostring">ToString</a>(<i>index</i>).</li>
5223 <li>Let <i>next</i> be <a href="#sec-get-o-p">Get</a>(<i>obj</i>, <i>indexName</i>).</li>
5224 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
5225 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>next</i>) is not an element of <i>elementTypes</i>,
5226 throw a <b>TypeError</b> exception.</li>
5227 <li>Append <i>next</i> as the last element of <i>list</i>.</li>
5228 <li>Set <i>index</i> to <i>index</i> + 1.</li>
5229 </ol>
5230 </li>
5231 <li>Return <i>list</i>.</li>
5232 </ol>
5233 </section>
5234
5235 <section id="sec-ordinaryhasinstance">
5236 <h1><span class="secnum" id="sec-7.3.19"><a href="#sec-ordinaryhasinstance" title="link to this section">7.3.19</a></span>
5237 OrdinaryHasInstance (C, O)</h1>
5238
5239 <p>The abstract operation <span style="font-family: Times New Roman">OrdinaryHasInstance</span> implements the default
5240 algorithm for determining if an object <var>O</var> inherits from the instance object inheritance path provided by
5241 constructor <var>C</var>. This abstract operation performs the following steps:</p>
5242
5243 <ol class="proc">
5244 <li>If <a href="#sec-iscallable">IsCallable</a>(<i>C</i>) is <b>false</b>, return <b>false</b>.</li>
5245 <li>If <i>C</i> has a <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
5246 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, then
5247 <ol class="block">
5248 <li>Let <i>BC</i> be the value of <i>C&rsquo;s</i> <a
5249 href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
5250 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
5251 <li>Return <a href="#sec-instanceofoperator">InstanceofOperator</a>(<i>O</i>,<i>BC</i>) (<a
5252 href="#sec-instanceofoperator">see 12.9.4</a>).</li>
5253 </ol>
5254 </li>
5255 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is not Object, return <b>false</b>.</li>
5256 <li>Let <i>P</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, <code>"prototype"</code>).</li>
5257 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>P</i>).</li>
5258 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is not Object, throw a <b>TypeError</b>
5259 exception.</li>
5260 <li>Repeat
5261 <ol class="block">
5262 <li>Let <i>O</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
5263 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>O</i>).</li>
5264 <li>If <i>O</i> is <code>null</code>, return <b>false</b>.</li>
5265 <li>If <a href="#sec-samevalue">SameValue</a>(<i>P</i>, <i>O</i>) is <b>true</b>, return <b>true</b>.</li>
5266 </ol>
5267 </li>
5268 </ol>
5269 </section>
5270
5271 <section id="sec-speciesconstructor">
5272 <h1><span class="secnum" id="sec-7.3.20"><a href="#sec-speciesconstructor" title="link to this section">7.3.20</a></span>
5273 SpeciesConstructor ( O, defaultConstructor )</h1>
5274
5275 <p>The abstract operation SpeciesConstructor is used to retrieve the constructor that should be used to create new objects
5276 that are derived from the argument object <var>O</var>. The <var>defaultConstructor</var> argument is the constructor to use
5277 if a constructor @@species property cannot be found starting from <var>O</var>. This abstract operation performs the
5278 following steps:</p>
5279
5280 <ol class="proc">
5281 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
5282 Object.</li>
5283 <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>O</i>, <code>"constructor"</code>).</li>
5284 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
5285 <li>If <i>C</i> is <b>undefined</b>, return <i>defaultConstructor</i>.</li>
5286 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>C</i>) is not Object, throw a <b>TypeError</b>
5287 exception.</li>
5288 <li>Let <i>S</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, @@species).</li>
5289 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>S</i>).</li>
5290 <li>If <i>S</i> is either <b>undefined</b> or <b>null</b>, return <i>defaultConstructor</i>.</li>
5291 <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>S</i>) is <b>true</b>, return <i>S.</i></li>
5292 <li>Throw a <b>TypeError</b> exception.</li>
5293 </ol>
5294 </section>
5295
5296 <section id="sec-enumerableownnames">
5297 <h1><span class="secnum" id="sec-7.3.21"><a href="#sec-enumerableownnames" title="link to this section">7.3.21</a></span>
5298 EnumerableOwnNames (O)</h1>
5299
5300 <p>When the abstract operation EnumerableOwnNames is called with Object <var>O</var> the following steps are taken:</p>
5301
5302 <ol class="proc">
5303 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>)
5304 is Object.</li>
5305 <li>Let <i>ownKeys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
5306 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ownKeys</i>).</li>
5307 <li>Let <i>names</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
5308 <li>Repeat, for each element <i>key</i> of <i>ownKeys</i> in <a href="#sec-list-and-record-specification-type">List</a>
5309 order
5310 <ol class="block">
5311 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>key</i>) is String, then
5312 <ol class="block">
5313 <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>key</i>).</li>
5314 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
5315 <li>If <i>desc</i> is not <b>undefined</b>, then
5316 <ol class="block">
5317 <li>If <i>desc.</i>[[Enumerable]] is <b>true</b>, append <i>key</i> to <i>names</i>.</li>
5318 </ol>
5319 </li>
5320 </ol>
5321 </li>
5322 </ol>
5323 </li>
5324 <li>Order the elements of <i>names</i> so they are in the same relative order as would be produced by the Iterator that
5325 would be returned if the [[Enumerate]] internal method was invoked on <i>O</i>.</li>
5326 <li>Return <i>names</i>.</li>
5327 </ol>
5328
5329 <div class="note">
5330 <p><span class="nh">NOTE</span> The order of elements is returned list is the same as the enumeration order that used by a
5331 for-in statement.</p>
5332 </div>
5333 </section>
5334
5335 <section id="sec-getfunctionrealm">
5336 <h1><span class="secnum" id="sec-7.3.22"><a href="#sec-getfunctionrealm" title="link to this section">7.3.22</a></span>
5337 GetFunctionRealm ( obj )</h1>
5338
5339 <p>The abstract operation GetFunctionRealm with argument <var>obj</var> performs the following steps:</p>
5340
5341 <ol class="proc">
5342 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>obj</i> is a callable object.</li>
5343 <li>If <i>obj</i> has a [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, then
5344 <ol class="block">
5345 <li>Return <i>obj</i>&rsquo;s [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal
5346 slot</a>.</li>
5347 </ol>
5348 </li>
5349 <li>If <i>obj</i> is a <a href="#sec-bound-function-exotic-objects">Bound Function</a> exotic object, then
5350 <ol class="block">
5351 <li>Let <i>target</i> be <i>obj</i>&rsquo;s <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a>
5352 <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
5353 <li>Return GetFunctionRealm(<i>target</i>).</li>
5354 </ol>
5355 </li>
5356 <li>If <i>obj</i> is a Proxy exotic object, then
5357 <ol class="block">
5358 <li>If the value of the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
5359 of <i>obj</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
5360 <li>Let <i>proxyTarget</i> be the value of <i>obj</i>&rsquo;s [[ProxyTarget]] <a
5361 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
5362 <li>Return GetFunctionRealm(<i>proxyTarget</i>).</li>
5363 </ol>
5364 </li>
5365 <li>Return <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
5366 href="#sec-code-realms">Realm</a>.</li>
5367 </ol>
5368
5369 <div class="note">
5370 <p><span class="nh">NOTE</span> Step 5 will only be reached if <i>target</i> is a non-standard exotic function object that
5371 does not have a [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</p>
5372 </div>
5373 </section>
5374 </section>
5375
5376 <section id="sec-operations-on-iterator-objects">
5377 <div class="front">
5378 <h1><span class="secnum" id="sec-7.4"><a href="#sec-operations-on-iterator-objects"
5379 title="link to this section">7.4</a></span> Operations on Iterator Objects</h1>
5380
5381 <p>See Common Iteration Interfaces (<a href="#sec-iteration">25.1</a>).</p>
5382 </div>
5383
5384 <section id="sec-getiterator">
5385 <h1><span class="secnum" id="sec-7.4.1"><a href="#sec-getiterator" title="link to this section">7.4.1</a></span> GetIterator
5386 ( obj, method )</h1>
5387
5388 <p>The abstract operation GetIterator with argument <span style="font-family: Times New Roman"><i>obj</i> and</span>
5389 optional argument <var>method</var> performs the following steps:</p>
5390
5391 <ol class="proc">
5392 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>obj</i>).</li>
5393 <li>If <i>method</i> was not passed, then
5394 <ol class="block">
5395 <li>Let <i>method</i> be <a href="#sec-getmethod">GetMethod</a>(<i>obj</i>, @@iterator).</li>
5396 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>method</i>).</li>
5397 </ol>
5398 </li>
5399 <li>Let <i>iterator</i> be <a href="#sec-call">Call</a>(<i>method</i>,<i>obj</i>).</li>
5400 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>)<i>.</i></li>
5401 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterator</i>) is not Object, throw a <b>TypeError</b>
5402 exception.</li>
5403 <li>Return <i>iterator</i>.</li>
5404 </ol>
5405 </section>
5406
5407 <section id="sec-iteratornext">
5408 <h1><span class="secnum" id="sec-7.4.2"><a href="#sec-iteratornext" title="link to this section">7.4.2</a></span>
5409 IteratorNext ( iterator, value )</h1>
5410
5411 <p>The abstract operation IteratorNext with argument <var>iterator</var> and optional argument <var>value</var> performs the
5412 following steps:</p>
5413
5414 <ol class="proc">
5415 <li>If <i>value</i> was not passed, then
5416 <ol class="block">
5417 <li>Let <i>result</i> be <a href="#sec-invoke">Invoke</a>(<i>iterator</i>, <code>"next"</code>, &laquo;&zwj;
5418 &raquo;).</li>
5419 </ol>
5420 </li>
5421 <li>Else,
5422 <ol class="block">
5423 <li>Let <i>result</i> be <a href="#sec-invoke">Invoke</a>(<i>iterator</i>, <code>"next"</code>,
5424 &laquo;&zwj;<i>value</i>&raquo;).</li>
5425 </ol>
5426 </li>
5427 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
5428 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, throw a <b>TypeError</b>
5429 exception.</li>
5430 <li>Return <i>result</i>.</li>
5431 </ol>
5432 </section>
5433
5434 <section id="sec-iteratorcomplete">
5435 <h1><span class="secnum" id="sec-7.4.3"><a href="#sec-iteratorcomplete" title="link to this section">7.4.3</a></span>
5436 IteratorComplete ( iterResult )</h1>
5437
5438 <p>The abstract operation IteratorComplete with argument <var>iterResult</var> performs the following steps:</p>
5439
5440 <ol class="proc">
5441 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
5442 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterResult</i>) is Object.</li>
5443 <li>Return <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>iterResult</i>,
5444 <code>"done"</code>)).</li>
5445 </ol>
5446 </section>
5447
5448 <section id="sec-iteratorvalue">
5449 <h1><span class="secnum" id="sec-7.4.4"><a href="#sec-iteratorvalue" title="link to this section">7.4.4</a></span>
5450 IteratorValue ( iterResult )</h1>
5451
5452 <p>The abstract operation IteratorValue with argument <var>iterResult</var> performs the following steps:</p>
5453
5454 <ol class="proc">
5455 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
5456 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterResult</i>) is Object.</li>
5457 <li>Return <a href="#sec-get-o-p">Get</a>(<i>iterResult</i>, <code>"value"</code>).</li>
5458 </ol>
5459 </section>
5460
5461 <section id="sec-iteratorstep">
5462 <h1><span class="secnum" id="sec-7.4.5"><a href="#sec-iteratorstep" title="link to this section">7.4.5</a></span>
5463 IteratorStep ( iterator )</h1>
5464
5465 <p>The abstract operation IteratorStep with argument <var>iterator</var> requests the next value from <var>iterator</var>
5466 and returns either <span class="value">false</span> indicating that the iterator has reached its end or the IteratorResult
5467 object if a next value is available. IteratorStep performs the following steps:</p>
5468
5469 <ol class="proc">
5470 <li>Let <i>result</i> be <a href="#sec-iteratornext">IteratorNext</a>(<i>iterator</i>).</li>
5471 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
5472 <li>Let <i>done</i> be <a href="#sec-iteratorcomplete">IteratorComplete</a>(<i>result</i>).</li>
5473 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>done</i>).</li>
5474 <li>If <i>done</i> is <b>true</b>, return <b>false</b>.</li>
5475 <li>Return <i>result</i>.</li>
5476 </ol>
5477 </section>
5478
5479 <section id="sec-iteratorclose">
5480 <h1><span class="secnum" id="sec-7.4.6"><a href="#sec-iteratorclose" title="link to this section">7.4.6</a></span>
5481 IteratorClose( iterator, completion )</h1>
5482
5483 <p>The abstract operation IteratorClose with arguments <var>iterator</var> and <var>completion</var> is used to notify an
5484 iterator that it should perform any actions it would normally perform when it has reached its completed state:</p>
5485
5486 <ol class="proc">
5487 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
5488 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterator</i>) is Object.</li>
5489 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>completion</i> is a <a
5490 href="#sec-completion-record-specification-type">Completion Record</a>.</li>
5491 <li>Let <i>return</i> be <a href="#sec-getmethod">GetMethod</a>(<i>iterator</i>, <code>"return"</code>).</li>
5492 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>return</i>).</li>
5493 <li>If <i>return</i> is <b>undefined</b>, return <a
5494 href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
5495 <li>Let <i>innerResult</i> be <a href="#sec-call">Call</a>(<i>return</i>, <i>iterator</i>, &laquo;&zwj; &raquo;).</li>
5496 <li>If <i>completion</i>.[[type]] is <span style="font-family: sans-serif">throw</span>, return <a
5497 href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
5498 <li>If <i>innerResult</i>.[[type]] is <span style="font-family: sans-serif">throw</span>, return <a
5499 href="#sec-completion-record-specification-type">Completion</a>(<i>innerResult</i>).</li>
5500 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>innerResult</i>.[[value]]) is not Object<i>,</i> throw
5501 a <b>TypeError</b> exception.</li>
5502 <li>Return <a href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
5503 </ol>
5504 </section>
5505
5506 <section id="sec-createiterresultobject">
5507 <h1><span class="secnum" id="sec-7.4.7"><a href="#sec-createiterresultobject" title="link to this section">7.4.7</a></span>
5508 CreateIterResultObject ( value, done )</h1>
5509
5510 <p>The abstract operation CreateIterResultObject with arguments <var>value</var> and <var>done</var> creates an object that
5511 supports the IteratorResult interface by performing the following steps:</p>
5512
5513 <ol class="proc">
5514 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>done</i>)
5515 is Boolean.</li>
5516 <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
5517 sans-serif">%ObjectPrototype%</span>).</li>
5518 <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <code>"value"</code>, <i>value</i>).</li>
5519 <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <code>"done"</code>, <i>done</i>).</li>
5520 <li>Return <i>obj</i>.</li>
5521 </ol>
5522 </section>
5523
5524 <section id="sec-createlistiterator">
5525 <div class="front">
5526 <h1><span class="secnum" id="sec-7.4.8"><a href="#sec-createlistiterator" title="link to this section">7.4.8</a></span>
5527 CreateListIterator ( list )</h1>
5528
5529 <p>The abstract operation CreateListIterator with argument <var>list</var> creates an Iterator (<a
5530 href="#sec-iterator-interface">25.1.1.2</a>) object whose next method returns the successive elements of <var>list</var>.
5531 It performs the following steps:</p>
5532
5533 <ol class="proc">
5534 <li>Let <i>iterator</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%IteratorPrototype%, &laquo;[[IteratorNext]],
5535 [[IteratedList]], [[ListIteratorNextIndex]]&raquo;).</li>
5536 <li>Set <i>iterator&rsquo;s</i> [[IteratedList]] <a href="#sec-object-internal-methods-and-internal-slots">internal
5537 slot</a> to <i>list</i>.</li>
5538 <li>Set <i>iterator&rsquo;s</i> [[ListIteratorNextIndex]] <a
5539 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to 0.</li>
5540 <li>Let <i>next</i> be a new built-in function object as defined in ListIterator <code>next</code> (<a
5541 href="#sec-listiterator-next">7.4.8.1</a>).</li>
5542 <li>Set <i>iterator&rsquo;s</i> [[IteratorNext]] <a href="#sec-object-internal-methods-and-internal-slots">internal
5543 slot</a> to <i>next</i>.</li>
5544 <li>Perform <a href="#sec-createmethodproperty">CreateMethodProperty</a>(<i>iterator</i>, <code>"next"</code>,
5545 <i>next</i>).</li>
5546 <li>Return <i>iterator</i>.</li>
5547 </ol>
5548 </div>
5549
5550 <section id="sec-listiterator-next">
5551 <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>
5552 ListIterator next( )</h1>
5553
5554 <p>The ListIterator <code>next</code> method is a standard built-in function object (<a
5555 href="#sec-ecmascript-standard-built-in-objects">clause 17</a>) that performs the following steps:</p>
5556
5557 <ol class="proc">
5558 <li>Let <i>O</i> be the <b>this</b> value.</li>
5559 <li>Let <i>f</i> be the active function object.</li>
5560 <li>If <i>O</i> does not have a [[IteratorNext]] <a href="#sec-object-internal-methods-and-internal-slots">internal
5561 slot</a>, throw a <b>TypeError</b> exception.</li>
5562 <li>Let <i>next</i> be the value of the [[IteratorNext]] <a
5563 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
5564 <li>If <a href="#sec-samevalue">SameValue</a>(<i>f</i>, <i>next</i>) is <b>false</b>, throw a <b>TypeError</b>
5565 exception.</li>
5566 <li>If <i>O</i> does not have a [[IteratedList]] <a href="#sec-object-internal-methods-and-internal-slots">internal
5567 slot</a>, throw a <b>TypeError</b> exception.</li>
5568 <li>Let <i>list</i> be the value of the [[IteratedList]] <a
5569 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
5570 <li>Let <i>index</i> be the value of the [[ListIteratorNextIndex]] <a
5571 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
5572 <li>Let <i>len</i> be the number of elements of <i>list</i>.</li>
5573 <li>If <i>index</i> &ge; <i>len</i>, then
5574 <ol class="block">
5575 <li>Return <a href="#sec-createiterresultobject">CreateIterResultObject</a>(<b>undefined</b>, <b>true</b>).</li>
5576 </ol>
5577 </li>
5578 <li>Set the value of the [[ListIteratorNextIndex]] <a href="#sec-object-internal-methods-and-internal-slots">internal
5579 slot</a> of <i>O</i> to <i>index</i>+1.</li>
5580 <li>Return <a href="#sec-createiterresultobject">CreateIterResultObject</a>(<i>list</i>[<i>index</i>],
5581 <b>false</b>).</li>
5582 </ol>
5583
5584 <div class="note">
5585 <p><span class="nh">NOTE</span> A ListIterator <code>next</code> method will throw an exception if applied to any object
5586 other than the one with which it was originally associated.</p>
5587 </div>
5588 </section>
5589 </section>
5590 </section>
5591 </section>
5592
5593 <section id="sec-executable-code-and-execution-contexts">
5594 <div class="front">
5595 <h1><span class="secnum" id="sec-8"><a href="#sec-executable-code-and-execution-contexts"
5596 title="link to this section">8</a></span> Executable Code and Execution Contexts</h1>
5597 </div>
5598
5599 <section id="sec-lexical-environments">
5600 <div class="front">
5601 <h1><span class="secnum" id="sec-8.1"><a href="#sec-lexical-environments" title="link to this section">8.1</a></span>
5602 Lexical Environments</h1>
5603
5604 <p>A <i>Lexical Environment</i> is a specification type used to define the association of <span
5605 class="nt">Identifiers</span> to specific variables and functions based upon the lexical nesting structure of ECMAScript
5606 code. A Lexical Environment consists of an <a href="#sec-environment-records">Environment Record</a> and a possibly null
5607 reference to an <i>outer</i> Lexical Environment. Usually a Lexical Environment is associated with some specific syntactic
5608 structure of ECMAScript code such as a <span class="nt">FunctionDeclaration</span>, a <span
5609 class="nt">BlockStatement</span>, or a <span class="nt">Catch</span> clause of a <span class="nt">TryStatement</span> and a
5610 new Lexical Environment is created each time such code is evaluated.</p>
5611
5612 <p>An <a href="#sec-environment-records">Environment Record</a> records the identifier bindings that are created within the
5613 scope of its associated Lexical Environment. It is referred to as the Lexical Environment&rsquo;s EnvironmentRecord</p>
5614
5615 <p>The outer environment reference is used to model the logical nesting of Lexical Environment values. The outer reference
5616 of a (inner) Lexical Environment is a reference to the Lexical Environment that logically surrounds the inner Lexical
5617 Environment. An outer Lexical Environment may, of course, have its own outer Lexical Environment. A Lexical Environment may
5618 serve as the outer environment for multiple inner Lexical Environments. For example, if a <span
5619 class="nt">FunctionDeclaration</span> contains two nested <span class="nt">FunctionDeclarations</span> then the Lexical
5620 Environments of each of the nested functions will have as their outer Lexical Environment the Lexical Environment of the
5621 current evaluation of the surrounding function.</p>
5622
5623 <p>A <i>global environment</i> is a Lexical Environment which does not have an outer environment. The global
5624 environment&rsquo;s outer environment reference is <b>null</b>. A global environment&rsquo;s <a
5625 href="#sec-environment-records">Environment Record</a> may be prepopulated with identifier bindings and includes an
5626 associated <i>global object</i> whose properties provide some of <a href="#sec-global-environment-records">the global
5627 environment</a>&rsquo;s identifier bindings. This global object is the value of a global environment&rsquo;s
5628 <code>this</code> binding. As ECMAScript code is executed, additional properties may be added to the global object and the
5629 initial properties may be modified.</p>
5630
5631 <p>A <i>module environment</i> is a Lexical Environment that contains the bindings for the top level declarations of a <span
5632 class="nt">Module</span>. It also contains the bindings that are explicitly imported by the <span class="nt">Module</span>.
5633 The outer environment of a module environment is a global environment.</p>
5634
5635 <p>A <i>function environment</i> is a Lexical Environment that corresponds to the invocation of an <a
5636 href="#sec-ecmascript-function-objects">ECMAScript function object</a>. A function environment may establish a new
5637 <code>this</code> binding. A function environment also captures the state necessary to support <code>super</code> method
5638 invocations.</p>
5639
5640 <p>Lexical Environments and <a href="#sec-environment-records">Environment Record</a> values are purely specification
5641 mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an
5642 ECMAScript program to directly access or manipulate such values.</p>
5643 </div>
5644
5645 <section id="sec-environment-records">
5646 <div class="front">
5647 <h1><span class="secnum" id="sec-8.1.1"><a href="#sec-environment-records" title="link to this section">8.1.1</a></span>
5648 Environment Records</h1>
5649
5650 <p>There are two primary kinds of Environment Record values used in this specification: <i>declarative Environment
5651 Records</i> and <i>object Environment Records</i>. Declarative Environment Records are used to define the effect of
5652 ECMAScript language syntactic elements such as <span class="nt">FunctionDeclarations</span>, <span
5653 class="nt">VariableDeclarations</span>, and <span class="nt">Catch</span> clauses that directly associate identifier
5654 bindings with <a href="#sec-ecmascript-language-types">ECMAScript language values</a>. Object Environment Records are used
5655 to define the effect of ECMAScript elements such as <span class="nt">WithStatement</span> that associate identifier
5656 bindings with the properties of some object. <a href="#sec-global-environment-records">Global Environment Records</a> and
5657 function Environment Records are specializations that are used for specifically for <span class="nt">Script</span> global
5658 declarations and for top-level declarations within functions.</p>
5659
5660 <p>For specification purposes Environment Record values are values of the Record specification type and can be thought of
5661 as existing in a simple object-oriented hierarchy where Environment Record is an abstract class with three concrete
5662 subclasses, declarative Environment Record, object Environment Record, and global Environment Record. <a
5663 href="#sec-function-environment-records">Function Environment Records</a> and module Environment Records are subclasses of
5664 declarative Environment Record. The abstract class includes the abstract specification methods defined in <a
5665 href="#table-15">Table 15</a>. These abstract methods have distinct concrete algorithms for each of the concrete
5666 subclasses.</p>
5667
5668 <figure>
5669 <figcaption><span id="table-15">Table 15</span> &mdash; Abstract Methods of Environment Records</figcaption>
5670 <table class="real-table">
5671 <tr>
5672 <th>Method</th>
5673 <th>Purpose</th>
5674 </tr>
5675 <tr>
5676 <td>HasBinding(N)</td>
5677 <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>
5678 </tr>
5679 <tr>
5680 <td>CreateMutableBinding(N, D)</td>
5681 <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>
5682 </tr>
5683 <tr>
5684 <td>CreateImmutableBinding(N, S)</td>
5685 <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>
5686 </tr>
5687 <tr>
5688 <td>InitializeBinding(N,V)</td>
5689 <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>
5690 </tr>
5691 <tr>
5692 <td>SetMutableBinding(N,V, S)</td>
5693 <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>
5694 </tr>
5695 <tr>
5696 <td>GetBindingValue(N,S)</td>
5697 <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>
5698 </tr>
5699 <tr>
5700 <td>DeleteBinding(N)</td>
5701 <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>
5702 </tr>
5703 <tr>
5704 <td>HasThisBinding()</td>
5705 <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>
5706 </tr>
5707 <tr>
5708 <td>HasSuperBinding()</td>
5709 <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>
5710 </tr>
5711 <tr>
5712 <td>WithBaseObject ()</td>
5713 <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>
5714 </tr>
5715 </table>
5716 </figure>
5717 </div>
5718
5719 <section id="sec-declarative-environment-records">
5720 <div class="front">
5721 <h1><span class="secnum" id="sec-8.1.1.1"><a href="#sec-declarative-environment-records"
5722 title="link to this section">8.1.1.1</a></span> Declarative Environment Records</h1>
5723
5724 <p>Each declarative <a href="#sec-environment-records">Environment Record</a> is associated with an ECMAScript program
5725 scope containing variable, constant, let, class, module, import, and/or function declarations. A declarative <a
5726 href="#sec-environment-records">Environment Record</a> binds the set of identifiers defined by the declarations
5727 contained within its scope.</p>
5728
5729 <p>The behaviour of the concrete specification methods for declarative environment records is defined by the following
5730 algorithms.</p>
5731 </div>
5732
5733 <section id="sec-declarative-environment-records-hasbinding-n">
5734 <h1><span class="secnum" id="sec-8.1.1.1.1"><a href="#sec-declarative-environment-records-hasbinding-n"
5735 title="link to this section">8.1.1.1.1</a></span> HasBinding(N)</h1>
5736
5737 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for declarative Environment
5738 Records simply determines if the argument identifier is one of the identifiers bound by the record:</p>
5739
5740 <ol class="proc">
5741 <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
5742 method was invoked.</li>
5743 <li>If <i>envRec</i> has a binding for the name that is the value of <i>N</i>, return <b>true</b>.</li>
5744 <li>Return <b>false</b>.</li>
5745 </ol>
5746 </section>
5747
5748 <section id="sec-declarative-environment-records-createmutablebinding-n-d">
5749 <h1><span class="secnum" id="sec-8.1.1.1.2"><a href="#sec-declarative-environment-records-createmutablebinding-n-d"
5750 title="link to this section">8.1.1.1.2</a></span> CreateMutableBinding (N, D)</h1>
5751
5752 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for declarative
5753 Environment Records creates a new mutable binding for the name <var>N</var> that is uninitialized. A binding must not
5754 already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
5755 <var>D</var> is provided and has the value <b>true</b> the new binding is marked as being subject to deletion.</p>
5756
5757 <ol class="proc">
5758 <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
5759 method was invoked.</li>
5760 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
5761 <li>Create a mutable binding in <i>envRec</i> for <i>N</i> and record that it is uninitialized. If <i>D</i> is
5762 <b>true</b> record that the newly created binding may be deleted by a subsequent DeleteBinding call.</li>
5763 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
5764 sans-serif">empty</span>).</li>
5765 </ol>
5766 </section>
5767
5768 <section id="sec-declarative-environment-records-createimmutablebinding-n-s">
5769 <h1><span class="secnum" id="sec-8.1.1.1.3"><a href="#sec-declarative-environment-records-createimmutablebinding-n-s"
5770 title="link to this section">8.1.1.1.3</a></span> CreateImmutableBinding (N, S)</h1>
5771
5772 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding for declarative
5773 Environment Records creates a new immutable binding for the name <var>N</var> that is uninitialized. A binding must not
5774 already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
5775 <var>S</var> is provided and has the value <b>true</b> the new binding is marked as a strict binding.</p>
5776
5777 <ol class="proc">
5778 <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
5779 method was invoked.</li>
5780 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
5781 <li>Create an immutable binding in <i>envRec</i> for <i>N</i> and record that it is uninitialized. If <i>S</i> is
5782 <b>true</b> record that the newly created binding is a strict binding.</li>
5783 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
5784 sans-serif">empty</span>).</li>
5785 </ol>
5786 </section>
5787
5788 <section id="sec-declarative-environment-records-initializebinding-n-v">
5789 <h1><span class="secnum" id="sec-8.1.1.1.4"><a href="#sec-declarative-environment-records-initializebinding-n-v"
5790 title="link to this section">8.1.1.1.4</a></span> InitializeBinding (N,V)</h1>
5791
5792 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for declarative
5793 Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
5794 the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
5795 exist.</p>
5796
5797 <ol class="proc">
5798 <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
5799 method was invoked.</li>
5800 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> must have an uninitialized binding for
5801 <i>N</i>.</li>
5802 <li>Set the bound value for <i>N</i> in <i>envRec</i> to <i>V</i>.</li>
5803 <li>Record that the binding for <i>N</i> in <i>envRec</i> has been initialized.</li>
5804 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
5805 sans-serif">empty</span>).</li>
5806 </ol>
5807 </section>
5808
5809 <section id="sec-declarative-environment-records-setmutablebinding-n-v-s">
5810 <h1><span class="secnum" id="sec-8.1.1.1.5"><a href="#sec-declarative-environment-records-setmutablebinding-n-v-s"
5811 title="link to this section">8.1.1.1.5</a></span> SetMutableBinding (N,V,S)</h1>
5812
5813 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for declarative
5814 Environment Records attempts to change the bound value of the current binding of the identifier whose name is the value
5815 of the argument <var>N</var> to the value of argument <var>V</var>. A binding for <var>N</var> normally already exist,
5816 but in rare cases it may not. If the binding is an immutable binding, a <b>TypeError</b> is thrown if <span
5817 style="font-family: Times New Roman">S</span> is <span class="value">true</span>.</p>
5818
5819 <ol class="proc">
5820 <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
5821 method was invoked.</li>
5822 <li>If <i>envRec</i> does not have a binding for <i>N</i>, then
5823 <ol class="block">
5824 <li>If <i>S</i> is <b>true</b> throw a <b>ReferenceError</b> exception.</li>
5825 <li>Perform <i>envRec</i>.CreateMutableBinding(<i>N</i>, <b>true</b>).</li>
5826 <li>Perform <i>envRec</i>.InitializeBinding(<i>N</i>, <i>V</i>).</li>
5827 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
5828 sans-serif">empty</span>).</li>
5829 </ol>
5830 </li>
5831 <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>
5832 <li>If the binding for <i>N</i> in <i>envRec</i> has not yet been initialized throw a <b>ReferenceError</b>
5833 exception.</li>
5834 <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>
5835 <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
5836 <b>TypeError</b> exception.</li>
5837 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
5838 sans-serif">empty</span>).</li>
5839 </ol>
5840
5841 <div class="note">
5842 <p><span class="nh">NOTE</span> An example of ECMAScript code that results in a missing binding at step 2 is:</p>
5843
5844 <pre>function f(){eval("var x; x = (delete x, 0);")}</pre>
5845 </div>
5846 </section>
5847
5848 <section id="sec-declarative-environment-records-getbindingvalue-n-s">
5849 <h1><span class="secnum" id="sec-8.1.1.1.6"><a href="#sec-declarative-environment-records-getbindingvalue-n-s"
5850 title="link to this section">8.1.1.1.6</a></span> GetBindingValue(N,S)</h1>
5851
5852 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for declarative
5853 Environment Records simply returns the value of its bound identifier whose name is the value of the argument
5854 <var>N</var>. If the binding exists but is uninitialized a <b>ReferenceError</b> is thrown, regardless of the value of
5855 <i><span style="font-family: Times New Roman">S</span>.</i></p>
5856
5857 <ol class="proc">
5858 <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
5859 method was invoked.</li>
5860 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for <i>N</i>.</li>
5861 <li>If the binding for <i>N</i> in <i>envRec</i> is an uninitialized binding, throw a <b>ReferenceError</b>
5862 exception.</li>
5863 <li>Return the value currently bound to <i>N</i> in <i>envRec</i>.</li>
5864 </ol>
5865 </section>
5866
5867 <section id="sec-declarative-environment-records-deletebinding-n">
5868 <h1><span class="secnum" id="sec-8.1.1.1.7"><a href="#sec-declarative-environment-records-deletebinding-n"
5869 title="link to this section">8.1.1.1.7</a></span> DeleteBinding (N)</h1>
5870
5871 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for declarative
5872 Environment Records can only delete bindings that have been explicitly designated as being subject to deletion.</p>
5873
5874 <ol class="proc">
5875 <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
5876 method was invoked.</li>
5877 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for the name that is the value of
5878 <i>N</i>.</li>
5879 <li>If the binding for <i>N</i> in <i>envRec</i> cannot be deleted, return <b>false</b>.</li>
5880 <li>Remove the binding for <i>N</i> from <i>envRec</i>.</li>
5881 <li>Return <b>true</b>.</li>
5882 </ol>
5883 </section>
5884
5885 <section id="sec-declarative-environment-records-hasthisbinding">
5886 <h1><span class="secnum" id="sec-8.1.1.1.8"><a href="#sec-declarative-environment-records-hasthisbinding"
5887 title="link to this section">8.1.1.1.8</a></span> HasThisBinding ()</h1>
5888
5889 <p>Regular declarative Environment Records do not provide a <code>this</code> binding.</p>
5890
5891 <ol class="proc">
5892 <li>Return <b>false</b>.</li>
5893 </ol>
5894 </section>
5895
5896 <section id="sec-declarative-environment-records-hassuperbinding">
5897 <h1><span class="secnum" id="sec-8.1.1.1.9"><a href="#sec-declarative-environment-records-hassuperbinding"
5898 title="link to this section">8.1.1.1.9</a></span> HasSuperBinding ()</h1>
5899
5900 <p>Regular declarative Environment Records do not provide a <code>super</code> binding.</p>
5901
5902 <ol class="proc">
5903 <li>Return <b>false</b>.</li>
5904 </ol>
5905 </section>
5906
5907 <section id="sec-declarative-environment-records-withbaseobject">
5908 <h1><span class="secnum" id="sec-8.1.1.1.10"><a href="#sec-declarative-environment-records-withbaseobject"
5909 title="link to this section">8.1.1.1.10</a></span> WithBaseObject()</h1>
5910
5911 <p>Declarative Environment Records always return <b>undefined</b> as their WithBaseObject.</p>
5912
5913 <ol class="proc">
5914 <li>Return <b>undefined</b>.</li>
5915 </ol>
5916 </section>
5917 </section>
5918
5919 <section id="sec-object-environment-records">
5920 <div class="front">
5921 <h1><span class="secnum" id="sec-8.1.1.2"><a href="#sec-object-environment-records"
5922 title="link to this section">8.1.1.2</a></span> Object Environment Records</h1>
5923
5924 <p>Each object <a href="#sec-environment-records">Environment Record</a> is associated with an object called its
5925 <i>binding object</i>. An object <a href="#sec-environment-records">Environment Record</a> binds the set of string
5926 identifier names that directly correspond to the property names of its binding object. Property keys that are not
5927 strings in the form of an <span class="nt">IdentifierName</span> are not included in the set of bound identifiers. Both
5928 own and inherited properties are included in the set regardless of the setting of their [[Enumerable]] attribute.
5929 Because properties can be dynamically added and deleted from objects, the set of identifiers bound by an object <a
5930 href="#sec-environment-records">Environment Record</a> may potentially change as a side-effect of any operation that
5931 adds or deletes properties. Any bindings that are created as a result of such a side-effect are considered to be a
5932 mutable binding even if the Writable attribute of the corresponding property has the value <b>false</b>. Immutable
5933 bindings do not exist for object Environment Records.</p>
5934
5935 <p>Object Environment Records created for <code>with</code> statements (<a href="#sec-with-statement">13.10</a>) can
5936 provide their binding object as an implicit <b>this</b> value for use in function calls. The capability is controlled by
5937 a <var>withEnvironment</var> Boolean value that is associated with each object <a
5938 href="#sec-environment-records">Environment Record</a>. By default, the value of <var>withEnvironment</var> is
5939 <b>false</b> for any object <a href="#sec-environment-records">Environment Record</a>.</p>
5940
5941 <p>The behaviour of the concrete specification methods for object environment records is defined by the following
5942 algorithms.</p>
5943 </div>
5944
5945 <section id="sec-object-environment-records-hasbinding-n">
5946 <h1><span class="secnum" id="sec-8.1.1.2.1"><a href="#sec-object-environment-records-hasbinding-n"
5947 title="link to this section">8.1.1.2.1</a></span> HasBinding(N)</h1>
5948
5949 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for object Environment
5950 Records determines if its associated binding object has a property whose name is the value of the argument
5951 <var>N</var>:</p>
5952
5953 <ol class="proc">
5954 <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
5955 invoked.</li>
5956 <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
5957 <li>Let <i>foundBinding</i> be <a href="#sec-hasproperty">HasProperty</a>(<i>bindings</i>, <i>N</i>)</li>
5958 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>foundBinding</i>).</li>
5959 <li>If <i>foundBinding</i> is <b>false</b>, return <b>false</b>.</li>
5960 <li>If the <i>withEnvironment</i> flag of <i>envRec</i> is <b>false</b>, return <b>true</b>.</li>
5961 <li>Let <i>unscopables</i> be <a href="#sec-get-o-p">Get</a>(<i>bindings</i>, @@unscopables).</li>
5962 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>unscopables</i>).</li>
5963 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>unscopables</i>) is Object, then
5964 <ol class="block">
5965 <li>Let <i>blocked</i> be <a href="#sec-toboolean">ToBoolean</a>(<a
5966 href="#sec-get-o-p">Get</a>(<i>unscopables</i>, <i>N</i>)).</li>
5967 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>blocked</i>).</li>
5968 <li>If <i>blocked</i> is <b>true</b>, return <b>false</b>.</li>
5969 </ol>
5970 </li>
5971 <li>Return <b>true</b>.</li>
5972 </ol>
5973 </section>
5974
5975 <section id="sec-object-environment-records-createmutablebinding-n-d">
5976 <h1><span class="secnum" id="sec-8.1.1.2.2"><a href="#sec-object-environment-records-createmutablebinding-n-d"
5977 title="link to this section">8.1.1.2.2</a></span> CreateMutableBinding (N, D)</h1>
5978
5979 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for object
5980 Environment Records creates in an Environment Record&rsquo;s associated binding object a property whose name is the
5981 String value and initializes it to the value <b>undefined</b>. If Boolean argument <var>D</var> is provided and has the
5982 value <b>true</b> the new property&rsquo;s [[Configurable]] attribute is set to <b>true</b>, otherwise it is set to
5983 <b>false</b>.</p>
5984
5985 <ol class="proc">
5986 <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
5987 invoked.</li>
5988 <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
5989 <li>If <i>D</i> is <b>true</b> then let <i>configValue</i> be <b>true</b> otherwise let <i>configValue</i> be
5990 <b>false</b>.</li>
5991 <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>bindings</i>, <i>N</i>,
5992 PropertyDescriptor{[[Value]]:<b>undefined</b>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>true</b> ,
5993 [[Configurable]]: <i>configValue</i>}).</li>
5994 </ol>
5995
5996 <div class="note">
5997 <p><span class="nh">NOTE</span> Normally <i>envRec</i> will not have a binding for <i>N</i> but if it does, the
5998 semantics of <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a> may result in an existing binding being
5999 replaced or shadowed or cause an <a href="#sec-completion-record-specification-type">abrupt completion</a> to be
6000 returned.</p>
6001 </div>
6002 </section>
6003
6004 <section id="sec-object-environment-records-createimmutablebinding-n-s">
6005 <h1><span class="secnum" id="sec-8.1.1.2.3"><a href="#sec-object-environment-records-createimmutablebinding-n-s"
6006 title="link to this section">8.1.1.2.3</a></span> CreateImmutableBinding (N, S)</h1>
6007
6008 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding is never used
6009 within this specification in association with Object Environment Records.</p>
6010 </section>
6011
6012 <section id="sec-object-environment-records-initializebinding-n-v">
6013 <h1><span class="secnum" id="sec-8.1.1.2.4"><a href="#sec-object-environment-records-initializebinding-n-v"
6014 title="link to this section">8.1.1.2.4</a></span> InitializeBinding (N,V)</h1>
6015
6016 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for object
6017 Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
6018 the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
6019 exist.</p>
6020
6021 <ol class="proc">
6022 <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
6023 invoked.</li>
6024 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> must have an uninitialized binding for
6025 <i>N</i>.</li>
6026 <li>Record that the binding for <i>N</i> in <i>envRec</i> has been initialized.</li>
6027 <li>Return <i>envRec</i>.SetMutableBinding(<i>N</i>, <i>V</i>, <b>false</b>).</li>
6028 </ol>
6029
6030 <div class="note">
6031 <p><span class="nh">NOTE</span> In this specification, all uses of CreateMutableBinding for object Environment Records
6032 are immediately followed by a call to InitializeBinding for the same name. Hence, implementations do not need to
6033 explicitly track the initialization state of individual object Environment Record bindings.</p>
6034 </div>
6035 </section>
6036
6037 <section id="sec-object-environment-records-setmutablebinding-n-v-s">
6038 <h1><span class="secnum" id="sec-8.1.1.2.5"><a href="#sec-object-environment-records-setmutablebinding-n-v-s"
6039 title="link to this section">8.1.1.2.5</a></span> SetMutableBinding (N,V,S)</h1>
6040
6041 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for object
6042 Environment Records attempts to set the value of the Environment Record&rsquo;s associated binding object&rsquo;s
6043 property whose name is the value of the argument <var>N</var> to the value of argument <var>V</var>. A property named
6044 <var>N</var> normally already exists but if it does not or is not currently writable, error handling is determined by
6045 the value of the Boolean argument <var>S</var>.</p>
6046
6047 <ol class="proc">
6048 <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
6049 invoked.</li>
6050 <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
6051 <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>
6052 </ol>
6053 </section>
6054
6055 <section id="sec-object-environment-records-getbindingvalue-n-s">
6056 <h1><span class="secnum" id="sec-8.1.1.2.6"><a href="#sec-object-environment-records-getbindingvalue-n-s"
6057 title="link to this section">8.1.1.2.6</a></span> GetBindingValue(N,S)</h1>
6058
6059 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for object Environment
6060 Records returns the value of its associated binding object&rsquo;s property whose name is the String value of the
6061 argument identifier <var>N</var>. The property should already exist but if it does not the result depends upon the value
6062 of the <var>S</var> argument:</p>
6063
6064 <ol class="proc">
6065 <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
6066 invoked.</li>
6067 <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
6068 <li>Let <i>value</i> be <a href="#sec-hasproperty">HasProperty</a>(<i>bindings</i>, <i>N</i>).</li>
6069 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
6070 <li>If <i>value</i> is <b>false</b>, then
6071 <ol class="block">
6072 <li>If <i>S</i> is <b>false</b>, return the value <b>undefined</b>, otherwise throw a <b>ReferenceError</b>
6073 exception.</li>
6074 </ol>
6075 </li>
6076 <li>Return <a href="#sec-get-o-p">Get</a>(<i>bindings</i>, <i>N</i>).</li>
6077 </ol>
6078 </section>
6079
6080 <section id="sec-object-environment-records-deletebinding-n">
6081 <h1><span class="secnum" id="sec-8.1.1.2.7"><a href="#sec-object-environment-records-deletebinding-n"
6082 title="link to this section">8.1.1.2.7</a></span> DeleteBinding (N)</h1>
6083
6084 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for object Environment
6085 Records can only delete bindings that correspond to properties of the environment object whose [[Configurable]]
6086 attribute have the value <b>true</b>.</p>
6087
6088 <ol class="proc">
6089 <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
6090 invoked.</li>
6091 <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
6092 <li>Return <i>bindings</i>.[[Delete]](<i>N</i>).</li>
6093 </ol>
6094 </section>
6095
6096 <section id="sec-object-environment-records-hasthisbinding">
6097 <h1><span class="secnum" id="sec-8.1.1.2.8"><a href="#sec-object-environment-records-hasthisbinding"
6098 title="link to this section">8.1.1.2.8</a></span> HasThisBinding ()</h1>
6099
6100 <p>Regular object environment records do not provide a <code>this</code> binding.</p>
6101
6102 <ol class="proc">
6103 <li>Return <b>false</b>.</li>
6104 </ol>
6105 </section>
6106
6107 <section id="sec-object-environment-records-hassuperbinding">
6108 <h1><span class="secnum" id="sec-8.1.1.2.9"><a href="#sec-object-environment-records-hassuperbinding"
6109 title="link to this section">8.1.1.2.9</a></span> HasSuperBinding ()</h1>
6110
6111 <p>Regular object environment records do not provide a <code>super</code> binding.</p>
6112
6113 <ol class="proc">
6114 <li>Return <b>false</b>.</li>
6115 </ol>
6116 </section>
6117
6118 <section id="sec-object-environment-records-withbaseobject">
6119 <h1><span class="secnum" id="sec-8.1.1.2.10"><a href="#sec-object-environment-records-withbaseobject"
6120 title="link to this section">8.1.1.2.10</a></span> WithBaseObject()</h1>
6121
6122 <p>Object environment records return <b>undefined</b> as their WithBaseObject unless their <var>withEnvironment</var>
6123 flag is <b>true</b>.</p>
6124
6125 <ol class="proc">
6126 <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
6127 invoked.</li>
6128 <li>If the <i>withEnvironment</i> flag of <i>envRec</i> is <b>true</b>, return the binding object for
6129 <i>envRec</i>.</li>
6130 <li>Otherwise, return <b>undefined</b>.</li>
6131 </ol>
6132 </section>
6133 </section>
6134
6135 <section id="sec-function-environment-records">
6136 <div class="front">
6137 <h1><span class="secnum" id="sec-8.1.1.3"><a href="#sec-function-environment-records"
6138 title="link to this section">8.1.1.3</a></span> Function Environment Records</h1>
6139
6140 <p>A function <a href="#sec-environment-records">Environment Record</a> is a declarative <a
6141 href="#sec-environment-records">Environment Record</a> that is used to represent the top-level scope of a function and,
6142 if the function is not an <span class="nt">ArrowFunction</span>, provides a <code>this</code> binding. If a function is
6143 not an <span class="nt">ArrowFunction</span> function and references <code>super</code>, its function <a
6144 href="#sec-environment-records">Environment Record</a> also contains the state that is used to perform
6145 <code>super</code> method invocations from within the function.</p>
6146
6147 <p>Function Environment Records have the additional state fields listed in <a href="#table-16">Table 16</a>.</p>
6148
6149 <figure>
6150 <figcaption><span id="table-16">Table 16</span> &mdash; Additional Fields of Function Environment Records</figcaption>
6151 <table class="real-table">
6152 <tr>
6153 <th>Field Name</th>
6154 <th>Value</th>
6155 <th>Meaning</th>
6156 </tr>
6157 <tr>
6158 <td>[[thisValue]]</td>
6159 <td>Any</td>
6160 <td>This is the <span class="value">this</span> value used for this invocation of the function.</td>
6161 </tr>
6162 <tr>
6163 <td>[[thisBindingStatus]]</td>
6164 <td><code>"lexical"</code> | <code>"initialized"</code> | <code>"uninitialized"</code></td>
6165 <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>
6166 </tr>
6167 <tr>
6168 <td>[[FunctionObject]]</td>
6169 <td>Object</td>
6170 <td>The function Object whose invocation caused this <a href="#sec-environment-records">Environment Record</a> to be created.</td>
6171 </tr>
6172 <tr>
6173 <td>[[HomeObject]]</td>
6174 <td>Object | <b>undefined</b></td>
6175 <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>
6176 </tr>
6177 <tr>
6178 <td>[[NewTarget]]</td>
6179 <td>Object | <b>undefined</b></td>
6180 <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>
6181 </tr>
6182 </table>
6183 </figure>
6184
6185 <p>Function Environment Records support all of the declarative Environment Record methods listed in <a
6186 href="#table-15">Table 15</a> and share the same specifications for all of those methods except for HasThisBinding and
6187 HasSuperBinding. In addition, function Environment Records support the methods listed in <a href="#table-17">Table
6188 17</a>:</p>
6189
6190 <figure>
6191 <figcaption><span id="table-17">Table 17</span> &mdash; Additional Methods of Function Environment Records</figcaption>
6192 <table class="real-table">
6193 <tr>
6194 <th>Method</th>
6195 <th>Purpose</th>
6196 </tr>
6197 <tr>
6198 <td><a href="#sec-bindthisvalue">BindThisValue</a>(V)</td>
6199 <td>Set the [[thisValue]] and record that it has been initialized.</td>
6200 </tr>
6201 <tr>
6202 <td>GetThisBinding()</td>
6203 <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>
6204 </tr>
6205 <tr>
6206 <td><a href="#sec-getsuperbase">GetSuperBase</a>()</td>
6207 <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>
6208 </tr>
6209 </table>
6210 </figure>
6211
6212 <p>The behaviour of the additional concrete specification methods for function Environment Records is defined by the
6213 following algorithms:</p>
6214 </div>
6215
6216 <section id="sec-bindthisvalue">
6217 <h1><span class="secnum" id="sec-8.1.1.3.1"><a href="#sec-bindthisvalue"
6218 title="link to this section">8.1.1.3.1</a></span> BindThisValue(V)</h1>
6219 <ol class="proc">
6220 <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
6221 was invoked.</li>
6222 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i>.[[thisBindingStatus]] is not
6223 <code>"lexical"</code>.</li>
6224 <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"initialized"</code>, throw a <b>ReferenceError</b>
6225 exception.</li>
6226 <li>Set <i>envRec</i>.[[thisValue]] to <i>V</i>.</li>
6227 <li>Set <i>envRec</i>.[[thisBindingStatus]] to <code>"initialized"</code>.</li>
6228 <li>Return <i>V</i>.</li>
6229 </ol>
6230 </section>
6231
6232 <section id="sec-function-environment-records-hasthisbinding">
6233 <h1><span class="secnum" id="sec-8.1.1.3.2"><a href="#sec-function-environment-records-hasthisbinding"
6234 title="link to this section">8.1.1.3.2</a></span> HasThisBinding ()</h1>
6235 <ol class="proc">
6236 <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
6237 was invoked.</li>
6238 <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"lexical"</code>, return <b>false</b>; otherwise, return
6239 <b>true</b>.</li>
6240 </ol>
6241 </section>
6242
6243 <section id="sec-function-environment-records-hassuperbinding">
6244 <h1><span class="secnum" id="sec-8.1.1.3.3"><a href="#sec-function-environment-records-hassuperbinding"
6245 title="link to this section">8.1.1.3.3</a></span> HasSuperBinding ()</h1>
6246 <ol class="proc">
6247 <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
6248 was invoked.</li>
6249 <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"lexical"</code>, return <b>false</b>.</li>
6250 <li>If <i>envRec</i>.[[HomeObject]] has the value <b>undefined</b>, return <b>false</b>, otherwise, return
6251 <b>true</b>.</li>
6252 </ol>
6253 </section>
6254
6255 <section id="sec-function-environment-records-getthisbinding">
6256 <h1><span class="secnum" id="sec-8.1.1.3.4"><a href="#sec-function-environment-records-getthisbinding"
6257 title="link to this section">8.1.1.3.4</a></span> GetThisBinding ()</h1>
6258 <ol class="proc">
6259 <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
6260 was invoked.</li>
6261 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i>.[[thisBindingStatus]] is not
6262 <code>"lexical"</code>.</li>
6263 <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"uninitialized"</code>, throw a <b>ReferenceError</b>
6264 exception.</li>
6265 <li>Return <i>envRec</i>.[[thisValue]].</li>
6266 </ol>
6267 </section>
6268
6269 <section id="sec-getsuperbase">
6270 <h1><span class="secnum" id="sec-8.1.1.3.5"><a href="#sec-getsuperbase"
6271 title="link to this section">8.1.1.3.5</a></span> GetSuperBase ()</h1>
6272 <ol class="proc">
6273 <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
6274 was invoked.</li>
6275 <li>Let <i>home</i> be the value of <i>envRec</i>.[[HomeObject]].</li>
6276 <li>If <i>home</i> has the value <b>undefined</b>, return <b>undefined</b>.</li>
6277 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
6278 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>home</i>) is Object.</li>
6279 <li>Return <i>home.</i>[[GetPrototypeOf]]().</li>
6280 </ol>
6281 </section>
6282 </section>
6283
6284 <section id="sec-global-environment-records">
6285 <div class="front">
6286 <h1><span class="secnum" id="sec-8.1.1.4"><a href="#sec-global-environment-records"
6287 title="link to this section">8.1.1.4</a></span> Global Environment Records</h1>
6288
6289 <p>A global <a href="#sec-environment-records">Environment Record</a> is used to represent the outer most scope that is
6290 shared by all of the ECMAScript <span class="nt">Script</span> elements that are processed in a common <a
6291 href="#sec-code-realms">Realm</a> (<a href="#sec-code-realms">8.2</a>). A global <a
6292 href="#sec-environment-records">Environment Record</a> provides the bindings for built-in globals (<a
6293 href="#sec-global-object">clause 18</a>), properties of the global object, and for all top-level declarations (<a
6294 href="#sec-block-static-semantics-toplevellexicallyscopeddeclarations">13.1.8</a>, <a
6295 href="#sec-block-static-semantics-toplevelvarscopeddeclarations">13.1.10</a>) that occur within a <span
6296 class="nt">Script</span>.</p>
6297
6298 <p>A global <a href="#sec-environment-records">Environment Record</a> is logically a single record but it is specified
6299 as a composite encapsulating an object <a href="#sec-environment-records">Environment Record</a> and a declarative <a
6300 href="#sec-environment-records">Environment Record</a>. The object <a href="#sec-environment-records">Environment
6301 Record</a> has as its base object the global object of the associated <a href="#sec-code-realms">Realm</a>. This global
6302 object is the value returned by the global <a href="#sec-environment-records">Environment Record</a>&rsquo;s
6303 GetThisBinding concrete method. The object <a href="#sec-environment-records">Environment Record</a> component of a
6304 global <a href="#sec-environment-records">Environment Record</a> contains the bindings for all built-in globals (<a
6305 href="#sec-global-object">clause 18</a>) and all bindings introduced by a <span style="font-family: Times New
6306 Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, or <span class="nt">VariableStatement</span>
6307 contained in global code. The bindings for all other ECMAScript declarations in global code are contained in the
6308 declarative <a href="#sec-environment-records">Environment Record</a> component of the global <a
6309 href="#sec-environment-records">Environment Record</a>.</p>
6310
6311 <p>Properties may be created directly on a global object. Hence, the object <a
6312 href="#sec-environment-records">Environment Record</a> component of a global <a
6313 href="#sec-environment-records">Environment Record</a> may contain both bindings created explicitly by <span
6314 style="font-family: Times New Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, or <span
6315 class="nt">VariableDeclaration</span> declarations and binding created implicitly as properties of the global object. In
6316 order to identify which bindings were explicitly created using declarations, a global <a
6317 href="#sec-environment-records">Environment Record</a> maintains a list of the names bound using its
6318 CreateGlobalVarBindings and CreateGlobalFunctionBindings concrete methods.</p>
6319
6320 <p>Global Environment Records have the additional fields listed in <a href="#table-18">Table 18</a> and the additional
6321 methods listed in <a href="#table-19">Table 19</a>.</p>
6322
6323 <figure>
6324 <figcaption><span id="table-18">Table 18</span> &mdash; Additional Fields of Global Environment Records</figcaption>
6325 <table class="real-table">
6326 <tr>
6327 <th>Field Name</th>
6328 <th>Value</th>
6329 <th>Meaning</th>
6330 </tr>
6331 <tr>
6332 <td>[[ObjectRecord]]</td>
6333 <td><a href="#sec-object-environment-records">Object Environment Record</a></td>
6334 <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>
6335 </tr>
6336 <tr>
6337 <td>[[DeclarativeRecord]]</td>
6338 <td><a href="#sec-declarative-environment-records">Declarative Environment Record</a></td>
6339 <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>
6340 </tr>
6341 <tr>
6342 <td>[[VarNames]]</td>
6343 <td><a href="#sec-list-and-record-specification-type">List</a> of String</td>
6344 <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>
6345 </tr>
6346 </table>
6347 </figure>
6348
6349 <figure>
6350 <figcaption><span id="table-19">Table 19</span> &mdash; Additional Methods of Global Environment Records</figcaption>
6351 <table class="real-table">
6352 <tr>
6353 <th>Method</th>
6354 <th>Purpose</th>
6355 </tr>
6356 <tr>
6357 <td>GetThisBinding()</td>
6358 <td>Return the value of this <a href="#sec-environment-records">Environment Record</a>&rsquo;s <code>this</code> binding.</td>
6359 </tr>
6360 <tr>
6361 <td><a href="#sec-hasvardeclaration">HasVarDeclaration</a> (N)</td>
6362 <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>
6363 </tr>
6364 <tr>
6365 <td><a href="#sec-haslexicaldeclaration">HasLexicalDeclaration</a> (N)</td>
6366 <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>
6367 </tr>
6368 <tr>
6369 <td><a href="#sec-hasrestrictedglobalproperty">HasRestrictedGlobalProperty</a> (N)</td>
6370 <td>Determines if the argument is the name of a global object property that may not be shadowed by a global lexically binding.</td>
6371 </tr>
6372 <tr>
6373 <td><a href="#sec-candeclareglobalvar">CanDeclareGlobalVar</a> (N)</td>
6374 <td>Determines if a corresponding <a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a> call would succeed if called for the same argument <var>N</var>.</td>
6375 </tr>
6376 <tr>
6377 <td><a href="#sec-candeclareglobalfunction">CanDeclareGlobalFunction</a> (N)</td>
6378 <td>Determines if a corresponding <a href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a> call would succeed if called for the same argument <var>N</var>.</td>
6379 </tr>
6380 <tr>
6381 <td><a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a>(N, D)</td>
6382 <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>
6383 </tr>
6384 <tr>
6385 <td><a href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a>(N, V, D)</td>
6386 <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>
6387 </tr>
6388 </table>
6389 </figure>
6390
6391 <p>The behaviour of the concrete specification methods for global Environment Records is defined by the following
6392 algorithms.</p>
6393 </div>
6394
6395 <section id="sec-global-environment-records-hasbinding-n">
6396 <h1><span class="secnum" id="sec-8.1.1.4.1"><a href="#sec-global-environment-records-hasbinding-n"
6397 title="link to this section">8.1.1.4.1</a></span> HasBinding(N)</h1>
6398
6399 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for global Environment
6400 Records simply determines if the argument identifier is one of the identifiers bound by the record:</p>
6401
6402 <ol class="proc">
6403 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6404 invoked.</li>
6405 <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
6406 <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, return <b>true</b>.</li>
6407 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6408 <li>Return <i>ObjRec.</i>HasBinding(<i>N</i>).</li>
6409 </ol>
6410 </section>
6411
6412 <section id="sec-global-environment-records-createmutablebinding-n-d">
6413 <h1><span class="secnum" id="sec-8.1.1.4.2"><a href="#sec-global-environment-records-createmutablebinding-n-d"
6414 title="link to this section">8.1.1.4.2</a></span> CreateMutableBinding (N, D)</h1>
6415
6416 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for global
6417 Environment Records creates a new mutable binding for the name <var>N</var> that is uninitialized. The binding is
6418 created in the associated DeclarativeRecord. A binding for <var>N</var> must not already exist in the DeclarativeRecord.
6419 If Boolean argument <var>D</var> is provided and has the value <b>true</b> the new binding is marked as being subject to
6420 deletion.</p>
6421
6422 <ol class="proc">
6423 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6424 invoked.</li>
6425 <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
6426 <li>If <i>DclRec</i>.HasBinding(<i>N</i>) is <b>true</b>, throw a <b>TypeError</b> exception.</li>
6427 <li>Return <i>DclRec</i>.CreateMutableBinding(<i>N</i>, <i>D</i>).</li>
6428 </ol>
6429 </section>
6430
6431 <section id="sec-global-environment-records-createimmutablebinding-n-s">
6432 <h1><span class="secnum" id="sec-8.1.1.4.3"><a href="#sec-global-environment-records-createimmutablebinding-n-s"
6433 title="link to this section">8.1.1.4.3</a></span> CreateImmutableBinding (N, S)</h1>
6434
6435 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding for global
6436 Environment Records creates a new immutable binding for the name <var>N</var> that is uninitialized. A binding must not
6437 already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
6438 <var>S</var> is provided and has the value <b>true</b> the new binding is marked as a strict binding.</p>
6439
6440 <ol class="proc">
6441 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6442 invoked.</li>
6443 <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
6444 <li>If <i>DclRec</i>.HasBinding(<i>N</i>) is <b>true</b>, throw a <b>TypeError</b> exception.</li>
6445 <li>Return <i>DclRec</i>.CreateImmutableBinding(<i>N</i>, <i>S</i>).</li>
6446 </ol>
6447 </section>
6448
6449 <section id="sec-global-environment-records-initializebinding-n-v">
6450 <h1><span class="secnum" id="sec-8.1.1.4.4"><a href="#sec-global-environment-records-initializebinding-n-v"
6451 title="link to this section">8.1.1.4.4</a></span> InitializeBinding (N,V)</h1>
6452
6453 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for global
6454 Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
6455 the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
6456 exist.</p>
6457
6458 <ol class="proc">
6459 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6460 invoked.</li>
6461 <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
6462 <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
6463 <ol class="block">
6464 <li>Return <i>DclRec</i>.InitializeBinding(<i>N</i>, <i>V</i>).</li>
6465 </ol>
6466 </li>
6467 <li><a href="#sec-algorithm-conventions">Assert</a>: If the binding exists it must be in the object <a
6468 href="#sec-environment-records">Environment Record</a>.</li>
6469 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6470 <li>Return <i>ObjRec.</i>InitializeBinding(<i>N</i>, <i>V</i>).</li>
6471 </ol>
6472 </section>
6473
6474 <section id="sec-global-environment-records-setmutablebinding-n-v-s">
6475 <h1><span class="secnum" id="sec-8.1.1.4.5"><a href="#sec-global-environment-records-setmutablebinding-n-v-s"
6476 title="link to this section">8.1.1.4.5</a></span> SetMutableBinding (N,V,S)</h1>
6477
6478 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for global
6479 Environment Records attempts to change the bound value of the current binding of the identifier whose name is the value
6480 of the argument <var>N</var> to the value of argument <var>V</var>. If the binding is an immutable binding, a
6481 <b>TypeError</b> is thrown if <span style="font-family: Times New Roman">S</span> is <span class="value">true</span>. A
6482 property named <var>N</var> normally already exists but if it does not or is not currently writable, error handling is
6483 determined by the value of the Boolean argument <var>S</var>.</p>
6484
6485 <ol class="proc">
6486 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6487 invoked.</li>
6488 <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
6489 <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
6490 <ol class="block">
6491 <li>Return <i>DclRec.</i>SetMutableBinding(<i>N</i>, <i>V</i>, <i>S</i>).</li>
6492 </ol>
6493 </li>
6494 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6495 <li>Return <i>ObjRec</i>.SetMutableBinding(<i>N</i>, <i>V</i>, <i>S</i>).</li>
6496 </ol>
6497 </section>
6498
6499 <section id="sec-global-environment-records-getbindingvalue-n-s">
6500 <h1><span class="secnum" id="sec-8.1.1.4.6"><a href="#sec-global-environment-records-getbindingvalue-n-s"
6501 title="link to this section">8.1.1.4.6</a></span> GetBindingValue(N,S)</h1>
6502
6503 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for global Environment
6504 Records returns the value of its bound identifier whose name is the value of the argument <var>N</var>. If the binding
6505 is an uninitialized binding throw a <b>ReferenceError</b> exception. A property named <var>N</var> normally already
6506 exists but if it does not or is not currently writable, error handling is determined by the value of the Boolean
6507 argument <var>S</var>.</p>
6508
6509 <ol class="proc">
6510 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6511 invoked.</li>
6512 <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
6513 <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
6514 <ol class="block">
6515 <li>Return <i>DclRec.</i>GetBindingValue(<i>N</i>, <i>S</i>).</li>
6516 </ol>
6517 </li>
6518 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6519 <li>Return <i>ObjRec</i>.GetBindingValue(<i>N</i>, <i>S</i>).</li>
6520 </ol>
6521 </section>
6522
6523 <section id="sec-global-environment-records-deletebinding-n">
6524 <h1><span class="secnum" id="sec-8.1.1.4.7"><a href="#sec-global-environment-records-deletebinding-n"
6525 title="link to this section">8.1.1.4.7</a></span> DeleteBinding (N)</h1>
6526
6527 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for global Environment
6528 Records can only delete bindings that have been explicitly designated as being subject to deletion.</p>
6529
6530 <ol class="proc">
6531 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6532 invoked.</li>
6533 <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
6534 <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
6535 <ol class="block">
6536 <li>Return <i>DclRec.</i>DeleteBinding(<i>N</i>).</li>
6537 </ol>
6538 </li>
6539 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6540 <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
6541 <li>Let <i>existingProp</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject</i>, <i>N</i>).</li>
6542 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
6543 <li>If <i>existingProp</i> is <b>true</b>, then
6544 <ol class="block">
6545 <li>Let <i>status</i> be <i>ObjRec.</i>DeleteBinding(<i>N</i>).</li>
6546 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
6547 <li>If <i>status</i> is <b>true</b>, then
6548 <ol class="block">
6549 <li>Let <i>varNames</i> be <i>envRec</i>.[[VarNames]].</li>
6550 <li>If <i>N</i> is an element of <i>varNames</i>, remove that element from the <i>varNames</i>.</li>
6551 </ol>
6552 </li>
6553 <li>Return <i>status</i>.</li>
6554 </ol>
6555 </li>
6556 <li>Return <b>true</b>.</li>
6557 </ol>
6558 </section>
6559
6560 <section id="sec-global-environment-records-hasthisbinding">
6561 <h1><span class="secnum" id="sec-8.1.1.4.8"><a href="#sec-global-environment-records-hasthisbinding"
6562 title="link to this section">8.1.1.4.8</a></span> HasThisBinding ()</h1>
6563
6564 <p><a href="#sec-global-environment-records">Global Environment Records</a> always provide a <code>this</code> binding
6565 whose value is the associated global object.</p>
6566
6567 <ol class="proc">
6568 <li>Return <b>true</b>.</li>
6569 </ol>
6570 </section>
6571
6572 <section id="sec-global-environment-records-hassuperbinding">
6573 <h1><span class="secnum" id="sec-8.1.1.4.9"><a href="#sec-global-environment-records-hassuperbinding"
6574 title="link to this section">8.1.1.4.9</a></span> HasSuperBinding ()</h1>
6575 <ol class="proc">
6576 <li>Return <b>false</b>.</li>
6577 </ol>
6578 </section>
6579
6580 <section id="sec-global-environment-records-withbaseobject">
6581 <h1><span class="secnum" id="sec-8.1.1.4.10"><a href="#sec-global-environment-records-withbaseobject"
6582 title="link to this section">8.1.1.4.10</a></span> WithBaseObject()</h1>
6583
6584 <p><a href="#sec-global-environment-records">Global Environment Records</a> always return <b>undefined</b> as their
6585 WithBaseObject.</p>
6586
6587 <ol class="proc">
6588 <li>Return <b>undefined</b>.</li>
6589 </ol>
6590 </section>
6591
6592 <section id="sec-global-environment-records-getthisbinding">
6593 <h1><span class="secnum" id="sec-8.1.1.4.11"><a href="#sec-global-environment-records-getthisbinding"
6594 title="link to this section">8.1.1.4.11</a></span> GetThisBinding ()</h1>
6595 <ol class="proc">
6596 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6597 invoked.</li>
6598 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6599 <li>Let <i>bindings</i> be the binding object for <i>ObjRec</i>.</li>
6600 <li>Return <i>bindings</i>.</li>
6601 </ol>
6602 </section>
6603
6604 <section id="sec-hasvardeclaration">
6605 <h1><span class="secnum" id="sec-8.1.1.4.12"><a href="#sec-hasvardeclaration"
6606 title="link to this section">8.1.1.4.12</a></span> HasVarDeclaration (N)</h1>
6607
6608 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasVarDeclaration for global
6609 Environment Records determines if the argument identifier has a binding in this record that was created using a <span
6610 class="nt">VariableStatement</span> or a <span class="prod"><span class="nt">FunctionDeclaration</span> <span
6611 class="geq">:</span></span></p>
6612
6613 <ol class="proc">
6614 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6615 invoked.</li>
6616 <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
6617 <li>If <i>varDeclaredNames</i> contains the value of <i>N</i>, return <b>true</b>.</li>
6618 <li>Return <b>false</b>.</li>
6619 </ol>
6620 </section>
6621
6622 <section id="sec-haslexicaldeclaration">
6623 <h1><span class="secnum" id="sec-8.1.1.4.13"><a href="#sec-haslexicaldeclaration"
6624 title="link to this section">8.1.1.4.13</a></span> HasLexicalDeclaration (N)</h1>
6625
6626 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasLexicalDeclaration for global
6627 Environment Records determines if the argument identifier has a binding in this record that was created using a lexical
6628 declaration such as a <span class="nt">LexicalDeclaration</span> or a <span class="prod"><span
6629 class="nt">ClassDeclaration</span> <span class="geq">:</span></span></p>
6630
6631 <ol class="proc">
6632 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6633 invoked.</li>
6634 <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
6635 <li>Return <i>DclRec.</i>HasBinding(<i>N</i>).</li>
6636 </ol>
6637 </section>
6638
6639 <section id="sec-hasrestrictedglobalproperty">
6640 <h1><span class="secnum" id="sec-8.1.1.4.14"><a href="#sec-hasrestrictedglobalproperty"
6641 title="link to this section">8.1.1.4.14</a></span> HasRestrictedGlobalProperty (N)</h1>
6642
6643 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasRestrictedGlobalProperty for global
6644 Environment Records determines if the argument identifier is the name of a property of the global object that must not
6645 be shadowed by a global lexically binding:</p>
6646
6647 <ol class="proc">
6648 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6649 invoked.</li>
6650 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6651 <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
6652 <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
6653 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
6654 <li>If <i>existingProp</i> is <b>undefined</b>, return <b>false</b>.</li>
6655 <li>If <i>existingProp</i>.[[Configurable]] is <b>true</b>, return <b>false</b>.</li>
6656 <li>Return <b>true</b>.</li>
6657 </ol>
6658
6659 <div class="note">
6660 <p><span class="nh">NOTE</span> Properties may exist upon a global object that were directly created rather than being
6661 declared using a var or function declaration. A global lexical binding may not be created that has the same name as a
6662 non-configurable property of the global object. The global property <code>undefined</code> is an example of such a
6663 property.</p>
6664 </div>
6665 </section>
6666
6667 <section id="sec-candeclareglobalvar">
6668 <h1><span class="secnum" id="sec-8.1.1.4.15"><a href="#sec-candeclareglobalvar"
6669 title="link to this section">8.1.1.4.15</a></span> CanDeclareGlobalVar (N)</h1>
6670
6671 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CanDeclareGlobalVar for global
6672 Environment Records determines if a corresponding <a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a> call
6673 would succeed if called for the same argument <var>N</var>. Redundant var declarations and var declarations for
6674 pre-existing global object properties are allowed.</p>
6675
6676 <ol class="proc">
6677 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6678 invoked.</li>
6679 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6680 <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
6681 <li>Let <i>hasProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject, N</i>).</li>
6682 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasProperty</i>).</li>
6683 <li>If <i>hasProperty</i> is <b>true</b>, return <b>true</b>.</li>
6684 <li>Return <a href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
6685 </ol>
6686 </section>
6687
6688 <section id="sec-candeclareglobalfunction">
6689 <h1><span class="secnum" id="sec-8.1.1.4.16"><a href="#sec-candeclareglobalfunction"
6690 title="link to this section">8.1.1.4.16</a></span> CanDeclareGlobalFunction (N)</h1>
6691
6692 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CanDeclareGlobalFunction for global
6693 Environment Records determines if a corresponding <a
6694 href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a> call would succeed if called for the same
6695 argument <var>N</var>.</p>
6696
6697 <ol class="proc">
6698 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6699 invoked.</li>
6700 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6701 <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
6702 <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
6703 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
6704 <li>If <i>existingProp</i> is <b>undefined</b>, return <a
6705 href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
6706 <li>If <i>existingProp</i>.[[Configurable]] is <b>true</b>, return <b>true</b>.</li>
6707 <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>existingProp</i>) is <b>true</b> and
6708 <i>existingProp</i> has attribute values {[[Writable]]: <b>true</b>, [[Enumerable]]: <b>true</b>}, return
6709 <b>true</b>.</li>
6710 <li>Return <b>false</b>.</li>
6711 </ol>
6712 </section>
6713
6714 <section id="sec-createglobalvarbinding">
6715 <h1><span class="secnum" id="sec-8.1.1.4.17"><a href="#sec-createglobalvarbinding"
6716 title="link to this section">8.1.1.4.17</a></span> CreateGlobalVarBinding (N, D)</h1>
6717
6718 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateGlobalVarBinding for global
6719 Environment Records creates and initializes a mutable binding in the associated object Environment Record and records
6720 the bound name in the associated [[VarNames]] <a href="#sec-list-and-record-specification-type">List</a>. If a binding
6721 already exists, it is reused and assumed to be initialized.</p>
6722
6723 <ol class="proc">
6724 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6725 invoked.</li>
6726 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6727 <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
6728 <li>Let <i>hasProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject, N</i>).</li>
6729 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasProperty</i>).</li>
6730 <li>Let <i>extensible</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
6731 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensible</i>).</li>
6732 <li>If <i>hasProperty</i> is <b>false</b> and <i>extensible</i> is <b>true</b>, then
6733 <ol class="block">
6734 <li>Let <i>status</i> be <i>ObjRec.</i>CreateMutableBinding(<i>N</i>, <i>D</i>).</li>
6735 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
6736 <li>Let <i>status</i> be <i>ObjRec.</i>InitializeBinding(<i>N</i>, <b>undefined</b>).</li>
6737 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
6738 </ol>
6739 </li>
6740 <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
6741 <li>If <i>varDeclaredNames</i> does not contain the value of <i>N</i>, then
6742 <ol class="block">
6743 <li>Append <i>N</i> to <i>varDeclaredNames</i>.</li>
6744 </ol>
6745 </li>
6746 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
6747 sans-serif">empty</span>).</li>
6748 </ol>
6749 </section>
6750
6751 <section id="sec-createglobalfunctionbinding">
6752 <h1><span class="secnum" id="sec-8.1.1.4.18"><a href="#sec-createglobalfunctionbinding"
6753 title="link to this section">8.1.1.4.18</a></span> CreateGlobalFunctionBinding (N, V, D)</h1>
6754
6755 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateGlobalFunctionBinding for global
6756 Environment Records creates and initializes a mutable binding in the associated object Environment Record and records
6757 the bound name in the associated [[VarNames]] <a href="#sec-list-and-record-specification-type">List</a>. If a binding
6758 already exists, it is replaced.</p>
6759
6760 <ol class="proc">
6761 <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
6762 invoked.</li>
6763 <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
6764 <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
6765 <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
6766 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
6767 <li>If <i>existingProp</i> is <b>undefined</b> or <i>existingProp</i>.[[Configurable]] is <b>true</b>, then
6768 <ol class="block">
6769 <li>Let <i>desc</i> be the PropertyDescriptor{[[Value]]:<i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
6770 <b>true</b> , [[Configurable]]: <i>D</i>}.</li>
6771 </ol>
6772 </li>
6773 <li>Else,
6774 <ol class="block">
6775 <li>Let <i>desc</i> be the PropertyDescriptor{[[Value]]:<i>V</i> }.</li>
6776 </ol>
6777 </li>
6778 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>globalObject</i>, <i>N</i>,
6779 <i>desc</i>).</li>
6780 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
6781 <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>,
6782 <b>false</b>).</li>
6783 <li>Record that the binding for <i>N</i> in <i>ObjRec</i> has been initialized.</li>
6784 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
6785 <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
6786 <li>If <i>varDeclaredNames</i> does not contain the value of <i>N</i>, then
6787 <ol class="block">
6788 <li>Append <i>N</i> to <i>varDeclaredNames</i>.</li>
6789 </ol>
6790 </li>
6791 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
6792 sans-serif">empty</span>).</li>
6793 </ol>
6794
6795 <div class="note">
6796 <p><span class="nh">NOTE</span> Global function declarations are always represented as own properties of the global
6797 object. If possible, an existing own property is reconfigured to have a standard set of attribute values. Steps 10-12
6798 are equivalent to what calling the InitializeBinding concrete method would do and if <i>globalObject</i> is a Proxy
6799 will produce the same sequence of Proxy trap calls.</p>
6800 </div>
6801 </section>
6802 </section>
6803
6804 <section id="sec-module-environment-records">
6805 <div class="front">
6806 <h1><span class="secnum" id="sec-8.1.1.5"><a href="#sec-module-environment-records"
6807 title="link to this section">8.1.1.5</a></span> Module Environment Records</h1>
6808
6809 <p>A module <a href="#sec-environment-records">Environment Record</a> is a declarative <a
6810 href="#sec-environment-records">Environment Record</a> that is used to represent the outer scope of an ECMAScript <span
6811 class="nt">Module</span>. In additional to normal mutable and immutable bindings, module Environment Records also
6812 provide immutable import bindings which are bindings that provide indirect access to a target binding that exists in
6813 another Environment Record.</p>
6814
6815 <p>Module Environment Records support all of the declarative Environment Record methods listed in <a
6816 href="#table-15">Table 15</a> and share the same specifications for all of those methods except for GetBindingValue,
6817 DeleteBinding, HasThisBinding and GetThisBinding. In addition, module Environment Records support the methods listed in
6818 <a href="#table-20">Table 20</a>:</p>
6819
6820 <figure>
6821 <figcaption><span id="table-20">Table 20</span> &mdash; Additional Methods of Module Environment Records</figcaption>
6822 <table class="real-table">
6823 <tr>
6824 <th>Method</th>
6825 <th>Purpose</th>
6826 </tr>
6827 <tr>
6828 <td><a href="#sec-createimportbinding">CreateImportBinding</a>(N, M, N2 )</td>
6829 <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>
6830 </tr>
6831 <tr>
6832 <td>GetThisBinding()</td>
6833 <td>Return the value of this <a href="#sec-environment-records">Environment Record</a>&rsquo;s <code>this</code> binding.</td>
6834 </tr>
6835 </table>
6836 </figure>
6837
6838 <p>The behaviour of the additional concrete specification methods for module Environment Records are defined by the
6839 following algorithms:</p>
6840 </div>
6841
6842 <section id="sec-module-environment-records-getbindingvalue-n-s">
6843 <h1><span class="secnum" id="sec-8.1.1.5.1"><a href="#sec-module-environment-records-getbindingvalue-n-s"
6844 title="link to this section">8.1.1.5.1</a></span> GetBindingValue(N,S)</h1>
6845
6846 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for module Environment
6847 Records returns the value of its bound identifier whose name is the value of the argument <var>N</var>. However, if the
6848 binding is an indirect binding the value of the target binding is returned. If the binding exists but is uninitialized a
6849 <span class="value">ReferenceError</span> is thrown, regardless of the value of <i><span style="font-family: Times New
6850 Roman">S</span>.</i></p>
6851
6852 <ol class="proc">
6853 <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
6854 invoked.</li>
6855 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for <i>N</i>.</li>
6856 <li>If the binding for <i>N</i> is an indirect binding, then
6857 <ol class="block">
6858 <li>Let <i>M</i> and <i>N2</i> be the indirection values provided when this binding for <i>N</i> was created.</li>
6859 <li>If <i>M</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
6860 <li>Let <i>targetEnv</i> be <i>M</i>.[[Environment]].</li>
6861 <li>If <i>targetEnv</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
6862 <li>Let <i>targetER</i> be <i>targetEnv</i>&rsquo;s EnvironmentRecord.</li>
6863 <li>Return <i>targetER</i>.GetBindingValue(<i>N2</i>, <i>S</i>).</li>
6864 </ol>
6865 </li>
6866 <li>If the binding for <i>N</i> in <i>envRec</i> is an uninitialized binding, throw a <b>ReferenceError</b>
6867 exception.</li>
6868 <li>Return the value currently bound to <i>N</i> in <i>envRec</i>.</li>
6869 </ol>
6870
6871 <div class="note">
6872 <p><span class="nh">NOTE</span> Because a <i>Module</i> is always <a href="#sec-strict-mode-code">strict mode
6873 code</a>, calls to GetBindingValue should always pass <b>true</b> <span style="font-family: sans-serif">as</span>
6874 <span style="font-family: sans-serif">the value of</span> <i>S</i>.</p>
6875 </div>
6876 </section>
6877
6878 <section id="sec-module-environment-records-deletebinding-n">
6879 <h1><span class="secnum" id="sec-8.1.1.5.2"><a href="#sec-module-environment-records-deletebinding-n"
6880 title="link to this section">8.1.1.5.2</a></span> DeleteBinding (N)</h1>
6881
6882 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for module Environment
6883 Records refuses to delete bindings.</p>
6884
6885 <ol class="proc">
6886 <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
6887 invoked.</li>
6888 <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>
6889 <li>Return <b>false</b>.</li>
6890 </ol>
6891
6892 <div class="note">
6893 <p><span class="nh">NOTE</span> Because the bindings of a module <a href="#sec-environment-records">Environment
6894 Record</a> are not deletable.</p>
6895 </div>
6896 </section>
6897
6898 <section id="sec-module-environment-records-hasthisbinding">
6899 <h1><span class="secnum" id="sec-8.1.1.5.3"><a href="#sec-module-environment-records-hasthisbinding"
6900 title="link to this section">8.1.1.5.3</a></span> HasThisBinding ()</h1>
6901
6902 <p>Module Environment Records provide a <code>this</code> binding.</p>
6903
6904 <ol class="proc">
6905 <li>Return <b>true</b>.</li>
6906 </ol>
6907 </section>
6908
6909 <section id="sec-module-environment-records-getthisbinding">
6910 <h1><span class="secnum" id="sec-8.1.1.5.4"><a href="#sec-module-environment-records-getthisbinding"
6911 title="link to this section">8.1.1.5.4</a></span> GetThisBinding ()</h1>
6912 <ol class="proc">
6913 <li>Return <b>undefined</b>.</li>
6914 </ol>
6915 </section>
6916
6917 <section id="sec-createimportbinding">
6918 <h1><span class="secnum" id="sec-8.1.1.5.5"><a href="#sec-createimportbinding"
6919 title="link to this section">8.1.1.5.5</a></span> CreateImportBinding (N, M, N2)</h1>
6920
6921 <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImportBinding for module
6922 Environment Records creates a new initialized immutable indirect binding for the name <var>N</var>. A binding must not
6923 already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. <var>M</var> is a
6924 Module Record (<a href="#sec-abstract-module-records">see 15.2.1.14</a>), and <var>N2</var> is the name of a binding
6925 that exists in M&rsquo;s module <a href="#sec-environment-records">Environment Record</a>. Accesses to the value of the
6926 new binding will indirectly access the bound value of value of the target binding.</p>
6927
6928 <ol class="proc">
6929 <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
6930 invoked.</li>
6931 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
6932 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>M</i> is a Module Record.</li>
6933 <li><a href="#sec-algorithm-conventions">Assert</a>: When <i>M</i>.[[Environment]] is instantiated it will have a
6934 direct binding for <i>N2</i>.</li>
6935 <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
6936 target binding and record that the binding is initialized.</li>
6937 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
6938 sans-serif">empty</span>).</li>
6939 </ol>
6940 </section>
6941 </section>
6942 </section>
6943
6944 <section id="sec-lexical-environment-operations">
6945 <div class="front">
6946 <h1><span class="secnum" id="sec-8.1.2"><a href="#sec-lexical-environment-operations"
6947 title="link to this section">8.1.2</a></span> Lexical Environment Operations</h1>
6948
6949 <p>The following abstract operations are used in this specification to operate upon lexical environments:</p>
6950 </div>
6951
6952 <section id="sec-getidentifierreference">
6953 <h1><span class="secnum" id="sec-8.1.2.1"><a href="#sec-getidentifierreference"
6954 title="link to this section">8.1.2.1</a></span> GetIdentifierReference (lex, name, strict)</h1>
6955
6956 <p>The abstract operation GetIdentifierReference is called with a <a href="#sec-lexical-environments">Lexical
6957 Environment</a> <var>lex</var>, a String <var>name</var>, and a Boolean flag <var>strict.</var> The value of
6958 <var>lex</var> may be <b>null</b>. When called, the following steps are performed:</p>
6959
6960 <ol class="proc">
6961 <li>If <i>lex</i> is the value <b>null</b>, then
6962 <ol class="block">
6963 <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is
6964 <b>undefined</b>, whose referenced name is <i>name</i>, and whose strict reference flag is <i>strict</i>.</li>
6965 </ol>
6966 </li>
6967 <li>Let <i>envRec</i> be <i>lex</i>&rsquo;s EnvironmentRecord.</li>
6968 <li>Let <i>exists</i> be <i>envRec</i>.HasBinding(<i>name</i>).</li>
6969 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exists</i>).</li>
6970 <li>If <i>exists</i> is <b>true</b>, then
6971 <ol class="block">
6972 <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is
6973 <i>envRec</i>, whose referenced name is <i>name</i>, and whose strict reference flag is <i>strict.</i></li>
6974 </ol>
6975 </li>
6976 <li>Else
6977 <ol class="block">
6978 <li>Let <i>outer</i> be the value of <i>lex&rsquo;s</i> <a href="#sec-lexical-environments">outer environment
6979 reference</a>.</li>
6980 <li>Return GetIdentifierReference(<i>outer</i>, <i>name</i>, <i>strict</i>).</li>
6981 </ol>
6982 </li>
6983 </ol>
6984 </section>
6985
6986 <section id="sec-newdeclarativeenvironment">
6987 <h1><span class="secnum" id="sec-8.1.2.2"><a href="#sec-newdeclarativeenvironment"
6988 title="link to this section">8.1.2.2</a></span> NewDeclarativeEnvironment (E)</h1>
6989
6990 <p>When the abstract operation NewDeclarativeEnvironment is called with a <a href="#sec-lexical-environments">Lexical
6991 Environment</a> as argument <var>E</var> the following steps are performed:</p>
6992
6993 <ol class="proc">
6994 <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
6995 <li>Let <i>envRec</i> be a new declarative <a href="#sec-environment-records">Environment Record</a> containing no
6996 bindings.</li>
6997 <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
6998 <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
6999 <li>Return <i>env</i>.</li>
7000 </ol>
7001 </section>
7002
7003 <section id="sec-newobjectenvironment">
7004 <h1><span class="secnum" id="sec-8.1.2.3"><a href="#sec-newobjectenvironment"
7005 title="link to this section">8.1.2.3</a></span> NewObjectEnvironment (O, E)</h1>
7006
7007 <p>When the abstract operation NewObjectEnvironment is called with an Object <var>O</var> and a <a
7008 href="#sec-lexical-environments">Lexical Environment</a> <var>E</var> as arguments, the following steps are performed:</p>
7009
7010 <ol class="proc">
7011 <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
7012 <li>Let <i>envRec</i> be a new object <a href="#sec-environment-records">Environment Record</a> containing <i>O</i> as
7013 the binding object.</li>
7014 <li>Set <i>env&rsquo;s</i> EnvironmentRecord to <i>envRec</i>.</li>
7015 <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
7016 <li>Return <i>env</i>.</li>
7017 </ol>
7018 </section>
7019
7020 <section id="sec-newfunctionenvironment">
7021 <h1><span class="secnum" id="sec-8.1.2.4"><a href="#sec-newfunctionenvironment"
7022 title="link to this section">8.1.2.4</a></span> NewFunctionEnvironment ( F, newTarget )</h1>
7023
7024 <p>When the abstract operation NewFunctionEnvironment is called with arguments <var>F</var> and <var>newTarget</var> the
7025 following steps are performed:</p>
7026
7027 <ol class="proc">
7028 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an ECMAScript function.</li>
7029 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
7030 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Undefined or Object.</li>
7031 <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
7032 <li>Let <i>envRec</i> be a new function <a href="#sec-environment-records">Environment Record</a> containing no
7033 bindings.</li>
7034 <li>Set <i>envRec</i>.[[FunctionObject]] to <i>F</i>.</li>
7035 <li>If <i>F&rsquo;s</i> [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is
7036 <span style="font-family: sans-serif">lexical</span>, set <i>envRec</i>.[[thisBindingStatus]] to
7037 <code>"lexical"</code>.</li>
7038 <li>Else, Set <i>envRec</i>.[[thisBindingStatus]] to <code>"uninitialized"</code>.</li>
7039 <li>Let <i>home</i> be the value of <i>F&rsquo;s</i> [[HomeObject]] <a
7040 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
7041 <li>Set <i>envRec</i>.[[HomeObject]] to <i>home</i>.</li>
7042 <li>Set <i>envRec</i>.[[NewTarget]] to <i>newTarget</i>.</li>
7043 <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
7044 <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to the value of
7045 <i>F&rsquo;s</i> [[Environment]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
7046 <li>Return <i>env</i>.</li>
7047 </ol>
7048 </section>
7049
7050 <section id="sec-newglobalenvironment">
7051 <h1><span class="secnum" id="sec-8.1.2.5"><a href="#sec-newglobalenvironment"
7052 title="link to this section">8.1.2.5</a></span> NewGlobalEnvironment ( G )</h1>
7053
7054 <p>When the abstract operation NewGlobalEnvironment is called with an ECMAScript Object <var>G</var> as its argument, the
7055 following steps are performed:</p>
7056
7057 <ol class="proc">
7058 <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
7059 <li>Let <i>objRec</i> be a new object <a href="#sec-environment-records">Environment Record</a> containing <i>G</i> as
7060 the binding object.</li>
7061 <li>Let <i>dclRec</i> be a new declarative <a href="#sec-environment-records">Environment Record</a> containing no
7062 bindings.</li>
7063 <li>Let <i>globalRec</i> be a new global <a href="#sec-environment-records">Environment Record</a>.</li>
7064 <li>Set <i>globalRec</i>.[[ObjectRecord]] to <i>objRec</i>.</li>
7065 <li>Set <i>globalRec</i>.[[DeclarativeRecord]] to <i>dclRec</i>.</li>
7066 <li>Set <i>globalRec</i>.[[VarNames]] to a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
7067 <li>Set <i>env&rsquo;s</i> EnvironmentRecord to <i>globalRec</i>.</li>
7068 <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to
7069 <b>null</b></li>
7070 <li>Return <i>env</i>.</li>
7071 </ol>
7072 </section>
7073
7074 <section id="sec-newmoduleenvironment">
7075 <h1><span class="secnum" id="sec-8.1.2.6"><a href="#sec-newmoduleenvironment"
7076 title="link to this section">8.1.2.6</a></span> NewModuleEnvironment (E)</h1>
7077
7078 <p>When the abstract operation NewModuleEnvironment is called with a <a href="#sec-lexical-environments">Lexical
7079 Environment</a> argument <var>E</var> the following steps are performed:</p>
7080
7081 <ol class="proc">
7082 <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
7083 <li>Let <i>envRec</i> be a new module <a href="#sec-environment-records">Environment Record</a> containing no
7084 bindings.</li>
7085 <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
7086 <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
7087 <li>Return <i>env</i>.</li>
7088 </ol>
7089 </section>
7090 </section>
7091 </section>
7092
7093 <section id="sec-code-realms">
7094 <div class="front">
7095 <h1><span class="secnum" id="sec-8.2"><a href="#sec-code-realms" title="link to this section">8.2</a></span> Code
7096 Realms</h1>
7097
7098 <p>Before it is evaluated, all ECMAScript code must be associated with a <i>Realm</i>. Conceptually, a realm consists of a
7099 set of intrinsic objects, an ECMAScript global environment, all of the ECMAScript code that is loaded within the scope of
7100 that global environment, and other associated state and resources.</p>
7101
7102 <p>A Realm is specified as a Record with the fields specified in <a href="#table-21">Table 21</a>:</p>
7103
7104 <figure>
7105 <figcaption><span id="table-21">Table 21</span> &mdash; Realm Record Fields</figcaption>
7106 <table class="real-table">
7107 <tr>
7108 <th>Field Name</th>
7109 <th>Value</th>
7110 <th>Meaning</th>
7111 </tr>
7112 <tr>
7113 <td>[[intrinsics]]</td>
7114 <td>Record whose field names are intrinsic keys and whose values are objects</td>
7115 <td>These are the intrinsic values used by code associated with this Realm</td>
7116 </tr>
7117 <tr>
7118 <td>[[globalThis]]</td>
7119 <td>Object</td>
7120 <td>The global object for this Realm</td>
7121 </tr>
7122 <tr>
7123 <td>[[globalEnv]]</td>
7124 <td><a href="#sec-lexical-environments">Lexical Environment</a></td>
7125 <td>The global environment for this Realm</td>
7126 </tr>
7127 <tr>
7128 <td>[[templateMap]]</td>
7129 <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>
7130 <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>
7131 </tr>
7132 </table>
7133 </figure>
7134
7135 <p>An implementation may define other, implementation specific fields.</p>
7136 </div>
7137
7138 <section id="sec-createrealm">
7139 <h1><span class="secnum" id="sec-8.2.1"><a href="#sec-createrealm" title="link to this section">8.2.1</a></span> CreateRealm
7140 ( )</h1>
7141
7142 <p>The abstract operation CreateRealm with no arguments performs the following steps:</p>
7143
7144 <ol class="proc">
7145 <li>Let <i>realmRec</i> be a new Record.</li>
7146 <li>Perform <a href="#sec-createintrinsics">CreateIntrinsics</a>(<i>realmRec</i>).</li>
7147 <li>Set <i>realmRec</i>.[[globalThis]] to <b>undefined</b>.</li>
7148 <li>Set <i>realmRec</i>.[[globalEnv]] to <b>undefined</b>.</li>
7149 <li>Set <i>realmRec</i>.[[templateMap]] to a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
7150 <li>Return <i>realmRec</i>.</li>
7151 </ol>
7152 </section>
7153
7154 <section id="sec-createintrinsics">
7155 <h1><span class="secnum" id="sec-8.2.2"><a href="#sec-createintrinsics" title="link to this section">8.2.2</a></span>
7156 CreateIntrinsics ( realmRec )</h1>
7157
7158 <p>When the abstract operation CreateIntrinsics with argument <var>realmRec</var> performs the following steps:</p>
7159
7160 <ol class="proc">
7161 <li>Let <i>intrinsics</i> be a new Record.</li>
7162 <li>Set <i>realmRec</i>.[[intrinsics]] to <i>intrinsics</i>.</li>
7163 <li>Let <i>objProto</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<b>null</b>).</li>
7164 <li>Set <i>intrinsics</i>.[[%ObjectPrototype%]] to <i>objProto</i>.</li>
7165 <li>Let <i>throwerSteps</i> be the algorithm steps specified in <a href="#sec-%throwtypeerror%">9.2.7.1</a> for the <a
7166 href="#sec-%throwtypeerror%">%ThrowTypeError%</a> function.</li>
7167 <li>Let <i>thrower</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
7168 <i>throwerSteps</i>, <b>null</b>).</li>
7169 <li>Set <i>intrinsics</i>.[[<span style="font-family: sans-serif"><a
7170 href="#sec-%throwtypeerror%">%ThrowTypeError%</a></span>]] to <i>thrower</i>.</li>
7171 <li>Let <i>noSteps</i> be an empty sequence of algorithm steps.</li>
7172 <li>Let <i>funcProto</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
7173 <i>noSteps</i>, <i>objProto</i>).</li>
7174 <li>Set <i>intrinsics</i>.[[%FunctionPrototype%]] to <i>funcProto</i>.</li>
7175 <li><a href="#sec-call">Call</a> <i>thrower</i>.[[SetPrototypeOf]](<i>funcProto</i>).</li>
7176 <li>Perform <a href="#sec-addrestrictedfunctionproperties">AddRestrictedFunctionProperties</a>(<i>funcProto</i>,
7177 <i>realmRec</i>).</li>
7178 <li>Set fields of <i>intrinsics</i> with the values listed in <a href="#table-7">Table 7</a> that have not already been
7179 handled above. The field names are the names listed in column one of the table. The value of each field is a new
7180 object value fully and recursively populated with property values as defined by the specification of each object in
7181 clauses 18-26. All object property values are newly created object values. All values that are built-in function
7182 objects are created by performing <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
7183 &lt;steps&gt;, &lt;prototype&gt;, &lt;slots&gt;) where &lt;steps&gt; is the definition of that function provided by
7184 this specification, &lt;prototype&gt; is the specified value of the function&rsquo;s [[Prototype]] <a
7185 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> and &lt;slots&gt; is a list of the names, if
7186 any, of the functions specified internal slots. The creation of the intrinsics and their properties must be ordered to
7187 avoid any dependencies upon objects that have not yet been created.</li>
7188 <li>Return <i>intrinsics</i>.</li>
7189 </ol>
7190 </section>
7191
7192 <section id="sec-setrealmglobalobject">
7193 <h1><span class="secnum" id="sec-8.2.3"><a href="#sec-setrealmglobalobject" title="link to this section">8.2.3</a></span>
7194 SetRealmGlobalObject ( realmRec, globalObj )</h1>
7195
7196 <p>The abstract operation SetRealmGlobalObject with arguments <var>realmRec</var> and <var>globalObj</var> performs the
7197 following steps:</p>
7198
7199 <ol class="proc">
7200 <li>If <i>globalObj</i> is <b>undefined</b>, then
7201 <ol class="block">
7202 <li>Let <i>intrinsics</i> be <i>realmRec</i>.[[intrinsics]].</li>
7203 <li>Let <i>globalObj</i> be <a
7204 href="#sec-objectcreate">ObjectCreate</a>(<i>intrinsics</i>.[[%ObjectPrototype%]]).</li>
7205 </ol>
7206 </li>
7207 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
7208 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>globalObj</i>) is Object.</li>
7209 <li>Set <i>realmRec</i>.[[globalThis]] to <i>globalObj</i>.</li>
7210 <li>Let <i>newGlobalEnv</i> be <a href="#sec-newglobalenvironment">NewGlobalEnvironment</a>(<i>globalObj</i>).</li>
7211 <li>Set <i>realmRec</i>.[[globalEnv]] to <i>newGlobalEnv</i>.</li>
7212 <li>Return <i>realmRec</i>.</li>
7213 </ol>
7214 </section>
7215
7216 <section id="sec-setdefaultglobalbindings">
7217 <h1><span class="secnum" id="sec-8.2.4"><a href="#sec-setdefaultglobalbindings"
7218 title="link to this section">8.2.4</a></span> SetDefaultGlobalBindings ( realmRec )</h1>
7219
7220 <p>The abstract operation SetDefaultGlobalBindings with argument <var>realmRec</var> performs the following steps:</p>
7221
7222 <ol class="proc">
7223 <li>Let <i>global</i> be <i>realmRec</i>.[[globalThis]].</li>
7224 <li>For each property of the Global Object specified in <a href="#sec-global-object">clause 18</a>, do
7225 <ol class="block">
7226 <li>Let <i>name</i> be the string value of the property name.</li>
7227 <li>Let <i>desc</i> be the fully populated data property descriptor for the property containing the specified
7228 attributes for the property. For properties listed in <a
7229 href="#sec-function-properties-of-the-global-object">18.2</a>, <a
7230 href="#sec-constructor-properties-of-the-global-object">18.3</a>, or <a
7231 href="#sec-other-properties-of-the-global-object">18.4</a> the value of the [[Value]] attribute is the
7232 corresponding intrinsic object from <i>realmRec</i>.</li>
7233 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>global</i>, <i>name</i>,
7234 <i>desc</i>).</li>
7235 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
7236 </ol>
7237 </li>
7238 <li>Return <i>global</i>.</li>
7239 </ol>
7240 </section>
7241 </section>
7242
7243 <section id="sec-execution-contexts">
7244 <div class="front">
7245 <h1><span class="secnum" id="sec-8.3"><a href="#sec-execution-contexts" title="link to this section">8.3</a></span>
7246 Execution Contexts</h1>
7247
7248 <p>An <i>execution context</i> is a specification device that is used to track the runtime evaluation of code by an
7249 ECMAScript implementation. At any point in time, there is at most one execution context that is actually executing code.
7250 This is known as the <i>running</i> execution context. A stack is used to track execution contexts. The running execution
7251 context is always the top element of this stack. A new execution context is created whenever control is transferred from the
7252 executable code associated with the currently running execution context to executable code that is not associated with that
7253 execution context. The newly created execution context is pushed onto the stack and becomes the running execution
7254 context.</p>
7255
7256 <p>An execution context contains whatever implementation specific state is necessary to track the execution progress of its
7257 associated code. Each execution context has at least the state components listed in <a href="#table-22">Table 22</a>.</p>
7258
7259 <figure>
7260 <figcaption><span id="table-22">Table 22</span> &mdash;State Components for All Execution Contexts</figcaption>
7261 <table class="real-table">
7262 <tr>
7263 <th>Component</th>
7264 <th>Purpose</th>
7265 </tr>
7266 <tr>
7267 <td>code evaluation state</td>
7268 <td>Any state needed to perform, suspend, and resume evaluation of the code associated with this execution context.</td>
7269 </tr>
7270 <tr>
7271 <td>Function</td>
7272 <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>
7273 </tr>
7274 <tr>
7275 <td><a href="#sec-code-realms">Realm</a></td>
7276 <td>The <a href="#sec-code-realms">Realm</a> from which associated code accesses ECMAScript resources.</td>
7277 </tr>
7278 </table>
7279 </figure>
7280
7281 <p>Evaluation of code by the running execution context may be suspended at various points defined within this specification.
7282 Once the running execution context has been suspended a different execution context may become the running execution context
7283 and commence evaluating its code. At some later time a suspended execution context may again become the running execution
7284 context and continue evaluating its code at the point where it had previously been suspended. Transition of the running
7285 execution context status among execution contexts usually occurs in stack-like last-in/first-out manner. However, some
7286 ECMAScript features require non-LIFO transitions of the running execution context.</p>
7287
7288 <p>The value of the <a href="#sec-code-realms">Realm</a> component of the running execution context is also called the
7289 <i>current <a href="#sec-code-realms">Realm</a></i>. The value of the Function component of the running execution context is
7290 also called the <i>active function object.</i></p>
7291
7292 <p>Execution contexts for ECMAScript code have the additional state components listed in <a href="#table-23">Table
7293 23</a>.</p>
7294
7295 <figure>
7296 <figcaption><span id="table-23">Table 23</span> &mdash; Additional State Components for ECMAScript Code Execution Contexts</figcaption>
7297 <table class="real-table">
7298 <tr>
7299 <th>Component</th>
7300 <th>Purpose</th>
7301 </tr>
7302 <tr>
7303 <td>LexicalEnvironment</td>
7304 <td>Identifies the <a href="#sec-lexical-environments">Lexical Environment</a> used to resolve identifier references made by code within this execution context.</td>
7305 </tr>
7306 <tr>
7307 <td>VariableEnvironment</td>
7308 <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>
7309 </tr>
7310 </table>
7311 </figure>
7312
7313 <p>The LexicalEnvironment and VariableEnvironment components of an execution context are always Lexical Environments. When
7314 an execution context is created its LexicalEnvironment and VariableEnvironment components initially have the same value.</p>
7315
7316 <p>Execution contexts representing the evaluation of generator objects have the additional state components listed in <a
7317 href="#table-24">Table 24</a>.</p>
7318
7319 <figure>
7320 <figcaption><span id="table-24">Table 24</span> &mdash; Additional State Components for Generator Execution Contexts</figcaption>
7321 <table class="real-table">
7322 <tr>
7323 <th>Component</th>
7324 <th>Purpose</th>
7325 </tr>
7326 <tr>
7327 <td>Generator</td>
7328 <td>The GeneratorObject that this execution context is evaluating.</td>
7329 </tr>
7330 </table>
7331 </figure>
7332
7333 <p>In most situations only the running execution context (the top of the execution context stack) is directly manipulated by
7334 algorithms within this specification. Hence when the terms &ldquo;LexicalEnvironment&rdquo;, and
7335 &ldquo;VariableEnvironment&rdquo; are used without qualification they are in reference to those components of the running
7336 execution context.</p>
7337
7338 <p>An execution context is purely a specification mechanism and need not correspond to any particular artefact of an
7339 ECMAScript implementation. It is impossible for ECMAScript code to directly access or observe an execution context.</p>
7340 </div>
7341
7342 <section id="sec-resolvebinding">
7343 <h1><span class="secnum" id="sec-8.3.1"><a href="#sec-resolvebinding" title="link to this section">8.3.1</a></span>
7344 ResolveBinding ( name, [env] )</h1>
7345
7346 <p>The ResolveBinding abstract operation is used to determine the binding of <var>name</var> passed as a string value. The
7347 optional argument <var>env</var> can be used to explicitly provide the <a href="#sec-lexical-environments">Lexical
7348 Environment</a> that is to be searched for the binding. During execution of ECMAScript code, ResolveBinding is performed
7349 using the following algorithm:</p>
7350
7351 <ol class="proc">
7352 <li>If <i>env</i> was not passed or if <i>env</i> is <b>undefined</b>, then
7353 <ol class="block">
7354 <li>Let <i>env</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
7355 href="#sec-execution-contexts">LexicalEnvironment</a>.</li>
7356 </ol>
7357 </li>
7358 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>env</i> is a <a href="#sec-lexical-environments">Lexical
7359 Environment</a>.</li>
7360 <li>If the code matching the syntactic production that is being evaluated is contained in <a
7361 href="#sec-strict-mode-code">strict mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be
7362 <b>false</b>.</li>
7363 <li>Return <a href="#sec-getidentifierreference">GetIdentifierReference</a>(<i>env</i>, <i>name</i>, <i>strict</i> ).</li>
7364 </ol>
7365
7366 <div class="note">
7367 <p><span class="nh">NOTE</span> The result of ResolveBinding is always a <a
7368 href="#sec-reference-specification-type">Reference</a> value with its referenced name component equal to the <i>name</i>
7369 argument.</p>
7370 </div>
7371 </section>
7372
7373 <section id="sec-getthisenvironment">
7374 <h1><span class="secnum" id="sec-8.3.2"><a href="#sec-getthisenvironment" title="link to this section">8.3.2</a></span>
7375 GetThisEnvironment ( )</h1>
7376
7377 <p>The abstract operation <span style="font-family: Times New Roman">GetThisEnvironment</span> finds the <a
7378 href="#sec-environment-records">Environment Record</a> that currently supplies the binding of the keyword <code>this</code>.
7379 <span style="font-family: Times New Roman">GetThisEnvironment</span> performs the following steps:</p>
7380
7381 <ol class="proc">
7382 <li>Let <i>lex</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
7383 href="#sec-execution-contexts">LexicalEnvironment</a>.</li>
7384 <li>Repeat
7385 <ol class="block">
7386 <li>Let <i>envRec</i> be <i>lex</i>&rsquo;s EnvironmentRecord.</li>
7387 <li>Let <i>exists</i> be <i>envRec</i>.HasThisBinding().</li>
7388 <li>If <i>exists</i> is <b>true</b>, return <i>envRec</i>.</li>
7389 <li>Let <i>outer</i> be the value of <i>lex&rsquo;s</i> <a href="#sec-lexical-environments">outer environment
7390 reference</a>.</li>
7391 <li>Let <i>lex</i> be <i>outer</i>.</li>
7392 </ol>
7393 </li>
7394 </ol>
7395
7396 <div class="note">
7397 <p><span class="nh">NOTE</span> The loop in step 2 will always terminate because the list of environments always ends with
7398 <a href="#sec-global-environment-records">the global environment</a> which has a <code>this</code> binding.</p>
7399 </div>
7400 </section>
7401
7402 <section id="sec-resolvethisbinding">
7403 <h1><span class="secnum" id="sec-8.3.3"><a href="#sec-resolvethisbinding" title="link to this section">8.3.3</a></span>
7404 ResolveThisBinding ( )</h1>
7405
7406 <p>The abstract operation ResolveThisBinding determines the binding of the keyword <code>this</code> using the <a
7407 href="#sec-execution-contexts">LexicalEnvironment</a> of <a href="#sec-execution-contexts">the running execution
7408 context</a>. ResolveThisBinding performs the following steps:</p>
7409
7410 <ol class="proc">
7411 <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
7412 <li>Return <i>envRec</i>.GetThisBinding().</li>
7413 </ol>
7414 </section>
7415
7416 <section id="sec-getnewtarget">
7417 <h1><span class="secnum" id="sec-8.3.4"><a href="#sec-getnewtarget" title="link to this section">8.3.4</a></span>
7418 GetNewTarget ( )</h1>
7419
7420 <p>The abstract operation GetNewTarget determines the NewTarget value using the <a
7421 href="#sec-execution-contexts">LexicalEnvironment</a> of <a href="#sec-execution-contexts">the running execution
7422 context</a>. GetNewTarget performs the following steps:</p>
7423
7424 <ol class="proc">
7425 <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
7426 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a [[NewTarget]] field.</li>
7427 <li>Return <i>envRec</i>.[[NewTarget]].</li>
7428 </ol>
7429 </section>
7430
7431 <section id="sec-getglobalobject">
7432 <h1><span class="secnum" id="sec-8.3.5"><a href="#sec-getglobalobject" title="link to this section">8.3.5</a></span>
7433 GetGlobalObject ( )</h1>
7434
7435 <p>The abstract operation <span style="font-family: Times New Roman">GetGlobalObject</span> returns the global object used
7436 by <a href="#sec-execution-contexts">the currently running execution context</a>. <span style="font-family: Times New
7437 Roman">GetGlobalObject</span> performs the following steps:</p>
7438
7439 <ol class="proc">
7440 <li>Let <i>ctx</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
7441 <li>Let <i>currentRealm</i> be <i>ctx&rsquo;s</i> <a href="#sec-code-realms">Realm</a>.</li>
7442 <li>Return <i>currentRealm</i>.[[globalThis]].</li>
7443 </ol>
7444 </section>
7445 </section>
7446
7447 <section id="sec-jobs-and-job-queues">
7448 <div class="front">
7449 <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
7450 and Job Queues</h1>
7451
7452 <p>A Job is an abstract operation that initiates an ECMAScript computation when no other ECMAScript computation is currently
7453 in progress. A Job abstract operation may be defined to accept an arbitrary set of job parameters.</p>
7454
7455 <p>Execution of a Job can be initiated only when there is no running <a href="#sec-execution-contexts">execution context</a>
7456 and <a href="#sec-execution-contexts">the execution context stack</a> is empty. A PendingJob is a request for the future
7457 execution of a Job. A PendingJob is an internal Record whose fields are specified in <a href="#table-25">Table 25</a>. Once
7458 execution of a Job is initiated, the Job always executes to completion. No other Job may be initiated until the currently
7459 running Job completes. However, the currently running Job or external events may cause the enqueuing of additional
7460 PendingJobs that may be initiated sometime after completion of the currently running Job.</p>
7461
7462 <figure>
7463 <figcaption><span id="table-25">Table 25</span> &mdash; PendingJob Record Fields</figcaption>
7464 <table class="real-table">
7465 <tr>
7466 <th>Field Name</th>
7467 <th>Value</th>
7468 <th>Meaning</th>
7469 </tr>
7470 <tr>
7471 <td>[[Job]]</td>
7472 <td>The name of a Job abstract operation</td>
7473 <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>
7474 </tr>
7475 <tr>
7476 <td>[[Arguments]]</td>
7477 <td>A <a href="#sec-list-and-record-specification-type">List</a></td>
7478 <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>
7479 </tr>
7480 <tr>
7481 <td>[[Realm]]</td>
7482 <td>A <a href="#sec-code-realms">Realm</a> Record</td>
7483 <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>
7484 </tr>
7485 <tr>
7486 <td>[[HostDefined]]</td>
7487 <td>Any, default value is <span class="value">undefined</span>.</td>
7488 <td>Field reserved for use by host environments that need to associate additional information with a pending Job.</td>
7489 </tr>
7490 </table>
7491 </figure>
7492
7493 <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
7494 defined by an ECMAScript implementation. Every ECMAScript implementation has at least the Job Queues defined in <a
7495 href="#table-26">Table 26</a>.</p>
7496
7497 <figure>
7498 <figcaption><span id="table-26">Table 26</span> &mdash; Required Job Queues</figcaption>
7499 <table class="real-table">
7500 <tr>
7501 <th>Name</th>
7502 <th>Purpose</th>
7503 </tr>
7504 <tr>
7505 <td>ScriptJobs</td>
7506 <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>
7507 </tr>
7508 <tr>
7509 <td>PromiseJobs</td>
7510 <td>Jobs that are responses to the settlement of a Promise (<a href="#sec-promise-objects">see 25.4</a>).</td>
7511 </tr>
7512 </table>
7513 </figure>
7514
7515 <p>A request for the future execution of a Job is made by enqueueing, on a Job Queue, a PendingJob record that includes a
7516 Job abstract operation name and any necessary argument values. When there is no running <a
7517 href="#sec-execution-contexts">execution context</a> and <a href="#sec-execution-contexts">the execution context stack</a>
7518 is empty, the ECMAScript implementation removes the first PendingJob from a Job Queue and uses the information contained in
7519 it to create an <a href="#sec-execution-contexts">execution context</a> and starts execution of the associated Job abstract
7520 operation.</p>
7521
7522 <p>The PendingJob records from a single Job Queue are always initiated in FIFO order. This specification does not define the
7523 order in which multiple Job Queues are serviced. An ECMAScript implementation may interweave the FIFO evaluation of the
7524 PendingJob records of a Job Queue with the evaluation of the PendingJob records of one or more other Job Queues. An
7525 implementation must define what occurs when there are no running <a href="#sec-execution-contexts">execution context</a> and
7526 all Job Queues are empty.</p>
7527
7528 <div class="note">
7529 <p><span class="nh">NOTE</span> Typically an ECMAScript implementation will have its Job Queues pre-initialized with at
7530 least one PendingJob and one of those Jobs will be the first to be executed. An implementation might choose to free all
7531 resources and terminate if the current Job completes and all Job Queues are empty. Alternatively, it might choose to wait
7532 for a some implementation specific agent or mechanism to enqueue new PendingJob requests.</p>
7533 </div>
7534
7535 <p>The following abstract operations are used to create and manage Jobs and Job Queues:</p>
7536 </div>
7537
7538 <section id="sec-enqueuejob">
7539 <h1><span class="secnum" id="sec-8.4.1"><a href="#sec-enqueuejob" title="link to this section">8.4.1</a></span> EnqueueJob (
7540 queueName, job, arguments)</h1>
7541
7542 <p>The EnqueueJob abstract operation requires three arguments: <var>queueName</var>, <var>job</var>, and
7543 <var>arguments</var>. It performs the following steps:</p>
7544
7545 <ol class="proc">
7546 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
7547 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>queueName</i>) is String and its value is the name of a Job
7548 Queue recognized by this implementation.</li>
7549 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>job</i> is the name of a Job.</li>
7550 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>arguments</i> is a <a
7551 href="#sec-list-and-record-specification-type">List</a> that has the same number of elements as the number of
7552 parameters required by <i>job</i>.</li>
7553 <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
7554 <li>Let <i>callerRealm</i> be <i>callerContext&rsquo;s</i> <a href="#sec-code-realms">Realm</a>.</li>
7555 <li>Let <i>pending</i> be PendingJob{ [[Job]]: <i>job</i>, [[Arguments]]: <i>arguments</i>, [[Realm]]: <i>callerRealm</i>,
7556 [[HostDefined]]: <b>undefined</b> }.</li>
7557 <li>Perform any implementation or host environment defined processing of <i>pending</i>. This may include modifying the
7558 [[HostDefined]] field or any other field of <i>pending</i>.</li>
7559 <li>Add <i>pending</i> at the back of the Job Queue named by <i>queueName</i>.</li>
7560 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>).</li>
7561 </ol>
7562 </section>
7563
7564 <section id="sec-nextjob-result">
7565 <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
7566 result</h1>
7567
7568 <p>An algorithm step such as:</p>
7569
7570 <ol class="proc">
7571 <li>NextJob <i>result</i>.</li>
7572 </ol>
7573
7574 <p>is used in Job abstract operations in place of:</p>
7575
7576 <ol class="proc">
7577 <li>Return <i>result</i>.</li>
7578 </ol>
7579
7580 <p>Job abstract operations must not contain a Return step or a <a href="#sec-returnifabrupt">ReturnIfAbrupt</a> step. The
7581 NextJob <var>result</var> operation is equivalent to the following steps:</p>
7582
7583 <ol class="proc">
7584 <li>If <i>result</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, perform
7585 implementation defined unhandled exception processing.</li>
7586 <li><a href="#sec-execution-contexts">Suspend</a> <a href="#sec-execution-contexts">the running execution context</a> and
7587 remove it from <a href="#sec-execution-contexts">the execution context stack</a>.</li>
7588 <li><a href="#sec-algorithm-conventions">Assert</a>: The <a href="#sec-execution-contexts">execution context stack</a> is
7589 now empty.</li>
7590 <li>Let <i>nextQueue</i> be a non-empty Job Queue chosen in an implementation defined manner. If all Job Queues are empty,
7591 the result is implementation defined.</li>
7592 <li>Let <i>nextPending</i> be the PendingJob record at the front of <i>nextQueue</i>. Remove that record from
7593 <i>nextQueue</i>.</li>
7594 <li>Let <i>newContext</i> be a new <a href="#sec-execution-contexts">execution context</a>.</li>
7595 <li>Set <i>newContext</i>&rsquo;s <a href="#sec-code-realms">Realm</a> to <i>nextPending</i>.[[Realm]].</li>
7596 <li>Push <i>newContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>newContext</i> is
7597 now <a href="#sec-execution-contexts">the running execution context</a>.</li>
7598 <li>Perform any implementation or host environment defined job initialization using <i>nextPending</i>.</li>
7599 <li>Perform the abstract operation named by <i>nextPending</i>.[[Job]] using the elements of
7600 <i>nextPending</i>.[[Arguments]] as its arguments.</li>
7601 </ol>
7602 </section>
7603 </section>
7604
7605 <section id="sec-ecmascript-initialization">
7606 <div class="front">
7607 <h1><span class="secnum" id="sec-8.5"><a href="#sec-ecmascript-initialization" title="link to this section">8.5</a></span>
7608 ECMAScript Initialization()</h1>
7609
7610 <p>An ECMAScript implementation performs the following steps prior to the execution of any Jobs or the evaluation of any
7611 ECMAScript code:</p>
7612
7613 <ol class="proc">
7614 <li>Let <i>realm</i> be <a href="#sec-createrealm">CreateRealm</a>().</li>
7615 <li>Let <i>newContext</i> be a new <a href="#sec-execution-contexts">execution context</a>.</li>
7616 <li>Set the Function of <i>newContext</i> to <b>null</b>.</li>
7617 <li>Set the <a href="#sec-code-realms">Realm</a> of <i>newContext</i> to <i>realm</i>.</li>
7618 <li>Push <i>newContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>newContext</i> is
7619 now <a href="#sec-execution-contexts">the running execution context</a>.</li>
7620 <li>Let <i>status</i> be <a href="#sec-initializehostdefinedrealm">InitializeHostDefinedRealm</a>(<i>realm</i>).</li>
7621 <li>If <i>status</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, then
7622 <ol class="block">
7623 <li><a href="#sec-algorithm-conventions">Assert</a>: The first realm could not be created.</li>
7624 <li>Terminate ECMAScript execution.</li>
7625 </ol>
7626 </li>
7627 <li>In an implementation dependent manner, obtain the ECMAScript source texts (see <a
7628 href="#sec-ecmascript-language-source-code">clause 10</a>) for zero or more ECMAScript scripts and/or ECMAScript
7629 modules. For each such <i>sourceText</i> do,
7630 <ol class="block">
7631 <li>If <i>sourceText</i> is the source code of a script, then
7632 <ol class="block">
7633 <li>Perform <a href="#sec-enqueuejob">EnqueueJob</a>(<code>"ScriptJobs"</code>, <a
7634 href="#sec-scriptevaluationjob">ScriptEvaluationJob</a>, &laquo; <i>sourceText</i> &raquo;).</li>
7635 </ol>
7636 </li>
7637 <li>Else <i>sourceText</i> is the source code of a module,
7638 <ol class="block">
7639 <li>Perform <a href="#sec-enqueuejob">EnqueueJob</a>(<code>"ScriptJobs"</code>, <a
7640 href="#sec-toplevelmoduleevaluationjob">TopLevelModuleEvaluationJob</a>, &laquo; <i>sourceText</i>
7641 &raquo;).</li>
7642 </ol>
7643 </li>
7644 </ol>
7645 </li>
7646 <li>NextJob <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
7647 </ol>
7648 </div>
7649
7650 <section id="sec-initializehostdefinedrealm">
7651 <h1><span class="secnum" id="sec-8.5.1"><a href="#sec-initializehostdefinedrealm"
7652 title="link to this section">8.5.1</a></span> InitializeHostDefinedRealm ( realm )</h1>
7653
7654 <p>The abstract operation InitializeHostDefinedRealm with parameter <var>realm</var> performs the following steps:</p>
7655
7656 <ol class="proc">
7657 <li>If this implementation requires use of an exotic object to serve as <i>realm</i>&rsquo;s global object, let
7658 <i>global</i> be such an object created in an implementation defined manner. Otherwise, let <i>global</i> be
7659 <b>undefined</b> indicating that an ordinary object should be created as the global object.</li>
7660 <li>Perform <a href="#sec-setrealmglobalobject">SetRealmGlobalObject</a>(<i>realm</i>, <i>global</i>).</li>
7661 <li>Let <i>globalObj</i> be <a href="#sec-setdefaultglobalbindings">SetDefaultGlobalBindings</a>(<i>realm</i>).</li>
7662 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>globalObj</i>).</li>
7663 <li>Create any implementation defined global object properties on <i>globalObj</i>.</li>
7664 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
7665 </ol>
7666 </section>
7667 </section>
7668 </section>
7669
7670 <section id="sec-ordinary-and-exotic-objects-behaviours">
7671 <div class="front">
7672 <h1><span class="secnum" id="sec-9"><a href="#sec-ordinary-and-exotic-objects-behaviours"
7673 title="link to this section">9</a></span> Ordinary and Exotic Objects Behaviours</h1>
7674 </div>
7675
7676 <section id="sec-ordinary-object-internal-methods-and-internal-slots">
7677 <div class="front">
7678 <h1><span class="secnum" id="sec-9.1"><a href="#sec-ordinary-object-internal-methods-and-internal-slots"
7679 title="link to this section">9.1</a></span> Ordinary Object Internal Methods and Internal Slots</h1>
7680
7681 <p>All ordinary objects have an <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called
7682 [[Prototype]]. The value of this <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is either
7683 <b>null</b> or an object and is used for implementing inheritance. Data properties of the [[Prototype]] object are inherited
7684 (are visible as properties of the child object) for the purposes of get access, but not for set access. Accessor properties
7685 are inherited for both get access and set access.</p>
7686
7687 <p>Every ordinary object has a Boolean-valued [[Extensible]] <a
7688 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> that controls whether or not properties may be
7689 added to the object. If the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal
7690 slot</a> is <b>false</b> then additional properties may not be added to the object. In addition, if [[Extensible]] is
7691 <b>false</b> the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
7692 the object may not be modified. Once the value of an object&rsquo;s [[Extensible]] <a
7693 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> has been set to <b>false</b> it may not be
7694 subsequently changed to <b>true</b>.</p>
7695
7696 <p>In the following algorithm descriptions, assume <var>O</var> is an ordinary object, <var>P</var> is a <a
7697 href="#sec-object-type">property key value</a>, <var>V</var> is any <a href="#sec-ecmascript-language-types">ECMAScript
7698 language value</a>, and <span class="nt">Desc</span> is a <a href="#sec-property-descriptor-specification-type">Property
7699 Descriptor</a> record.</p>
7700 </div>
7701
7702 <section id="sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof">
7703 <h1><span class="secnum" id="sec-9.1.1"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof"
7704 title="link to this section">9.1.1</a></span> [[GetPrototypeOf]] ( )</h1>
7705
7706 <p>When the [[GetPrototypeOf]] internal method of <var>O</var> is called the following steps are taken:</p>
7707
7708 <ol class="proc">
7709 <li>Return the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
7710 <i>O</i>.</li>
7711 </ol>
7712 </section>
7713
7714 <section id="sec-ordinary-object-internal-methods-and-internal-slots-setprototypeof-v">
7715 <h1><span class="secnum" id="sec-9.1.2"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-setprototypeof-v"
7716 title="link to this section">9.1.2</a></span> [[SetPrototypeOf]] (V)</h1>
7717
7718 <p>When the [[SetPrototypeOf]] internal method of <var>O</var> is called with argument <var>V</var> the following steps are
7719 taken:</p>
7720
7721 <ol class="proc">
7722 <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
7723 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
7724 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
7725 <li>Let <i>extensible</i> be the value of the [[Extensible]] <a
7726 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
7727 <li>Let <i>current</i> be the value of the [[Prototype]] <a
7728 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
7729 <li>If <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>current</i>), return <b>true.</b></li>
7730 <li>If <i>extensible</i> is <b>false</b>, return <b>false</b>.</li>
7731 <li>Let <i>p</i> be <i>V</i>.</li>
7732 <li>Let <i>done</i> be <b>false</b>.</li>
7733 <li>Repeat while <i>done</i> is <b>false</b>,
7734 <ol class="block">
7735 <li>If <i>p</i> is <b>null</b>, let <i>done</i> be <b>true</b>.</li>
7736 <li>Else, if <a href="#sec-samevalue">SameValue</a>(<i>p</i>, <i>O</i>) is <b>true</b>, return <b>false</b>.</li>
7737 <li>Else,
7738 <ol class="block">
7739 <li>If the [[GetPrototypeOf]] internal method of <i>p</i> is not the ordinary object internal method defined in <a
7740 href="#sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof">9.1.1</a>, let <i>done</i> be
7741 <b>true</b>.</li>
7742 <li>Else, let <i>p</i> be the value of <i>p</i>&rsquo;s [[Prototype]] <a
7743 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
7744 </ol>
7745 </li>
7746 </ol>
7747 </li>
7748 <li>Set the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
7749 <i>O</i> to <i>V</i>.</li>
7750 <li>Return <b>true</b>.</li>
7751 </ol>
7752
7753 <div class="note">
7754 <p><span class="nh">NOTE</span> The loop in step 8 guarantees that there will be no circularities in any prototype chain
7755 that only includes objects that use the ordinary object definitions for [[GetPrototypeOf]] and [[SetPrototypeOf]].</p>
7756 </div>
7757 </section>
7758
7759 <section id="sec-ordinary-object-internal-methods-and-internal-slots-isextensible">
7760 <h1><span class="secnum" id="sec-9.1.3"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-isextensible"
7761 title="link to this section">9.1.3</a></span> [[IsExtensible]] ( )</h1>
7762
7763 <p>When the [[IsExtensible]] internal method of <var>O</var> is called the following steps are taken:</p>
7764
7765 <ol class="proc">
7766 <li>Return the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
7767 <i>O</i>.</li>
7768 </ol>
7769 </section>
7770
7771 <section id="sec-ordinary-object-internal-methods-and-internal-slots-preventextensions">
7772 <h1><span class="secnum" id="sec-9.1.4"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-preventextensions"
7773 title="link to this section">9.1.4</a></span> [[PreventExtensions]] ( )</h1>
7774
7775 <p>When the [[PreventExtensions]] internal method of <var>O</var> is called the following steps are taken:</p>
7776
7777 <ol class="proc">
7778 <li>Set the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
7779 <i>O</i> to <b>false</b>.</li>
7780 <li>Return <b>true.</b></li>
7781 </ol>
7782 </section>
7783
7784 <section id="sec-ordinary-object-internal-methods-and-internal-slots-getownproperty-p">
7785 <div class="front">
7786 <h1><span class="secnum" id="sec-9.1.5"><a
7787 href="#sec-ordinary-object-internal-methods-and-internal-slots-getownproperty-p"
7788 title="link to this section">9.1.5</a></span> [[GetOwnProperty]] (P)</h1>
7789
7790 <p>When the [[GetOwnProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
7791 <var>P</var>, the following steps are taken:</p>
7792
7793 <ol class="proc">
7794 <li>Return <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
7795 </ol>
7796 </div>
7797
7798 <section id="sec-ordinarygetownproperty">
7799 <h1><span class="secnum" id="sec-9.1.5.1"><a href="#sec-ordinarygetownproperty"
7800 title="link to this section">9.1.5.1</a></span> OrdinaryGetOwnProperty (O, P)</h1>
7801
7802 <p>When the abstract operation OrdinaryGetOwnProperty is called with Object <var>O</var> and with <a
7803 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
7804
7805 <ol class="proc">
7806 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
7807 <b>true</b>.</li>
7808 <li>If <i>O</i> does not have an own property with key <i>P</i>, return <b>undefined</b>.</li>
7809 <li>Let <i>D</i> be a newly created <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> with
7810 no fields.</li>
7811 <li>Let <i>X</i> be <i>O</i>&rsquo;s own property whose key is <i>P</i>.</li>
7812 <li>If <i>X</i> is a data property, then
7813 <ol class="block">
7814 <li>Set <i>D</i>.[[Value]] to the value of <i>X</i>&rsquo;s [[Value]] attribute.</li>
7815 <li>Set <i>D</i>.[[Writable]] to the value of <i>X</i>&rsquo;s [[Writable]] attribute</li>
7816 </ol>
7817 </li>
7818 <li>Else <i>X</i> is an accessor property, so
7819 <ol class="block">
7820 <li>Set <i>D</i>.[[Get]] to the value of <i>X</i>&rsquo;s [[Get]] attribute.</li>
7821 <li>Set <i>D</i>.[[Set]] to the value of <i>X</i>&rsquo;s [[Set]] attribute.</li>
7822 </ol>
7823 </li>
7824 <li>Set <i>D</i>.[[Enumerable]] to the value of <i>X</i>&rsquo;s [[Enumerable]] attribute.</li>
7825 <li>Set <i>D</i>.[[Configurable]] to the value of <i>X</i>&rsquo;s [[Configurable]] attribute.</li>
7826 <li>Return <i>D</i>.</li>
7827 </ol>
7828 </section>
7829 </section>
7830
7831 <section id="sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc">
7832 <div class="front">
7833 <h1><span class="secnum" id="sec-9.1.6"><a
7834 href="#sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc"
7835 title="link to this section">9.1.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
7836
7837 <p>When the [[DefineOwnProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property
7838 key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span
7839 class="nt">Desc</span>, the following steps are taken:</p>
7840
7841 <ol class="proc">
7842 <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>O</i>, <i>P</i>, <i>Desc</i>).</li>
7843 </ol>
7844 </div>
7845
7846 <section id="sec-ordinarydefineownproperty">
7847 <h1><span class="secnum" id="sec-9.1.6.1"><a href="#sec-ordinarydefineownproperty"
7848 title="link to this section">9.1.6.1</a></span> OrdinaryDefineOwnProperty (O, P, Desc)</h1>
7849
7850 <p>When the abstract operation <span style="font-family: Times New Roman">OrdinaryDefineOwnProperty</span> is called with
7851 Object <var>O</var>, <a href="#sec-object-type">property key</a> <span style="font-family: Times New
7852 Roman"><i>P</i>,</span> and <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span
7853 class="nt">Desc</span> the following steps are taken:</p>
7854
7855 <ol class="proc">
7856 <li>Let <i>current</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
7857 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>current</i>).</li>
7858 <li>Let <i>extensible</i> be the value of the [[Extensible]] <a
7859 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
7860 <li>Return <a href="#sec-validateandapplypropertydescriptor">ValidateAndApplyPropertyDescriptor</a>(<i>O</i>, <i>P</i>,
7861 <i>extensible</i>, <i>Desc</i>, <i>current</i>).</li>
7862 </ol>
7863 </section>
7864
7865 <section id="sec-iscompatiblepropertydescriptor">
7866 <h1><span class="secnum" id="sec-9.1.6.2"><a href="#sec-iscompatiblepropertydescriptor"
7867 title="link to this section">9.1.6.2</a></span> IsCompatiblePropertyDescriptor (Extensible, Desc, Current)</h1>
7868
7869 <p>When the abstract operation <span style="font-family: Times New Roman">IsCompatiblePropertyDescriptor</span> is called
7870 with Boolean value <span class="nt">Extensible</span>, and Property Descriptors <span class="nt">Desc</span>, and <span
7871 class="nt">Current</span> the following steps are taken:</p>
7872
7873 <ol class="proc">
7874 <li>Return <a href="#sec-validateandapplypropertydescriptor">ValidateAndApplyPropertyDescriptor</a>(<b>undefined</b>,
7875 <b>undefined</b>, <i>Extensible</i>, <i>Desc</i>, <i>Current</i>).</li>
7876 </ol>
7877 </section>
7878
7879 <section id="sec-validateandapplypropertydescriptor">
7880 <h1><span class="secnum" id="sec-9.1.6.3"><a href="#sec-validateandapplypropertydescriptor"
7881 title="link to this section">9.1.6.3</a></span> ValidateAndApplyPropertyDescriptor (O, P, extensible, Desc,
7882 current)</h1>
7883
7884 <p>When the abstract operation <span style="font-family: Times New Roman">ValidateAndApplyPropertyDescriptor</span> is
7885 called with Object <var>O</var>, <a href="#sec-object-type">property key</a> <span style="font-family: Times New
7886 Roman"><i>P</i>,</span> Boolean value <var>extensible</var>, and Property Descriptors <span class="nt">Desc</span>, and
7887 <var>current</var> the following steps are taken:</p>
7888
7889 <p>This algorithm contains steps that test various fields of the <a
7890 href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> for specific
7891 values. The fields that are tested in this manner need not actually exist in <span class="nt">Desc</span>. If a field is
7892 absent then its value is considered to be <b>false</b>.</p>
7893
7894 <div class="note">
7895 <p><span class="nh">NOTE</span> If <b>undefined</b> is passed as the <i>O</i> argument only validation is performed and
7896 no object updates are performed.</p>
7897 </div>
7898
7899 <ol class="proc">
7900 <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
7901 href="#sec-object-type">property key</a>.</li>
7902 <li>If <i>current</i> is <b>undefined</b>, then
7903 <ol class="block">
7904 <li>If <i>extensible</i> is <b>false</b>, return <b>false</b>.</li>
7905 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>extensible</i> is <b>true</b>.</li>
7906 <li>If <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) or <a
7907 href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
7908 <ol class="block">
7909 <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
7910 [[Value]], [[Writable]], [[Enumerable]] and [[Configurable]] attribute values are described by <i>Desc</i>.
7911 If the value of an attribute field of <i>Desc</i> is absent, the attribute of the newly created property is
7912 set to its default value.</li>
7913 </ol>
7914 </li>
7915 <li>Else <i>Desc</i> must be an accessor <a href="#sec-property-descriptor-specification-type">Property
7916 Descriptor</a>,
7917 <ol class="block">
7918 <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
7919 [[Get]], [[Set]], [[Enumerable]] and [[Configurable]] attribute values are described by <i>Desc</i>. If the
7920 value of an attribute field of <i>Desc</i> is absent, the attribute of the newly created property is set to
7921 its default value.</li>
7922 </ol>
7923 </li>
7924 <li>Return <b>true</b>.</li>
7925 </ol>
7926 </li>
7927 <li>Return <b>true</b>, if every field in <i>Desc</i> is absent.</li>
7928 <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
7929 <i>Desc</i> is the same value as the corresponding field in <i>current</i> when compared using <a
7930 href="#sec-samevalue">the SameValue algorithm</a>.</li>
7931 <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
7932 <ol class="block">
7933 <li>Return <b>false</b>, if the [[Configurable]] field of <i>Desc</i> is <b>true</b>.</li>
7934 <li>Return <b>false</b>, if the [[Enumerable]] field of <i>Desc</i> is present and the [[Enumerable]] fields of
7935 <i>current</i> and <i>Desc</i> are the Boolean negation of each other.</li>
7936 </ol>
7937 </li>
7938 <li>If <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) is <b>true</b>, no further validation is
7939 required.</li>
7940 <li>Else if <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) and <a
7941 href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) have different results, then
7942 <ol class="block">
7943 <li>Return <b>false</b>, if the [[Configurable]] field of <i>current</i> is <b>false</b>.</li>
7944 <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) is <b>true</b>, then
7945 <ol class="block">
7946 <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
7947 property to an accessor property. Preserve the existing values of the converted property&rsquo;s
7948 [[Configurable]] and [[Enumerable]] attributes and set the rest of the property&rsquo;s attributes to their
7949 default values.</li>
7950 </ol>
7951 </li>
7952 <li>Else,
7953 <ol class="block">
7954 <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
7955 property to a data property. Preserve the existing values of the converted property&rsquo;s [[Configurable]]
7956 and [[Enumerable]] attributes and set the rest of the property&rsquo;s attributes to their default
7957 values.</li>
7958 </ol>
7959 </li>
7960 </ol>
7961 </li>
7962 <li>Else if <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) and <a
7963 href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) are both <b>true</b>, then
7964 <ol class="block">
7965 <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
7966 <ol class="block">
7967 <li>Return <b>false</b>, if the [[Writable]] field of <i>current</i> is <b>false</b> and the [[Writable]] field
7968 of <i>Desc</i> is <b>true</b>.</li>
7969 <li>If the [[Writable]] field of <i>current</i> is <b>false</b>, then
7970 <ol class="block">
7971 <li>Return <b>false</b>, if the [[Value]] field of <i>Desc</i> is present and <a
7972 href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Value]], <i>current</i>.[[Value]]) is
7973 <b>false</b>.</li>
7974 </ol>
7975 </li>
7976 </ol>
7977 </li>
7978 <li>Else the [[Configurable]] field of <i>current</i> is <b>true</b>, so any change is acceptable.</li>
7979 </ol>
7980 </li>
7981 <li>Else <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>current</i>) and <a
7982 href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) are both <b>true</b>,
7983 <ol class="block">
7984 <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
7985 <ol class="block">
7986 <li>Return <b>false</b>, if the [[Set]] field of <i>Desc</i> is present and <a
7987 href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Set]], <i>current</i>.[[Set]]) is <b>false</b>.</li>
7988 <li>Return <b>false</b>, if the [[Get]] field of <i>Desc</i> is present and <a
7989 href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Get]], <i>current</i>.[[Get]]) is <b>false</b>.</li>
7990 </ol>
7991 </li>
7992 </ol>
7993 </li>
7994 <li>If <i>O</i> is not <b>undefined</b>, then
7995 <ol class="block">
7996 <li>For each field of <i>Desc</i> that is present, set the corresponding attribute of the property named <i>P</i> of
7997 object <i>O</i> to the value of the field.</li>
7998 </ol>
7999 </li>
8000 <li>Return <b>true</b>.</li>
8001 </ol>
8002
8003 <div class="note">
8004 <p><span class="nh">NOTE</span> Step 8.b allows any field of Desc to be different from the corresponding field of
8005 current if current&rsquo;s [[Configurable]] field is <b>true</b>. This even permits changing the [[Value]] of a property
8006 whose [[Writable]] attribute is <b>false</b>. This is allowed because a <b>true</b> [[Configurable]] attribute would
8007 permit an equivalent sequence of calls where [[Writable]] is first set to <b>true</b>, a new [[Value]] is set, and then
8008 [[Writable]] is set to <b>false</b>.</p>
8009 </div>
8010 </section>
8011 </section>
8012
8013 <section id="sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p">
8014 <div class="front">
8015 <h1><span class="secnum" id="sec-9.1.7"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p"
8016 title="link to this section">9.1.7</a></span> [[HasProperty]](P)</h1>
8017
8018 <p>When the [[HasProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
8019 <var>P</var>, the following steps are taken:</p>
8020
8021 <ol class="proc">
8022 <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
8023 </ol>
8024 </div>
8025
8026 <section id="sec-ordinaryhasproperty">
8027 <h1><span class="secnum" id="sec-9.1.7.1"><a href="#sec-ordinaryhasproperty"
8028 title="link to this section">9.1.7.1</a></span> OrdinaryHasProperty (O, P)</h1>
8029
8030 <p>When the abstract operation OrdinaryHasProperty is called with Object <var>O</var> and with <a
8031 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
8032
8033 <ol class="proc">
8034 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
8035 <b>true</b>.</li>
8036 <li>Let <i>hasOwn</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
8037 <li>If <i>hasOwn</i> is not <b>undefined</b>, return <b>true</b>.</li>
8038 <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
8039 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
8040 <li>If <i>parent</i> is not <b>null</b>, then
8041 <ol class="block">
8042 <li>Return <i>parent</i>.[[HasProperty]](<i>P</i>).</li>
8043 </ol>
8044 </li>
8045 <li>Return <b>false</b>.</li>
8046 </ol>
8047 </section>
8048 </section>
8049
8050 <section id="sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">
8051 <h1><span class="secnum" id="sec-9.1.8"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver"
8052 title="link to this section">9.1.8</a></span> [[Get]] (P, Receiver)</h1>
8053
8054 <p>When the [[Get]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>
8055 and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span> the following
8056 steps are taken:</p>
8057
8058 <ol class="proc">
8059 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
8060 <b>true</b>.</li>
8061 <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
8062 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
8063 <li>If <i>desc</i> is <b>undefined</b>, then
8064 <ol class="block">
8065 <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
8066 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
8067 <li>If <i>parent</i> is <b>null</b>, return <b>undefined.</b></li>
8068 <li>Return <i>parent</i>.[[Get]](<i>P</i>, <i>Receiver</i>).</li>
8069 </ol>
8070 </li>
8071 <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>desc</i>) is <b>true</b>, return
8072 <i>desc</i>.[[Value]].</li>
8073 <li>Otherwise, <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>desc</i>) must be <b>true</b> so, let
8074 <i>getter</i> be <i>desc</i>.[[Get]].</li>
8075 <li>If <i>getter</i> is <b>undefined</b>, return <b>undefined</b>.</li>
8076 <li>Return <a href="#sec-call">Call</a>(<i>getter,</i> <i>Receiver</i>).</li>
8077 </ol>
8078 </section>
8079
8080 <section id="sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver">
8081 <h1><span class="secnum" id="sec-9.1.9"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver"
8082 title="link to this section">9.1.9</a></span> [[Set]] ( P, V, Receiver)</h1>
8083
8084 <p>When the [[Set]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>,
8085 value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
8086 class="nt">Receiver</span>, the following steps are taken:</p>
8087
8088 <ol class="proc">
8089 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
8090 <b>true</b>.</li>
8091 <li>Let <i>ownDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
8092 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ownDesc</i>).</li>
8093 <li>If <i>ownDesc</i> is <b>undefined</b>, then
8094 <ol class="block">
8095 <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
8096 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
8097 <li>If <i>parent</i> is not <b>null</b>, then
8098 <ol class="block">
8099 <li>Return <i>parent</i>.[[Set]](<i>P</i>, <i>V</i>, <i>Receiver</i>).</li>
8100 </ol>
8101 </li>
8102 <li>Else,
8103 <ol class="block">
8104 <li>Let <i>ownDesc</i> be the PropertyDescriptor{[[Value]]: <b>undefined</b>, [[Writable]]: <b>true</b>,
8105 [[Enumerable]]: <b>true</b>, [[Configurable]]: <b>true</b>}.</li>
8106 </ol>
8107 </li>
8108 </ol>
8109 </li>
8110 <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>ownDesc</i>) is <b>true</b>, then
8111 <ol class="block">
8112 <li>If <i>ownDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
8113 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Receiver</i>) is not Object, return
8114 <b>false</b>.</li>
8115 <li>Let <i>existingDescriptor</i> be <i>Receiver</i>.[[GetOwnProperty]](<i>P</i>).</li>
8116 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingDescriptor</i>).</li>
8117 <li>If <i>existingDescriptor</i> is not <b>undefined</b>, then
8118 <ol class="block">
8119 <li>Let <i>valueDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>}.</li>
8120 <li>Return <i>Receiver</i>.[[DefineOwnProperty]](<i>P</i>, <i>valueDesc</i>).</li>
8121 </ol>
8122 </li>
8123 <li>Else <i>Receiver</i> does not currently have a property <i>P</i>,
8124 <ol class="block">
8125 <li>Return <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>Receiver</i>, <i>P</i>, <i>V</i>).</li>
8126 </ol>
8127 </li>
8128 </ol>
8129 </li>
8130 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
8131 href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>ownDesc</i>) is <b>true</b>.</li>
8132 <li>Let <i>setter</i> be <i>ownDesc</i>.[[Set]].</li>
8133 <li>If <i>setter</i> is <b>undefined</b>, return <b>false</b>.</li>
8134 <li>Let <i>setterResult</i> be <a href="#sec-call">Call</a>(<i>setter</i>, <i>Receiver</i>, &laquo;<i>V</i>&raquo;).</li>
8135 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>setterResult</i>).</li>
8136 <li>Return <b>true</b>.</li>
8137 </ol>
8138 </section>
8139
8140 <section id="sec-ordinary-object-internal-methods-and-internal-slots-delete-p">
8141 <h1><span class="secnum" id="sec-9.1.10"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-delete-p"
8142 title="link to this section">9.1.10</a></span> [[Delete]] (P)</h1>
8143
8144 <p>When the [[Delete]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
8145 <var>P</var> the following steps are taken:</p>
8146
8147 <ol class="proc">
8148 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
8149 <b>true</b>.</li>
8150 <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
8151 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
8152 <li>If <i>desc</i> is <b>undefined</b>, return <b>true</b>.</li>
8153 <li>If <i>desc</i>.[[Configurable]] is <b>true</b>, then
8154 <ol class="block">
8155 <li>Remove the own property with name <i>P</i> from <i>O</i>.</li>
8156 <li>Return <b>true</b>.</li>
8157 </ol>
8158 </li>
8159 <li>Return <b>false</b>.</li>
8160 </ol>
8161 </section>
8162
8163 <section id="sec-ordinary-object-internal-methods-and-internal-slots-enumerate">
8164 <h1><span class="secnum" id="sec-9.1.11"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-enumerate"
8165 title="link to this section">9.1.11</a></span> [[Enumerate]] ()</h1>
8166
8167 <p>When the [[Enumerate]] internal method of <var>O</var> is called the following steps are taken:</p>
8168
8169 <ol class="proc">
8170 <li>Return an Iterator object (<a href="#sec-iterator-interface">25.1.1.2</a>) whose <code>next</code> method iterates
8171 over all the String-valued keys of enumerable properties of <i>O</i>. The Iterator object must inherit from
8172 %IteratorPrototype% (<a href="#sec-%iteratorprototype%-object">25.1.2</a>). The mechanics and order of enumerating the
8173 properties is not specified but must conform to the rules specified below.</li>
8174 </ol>
8175
8176 <p>The iterator&rsquo;s <code>next</code> method processes object properties to determine whether the <a
8177 href="#sec-object-type">property key</a> should be returned as an iterator value. Returned property keys do not include keys
8178 that are Symbols. Properties of the target object may be deleted during enumeration. A property that is deleted before it is
8179 processed by the iterator&rsquo;s <code>next</code> method is ignored. If new properties are added to the target object
8180 during enumeration, the newly added properties are not guaranteed to be processed in the active enumeration. A property name
8181 will be returned by the iterator&rsquo;s <code>next</code> method at most once in any enumeration.</p>
8182
8183 <p>Enumerating the properties of the target object includes enumerating properties of its prototype, and the prototype of
8184 the prototype, and so on, recursively; but a property of a prototype is not processed if it has the same name as a property
8185 that has already been processed by the iterator&rsquo;s <code>next</code> method. The values of [[Enumerable]] attributes
8186 are not considered when determining if a property of a prototype object has already been processed. The enumerable property
8187 names of prototype objects must be obtained as if by invoking the prototype object&rsquo;s [[Enumerate]] internal method.
8188 [[Enumerate]] must obtain the own property keys of the target object as if by calling its [[OwnPropertyKeys]] internal
8189 method. Property attributes of the target object must be obtained as if by calling its [[GetOwnProperty]] internal
8190 method.</p>
8191
8192 <p class="Note">NOTE The following is an informative definition of an ECMAScript generator function that conforms to these
8193 rules:</p>
8194
8195 <pre>function* enumerate(obj) {</pre>
8196 <pre>let visited=new Set;</pre>
8197 <pre>for (let key of <a href="#sec-reflect.ownkeys">Reflect.ownKeys</a>(obj)) {</pre>
8198 <pre>if (typeof key === "string") {</pre>
8199 <pre>let desc = <a href="#sec-reflect.getownpropertydescriptor">Reflect.getOwnPropertyDescriptor</a>(obj,key);</pre>
8200 <pre>if (desc) {</pre>
8201 <pre>visited.add(key);</pre>
8202 <pre>if (desc.enumerable) yield key;</pre>
8203 <pre>}</pre>
8204 <pre>}</pre>
8205 <pre>}</pre>
8206 <pre>let proto = <a href="#sec-reflect.getprototypeof">Reflect.getPrototypeOf</a>(obj)</pre>
8207 <pre>if (proto === null) return;</pre>
8208 <pre>for (let protoName of <a href="#sec-reflect.enumerate">Reflect.enumerate</a>(proto)) {</pre>
8209 <pre>if (!visited.has(protoName)) yield protoName;</pre>
8210 <pre>}</pre>
8211 <pre>}</pre>
8212 </section>
8213
8214 <section id="sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys">
8215 <h1><span class="secnum" id="sec-9.1.12"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys"
8216 title="link to this section">9.1.12</a></span> [[OwnPropertyKeys]] ( )</h1>
8217
8218 <p>When the [[OwnPropertyKeys]] internal method of <var>O</var> is called the following steps are taken:</p>
8219
8220 <ol class="proc">
8221 <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
8222 <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
8223 numeric index order
8224 <ol class="block">
8225 <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
8226 </ol>
8227 </li>
8228 <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
8229 index, in property creation order
8230 <ol class="block">
8231 <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
8232 </ol>
8233 </li>
8234 <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
8235 order
8236 <ol class="block">
8237 <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
8238 </ol>
8239 </li>
8240 <li>Return <i>keys</i>.</li>
8241 </ol>
8242 </section>
8243
8244 <section id="sec-objectcreate">
8245 <h1><span class="secnum" id="sec-9.1.13"><a href="#sec-objectcreate" title="link to this section">9.1.13</a></span>
8246 ObjectCreate(proto, internalSlotsList)</h1>
8247
8248 <p>The abstract operation ObjectCreate with argument <var>proto</var> (an object or null) is used to specify the runtime
8249 creation of new ordinary objects. The optional argument <var>internalSlotsList</var> is a <a
8250 href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
8251 part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
8252 used. This abstract operation performs the following steps:</p>
8253
8254 <ol class="proc">
8255 <li>If <i>internalSlotsList</i> was not provided, let <i>internalSlotsList</i> be an empty <a
8256 href="#sec-list-and-record-specification-type">List</a>.</li>
8257 <li>Let <i>obj</i> be a newly created object with an <a href="#sec-object-internal-methods-and-internal-slots">internal
8258 slot</a> for each name in <i>internalSlotsList</i>.</li>
8259 <li>Set <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
8260 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
8261 <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
8262 <i>proto</i>.</li>
8263 <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
8264 <b>true</b>.</li>
8265 <li>Return <i>obj</i>.</li>
8266 </ol>
8267 </section>
8268
8269 <section id="sec-ordinarycreatefromconstructor">
8270 <h1><span class="secnum" id="sec-9.1.14"><a href="#sec-ordinarycreatefromconstructor"
8271 title="link to this section">9.1.14</a></span> OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto,
8272 internalSlotsList )</h1>
8273
8274 <p>The abstract operation OrdinaryCreateFromConstructor creates an ordinary object whose [[Prototype]] value is retrieved
8275 from a constructor&rsquo;s <code>prototype</code> property, if it exists. Otherwise the intrinsic named by
8276 <var>intrinsicDefaultProto</var> is used for [[Prototype]]. The optional <var>internalSlotsList</var> is a <a
8277 href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
8278 part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
8279 used. This abstract operation performs the following steps:</p>
8280
8281 <ol class="proc">
8282 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>intrinsicDefaultProto</i> is a string value that is this
8283 specification&rsquo;s name of an intrinsic object. The corresponding object must be an intrinsic that is intended to
8284 be used as the [[Prototype]] value of an object.</li>
8285 <li>Let <i>proto</i> be <a href="#sec-getprototypefromconstructor">GetPrototypeFromConstructor</a>(<i>constructor</i>,
8286 <i>intrinsicDefaultProto</i>).</li>
8287 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
8288 <li>Return <a href="#sec-objectcreate">ObjectCreate</a>(<i>proto</i>, <i>internalSlotsList</i>).</li>
8289 </ol>
8290 </section>
8291
8292 <section id="sec-getprototypefromconstructor">
8293 <h1><span class="secnum" id="sec-9.1.15"><a href="#sec-getprototypefromconstructor"
8294 title="link to this section">9.1.15</a></span> GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )</h1>
8295
8296 <p>The abstract operation GetPrototypeFromConstructor determines the [[Prototype]] value that should be used to create an
8297 object corresponding to a specific constructor. The value is retrieved from the constructor&rsquo;s <code>prototype</code>
8298 property, if it exists. Otherwise the intrinsic named by <var>intrinsicDefaultProto</var> is used for [[Prototype]]. This
8299 abstract operation performs the following steps:</p>
8300
8301 <ol class="proc">
8302 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>intrinsicDefaultProto</i> is a string value that is this
8303 specification&rsquo;s name of an intrinsic object. The corresponding object must be an intrinsic that is intended to
8304 be used as the [[Prototype]] value of an object.</li>
8305 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>constructor</i>)
8306 is <b>true</b>.</li>
8307 <li>Let <i>proto</i> be <a href="#sec-get-o-p">Get</a>(<i>constructor</i>, <code>"prototype"</code>).</li>
8308 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
8309 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>proto</i>) is not Object, then
8310 <ol class="block">
8311 <li>Let <i>realm</i> be <a href="#sec-getfunctionrealm">GetFunctionRealm</a>(<i>constructor</i>).</li>
8312 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>realm</i>).</li>
8313 <li>Let <i>proto</i> be <i>realm&rsquo;s</i> intrinsic object named <i>intrinsicDefaultProto</i>.</li>
8314 </ol>
8315 </li>
8316 <li>Return <i>proto</i>.</li>
8317 </ol>
8318
8319 <div class="note">
8320 <p><span class="nh">NOTE</span> If <i>constructor</i> does not supply a [[Prototype]] value, the default value that is
8321 used is obtained from the <a href="#sec-code-realms">Code Realm</a> of the <i>constructor</i> function rather than from <a
8322 href="#sec-execution-contexts">the running execution context</a>.</p>
8323 </div>
8324 </section>
8325 </section>
8326
8327 <section id="sec-ecmascript-function-objects">
8328 <div class="front">
8329 <h1><span class="secnum" id="sec-9.2"><a href="#sec-ecmascript-function-objects" title="link to this section">9.2</a></span>
8330 ECMAScript Function Objects</h1>
8331
8332 <p>ECMAScript function objects encapsulate parameterized ECMAScript code closed over a <a
8333 href="#sec-lexical-environments">lexical environment</a> and support the dynamic evaluation of that code. An ECMAScript
8334 function object is an ordinary object and has the same internal slots and the same internal methods as other ordinary
8335 objects. The code of an ECMAScript function object may be either <a href="#sec-strict-mode-code">strict mode code</a> (<a
8336 href="#sec-strict-mode-code">10.2.1</a>) or non-<a href="#sec-strict-mode-code">strict mode code</a>. An ECMAScript function
8337 object whose code is <a href="#sec-strict-mode-code">strict mode code</a> is called a <i>strict function</i>. One whose code
8338 is not <a href="#sec-strict-mode-code">strict mode code</a> is called a <i>non-strict function</i>.</p>
8339
8340 <p>ECMAScript function objects have the additional internal slots listed in <a href="#table-27">Table 27</a>.</p>
8341
8342 <figure>
8343 <figcaption><span id="table-27">Table 27</span> &mdash; Internal Slots of ECMAScript Function Objects</figcaption>
8344 <table class="real-table">
8345 <tr>
8346 <th>Internal Slot</th>
8347 <th>Type</th>
8348 <th>Description</th>
8349 </tr>
8350 <tr>
8351 <td>[[Environment]]</td>
8352 <td><a href="#sec-lexical-environments">Lexical Environment</a></td>
8353 <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>
8354 </tr>
8355 <tr>
8356 <td>[[FormalParameters]]</td>
8357 <td>Parse Node</td>
8358 <td>The root parse node of the source text that defines the function&rsquo;s formal parameter list.</td>
8359 </tr>
8360 <tr>
8361 <td>[[FunctionKind]]</td>
8362 <td>String</td>
8363 <td>Either <code>"normal"</code>, <code>"classConstructor"</code> or <code>"generator"</code>.</td>
8364 </tr>
8365 <tr>
8366 <td>[[ECMAScriptCode]]</td>
8367 <td>Parse Node</td>
8368 <td>The root parse node of the source text that defines the function&rsquo;s body.</td>
8369 </tr>
8370 <tr>
8371 <td>[[ConstructorKind]]</td>
8372 <td>String</td>
8373 <td>Either <code>"base"</code> or <code>"derived"</code>.</td>
8374 </tr>
8375 <tr>
8376 <td>[[Realm]]</td>
8377 <td><a href="#sec-code-realms">Realm</a> Record</td>
8378 <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>
8379 </tr>
8380 <tr>
8381 <td>[[ThisMode]]</td>
8382 <td>(lexical, strict, global)</td>
8383 <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>
8384 </tr>
8385 <tr>
8386 <td>[[Strict]]</td>
8387 <td>Boolean</td>
8388 <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>
8389 </tr>
8390 <tr>
8391 <td>[[HomeObject]]</td>
8392 <td>Object</td>
8393 <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>
8394 </tr>
8395 </table>
8396 </figure>
8397
8398 <p>All ECMAScript function objects have the [[Call]] internal method defined here. ECMAScript functions that are also
8399 constructors in addition have the [[Construct]] internal method. ECMAScript function objects whose code is not <a
8400 href="#sec-strict-mode-code">strict mode code</a> have the [[GetOwnProperty]] internal method defined here.</p>
8401 </div>
8402
8403 <section id="sec-ecmascript-function-objects-call-thisargument-argumentslist">
8404 <div class="front">
8405 <h1><span class="secnum" id="sec-9.2.1"><a href="#sec-ecmascript-function-objects-call-thisargument-argumentslist"
8406 title="link to this section">9.2.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
8407
8408 <p>The [[Call]] internal method for an <a href="#sec-ecmascript-function-objects">ECMAScript function object</a>
8409 <var>F</var> is called with parameters <var>thisArgument</var> and <var>argumentsList</var>, a <a
8410 href="#sec-list-and-record-specification-type">List</a> of <a href="#sec-ecmascript-language-types">ECMAScript language
8411 values</a>. The following steps are taken:</p>
8412
8413 <ol class="proc">
8414 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a
8415 href="#sec-ecmascript-function-objects">ECMAScript function object</a>.</li>
8416 <li>If <i>F</i>&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is
8417 <code>"classConstructor"</code>, throw a <b>TypeError</b> exception.</li>
8418 <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
8419 <li>Let <i>calleeContext</i> be <a href="#sec-prepareforordinarycall">PrepareForOrdinaryCall</a>(<i>F</i>,
8420 <b>undefined</b>).</li>
8421 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>calleeContext</i> is now <a href="#sec-execution-contexts">the
8422 running execution context</a>.</li>
8423 <li>Perform <a href="#sec-ordinarycallbindthis">OrdinaryCallBindThis</a>(<i>F</i>, <i>calleeContext</i>,
8424 <i>thisArgument</i>).</li>
8425 <li>Let <i>result</i> be <a href="#sec-ordinarycallevaluatebody">OrdinaryCallEvaluateBody</a>(<i>F</i>,
8426 <i>argumentsList</i>).</li>
8427 <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
8428 <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
8429 <li>If <i>result</i>.[[type]] is <span style="font-family: sans-serif">return</span>, return <a
8430 href="#sec-normalcompletion">NormalCompletion</a>(<i>result</i>.[[value]]).</li>
8431 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
8432 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
8433 </ol>
8434
8435 <div class="note">
8436 <p><span class="nh">NOTE</span> When <i>calleeContext</i> is removed from <a href="#sec-execution-contexts">the
8437 execution context stack</a> in step 8 it must not be destroyed if it is <a href="#sec-execution-contexts">suspended</a>
8438 and retained for later resumption by an accessible generator object<i>.</i></p>
8439 </div>
8440 </div>
8441
8442 <section id="sec-prepareforordinarycall">
8443 <h1><span class="secnum" id="sec-9.2.1.1"><a href="#sec-prepareforordinarycall"
8444 title="link to this section">9.2.1.1</a></span> PrepareForOrdinaryCall( F, newTarget )</h1>
8445
8446 <p>When the abstract operation PrepareForOrdinaryCall is called with function object <var>F</var> <span
8447 style="font-family: Times New Roman">and <a href="#sec-ecmascript-language-types">ECMAScript language value</a>
8448 <i>newTarget</i></span>, the following steps are taken:</p>
8449
8450 <ol class="proc">
8451 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
8452 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Undefined or Object.</li>
8453 <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
8454 <li>Let <i>calleeContext</i> be a new <a href="#sec-execution-contexts">ECMAScript code execution context</a>.</li>
8455 <li>Set the Function of <i>calleeContext</i> to <i>F</i>.</li>
8456 <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
8457 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
8458 <li>Set the <a href="#sec-code-realms">Realm</a> of <i>calleeContext</i> to <i>calleeRealm</i>.</li>
8459 <li>Let <i>localEnv</i> be <a href="#sec-newfunctionenvironment">NewFunctionEnvironment</a>(<i>F</i>,
8460 <i>newTarget</i>).</li>
8461 <li>Set the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i> to <i>localEnv</i>.</li>
8462 <li>Set the <a href="#sec-execution-contexts">VariableEnvironment</a> of <i>calleeContext</i> to <i>localEnv</i>.</li>
8463 <li>If <i>callerContext</i> is not already <a href="#sec-execution-contexts">suspended</a>, <a
8464 href="#sec-execution-contexts">Suspend</a> <i>callerContext</i>.</li>
8465 <li>Push <i>calleeContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>;
8466 <i>calleeContext</i> is now <a href="#sec-execution-contexts">the running execution context</a>.</li>
8467 <li><span style="font-family: sans-serif">NOTE Any exception objects produced after this point are associated
8468 with</span> <i>calleeRealm</i>.</li>
8469 <li>Return <i>calleeContext</i>.</li>
8470 </ol>
8471 </section>
8472
8473 <section id="sec-ordinarycallbindthis">
8474 <h1><span class="secnum" id="sec-9.2.1.2"><a href="#sec-ordinarycallbindthis"
8475 title="link to this section">9.2.1.2</a></span> OrdinaryCallBindThis ( F, calleeContext, thisArgument )</h1>
8476
8477 <p>When the abstract operation OrdinaryCallBindThis is called with function object <var>F</var>, <a
8478 href="#sec-execution-contexts">execution context</a> <var>calleeContext</var>, and ECMAScript value
8479 <var>thisArgument</var> the following steps are taken:</p>
8480
8481 <ol class="proc">
8482 <li>Let <i>thisMode</i> be the value of <i>F</i>&rsquo;s [[ThisMode]] <a
8483 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
8484 <li>If <i>thisMode</i> is <span style="font-family: sans-serif">lexical</span>, return <a
8485 href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
8486 <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
8487 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
8488 <li>Let <i>localEnv</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i>.</li>
8489 <li>If <i>thisMode</i> is <span style="font-family: sans-serif">strict</span>, let <i>thisValue</i> be
8490 <i>thisArgument</i>.</li>
8491 <li>Else
8492 <ol class="block">
8493 <li>if <i>thisArgument</i> is <b>null</b> or <b>undefined</b>, then
8494 <ol class="block">
8495 <li>Let <i>thisValue</i> be <i>calleeRealm</i>.[[globalThis]].</li>
8496 </ol>
8497 </li>
8498 <li>Else
8499 <ol class="block">
8500 <li>Let <i>thisValue</i> be <a href="#sec-toobject">ToObject</a>(<i>thisArgument</i>).</li>
8501 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>thisValue</i> is not an <a
8502 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
8503 <li><span style="font-family: sans-serif">NOTE <a href="#sec-toobject">ToObject</a> produces</span> <span
8504 style="font-family: sans-serif">wrapper objects using</span> <i>calleeRealm</i>.</li>
8505 </ol>
8506 </li>
8507 </ol>
8508 </li>
8509 <li>Let <i>envRec</i> be <i>localEnv</i>&rsquo;s EnvironmentRecord.</li>
8510 <li><a href="#sec-algorithm-conventions">Assert</a>: The next step never returns an <a
8511 href="#sec-completion-record-specification-type">abrupt completion</a> because <i>envRec</i>.[[thisBindingStatus]]
8512 is <code>"uninitialized"</code>.</li>
8513 <li>Return <i>envRec</i>.<a href="#sec-bindthisvalue">BindThisValue</a>(<i>thisValue</i>).</li>
8514 </ol>
8515 </section>
8516
8517 <section id="sec-ordinarycallevaluatebody">
8518 <h1><span class="secnum" id="sec-9.2.1.3"><a href="#sec-ordinarycallevaluatebody"
8519 title="link to this section">9.2.1.3</a></span> OrdinaryCallEvaluateBody ( F, argumentsList )</h1>
8520
8521 <p>When the abstract operation OrdinaryCallEvaluateBody is called with function object <var>F</var> and <a
8522 href="#sec-list-and-record-specification-type">List</a> <var>argumentsList</var> the following steps are taken:</p>
8523
8524 <ol class="proc">
8525 <li>Let <i>status</i> be <a href="#sec-functiondeclarationinstantiation">FunctionDeclarationInstantiation</a>(<i>F</i>,
8526 <i>argumentsList</i>).</li>
8527 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>)</li>
8528 <li>Return the result of EvaluateBody of the parsed code that is the value of <i>F</i>'s [[ECMAScriptCode]] <a
8529 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> passing <i>F</i> as the argument.</li>
8530 </ol>
8531 </section>
8532 </section>
8533
8534 <section id="sec-ecmascript-function-objects-construct-argumentslist-newtarget">
8535 <h1><span class="secnum" id="sec-9.2.2"><a href="#sec-ecmascript-function-objects-construct-argumentslist-newtarget"
8536 title="link to this section">9.2.2</a></span> [[Construct]] ( argumentsList, newTarget)</h1>
8537
8538 <p>The [[Construct]] internal method for an <a href="#sec-ecmascript-function-objects">ECMAScript Function object</a>
8539 <var>F</var> is called with parameters <var>argumentsList</var> and <span style="font-family: Times New
8540 Roman"><i>newTarget</i>. <i>argumentsList</i></span> is a possibly empty <a
8541 href="#sec-list-and-record-specification-type">List</a> of <a href="#sec-ecmascript-language-types">ECMAScript language
8542 values</a>. The following steps are taken:</p>
8543
8544 <ol class="proc">
8545 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
8546 function object</a>.</li>
8547 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
8548 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Object.</li>
8549 <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
8550 <li>Let <i>kind</i> be <i>F</i>&rsquo;s [[ConstructorKind]] <a
8551 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
8552 <li>If <i>kind</i> is <code>"base"</code>, then
8553 <ol class="block">
8554 <li>Let <i>thisArgument</i> be <a
8555 href="#sec-ordinarycreatefromconstructor">OrdinaryCreateFromConstructor</a>(<i>newTarget</i>,
8556 <code>"%ObjectPrototype%"</code>).</li>
8557 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>thisArgument</i>).</li>
8558 </ol>
8559 </li>
8560 <li>Let <i>calleeContext</i> be <a href="#sec-prepareforordinarycall">PrepareForOrdinaryCall</a>(<i>F</i>,
8561 <i>newTarget</i>).</li>
8562 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>calleeContext</i> is now <a href="#sec-execution-contexts">the
8563 running execution context</a>.</li>
8564 <li>If <i>kind</i> is <code>"base"</code>, perform <a href="#sec-ordinarycallbindthis">OrdinaryCallBindThis</a>(<i>F</i>,
8565 <i>calleeContext</i>, <i>thisArgument</i>).</li>
8566 <li>Let <i>constructorEnv</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of
8567 <i>calleeContext</i>.</li>
8568 <li>Let <i>envRec</i> be <i>constructorEnv</i>&rsquo;s EnvironmentRecord.</li>
8569 <li>Let <i>result</i> be <a href="#sec-ordinarycallevaluatebody">OrdinaryCallEvaluateBody</a>(<i>F</i>,
8570 <i>argumentsList</i>).</li>
8571 <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
8572 <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
8573 <li>If <i>result</i>.[[type]] is <span style="font-family: sans-serif">return</span>, then
8574 <ol class="block">
8575 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>.[[value]]) is Object, return <a
8576 href="#sec-normalcompletion">NormalCompletion</a>(<i>result</i>.[[value]]).</li>
8577 <li>If <i>kind</i> is <code>"base"</code>, return <a
8578 href="#sec-normalcompletion">NormalCompletion</a>(<i>thisArgument</i>).</li>
8579 <li>If <i>result</i>.[[value]] is not <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
8580 </ol>
8581 </li>
8582 <li>Else, <a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
8583 <li>Return <i>envRec</i>.GetThisBinding().</li>
8584 </ol>
8585 </section>
8586
8587 <section id="sec-functionallocate">
8588 <h1><span class="secnum" id="sec-9.2.3"><a href="#sec-functionallocate" title="link to this section">9.2.3</a></span>
8589 FunctionAllocate (functionPrototype, strict [,functionKind] )</h1>
8590
8591 <p>The abstract operation FunctionAllocate requires the two arguments <span style="font-family: Times New
8592 Roman"><i>functionPrototype</i> and <i>strict</i>.</span> It also accepts one optional argument, <var>functionKind</var>.
8593 FunctionAllocate performs the following steps:</p>
8594
8595 <ol class="proc">
8596 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
8597 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>functionPrototype</i>) is Object.</li>
8598 <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>functionKind</i> is present, its value is either
8599 <code>"normal"</code>, <code>"non-constructor"</code> or <code>"generator"</code>.</li>
8600 <li>If <i>functionKind</i> is not present, let <i>functionKind</i> be <code>"normal"</code>.</li>
8601 <li>If <i>functionKind</i> is <code>"non-constructor"</code>, then
8602 <ol class="block">
8603 <li>Let <i>functionKind</i> be <code>"normal"</code>.</li>
8604 <li>Let <i>needsConstruct</i> be <b>false</b>.</li>
8605 </ol>
8606 </li>
8607 <li>Else let <i>needsConstruct</i> be <b>true</b>.</li>
8608 <li>Let <i>F</i> be a newly created <a href="#sec-ecmascript-function-objects">ECMAScript function object</a> with the
8609 internal slots listed in <a href="#table-27">Table 27</a>. All of those internal slots are initialized to
8610 <b>undefined</b>.</li>
8611 <li>Set <i>F</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
8612 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
8613 <li>Set <i>F</i>&rsquo;s [[Call]] internal method to the definition specified in <a
8614 href="#sec-ecmascript-function-objects-call-thisargument-argumentslist">9.2.1</a>.</li>
8615 <li>If <i>needsConstruct</i> is <b>true</b>, then
8616 <ol class="block">
8617 <li>Set <i>F</i>&rsquo;s [[Construct]] internal method to the definition specified in <a
8618 href="#sec-ecmascript-function-objects-construct-argumentslist-newtarget">9.2.2</a>.</li>
8619 <li>If <i>functionKind</i> is <code>"generator"</code>, set the [[ConstructorKind]] <a
8620 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
8621 <code>"derived"</code>.</li>
8622 <li>Else, set the [[ConstructorKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
8623 <i>F</i> to <code>"base"</code>.</li>
8624 <li>NOTE Generator functions are tagged as <code>"derived"</code> constructors to prevent [[Construct]] from
8625 preallocating a generator instance. Generator instance objects are allocated when EvaluateBody is applied to the
8626 <span class="nt">GeneratorBody</span> of a generator function.</li>
8627 </ol>
8628 </li>
8629 <li>Set the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
8630 <i>strict</i>.</li>
8631 <li>Set the [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
8632 <i>functionKind</i>.</li>
8633 <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
8634 <i>functionPrototype</i>.</li>
8635 <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
8636 <b>true</b>.</li>
8637 <li>Set the [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <a
8638 href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a href="#sec-code-realms">Realm</a>.</li>
8639 <li>Return <i>F</i>.</li>
8640 </ol>
8641 </section>
8642
8643 <section id="sec-functioninitialize">
8644 <h1><span class="secnum" id="sec-9.2.4"><a href="#sec-functioninitialize" title="link to this section">9.2.4</a></span>
8645 FunctionInitialize (F, kind, ParameterList, Body, Scope)</h1>
8646
8647 <p>The abstract operation FunctionInitialize requires the arguments: a function object <var>F</var>, <var>kind</var> which
8648 is one of (Normal, Method, Arrow), a parameter list production specified by <span class="nt">ParameterList</span>, a body
8649 production specified by <span class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a>
8650 specified by <span style="font-family: Times New Roman"><i>Scope</i>.</span> FunctionInitialize performs the following
8651 steps:</p>
8652
8653 <ol class="proc">
8654 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
8655 <code>length</code> own property.</li>
8656 <li>Let <i>len</i> be the ExpectedArgumentCount of <i>ParameterList</i>.</li>
8657 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"length"</code>,
8658 PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
8659 <b>true</b>}).</li>
8660 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
8661 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
8662 <li>Let <i>Strict</i> be the value of the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal
8663 slot</a> of <i>F</i>.</li>
8664 <li>Set the [[Environment]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to the
8665 value of <i>Scope</i>.</li>
8666 <li>Set the [[FormalParameters]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i>
8667 to <i>ParameterList</i> .</li>
8668 <li>Set the [[ECMAScriptCode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
8669 <i>Body</i>.</li>
8670 <li>If <i>kind</i> is <span style="font-family: sans-serif">Arrow</span>, set the [[ThisMode]] <a
8671 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <span style="font-family:
8672 sans-serif">lexical</span>.</li>
8673 <li>Else if <i>Strict</i> is <b>true</b>, set the [[ThisMode]] <a
8674 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <span style="font-family:
8675 sans-serif">strict</span>.</li>
8676 <li>Else set the [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
8677 <span style="font-family: sans-serif">global</span>.</li>
8678 <li>Return <i>F</i>.</li>
8679 </ol>
8680 </section>
8681
8682 <section id="sec-functioncreate">
8683 <h1><span class="secnum" id="sec-9.2.5"><a href="#sec-functioncreate" title="link to this section">9.2.5</a></span>
8684 FunctionCreate (kind, ParameterList, Body, Scope, Strict, prototype)</h1>
8685
8686 <p>The abstract operation FunctionCreate requires the arguments: <var>kind</var> which is one of (Normal, Method, Arrow), a
8687 parameter list production specified by <span class="nt">ParameterList</span>, a body production specified by <span
8688 class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a> specified by <span
8689 class="nt">Scope</span>, a Boolean flag <span class="nt">Strict</span>, and optionally, an object <span style="font-family:
8690 Times New Roman"><i>prototype</i>.</span> FunctionCreate performs the following steps:</p>
8691
8692 <ol class="proc">
8693 <li>If the <i>prototype</i> argument was not passed, then
8694 <ol class="block">
8695 <li>Let <i>prototype</i> be the intrinsic object %FunctionPrototype%.</li>
8696 </ol>
8697 </li>
8698 <li>If <i>kind</i> is not <span style="font-family: sans-serif">Normal</span>, let <i>allocKind</i> be
8699 <code>"non-constructor"</code>.</li>
8700 <li>Else let <i>allocKind</i> be <code>"normal"</code>.</li>
8701 <li>Let <i>F</i> be <a href="#sec-functionallocate">FunctionAllocate</a>(<i>prototype</i>, <i>Strict</i>,
8702 <i>allocKind</i>).</li>
8703 <li>Return <a href="#sec-functioninitialize">FunctionInitialize</a>(<i>F</i>, <i>kind</i>, <i>ParameterList</i>,
8704 <i>Body</i>, <i>Scope</i>).</li>
8705 </ol>
8706 </section>
8707
8708 <section id="sec-generatorfunctioncreate">
8709 <h1><span class="secnum" id="sec-9.2.6"><a href="#sec-generatorfunctioncreate" title="link to this section">9.2.6</a></span>
8710 GeneratorFunctionCreate (kind, ParameterList, Body, Scope, Strict)</h1>
8711
8712 <p>The abstract operation GeneratorFunctionCreate requires the arguments: <var>kind</var> which is one of (Normal, Method),
8713 a parameter list production specified by <span class="nt">ParameterList</span>, a body production specified by <span
8714 class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a> specified by <span
8715 class="nt">Scope</span>, and a Boolean flag <span class="nt">Strict</span>. GeneratorFunctionCreate performs the following
8716 steps:</p>
8717
8718 <ol class="proc">
8719 <li>Let <i>functionPrototype</i> be the intrinsic object %Generator%.</li>
8720 <li>Let <i>F</i> be <a href="#sec-functionallocate">FunctionAllocate</a>(<i>functionPrototype</i>, <i>Strict</i>,
8721 <code>"generator"</code>).</li>
8722 <li>Return <a href="#sec-functioninitialize">FunctionInitialize</a>(<i>F</i>, <i>kind</i>, <i>ParameterList</i>,
8723 <i>Body</i>, <i>Scope</i>).</li>
8724 </ol>
8725 </section>
8726
8727 <section id="sec-addrestrictedfunctionproperties">
8728 <div class="front">
8729 <h1><span class="secnum" id="sec-9.2.7"><a href="#sec-addrestrictedfunctionproperties"
8730 title="link to this section">9.2.7</a></span> AddRestrictedFunctionProperties ( F, realm )</h1>
8731
8732 <p>The abstract operation AddRestrictedFunctionProperties is called with a function object <var>F</var> and <a
8733 href="#sec-code-realms">Realm</a> Record <var>realm</var> as its argument. It performs the following steps:</p>
8734
8735 <ol class="proc">
8736 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>realm</i>.[[intrinsics]].[[<span style="font-family:
8737 sans-serif">%ThrowTypeError%]] exists and has been initialized.</span></li>
8738 <li>Let <i>thrower</i> be <i>realm</i>.[[intrinsics]].[[<span style="font-family:
8739 sans-serif">%ThrowTypeError%]].</span></li>
8740 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"caller"</code>,
8741 PropertyDescriptor {[[Get]]: <i>thrower</i>, [[Set]]: <i>thrower</i>, [[Enumerable]]: <b>false</b>,
8742 [[Configurable]]: <b>true</b>}).</li>
8743 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
8744 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
8745 <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i> , <code>"arguments"</code>,
8746 PropertyDescriptor {[[Get]]: <i>thrower</i>, [[Set]]: <i>thrower</i>, [[Enumerable]]: <b>false</b>,
8747 [[Configurable]]: <b>true</b>}).</li>
8748 <li><a href="#sec-algorithm-conventions">Assert</a>: The above returned value is not an <a
8749 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
8750 </ol>
8751 </div>
8752
8753 <section id="sec-%throwtypeerror%">
8754 <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>
8755 %ThrowTypeError% ( )</h1>
8756
8757 <p>The %ThrowTypeError% intrinsic is an anonymous built-in function object that is defined once for each <a
8758 href="#sec-code-realms">Realm</a>. When %ThrowTypeError% is called it performs the following steps:</p>
8759
8760 <ol class="proc">
8761 <li>Throw a <b>TypeError</b> exception.</li>
8762 </ol>
8763
8764 <p>The value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of a
8765 %ThrowTypeError% function is <span class="value">false</span>.</p>
8766
8767 <p>The <code>length</code> property of a %ThrowTypeError% function has the attributes {&nbsp;[[Writable]]: <b>false</b>,
8768 [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b> }.</p>
8769 </section>
8770 </section>
8771
8772 <section id="sec-makeconstructor">
8773 <h1><span class="secnum" id="sec-9.2.8"><a href="#sec-makeconstructor" title="link to this section">9.2.8</a></span>
8774 MakeConstructor (F, writablePrototype, prototype)</h1>
8775
8776 <p>The abstract operation MakeConstructor requires a Function argument <var>F</var> and optionally, a Boolean
8777 <var>writablePrototype</var> and an object <var>prototype</var>. If <var>prototype</var> is provided it is assumed to
8778 already contain, if needed, a <code>"constructor"</code> property whose value is <var>F</var>. This operation converts
8779 <var>F</var> into a constructor by performing the following steps:</p>
8780
8781 <ol class="proc">
8782 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
8783 function object</a>.</li>
8784 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> has a [[Construct]] internal method.</li>
8785 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
8786 <code>prototype</code> own property.</li>
8787 <li>Let <i>installNeeded</i> be <b>false</b>.</li>
8788 <li>If the <i>prototype</i> argument was not provided, then
8789 <ol class="block">
8790 <li>Let <i>installNeeded</i> be <b>true</b>.</li>
8791 <li>Let <i>prototype</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
8792 sans-serif">%ObjectPrototype%</span>).</li>
8793 </ol>
8794 </li>
8795 <li>If the <i>writablePrototype</i> argument was not provided, then
8796 <ol class="block">
8797 <li>Let <i>writablePrototype</i> be <b>true</b>.</li>
8798 </ol>
8799 </li>
8800 <li>If <i>installNeeded</i>, then
8801 <ol class="block">
8802 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>prototype</i>,
8803 <code>"constructor"</code>, PropertyDescriptor{[[Value]]: <i>F</i>, [[Writable]]: <i>writablePrototype</i>,
8804 [[Enumerable]]: <b>false</b>, [[Configurable]]: <i>writablePrototype</i> }).</li>
8805 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
8806 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
8807 </ol>
8808 </li>
8809 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>,
8810 <code>"prototype"</code>, PropertyDescriptor{[[Value]]: <i>prototype</i>, [[Writable]]: <i>writablePrototype</i>,
8811 [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b>}).</li>
8812 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
8813 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
8814 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
8815 </ol>
8816 </section>
8817
8818 <section id="sec-makeclassconstructor">
8819 <h1><span class="secnum" id="sec-9.2.9"><a href="#sec-makeclassconstructor" title="link to this section">9.2.9</a></span>
8820 MakeClassConstructor ( F)</h1>
8821
8822 <p>The abstract operation MakeClassConstructor with argument <var>F</var> performs the following steps:</p>
8823
8824 <ol class="proc">
8825 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
8826 function object</a>.</li>
8827 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i>&rsquo;s [[FunctionKind]] <a
8828 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is <code>"normal"</code>.</li>
8829 <li>Set <i>F</i>&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
8830 <code>"classConstructor"</code>.</li>
8831 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
8832 </ol>
8833 </section>
8834
8835 <section id="sec-makemethod">
8836 <h1><span class="secnum" id="sec-9.2.10"><a href="#sec-makemethod" title="link to this section">9.2.10</a></span> MakeMethod
8837 ( F, homeObject)</h1>
8838
8839 <p>The abstract operation MakeMethod with arguments <var>F</var> and <var>homeObject</var> configures <var>F</var> as a
8840 method by performing the following steps:</p>
8841
8842 <ol class="proc">
8843 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
8844 function object</a>.</li>
8845 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
8846 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>homeObject</i> ) is Object.</li>
8847 <li>Set the [[HomeObject]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
8848 <i>homeObject</i>.</li>
8849 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
8850 </ol>
8851 </section>
8852
8853 <section id="sec-setfunctionname">
8854 <h1><span class="secnum" id="sec-9.2.11"><a href="#sec-setfunctionname" title="link to this section">9.2.11</a></span>
8855 SetFunctionName (F, name, prefix)</h1>
8856
8857 <p>The abstract operation SetFunctionName requires a Function argument <var>F</var>, a String or Symbol argument
8858 <var>name</var> and optionally a String argument <var>prefix</var>. This operation adds a <code>name</code> property to
8859 <var>F</var> by performing the following steps:</p>
8860
8861 <ol class="proc">
8862 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
8863 <code>name</code> own property.</li>
8864 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>)
8865 is either Symbol or String.</li>
8866 <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>prefix</i> was passed then <a
8867 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>prefix</i>) is String.</li>
8868 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>) is Symbol, then
8869 <ol class="block">
8870 <li>Let <i>description</i> be <i>name</i>&rsquo;s [[Description]] value.</li>
8871 <li>If <i>description</i> is <b>undefined</b>, let <i>name</i> be the empty String.</li>
8872 <li>Else, let <i>name</i> be the concatenation of <code>"["</code>, <i>description</i>, and <code>"]"</code>.</li>
8873 </ol>
8874 </li>
8875 <li>If <i>prefix</i> was passed, then
8876 <ol class="block">
8877 <li>Let <i>name</i> be the concatenation of <i>prefix</i>, code unit 0x0020 (SPACE), and <i>name</i>.</li>
8878 </ol>
8879 </li>
8880 <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"name"</code>,
8881 PropertyDescriptor{[[Value]]: <i>name</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
8882 <b>true</b>}).</li>
8883 <li><a href="#sec-algorithm-conventions">Assert</a>: the result is never an <a
8884 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
8885 </ol>
8886 </section>
8887
8888 <section id="sec-functiondeclarationinstantiation">
8889 <h1><span class="secnum" id="sec-9.2.12"><a href="#sec-functiondeclarationinstantiation"
8890 title="link to this section">9.2.12</a></span> FunctionDeclarationInstantiation(func, argumentsList)</h1>
8891
8892 <div class="note">
8893 <p><span class="nh">NOTE</span> When an <a href="#sec-execution-contexts">execution context</a> is established for
8894 evaluating an ECMAScript function a new function <a href="#sec-environment-records">Environment Record</a> is created and
8895 bindings for each formal parameter are instantiated in that <a href="#sec-environment-records">Environment Record</a>.
8896 Each declaration in the function body is also instantiated. If the function&rsquo;s formal parameters do not include any
8897 default value initializers then the body declarations are instantiated in the same <a
8898 href="#sec-environment-records">Environment Record</a> as the parameters. If default value parameter initializers exist, a
8899 second <a href="#sec-environment-records">Environment Record</a> is created for the body declarations. Formal parameters
8900 and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during
8901 evaluation of the function body.</p>
8902 </div>
8903
8904 <p>FunctionDeclarationInstantiation is performed as follows using arguments <var>func</var> and <var>argumentsList</var>.
8905 <var>func</var> is the function object for which the <a href="#sec-execution-contexts">execution context</a> is being
8906 established.</p>
8907
8908 <ol class="proc">
8909 <li>Let <i>calleeContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
8910 <li>Let <i>env</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i>.</li>
8911 <li>Let <i>envRec</i> be <i>env</i>&rsquo;s <a href="#sec-environment-records">Environment Record</a>.</li>
8912 <li>Let <i>code</i> be the value of the [[ECMAScriptCode]] <a
8913 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i>.</li>
8914 <li>Let <i>strict</i> be the value of the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal
8915 slot</a> of <i>func</i>.</li>
8916 <li>Let <i>formals</i> be the value of the [[FormalParameters]] <a
8917 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i>.</li>
8918 <li>Let <i>parameterNames</i> be the BoundNames of <i>formals</i>.</li>
8919 <li>If <i>parameterNames</i> has any duplicate entries, let <i>hasDuplicates</i> be <b>true</b>. Otherwise, let
8920 <i>hasDuplicates</i> be <b>false</b>.</li>
8921 <li>Let <i>simpleParameterList</i> be IsSimpleParameterList of <i>formals</i>.</li>
8922 <li>Let <i>hasParameterExpressions</i> be ContainsExpression of <i>formals.</i></li>
8923 <li>Let <i>varNames</i> be the VarDeclaredNames of <i>code</i>.</li>
8924 <li>Let <i>varDeclarations</i> be the VarScopedDeclarations of <i>code</i>.</li>
8925 <li>Let <i>lexicalNames</i> be the LexicallyDeclaredNames of <i>code</i>.</li>
8926 <li>Let <i>functionNames</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
8927 <li>Let <i>functionsToInitialize</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
8928 <li>For each <i>d</i> in <i>varDeclarations</i>, in reverse list order do
8929 <ol class="block">
8930 <li>If <i>d</i> is neither a <i>VariableDeclaration</i> or a <i>ForBinding</i>, then
8931 <ol class="block">
8932 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>d</i> is either a <i>FunctionDeclaration</i> or a
8933 <i>GeneratorDeclaration</i>.</li>
8934 <li>Let <i>fn</i> be the sole element of the BoundNames of <i>d.</i></li>
8935 <li>If <i>fn</i> is not an element of <i>functionNames</i>, then
8936 <ol class="block">
8937 <li>Insert <i>fn</i> as the first element of <i>functionNames</i>.</li>
8938 <li>NOTE If there are multiple <span style="font-family: Times New Roman"><i>FunctionDeclarations</i> or
8939 <i>GeneratorDeclarations</i></span> for the same name, the last declaration is used.</li>
8940 <li>Insert <i>d</i> as the first element of <i>functionsToInitialize</i>.</li>
8941 </ol>
8942 </li>
8943 </ol>
8944 </li>
8945 </ol>
8946 </li>
8947 <li>Let <i>argumentsObjectNeeded</i> be <b>true</b>.</li>
8948 <li>If the value of the [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
8949 <i>func</i> is <span style="font-family: sans-serif">lexical</span>, then
8950 <ol class="block">
8951 <li>NOTE Arrow functions never have an arguments objects.</li>
8952 <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
8953 </ol>
8954 </li>
8955 <li>Else if <code>"arguments"</code> is an element of <i>parameterNames</i>, then
8956 <ol class="block">
8957 <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
8958 </ol>
8959 </li>
8960 <li>Else if <i>hasParameterExpressions</i> is <b>false</b>, then
8961 <ol class="block">
8962 <li>If <code>"arguments"</code> is an element of <i>functionNames</i> or if <code>"arguments"</code> is an element of
8963 <i>lexicalNames</i>, then
8964 <ol class="block">
8965 <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
8966 </ol>
8967 </li>
8968 </ol>
8969 </li>
8970 <li>For each String <i>paramName</i> in <i>parameterNames</i>, do
8971 <ol class="block">
8972 <li>Let <i>alreadyDeclared</i> be <i>envRec</i>.HasBinding(<i>paramName</i>).</li>
8973 <li>NOTE Early errors ensure that duplicate parameter names can only occur in non-strict functions that do not have
8974 parameter default values or rest parameters.</li>
8975 <li>If <i>alreadyDeclared</i> is <b>false</b>, then
8976 <ol class="block">
8977 <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<i>paramName</i>).</li>
8978 <li>If <i>hasDuplicates</i> is <b>true</b>, then
8979 <ol class="block">
8980 <li>Let <i>status</i> be <i>envRec</i>.InitializeBinding(<i>paramName</i>, <b>undefined</b>).</li>
8981 </ol>
8982 </li>
8983 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
8984 href="#sec-completion-record-specification-type">abrupt completion</a> for either of the above
8985 operations.</li>
8986 </ol>
8987 </li>
8988 </ol>
8989 </li>
8990 <li>If <i>argumentsObjectNeeded</i> is <b>true</b>, then
8991 <ol class="block">
8992 <li>If <i>strict</i> is <b>true</b> or if <i>simpleParameterList</i> is <b>false</b>, then
8993 <ol class="block">
8994 <li>Let <i>ao</i> be <a
8995 href="#sec-createunmappedargumentsobject">CreateUnmappedArgumentsObject</a>(<i>argumentsList</i>)<i>.</i></li>
8996 </ol>
8997 </li>
8998 <li>Else,
8999 <ol class="block">
9000 <li>NOTE mapped argument object is only provided for non-strict functions that don&rsquo;t have a rest parameter,
9001 any parameter default value initializers, or any destructured parameters .</li>
9002 <li>Let <i>ao</i> be <a href="#sec-createmappedargumentsobject">CreateMappedArgumentsObject</a>(<i>func</i>,
9003 <i>formals</i>, <i>argumentsList</i>, <i>env</i>).</li>
9004 </ol>
9005 </li>
9006 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ao</i>).</li>
9007 <li>If <i>strict</i> is <b>true</b>, then
9008 <ol class="block">
9009 <li>Let <i>status</i> be <i>envRec</i>.CreateImmutableBinding(<code>"arguments"</code>).</li>
9010 </ol>
9011 </li>
9012 <li>Else,
9013 <ol class="block">
9014 <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<code>"arguments"</code>).</li>
9015 </ol>
9016 </li>
9017 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
9018 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9019 <li><a href="#sec-call">Call</a> <i>envRec</i>.InitializeBinding(<code>"arguments"</code>, <i>ao</i>).</li>
9020 <li>Append <code>"arguments"</code> to <i>parameterNames</i>.</li>
9021 </ol>
9022 </li>
9023 <li>Let <i>iteratorRecord</i> be Record {[[iterator]]: <a
9024 href="#sec-createlistiterator">CreateListIterator</a>(<i>argumentsList</i>), [[done]]: <b>false</b>}.</li>
9025 <li>If <i>hasDuplicates</i> is <b>true</b>, then
9026 <ol class="block">
9027 <li>Let <i>formalStatus</i> be IteratorBindingInitialization for <i>formals</i> with <i>iteratorRecord</i> and
9028 <b>undefined</b> as arguments.</li>
9029 </ol>
9030 </li>
9031 <li>Else,
9032 <ol class="block">
9033 <li>Let <i>formalStatus</i> be IteratorBindingInitialization for <i>formals</i> with <i>iteratorRecord</i> and
9034 <i>envRec</i> as arguments.</li>
9035 </ol>
9036 </li>
9037 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>formalStatus</i>).</li>
9038 <li>If <i>hasParameterExpressions</i> is <b>false</b>, then
9039 <ol class="block">
9040 <li>NOTE Only a single <a href="#sec-lexical-environments">lexical environment</a> is needed for the parameters and
9041 top-level vars.</li>
9042 <li>Let <i>instantiatedVarNames</i> be a copy of the <a href="#sec-list-and-record-specification-type">List</a>
9043 <i>parameterNames</i>.</li>
9044 <li>For each <i>n</i> in <i>varNames</i>, do
9045 <ol class="block">
9046 <li>If <i>n</i> is not an element of <i>instantiatedVarNames</i>, then
9047 <ol class="block">
9048 <li>Append <i>n</i> to <i>instantiatedVarNames</i>.</li>
9049 <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<i>n</i>).</li>
9050 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
9051 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9052 <li><a href="#sec-call">Call</a> <i>envRec</i>.InitializeBinding(<i>n</i>, <b>undefined</b>).</li>
9053 </ol>
9054 </li>
9055 </ol>
9056 </li>
9057 <li>Let <i>varEnv</i> be <i>env</i>.</li>
9058 <li>Let <i>varEnvRec</i> be <i>envRec</i>.</li>
9059 </ol>
9060 </li>
9061 <li>Else,
9062 <ol class="block">
9063 <li>NOTE A separate <a href="#sec-environment-records">Environment Record</a> is needed to ensure that closures
9064 created by expressions in the formal parameter list do not have visibility of declarations in the function
9065 body.</li>
9066 <li>Let <i>varEnv</i> be <a href="#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a>(<i>env</i>).</li>
9067 <li>Let <i>varEnvRec</i> be <i>varEnv</i>&rsquo;s EnvironmentRecord.</li>
9068 <li>Set the <a href="#sec-execution-contexts">VariableEnvironment</a> of <i>calleeContext</i> to <i>varEnv</i>.</li>
9069 <li>Let <i>instantiatedVarNames</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
9070 <li>For each <i>n</i> in <i>varNames</i>, do
9071 <ol class="block">
9072 <li>If <i>n</i> is not an element of <i>instantiatedVarNames</i>, then
9073 <ol class="block">
9074 <li>Append <i>n</i> to <i>instantiatedVarNames</i>.</li>
9075 <li>Let <i>status</i> be <i>varEnvRec</i>.CreateMutableBinding(<i>n</i>).</li>
9076 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
9077 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9078 <li>If <i>n</i> is not an element of <i>parameterNames</i> or if <i>n</i> is an element of
9079 <i>functionNames</i>, let <i>initialValue</i> be <b>undefined</b>.</li>
9080 <li>else,
9081 <ol class="block">
9082 <li>Let <i>initialValue</i> be <i>envRec.</i>GetBindingValue(<i>n</i>, <b>false</b>).</li>
9083 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initialValue</i>).</li>
9084 </ol>
9085 </li>
9086 <li><a href="#sec-call">Call</a> <i>varEnvRec</i>.InitializeBinding(<i>n</i>, <i>initialValue</i>).</li>
9087 <li>NOTE vars whose names are the same as a formal parameter, initially have the same value as the
9088 corresponding initialized parameter.</li>
9089 </ol>
9090 </li>
9091 </ol>
9092 </li>
9093 </ol>
9094 </li>
9095 <li>NOTE: Annex <a href="#sec-block-level-function-declarations-web-legacy-compatibility-semantics">B.3.3</a> adds
9096 additional steps at this point.</li>
9097 <li>If <i>strict</i> is <b>false</b>, then
9098 <ol class="block">
9099 <li>Let <i>lexEnv</i> be <a href="#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a>(<i>varEnv</i>).</li>
9100 <li>NOTE: Non-strict functions use a separate lexical <a href="#sec-environment-records">Environment Record</a> for
9101 top-level lexical declarations so that a direct <code>eval</code> (<a
9102 href="#sec-function-calls-runtime-semantics-evaluation">see 12.3.4.1</a>) can determine whether any var scoped
9103 declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This
9104 is not needed for strict functions because a strict direct <code>eval</code> always places all declarations into a
9105 new <a href="#sec-environment-records">Environment Record</a>.</li>
9106 </ol>
9107 </li>
9108 <li>Else, let <i>lexEnv</i> be <i>varEnv</i>.</li>
9109 <li>Let <i>lexEnvRec</i> be <i>lexEnv</i>&rsquo;s EnvironmentRecord.</li>
9110 <li>Set the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i> to <i>lexEnv</i>.</li>
9111 <li>Let <i>lexDeclarations</i> be the LexicallyScopedDeclarations of <i>code</i>.</li>
9112 <li>For each element <i>d</i> in <i>lexDeclarations</i> do
9113 <ol class="block">
9114 <li>NOTE A lexically declared name cannot be the same as a function/generator declaration, formal parameter, or a var
9115 name. Lexically declared names are only instantiated here but not initialized.</li>
9116 <li>For each element <i>dn</i> of the BoundNames of <i>d</i> do
9117 <ol class="block">
9118 <li>If IsConstantDeclaration of <i>d</i> is <b>true</b>, then
9119 <ol class="block">
9120 <li>Let <i>status</i> be <i>lexEnvRec</i>.CreateImmutableBinding(<i>dn</i>, <b>true</b>).</li>
9121 </ol>
9122 </li>
9123 <li>Else,
9124 <ol class="block">
9125 <li>Let <i>status</i> be <i>lexEnvRec</i>.CreateMutableBinding(<i>dn</i>, <b>false</b>).</li>
9126 </ol>
9127 </li>
9128 </ol>
9129 </li>
9130 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
9131 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9132 </ol>
9133 </li>
9134 <li>For each parsed grammar phrase <i>f</i> in <i>functionsToInitialize</i>, do
9135 <ol class="block">
9136 <li>Let <i>fn</i> be the sole element of the BoundNames of <i>f.</i></li>
9137 <li>Let <i>fo</i> be the result of performing InstantiateFunctionObject for <i>f</i> with argument <i>lexEnv</i>.</li>
9138 <li>Let <i>status</i> be <i>varEnvRec</i>.SetMutableBinding(<i>fn</i>, <i>fo</i>, <b>false</b>).</li>
9139 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
9140 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9141 </ol>
9142 </li>
9143 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>).</li>
9144 </ol>
9145
9146 <div class="note">
9147 <p><span class="nh">NOTE 1</span> <a
9148 href="#sec-block-level-function-declarations-web-legacy-compatibility-semantics">B.3.3</a> provides an extension to the
9149 above algorithm that is necessary for backwards compatibility with web browser implementations of ECMAScript that predate
9150 the sixth edition of ECMA-262.</p>
9151 </div>
9152
9153 <div class="note">
9154 <p><span class="nh">NOTE 2</span> Parameter <i>Initializers</i> may contain direct eval expressions (<a
9155 href="#sec-function-calls-runtime-semantics-evaluation">12.3.4.1</a>). Any top level declarations of such evals are only
9156 visible to the eval code (<a href="#sec-types-of-source-code">10.2</a>). The creation of the environment for such
9157 declarations is described in <a
9158 href="#sec-function-definitions-runtime-semantics-iteratorbindinginitialization">14.1.18</a>.</p>
9159 </div>
9160 </section>
9161 </section>
9162
9163 <section id="sec-built-in-function-objects">
9164 <div class="front">
9165 <h1><span class="secnum" id="sec-9.3"><a href="#sec-built-in-function-objects" title="link to this section">9.3</a></span>
9166 Built-in Function Objects</h1>
9167
9168 <p>The built-in function objects defined in this specification may be implemented as either ECMAScript function objects (<a
9169 href="#sec-ecmascript-function-objects">9.2</a>) whose behaviour is provided using ECMAScript code or as implementation
9170 provided exotic function objects whose behaviour is provided in some other manner. In either case, the effect of calling
9171 such functions must conform to their specifications. An implementation may also provide additional built-in function objects
9172 that are not defined in this specification.</p>
9173
9174 <p>If a built-in function object is implemented as an exotic object it must have the ordinary object behaviour specified in
9175 <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>. All such exotic function objects also have
9176 [[Prototype]], [[Extensible]], and [[Realm]] internal slots.</p>
9177
9178 <p>Unless otherwise specified every built-in function object has the %FunctionPrototype% object (<a
9179 href="#sec-properties-of-the-function-prototype-object">19.2.3</a>) as the initial value of its [[Prototype]] <a
9180 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</p>
9181
9182 <p>The behaviour specified for each built-in function via algorithm steps or other means is the specification of the
9183 function body behaviour for both [[Call]] and [[Construct]] invocations of the function. However, [[Construct]] invocation
9184 is not supported by all built-in functions. For each built-in function, when invoked with [[Call]], the [[Call]]
9185 <var>thisArgument</var> provides the <span class="value">this</span> value, the [[Call]] <var>argumentsList</var> provides
9186 the named parameters, and the NewTarget value is <span class="value">undefined</span>. When invoked with [[Construct]], the
9187 <span class="value">this</span> value is uninitialized, the [[Construct]] <var>argumentsList</var> provides the named
9188 parameters, and the [[Construct]] <var>newTarget</var> parameter provides the NewTarget value. If the built-in function is
9189 implemented as an <a href="#sec-ecmascript-function-objects">ECMAScript function object</a> then this specified behaviour
9190 must be implemented by the ECMAScript code that is the body of the function. Built-in functions that are ECMAScript function
9191 objects must be strict mode functions. If a built-in constructor has any [[Call]] behaviour other than throwing a <span
9192 class="value">TypeError</span> exception, an ECMAScript implementation of the function must be done in a manner that does
9193 not cause the function&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
9194 to have the value <code>"classConstructor"</code>.</p>
9195
9196 <p>Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method
9197 unless otherwise specified in the description of a particular function. When a built-in constructor is called as part of a
9198 <code>new</code> expression the <var>argumentsList</var> parameter of the invoked [[Construct]] internal method provides the
9199 values for the built-in constructor&rsquo;s named parameters.</p>
9200
9201 <p>Built-in functions that are not constructors do not have a <code>prototype</code> property unless otherwise specified in
9202 the description of a particular function.</p>
9203
9204 <p>If a built-in function object is not implemented as an ECMAScript function it must provide [[Call]] and [[Construct]]
9205 internal methods that conform to the following definitions:</p>
9206 </div>
9207
9208 <section id="sec-built-in-function-objects-call-thisargument-argumentslist">
9209 <h1><span class="secnum" id="sec-9.3.1"><a href="#sec-built-in-function-objects-call-thisargument-argumentslist"
9210 title="link to this section">9.3.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
9211
9212 <p>The [[Call]] internal method for a built-in function object <var>F</var> is called with parameters
9213 <var>thisArgument</var> and <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
9214 href="#sec-ecmascript-language-types">ECMAScript language values</a>. The following steps are taken:</p>
9215
9216 <ol class="proc">
9217 <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
9218 <li>If <i>callerContext</i> is not already <a href="#sec-execution-contexts">suspended</a>, <a
9219 href="#sec-execution-contexts">Suspend</a> <i>callerContext</i>.</li>
9220 <li>Let <i>calleeContext</i> be a new <a href="#sec-execution-contexts">ECMAScript code execution context</a>.</li>
9221 <li>Set the Function of <i>calleeContext</i> to <i>F</i>.</li>
9222 <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
9223 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
9224 <li>Set the <a href="#sec-code-realms">Realm</a> of <i>calleeContext</i> to <i>calleeRealm</i>.</li>
9225 <li>Perform any necessary implementation defined initialization of <i>calleeContext</i>.</li>
9226 <li>Push <i>calleeContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>calleeContext</i>
9227 is now <a href="#sec-execution-contexts">the running execution context</a>.</li>
9228 <li>Let <i>result</i> be the <a href="#sec-completion-record-specification-type">Completion Record</a> that is the result
9229 of evaluating <i>F</i> in an implementation defined manner that conforms to the specification of <i>F</i>.
9230 <i>thisArgument</i> is the <b>this</b> value, <i>argumentsList</i> provides the named parameters, and the NewTarget
9231 value is <b>undefined</b>.</li>
9232 <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
9233 <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
9234 <li>Return <i>result</i>.</li>
9235 </ol>
9236
9237 <div class="note">
9238 <p><span class="nh">NOTE 1</span> When <i>calleeContext</i> is removed from <a href="#sec-execution-contexts">the
9239 execution context stack</a> it must not be destroyed if it has been <a href="#sec-execution-contexts">suspended</a> and
9240 retained by an accessible generator object for later resumption<i>.</i></p>
9241 </div>
9242 </section>
9243
9244 <section id="sec-built-in-function-objects-construct-argumentslist-newtarget">
9245 <h1><span class="secnum" id="sec-9.3.2"><a href="#sec-built-in-function-objects-construct-argumentslist-newtarget"
9246 title="link to this section">9.3.2</a></span> [[Construct]] (argumentsList, newTarget)</h1>
9247
9248 <p>The [[Construct]] internal method for built-in function object <var>F</var> is called with parameters
9249 <var>argumentsList</var> and <var>newTarget</var>. The steps performed are the same as [[Call]] (<a
9250 href="#sec-built-in-function-objects-call-thisargument-argumentslist">see 9.3.1</a>) except that step 9 is replaced by:</p>
9251
9252 <ol class="proc">
9253 <li>Let <i>result</i> be the <a href="#sec-completion-record-specification-type">Completion Record</a> that is the result
9254 of evaluating <i>F</i> in an implementation defined manner that conforms to the specification of <i>F</i>. The
9255 <b>this</b> value is uninitialized, <i>argumentsList</i> provides the named parameters, and <i>newTarget</i> provides
9256 the NewTarget value.</li>
9257 </ol>
9258 </section>
9259
9260 <section id="sec-createbuiltinfunction">
9261 <h1><span class="secnum" id="sec-9.3.3"><a href="#sec-createbuiltinfunction" title="link to this section">9.3.3</a></span>
9262 CreateBuiltinFunction(realm, steps, prototype, internalSlotsList)</h1>
9263
9264 <p>The abstract operation CreateBuiltinFunction takes arguments <span style="font-family: Times New Roman"><i>realm</i>,
9265 <i>prototype</i>,</span> and <var>steps</var>. The optional argument <var>internalSlotsList</var> is a <a
9266 href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
9267 part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
9268 used. CreateBuiltinFunction returns a built-in function object created by the following steps:</p>
9269
9270 <ol class="proc">
9271 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>realm</i> is a <a href="#sec-code-realms">Realm</a> Record.</li>
9272 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>steps</i> is either a set of algorithm steps or other definition
9273 of a functions behaviour provided in this specification.</li>
9274 <li>Let <i>func</i> be a new built-in function object that when called performs the action described by <i>steps</i>. The
9275 new function object has internal slots whose names are the elements of <i>internalSlotsList</i>. The initial value of
9276 each of those internal slots is <b>undefined<i>.</i></b></li>
9277 <li>Set the [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i> to
9278 <i>realm</i>.</li>
9279 <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i> to
9280 <i>prototype</i>.</li>
9281 <li>Return <i>func</i>.</li>
9282 </ol>
9283
9284 <p>Each built-in function defined in this specification is created as if by calling the CreateBuiltinFunction abstract
9285 operation, unless otherwise specified.</p>
9286 </section>
9287 </section>
9288
9289 <section id="sec-built-in-exotic-object-internal-methods-and-slots">
9290 <div class="front">
9291 <h1><span class="secnum" id="sec-9.4"><a href="#sec-built-in-exotic-object-internal-methods-and-slots"
9292 title="link to this section">9.4</a></span> Built-in Exotic Object Internal Methods and Slots</h1>
9293
9294 <p>This specification defines several kinds of built-in exotic objects. These objects generally behave similar to ordinary
9295 objects except for a few specific situations. The following exotic objects use the ordinary object internal methods except
9296 where it is explicitly specified otherwise below:</p>
9297 </div>
9298
9299 <section id="sec-bound-function-exotic-objects">
9300 <div class="front">
9301 <h1><span class="secnum" id="sec-9.4.1"><a href="#sec-bound-function-exotic-objects"
9302 title="link to this section">9.4.1</a></span> Bound Function Exotic Objects</h1>
9303
9304 <p>A <i>bound function</i> is an exotic object that wraps another function object. A bound function is callable (it has a
9305 [[Call]] internal method and may have a [[Construct]] internal method). Calling a bound function generally results in a
9306 call of its wrapped function.</p>
9307
9308 <p>Bound function objects do not have the internal slots of ECMAScript function objects defined in <a
9309 href="#table-27">Table 27</a>. Instead they have the internal slots defined in <a href="#table-28">Table 28</a>.</p>
9310
9311 <figure>
9312 <figcaption><span id="table-28">Table 28</span> &mdash; Internal Slots of Exotic Bound Function Objects</figcaption>
9313 <table class="real-table">
9314 <tr>
9315 <th>Internal Slot</th>
9316 <th>Type</th>
9317 <th>Description</th>
9318 </tr>
9319 <tr>
9320 <td>[[BoundTargetFunction]]</td>
9321 <td>Callable Object</td>
9322 <td>The wrapped function object.</td>
9323 </tr>
9324 <tr>
9325 <td>[[BoundThis]]</td>
9326 <td>Any</td>
9327 <td>The value that is always passed as the <b>this</b> value when calling the wrapped function.</td>
9328 </tr>
9329 <tr>
9330 <td>[[BoundArguments]]</td>
9331 <td><a href="#sec-list-and-record-specification-type">List</a> of Any</td>
9332 <td>A list of values whose elements are used as the first arguments to any call to the wrapped function.</td>
9333 </tr>
9334 </table>
9335 </figure>
9336
9337 <p>Unlike ECMAScript function objects, bound function objects do not use an alternative definition of the
9338 [[GetOwnProperty]] internal methods. Bound function objects provide all of the essential internal methods as specified in
9339 <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>. However, they use the following definitions
9340 for the essential internal methods of function objects.</p>
9341 </div>
9342
9343 <section id="sec-bound-function-exotic-objects-call-thisargument-argumentslist">
9344 <h1><span class="secnum" id="sec-9.4.1.1"><a href="#sec-bound-function-exotic-objects-call-thisargument-argumentslist"
9345 title="link to this section">9.4.1.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
9346
9347 <p>When the [[Call]] internal method of an exotic <a href="#sec-bound-function-exotic-objects">bound function</a> object,
9348 <var>F</var>, which was created using the bind function is called with parameters <var>thisArgument</var> and
9349 <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
9350 href="#sec-ecmascript-language-types">ECMAScript language values</a>, the following steps are taken:</p>
9351
9352 <ol class="proc">
9353 <li>Let <i>target</i> be the value of <i>F&rsquo;s</i> <a
9354 href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
9355 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
9356 <li>Let <i>boundThis</i> be the value of <i>F&rsquo;s</i> <a href="#sec-bound-function-exotic-objects">[[BoundThis]]</a>
9357 <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
9358 <li>Let <i>boundArgs</i> be the value of <i>F&rsquo;s</i> <a
9359 href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
9360 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
9361 <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
9362 the same values as the list <i>argumentsList</i> in the same order.</li>
9363 <li>Return <a href="#sec-call">Call</a>(<i>target</i>, <i>boundThis</i>, <i>args</i>).</li>
9364 </ol>
9365 </section>
9366
9367 <section id="sec-bound-function-exotic-objects-construct-argumentslist-newtarget">
9368 <h1><span class="secnum" id="sec-9.4.1.2"><a href="#sec-bound-function-exotic-objects-construct-argumentslist-newtarget"
9369 title="link to this section">9.4.1.2</a></span> [[Construct]] (argumentsList, newTarget)</h1>
9370
9371 <p>When the [[Construct]] internal method of an exotic <a href="#sec-bound-function-exotic-objects">bound function</a>
9372 object, <var>F</var> that was created using the bind function is called with a list of arguments <span style="font-family:
9373 Times New Roman"><i>argumentsList</i> and <i>newTarget</i></span>, the following steps are taken:</p>
9374
9375 <ol class="proc">
9376 <li>Let <i>target</i> be the value of <i>F&rsquo;s</i> <a
9377 href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
9378 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
9379 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>target</i> has a [[Construct]] internal method.</li>
9380 <li>Let <i>boundArgs</i> be the value of <i>F&rsquo;s</i> <a
9381 href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
9382 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
9383 <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
9384 the same values as the list <i>argumentsList</i> in the same order.</li>
9385 <li>If <a href="#sec-samevalue">SameValue</a>(<i>F</i>, <i>newTarget</i>) is <b>true</b>, let <i>newTarget</i> be
9386 <i>target</i>.</li>
9387 <li>Return <a href="#sec-construct">Construct</a>(<i>target</i>, <i>args</i>, <i>newTarget</i>).</li>
9388 </ol>
9389 </section>
9390
9391 <section id="sec-boundfunctioncreate">
9392 <h1><span class="secnum" id="sec-9.4.1.3"><a href="#sec-boundfunctioncreate"
9393 title="link to this section">9.4.1.3</a></span> BoundFunctionCreate (targetFunction, boundThis, boundArgs)</h1>
9394
9395 <p>The abstract operation BoundFunctionCreate with arguments <var>targetFunction</var>, <var>boundThis</var> and
9396 <var>boundArgs</var> is used to specify the creation of new <a href="#sec-bound-function-exotic-objects">Bound
9397 Function</a> exotic objects. It performs the following steps:</p>
9398
9399 <ol class="proc">
9400 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
9401 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>targetFunction</i>) is Object.</li>
9402 <li>Let <i>proto</i> be <i>targetFunction</i>.[[GetPrototypeOf]]().</li>
9403 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
9404 <li>Let <i>obj</i> be a newly created object.</li>
9405 <li>Set <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
9406 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
9407 <li>Set the [[Call]] internal method of <i>obj</i> as described in <a
9408 href="#sec-bound-function-exotic-objects-call-thisargument-argumentslist">9.4.1.1</a>.</li>
9409 <li>If <i>targetFunction</i> has a [[Construct]] internal method, then
9410 <ol class="block">
9411 <li>Set the [[Construct]] internal method of <i>obj</i> as described in <a
9412 href="#sec-bound-function-exotic-objects-construct-argumentslist-newtarget">9.4.1.2</a>.</li>
9413 </ol>
9414 </li>
9415 <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
9416 <i>proto</i>.</li>
9417 <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
9418 <b>true</b>.</li>
9419 <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
9420 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
9421 <i>targetFunction</i>.</li>
9422 <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundThis]]</a> <a
9423 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to the value of
9424 <i>boundThis</i>.</li>
9425 <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
9426 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to <i>boundArgs</i>.</li>
9427 <li>Return <i>obj</i>.</li>
9428 </ol>
9429 </section>
9430 </section>
9431
9432 <section id="sec-array-exotic-objects">
9433 <div class="front">
9434 <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>
9435 Array Exotic Objects</h1>
9436
9437 <p>An <i>Array object</i> is an exotic object that gives special treatment to array index property keys (<a
9438 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>.
9439 Every Array object has a <code>length</code> property whose value is always a nonnegative integer less than <span
9440 style="font-family: Times New Roman">2<sup>32</sup></span>. The value of the <code>length</code> property is numerically
9441 greater than the name of every own property whose name is an array index; whenever an own property of an Array object is
9442 created or changed, other properties are adjusted as necessary to maintain this invariant. Specifically, whenever an own
9443 property is added whose name is an array index, the value of the <code>length</code> property is changed, if necessary, to
9444 be one more than the numeric value of that array index; and whenever the value of the <code>length</code> property is
9445 changed, every own property whose name is an array index whose value is not smaller than the new length is deleted. This
9446 constraint applies only to own properties of an Array object and is unaffected by <code>length</code> or array index
9447 properties that may be inherited from its prototypes.</p>
9448
9449 <div class="note">
9450 <p><span class="nh">NOTE</span> A String property name <i>P</i> is an <i>array index</i> if and only if <a
9451 href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>P</i>)) is equal to <i>P</i> and <a
9452 href="#sec-touint32">ToUint32</a>(<i>P</i>) is not equal to 2<sup>32</sup>&minus;1.</p>
9453 </div>
9454
9455 <p>Array exotic objects always have a non-configurable property named <code>"length"</code>.</p>
9456
9457 <p>Array exotic objects provide an alternative definition for the [[DefineOwnProperty]] internal method. Except for that
9458 internal method, Array exotic objects provide all of the other essential internal methods as specified in <a
9459 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
9460 </div>
9461
9462 <section id="sec-array-exotic-objects-defineownproperty-p-desc">
9463 <h1><span class="secnum" id="sec-9.4.2.1"><a href="#sec-array-exotic-objects-defineownproperty-p-desc"
9464 title="link to this section">9.4.2.1</a></span> [[DefineOwnProperty]] ( P, Desc)</h1>
9465
9466 <p>When the [[DefineOwnProperty]] internal method of an <a href="#sec-array-exotic-objects">Array exotic object</a>
9467 <var>A</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>, and <a
9468 href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
9469 steps are taken:</p>
9470
9471 <ol class="proc">
9472 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
9473 <b>true</b>.</li>
9474 <li>If <i>P</i> is <code>"length"</code>, then
9475 <ol class="block">
9476 <li>Return <a href="#sec-arraysetlength">ArraySetLength</a>(<i>A</i>, <i>Desc</i>).</li>
9477 </ol>
9478 </li>
9479 <li>Else if <i>P</i> is an array index, then
9480 <ol class="block">
9481 <li>Let <i>oldLenDesc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>A</i>,
9482 <code>"length"</code>).</li>
9483 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>oldLenDesc</i> will never be <b>undefined</b> or an accessor
9484 descriptor because Array objects are created with a length data property that cannot be deleted or
9485 reconfigured.</li>
9486 <li>Let <i>oldLen</i> be <i>oldLenDesc</i>.[[Value]].</li>
9487 <li>Let <i>index</i> be <a href="#sec-touint32">ToUint32</a>(<i>P</i>).</li>
9488 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>index</i> will never be an <a
9489 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9490 <li>If <i>index</i> &ge; <i>oldLen</i> and <i>oldLenDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
9491 <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
9492 <i>P</i>, <i>Desc</i>).</li>
9493 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
9494 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9495 <li>If <i>succeeded</i> is <b>false</b>, return <b>false</b>.</li>
9496 <li>If <i>index</i> &ge; <i>oldLen</i>
9497 <ol class="block">
9498 <li>Set <i>oldLenDesc</i>.[[Value]] to <i>index</i> + 1.</li>
9499 <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
9500 <code>"length"</code>, <i>oldLenDesc</i>).</li>
9501 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is <b>true</b>.</li>
9502 </ol>
9503 </li>
9504 <li>Return <b>true</b>.</li>
9505 </ol>
9506 </li>
9507 <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <i>P</i>, <i>Desc</i>).</li>
9508 </ol>
9509 </section>
9510
9511 <section id="sec-arraycreate">
9512 <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>
9513 ArrayCreate(length, proto)</h1>
9514
9515 <p>The abstract operation ArrayCreate with argument <var>length</var> (a positive integer) and optional argument
9516 <var>proto</var> is used to specify the creation of new Array exotic objects. It performs the following steps:</p>
9517
9518 <ol class="proc">
9519 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>length</i> is an integer Number &ge; 0.</li>
9520 <li>If <i>length</i> is &minus;0, let <i>length</i> be +0.</li>
9521 <li>If <i>length</i>&gt;2<sup>32</sup>-1, throw a <b>RangeError</b> exception.</li>
9522 <li>If the <i>proto</i> argument was not passed, let <i>proto</i> be the intrinsic object <span style="font-family:
9523 sans-serif">%ArrayPrototype%</span>.</li>
9524 <li>Let <i>A</i> be a newly created <a href="#sec-array-exotic-objects">Array exotic object</a>.</li>
9525 <li>Set <i>A</i>&rsquo;s essential internal methods except for [[DefineOwnProperty]] to the default ordinary object
9526 definitions specified in <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
9527 <li>Set the [[DefineOwnProperty]] internal method of <i>A</i> as specified in <a
9528 href="#sec-array-exotic-objects-defineownproperty-p-desc">9.4.2.1</a>.</li>
9529 <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
9530 <i>proto</i>.</li>
9531 <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
9532 <b>true</b>.</li>
9533 <li>Perform <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
9534 PropertyDescriptor{[[Value]]: <i>length</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
9535 [[Configurable]]: <b>false</b>}).</li>
9536 <li><a href="#sec-algorithm-conventions">Assert</a>: the preceding step never produces an <a
9537 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9538 <li>Return <i>A</i>.</li>
9539 </ol>
9540 </section>
9541
9542 <section id="sec-arrayspeciescreate">
9543 <h1><span class="secnum" id="sec-9.4.2.3"><a href="#sec-arrayspeciescreate"
9544 title="link to this section">9.4.2.3</a></span> ArraySpeciesCreate(originalArray, length)</h1>
9545
9546 <p>The abstract operation ArraySpeciesCreate with arguments <var>originalArray</var> and <var>length</var> is used to
9547 specify the creation of a new Array object using a constructor function that is derived from <var>originalArray</var>. It
9548 performs the following steps:</p>
9549
9550 <ol class="proc">
9551 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>length</i> is an integer Number &ge; 0.</li>
9552 <li>If <i>length</i> is &minus;0, let <i>length</i> be +0.</li>
9553 <li>Let <i>C</i> be <b>undefined</b>.</li>
9554 <li>Let <i>isArray</i> be <a href="#sec-isarray">IsArray</a>(<i>originalArray</i>).</li>
9555 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>isArray</i>).</li>
9556 <li>If <i>isArray</i> is <b>true</b>, then
9557 <ol class="block">
9558 <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>originalArray</i>, <code>"constructor"</code>).</li>
9559 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
9560 <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>C</i>) is <b>true</b>, then
9561 <ol class="block">
9562 <li>Let <i>thisRealm</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
9563 href="#sec-code-realms">Realm</a>.</li>
9564 <li>Let <i>realmC</i> be <a href="#sec-getfunctionrealm">GetFunctionRealm</a>(<i>C</i>).</li>
9565 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>realmC</i>).</li>
9566 <li>If <i>thisRealm</i> and <i>realmC</i> are not the same <a href="#sec-code-realms">Realm</a> Record, then
9567 <ol class="block">
9568 <li>If <a href="#sec-samevalue">SameValue</a>(<i>C</i>, <i>realmC</i>.[[intrinsics]].[[%Array%]]) is
9569 <b>true</b>, let <i>C</i> be <b>undefined</b>.</li>
9570 </ol>
9571 </li>
9572 </ol>
9573 </li>
9574 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>C</i>) is Object, then
9575 <ol class="block">
9576 <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, @@species).</li>
9577 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
9578 <li>If <i>C</i> is <b>null</b>, let <i>C</i> be <b>undefined</b>.</li>
9579 </ol>
9580 </li>
9581 </ol>
9582 </li>
9583 <li>If <i>C</i> is <b>undefined</b>, return <a href="#sec-arraycreate">ArrayCreate</a>(<i>length</i>).</li>
9584 <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>C</i>) is <b>false</b>, throw a <b>TypeError</b>
9585 exception<i>.</i></li>
9586 <li>Return <a href="#sec-construct">Construct</a>(<i>C</i>, &laquo;<i>length</i>&raquo;).</li>
9587 </ol>
9588
9589 <div class="note">
9590 <p><span class="nh">NOTE</span> If <i>originalArray</i> was created using the standard built-in Array constructor for a
9591 <a href="#sec-code-realms">Realm</a> that is not the <a href="#sec-code-realms">Realm</a> of <a
9592 href="#sec-execution-contexts">the running execution context</a>, then a new Array is created using the <a
9593 href="#sec-code-realms">Realm</a> of <a href="#sec-execution-contexts">the running execution context</a>. This maintains
9594 compatibility with Web browsers that have historically had that behaviour for the Array.prototype methods that now are
9595 defined using ArraySpeciesCreate.</p>
9596 </div>
9597 </section>
9598
9599 <section id="sec-arraysetlength">
9600 <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>
9601 ArraySetLength(A, Desc)</h1>
9602
9603 <p>When the abstract operation ArraySetLength is called with an <a href="#sec-array-exotic-objects">Array exotic
9604 object</a> <span style="font-family: Times New Roman"><i>A</i>,</span> and <a
9605 href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
9606 steps are taken:</p>
9607
9608 <ol class="proc">
9609 <li>If the [[Value]] field of <i>Desc</i> is absent, then
9610 <ol class="block">
9611 <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
9612 <i>Desc</i>).</li>
9613 </ol>
9614 </li>
9615 <li>Let <i>newLenDesc</i> be a copy of <i>Desc</i>.</li>
9616 <li>Let <i>newLen</i> be <a href="#sec-touint32">ToUint32</a>(<i>Desc</i>.[[Value]]).</li>
9617 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newLen</i>).</li>
9618 <li>Let <i>numberLen</i> be <a href="#sec-tonumber">ToNumber</a>(<i>Desc</i>.[[Value]]).</li>
9619 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newLen</i>).</li>
9620 <li>If <i>newLen</i> &ne; <i>numberLen</i>, throw a <b>RangeError</b> exception.</li>
9621 <li>Set <i>newLenDesc</i>.[[Value]] to <i>newLen</i>.</li>
9622 <li>Let <i>oldLenDesc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>A</i>,
9623 <code>"length"</code>).</li>
9624 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>oldLenDesc</i> will never be <b>undefined</b> or an accessor
9625 descriptor because Array objects are created with a length data property that cannot be deleted or
9626 reconfigured.</li>
9627 <li>Let <i>oldLen</i> be <i>oldLenDesc</i>.[[Value]].</li>
9628 <li>If <i>newLen</i> &ge;<i>oldLen</i>, then
9629 <ol class="block">
9630 <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
9631 <i>newLenDesc</i>).</li>
9632 </ol>
9633 </li>
9634 <li>If <i>oldLenDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
9635 <li>If <i>newLenDesc</i>.[[Writable]] is absent or has the value <b>true</b>, let <i>newWritable</i> be
9636 <b>true</b>.</li>
9637 <li>Else,
9638 <ol class="block">
9639 <li>Need to defer setting the [[Writable]] attribute to <b>false</b> in case any elements cannot be deleted.</li>
9640 <li>Let <i>newWritable</i> be <b>false</b>.</li>
9641 <li>Set <i>newLenDesc</i>.[[Writable]] to <b>true</b>.</li>
9642 </ol>
9643 </li>
9644 <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
9645 <code>"length"</code>, <i>newLenDesc</i>).</li>
9646 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
9647 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9648 <li>If <i>succeeded</i> is <b>false</b>, return <b>false</b>.</li>
9649 <li>While <i>newLen</i> &lt; <i>oldLen</i> repeat,
9650 <ol class="block">
9651 <li>Set <i>oldLen</i> to <i>oldLen</i> &ndash; 1.</li>
9652 <li>Let <i>deleteSucceeded</i> be <i>A</i>.[[Delete]](<a href="#sec-tostring">ToString</a>(<i>oldLen</i>)).</li>
9653 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>deleteSucceeded</i> is not an <a
9654 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9655 <li>If <i>deleteSucceeded</i> is <b>false</b>, then
9656 <ol class="block">
9657 <li>Set <i>newLenDesc</i>.[[Value]] to <i>oldLen</i> <i>+</i> 1.</li>
9658 <li>If <i>newWritable</i> is <b>false</b>, set <i>newLenDesc</i>.[[Writable]] to <b>false</b>.</li>
9659 <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
9660 <code>"length"</code>, <i>newLenDesc</i>).</li>
9661 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
9662 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9663 <li>Return <b>false</b>.</li>
9664 </ol>
9665 </li>
9666 </ol>
9667 </li>
9668 <li>If <i>newWritable</i> is <b>false</b>, then
9669 <ol class="block">
9670 <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
9671 PropertyDescriptor{[[Writable]]: <b>false</b>}). This call will always return <b>true</b>.</li>
9672 </ol>
9673 </li>
9674 <li>Return <b>true</b>.</li>
9675 </ol>
9676
9677 <div class="note">
9678 <p><span class="nh">NOTE</span> In steps 3 and 4, if <i>Desc</i>.[[Value]] is an object then its <code>valueOf</code>
9679 method is called twice. This is legacy behaviour that was specified with this effect starting with the 2<sup>nd</sup>
9680 Edition of this specification.</p>
9681 </div>
9682 </section>
9683 </section>
9684
9685 <section id="sec-string-exotic-objects">
9686 <div class="front">
9687 <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>
9688 String Exotic Objects</h1>
9689
9690 <p>A <i>String object</i> is an exotic object that encapsulates a String value and exposes virtual integer indexed data
9691 properties corresponding to the individual code unit elements of the string value. Exotic String objects always have a
9692 data property named <code>"length"</code> whose value is the number of code unit elements in the encapsulated String
9693 value. Both the code unit data properties and the <code>"length"</code> property are non-writable and
9694 non-configurable.</p>
9695
9696 <p>Exotic String objects have the same internal slots as ordinary objects. They also have a [[StringData]] internal
9697 slot.</p>
9698
9699 <p>Exotic String objects provide alternative definitions for the following internal methods. All of the other exotic
9700 String object essential internal methods that are not defined below are as specified in <a
9701 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
9702 </div>
9703
9704 <section id="sec-string-exotic-objects-getownproperty-p">
9705 <div class="front">
9706 <h1><span class="secnum" id="sec-9.4.3.1"><a href="#sec-string-exotic-objects-getownproperty-p"
9707 title="link to this section">9.4.3.1</a></span> [[GetOwnProperty]] ( P )</h1>
9708
9709 <p>When the [[GetOwnProperty]] internal method of an exotic String object <var>S</var> is called with <a
9710 href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
9711
9712 <ol class="proc">
9713 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
9714 <b>true</b>.</li>
9715 <li>Let <i>desc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>S</i>, <i>P</i>).</li>
9716 <li>If <i>desc</i> is not <b>undefined</b> return <i>desc</i>.</li>
9717 <li>Return <a href="#sec-stringgetindexproperty">StringGetIndexProperty</a>(<i>S</i>, <i>P</i>).</li>
9718 </ol>
9719 </div>
9720
9721 <section id="sec-stringgetindexproperty">
9722 <h1><span class="secnum" id="sec-9.4.3.1.1"><a href="#sec-stringgetindexproperty"
9723 title="link to this section">9.4.3.1.1</a></span> StringGetIndexProperty (S, P)</h1>
9724
9725 <p>When the abstract operation StringGetIndexProperty is called with an exotic String object <var>S</var> and with <a
9726 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
9727
9728 <ol class="proc">
9729 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is not String, return <b>undefined</b>.</li>
9730 <li>Let <i>index</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a> (<i>P</i>).</li>
9731 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>index</i> is not an <a
9732 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9733 <li>If <i>index</i> is <b>undefined</b>, return <b>undefined</b>.</li>
9734 <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>undefined</b>.</li>
9735 <li>If <i>index</i> = &minus;0, return <b>undefined</b>.</li>
9736 <li>Let <i>str</i> be the String value of the [[StringData]] <a
9737 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i>.</li>
9738 <li>Let <i>len</i> be the number of elements in <i>str</i>.</li>
9739 <li>If <i>index</i> &lt; 0 or <i>len</i> &le; <i>index</i>, return <b>undefined</b>.</li>
9740 <li>Let <i>resultStr</i> be a String value of length 1, containing one code unit from <i>str</i>, specifically the
9741 code unit at index <i>index</i>.</li>
9742 <li>Return a PropertyDescriptor{ [[Value]]: <i>resultStr</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>,
9743 [[Configurable]]: <b>false</b> }.</li>
9744 </ol>
9745 </section>
9746 </section>
9747
9748 <section id="sec-string-exotic-objects-hasproperty-p">
9749 <h1><span class="secnum" id="sec-9.4.3.2"><a href="#sec-string-exotic-objects-hasproperty-p"
9750 title="link to this section">9.4.3.2</a></span> [[HasProperty]](P)</h1>
9751
9752 <p>When the [[HasProperty]] internal method of an exotic String object <var>S</var> is called with <a
9753 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
9754
9755 <ol class="proc">
9756 <li>Let <i>elementDesc</i> be <a href="#sec-stringgetindexproperty">StringGetIndexProperty</a>(<i>S</i>, <i>P</i>).</li>
9757 <li>If <i>elementDesc</i> is not <b>undefined</b>, return <b>true</b>.</li>
9758 <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>S</i>, <i>P</i>)..</li>
9759 </ol>
9760 </section>
9761
9762 <section id="sec-string-exotic-objects-ownpropertykeys">
9763 <h1><span class="secnum" id="sec-9.4.3.3"><a href="#sec-string-exotic-objects-ownpropertykeys"
9764 title="link to this section">9.4.3.3</a></span> [[OwnPropertyKeys]] ( )</h1>
9765
9766 <p>When the [[OwnPropertyKeys]] internal method of a <a href="#sec-string-exotic-objects">String exotic object</a>
9767 <var>O</var> is called the following steps are taken:</p>
9768
9769 <ol class="proc">
9770 <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
9771 <li>Let <i>str</i> be the String value of the [[StringData]] <a
9772 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
9773 <li>Let <i>len</i> be the number of elements in <i>str</i>.</li>
9774 <li>For each integer <i>i</i> starting with 0 such that <i>i</i> &lt; <i>len</i>, in ascending order,
9775 <ol class="block">
9776 <li>Add <a href="#sec-tostring">ToString</a>(<i>i</i>) as the last element of <i>keys</i></li>
9777 </ol>
9778 </li>
9779 <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
9780 and <a href="#sec-tointeger">ToInteger</a>(<i>P</i>) &ge; <i>len</i>, in ascending numeric index order,
9781 <ol class="block">
9782 <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
9783 </ol>
9784 </li>
9785 <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
9786 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and <i>P</i> is not an integer index, in
9787 property creation order,
9788 <ol class="block">
9789 <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
9790 </ol>
9791 </li>
9792 <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
9793 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, in property creation order,
9794 <ol class="block">
9795 <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
9796 </ol>
9797 </li>
9798 <li>Return <i>keys</i>.</li>
9799 </ol>
9800 </section>
9801
9802 <section id="sec-stringcreate">
9803 <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>
9804 StringCreate( value, prototype)</h1>
9805
9806 <p>The abstract operation StringCreate with arguments <var>value</var> and <var>prototype</var> is used to specify the
9807 creation of new exotic String objects. It performs the following steps:</p>
9808
9809 <ol class="proc">
9810 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>prototype</i>).</li>
9811 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
9812 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>value</i>) is String.</li>
9813 <li>Let <i>S</i> be a newly created <a href="#sec-string-exotic-objects">String exotic object</a>.</li>
9814 <li>Set the [[StringData]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
9815 <i>value</i>.</li>
9816 <li>Set <i>S</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
9817 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
9818 <li>Set the [[GetOwnProperty]] internal method of <i>S</i> as specified in <a
9819 href="#sec-string-exotic-objects-getownproperty-p">9.4.3.1</a>.</li>
9820 <li>Set the [[HasProperty]] internal method of <i>S</i> as specified in <a
9821 href="#sec-string-exotic-objects-hasproperty-p">9.4.3.2</a>.</li>
9822 <li>Set the [[OwnPropertyKeys]] internal method of <i>S</i> as specified in <a
9823 href="#sec-string-exotic-objects-ownpropertykeys">9.4.3.3</a>.</li>
9824 <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
9825 <i>prototype</i>.</li>
9826 <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
9827 <b>true</b>.</li>
9828 <li>Let <i>length</i> be the number of code unit elements in <i>value.</i></li>
9829 <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>S</i>, <code>"length"</code>,
9830 PropertyDescriptor{[[Value]]: <i>length</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>,
9831 [[Configurable]]: <b>false</b> }).</li>
9832 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
9833 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9834 <li>Return <i>S</i>.</li>
9835 </ol>
9836 </section>
9837 </section>
9838
9839 <section id="sec-arguments-exotic-objects">
9840 <div class="front">
9841 <h1><span class="secnum" id="sec-9.4.4"><a href="#sec-arguments-exotic-objects"
9842 title="link to this section">9.4.4</a></span> Arguments Exotic Objects</h1>
9843
9844 <p>Most ECMAScript functions make an arguments objects available to their code. Depending upon the characteristics of the
9845 function definition, its argument object is either an ordinary object or an <i>arguments exotic object</i>. An arguments
9846 exotic object is an exotic object whose array index properties map to the formal parameters bindings of an invocation of
9847 its associated ECMAScript function.</p>
9848
9849 <p>Arguments exotic objects have the same internal slots as ordinary objects. They also have a [[ParameterMap]] internal
9850 slot. Ordinary arguments objects also have a [[ParameterMap]] internal slot whose value is always undefined. For ordinary
9851 argument objects the [[ParameterMap]] internal slot is only used by <code><a
9852 href="#sec-object.prototype.tostring">Object.prototype.toString</a></code> (<a
9853 href="#sec-object.prototype.tostring">19.1.3.6</a>) to identify them as such.</p>
9854
9855 <p>Arguments exotic objects provide alternative definitions for the following internal methods. All of the other exotic
9856 arguments object essential internal methods that are not defined below are as specified in <a
9857 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a></p>
9858
9859 <div class="note">
9860 <p><span class="nh">NOTE 1</span> For non-strict functions the integer indexed data properties of an arguments object
9861 whose numeric name values are less than the number of formal parameters of the corresponding function object initially
9862 share their values with the corresponding argument bindings in the function&rsquo;s <a
9863 href="#sec-execution-contexts">execution context</a>. This means that changing the property changes the corresponding
9864 value of the argument binding and vice-versa. This correspondence is broken if such a property is deleted and then
9865 redefined or if the property is changed into an accessor property. For strict mode functions, the values of the
9866 arguments object&rsquo;s properties are simply a copy of the arguments passed to the function and there is no dynamic
9867 linkage between the property values and the formal parameter values.</p>
9868 </div>
9869
9870 <div class="note">
9871 <p><span class="nh">NOTE 2</span> The ParameterMap object and its property values are used as a device for specifying
9872 the arguments object correspondence to argument bindings. The ParameterMap object and the objects that are the values of
9873 its properties are not directly observable from ECMAScript code. An ECMAScript implementation does not need to actually
9874 create or use such objects to implement the specified semantics.</p>
9875 </div>
9876
9877 <div class="note">
9878 <p><span class="nh">NOTE 3</span> Arguments objects for strict mode functions define non-configurable accessor
9879 properties named <code>"caller"</code> and <code>"callee"</code> which throw a <b>TypeError</b> exception on access. The
9880 <code>"callee"</code> property has a more specific meaning for non-strict functions and a <code>"caller"</code> property
9881 has historically been provided as an implementation-defined extension by some ECMAScript implementations. The strict
9882 mode definition of these properties exists to ensure that neither of them is defined in any other manner by conforming
9883 ECMAScript implementations.</p>
9884 </div>
9885 </div>
9886
9887 <section id="sec-arguments-exotic-objects-getownproperty-p">
9888 <h1><span class="secnum" id="sec-9.4.4.1"><a href="#sec-arguments-exotic-objects-getownproperty-p"
9889 title="link to this section">9.4.4.1</a></span> [[GetOwnProperty]] (P)</h1>
9890
9891 <p>The [[GetOwnProperty]] internal method of an arguments exotic object when called with a <a
9892 href="#sec-object-type">property key</a> <var>P</var> performs the following steps:</p>
9893
9894 <ol class="proc">
9895 <li>Let <i>args</i> be the arguments object.</li>
9896 <li>Let <i>desc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>args</i>, <i>P</i>).</li>
9897 <li>If <i>desc</i> is <b>undefined</b>, return <i>desc</i>.</li>
9898 <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
9899 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
9900 <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
9901 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is never an <a
9902 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9903 <li>If the value of <i>isMapped</i> is <b>true</b>, then
9904 <ol class="block">
9905 <li>Set <i>desc</i>.[[Value]] to <a href="#sec-get-o-p">Get</a>(<i>map</i>, <i>P</i>).</li>
9906 </ol>
9907 </li>
9908 <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>desc</i>) is <b>true</b> and <i>P</i> is
9909 <code>"caller"</code> and <i>desc</i>.[[Value]] is a strict mode Function object, throw a <b>TypeError</b>
9910 exception.</li>
9911 <li>Return <i>desc</i>.</li>
9912 </ol>
9913
9914 <p>If an implementation does not provide a built-in <code>caller</code> property for argument exotic objects then step 8
9915 of this algorithm is must be skipped.</p>
9916 </section>
9917
9918 <section id="sec-arguments-exotic-objects-defineownproperty-p-desc">
9919 <h1><span class="secnum" id="sec-9.4.4.2"><a href="#sec-arguments-exotic-objects-defineownproperty-p-desc"
9920 title="link to this section">9.4.4.2</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
9921
9922 <p>The [[DefineOwnProperty]] internal method of an arguments exotic object when called with a <a
9923 href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
9924 Descriptor</a> <span class="nt">Desc</span> performs the following steps:</p>
9925
9926 <ol class="proc">
9927 <li>Let <i>args</i> be the arguments object.</li>
9928 <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
9929 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
9930 <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
9931 <li>Let <i>allowed</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>args</i>, <i>P</i>,
9932 <i>Desc</i>).</li>
9933 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>allowed</i>).</li>
9934 <li>If <i>allowed</i> is <b>false</b>, return <b>false</b>.</li>
9935 <li>If the value of <i>isMapped</i> is <b>true</b>, then
9936 <ol class="block">
9937 <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
9938 <ol class="block">
9939 <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
9940 </ol>
9941 </li>
9942 <li>Else
9943 <ol class="block">
9944 <li>If <i>Desc</i>.[[Value]] is present, then
9945 <ol class="block">
9946 <li>Let <i>setStatus</i> be <a href="#sec-set-o-p-v-throw">Set</a>(<i>map</i>, <i>P</i>,
9947 <i>Desc</i>.[[Value]], <b>false</b>).</li>
9948 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>setStatus</i> is <b>true</b> because formal
9949 parameters mapped by argument objects are always writable.</li>
9950 </ol>
9951 </li>
9952 <li>If <i>Desc</i>.[[Writable]] is present and its value is <b>false</b>, then
9953 <ol class="block">
9954 <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
9955 </ol>
9956 </li>
9957 </ol>
9958 </li>
9959 </ol>
9960 </li>
9961 <li>Return <b>true</b>.</li>
9962 </ol>
9963 </section>
9964
9965 <section id="sec-arguments-exotic-objects-get-p-receiver">
9966 <h1><span class="secnum" id="sec-9.4.4.3"><a href="#sec-arguments-exotic-objects-get-p-receiver"
9967 title="link to this section">9.4.4.3</a></span> [[Get]] (P, Receiver)</h1>
9968
9969 <p>The [[Get]] internal method of an arguments exotic object when called with a <a href="#sec-object-type">property
9970 key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
9971 class="nt">Receiver</span> performs the following steps:</p>
9972
9973 <ol class="proc">
9974 <li>Let <i>args</i> be the arguments object.</li>
9975 <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
9976 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
9977 <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
9978 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
9979 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
9980 <li>If the value of <i>isMapped</i> is <b>false</b>, then
9981 <ol class="block">
9982 <li>Let <i>v</i> be the result of calling the default ordinary object [[Get]] internal method (<a
9983 href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>args</i> passing
9984 <i>P</i> and <i>Receiver</i> as the arguments.</li>
9985 </ol>
9986 </li>
9987 <li>Else <i>map</i> contains a formal parameter mapping for <i>P</i>,
9988 <ol class="block">
9989 <li>Let <i>v</i> be <a href="#sec-get-o-p">Get</a>(<i>map</i>, <i>P</i>).</li>
9990 </ol>
9991 </li>
9992 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>v</i>).</li>
9993 <li>Return <i>v</i>.</li>
9994 </ol>
9995 </section>
9996
9997 <section id="sec-arguments-exotic-objects-set-p-v-receiver">
9998 <h1><span class="secnum" id="sec-9.4.4.4"><a href="#sec-arguments-exotic-objects-set-p-v-receiver"
9999 title="link to this section">9.4.4.4</a></span> [[Set]] ( P, V, Receiver)</h1>
10000
10001 <p>The [[Set]] internal method of an arguments exotic object when called with <a href="#sec-object-type">property key</a>
10002 <var>P</var>, value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
10003 class="nt">Receiver</span> performs the following steps:</p>
10004
10005 <ol class="proc">
10006 <li>Let <i>args</i> be the arguments object.</li>
10007 <li>If <a href="#sec-samevalue">SameValue</a>(<i>args</i>, <i>Receiver</i>) is <b>false</b>, then
10008 <ol class="block">
10009 <li>Let <i>isMapped</i> be <b>false</b>.</li>
10010 </ol>
10011 </li>
10012 <li>Else,
10013 <ol class="block">
10014 <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
10015 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
10016 <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
10017 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
10018 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10019 </ol>
10020 </li>
10021 <li>If the value of <i>isMapped</i> is <b>false</b>, then
10022 <ol class="block">
10023 <li>Return the result of calling the default ordinary object [[Set]] internal method (<a
10024 href="#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver">9.1.9</a>) on <i>args</i>
10025 passing <i>P</i>, <i>V</i> and <i>Receiver</i> as the arguments.</li>
10026 </ol>
10027 </li>
10028 <li>Else <i>map</i> contains a formal parameter mapping for <i>P</i>,
10029 <ol class="block">
10030 <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>
10031 </ol>
10032 </li>
10033 </ol>
10034 </section>
10035
10036 <section id="sec-arguments-exotic-objects-delete-p">
10037 <h1><span class="secnum" id="sec-9.4.4.5"><a href="#sec-arguments-exotic-objects-delete-p"
10038 title="link to this section">9.4.4.5</a></span> [[Delete]] (P)</h1>
10039
10040 <p>The [[Delete]] internal method of an arguments exotic object when called with a <a href="#sec-object-type">property
10041 key</a> <var>P</var> performs the following steps:</p>
10042
10043 <ol class="proc">
10044 <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
10045 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
10046 <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
10047 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
10048 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10049 <li>Let <i>result</i> be the result of calling the default [[Delete]] internal method for ordinary objects (<a
10050 href="#sec-ordinary-object-internal-methods-and-internal-slots-delete-p">9.1.10</a>) on the arguments object passing
10051 <i>P</i> as the argument.</li>
10052 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
10053 <li>If <i>result</i> is <b>true</b> and the value of <i>isMapped</i> is <b>true</b>, then
10054 <ol class="block">
10055 <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
10056 </ol>
10057 </li>
10058 <li>Return <i>result</i>.</li>
10059 </ol>
10060 </section>
10061
10062 <section id="sec-createunmappedargumentsobject">
10063 <h1><span class="secnum" id="sec-9.4.4.6"><a href="#sec-createunmappedargumentsobject"
10064 title="link to this section">9.4.4.6</a></span> CreateUnmappedArgumentsObject(argumentsList)</h1>
10065
10066 <p>The abstract operation <span style="font-family: Times New Roman">CreateUnmappedArgumentsObject</span> called with an
10067 argument <var>argumentsList</var> performs the following steps:</p>
10068
10069 <ol class="proc">
10070 <li>Let <i>len</i> be the number of elements in <i>argumentsList</i>.</li>
10071 <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%ObjectPrototype%,
10072 &laquo;&zwj;[[ParameterMap]]&raquo;).</li>
10073 <li>Set <i>obj</i>&rsquo;s [[ParameterMap]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
10074 to <b>undefined</b>.</li>
10075 <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"length"</code>,
10076 PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
10077 <b>true</b>}).</li>
10078 <li>Let <i>index</i> be 0.</li>
10079 <li>Repeat while <i>index</i> &lt; <i>len</i>,
10080 <ol class="block">
10081 <li>Let <i>val</i> be <i>argumentsList</i>[<i>index</i>].</li>
10082 <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <a
10083 href="#sec-tostring">ToString</a>(<i>index</i>), <i>val</i>).</li>
10084 <li>Let <i>index</i> be <i>index</i> + 1</li>
10085 </ol>
10086 </li>
10087 <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, @@iterator, PropertyDescriptor
10088 {[[Value]]:%ArrayProto_values%, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
10089 <b>true</b>}).</li>
10090 <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"caller"</code>,
10091 PropertyDescriptor {[[Get]]: <a href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Set]]: <a
10092 href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
10093 <b>false</b>}).</li>
10094 <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"callee"</code>,
10095 PropertyDescriptor {[[Get]]: <a href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Set]]: <a
10096 href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
10097 <b>false</b>}).</li>
10098 <li><a href="#sec-algorithm-conventions">Assert</a>: the above property definitions will not produce an <a
10099 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10100 <li>Return <i>obj</i></li>
10101 </ol>
10102 </section>
10103
10104 <section id="sec-createmappedargumentsobject">
10105 <div class="front">
10106 <h1><span class="secnum" id="sec-9.4.4.7"><a href="#sec-createmappedargumentsobject"
10107 title="link to this section">9.4.4.7</a></span> CreateMappedArgumentsObject ( func, formals, argumentsList, env
10108 )</h1>
10109
10110 <p>The abstract operation <span style="font-family: Times New Roman">CreateMappedArgumentsObject</span> is called with
10111 object <var>func</var>, parsed grammar phrase <var>formals</var>, <a
10112 href="#sec-list-and-record-specification-type">List</a> <var>argumentsList</var>, and <a
10113 href="#sec-environment-records">Environment Record</a> <span style="font-family: Times New Roman"><i>env</i>.</span> The
10114 following steps are performed:</p>
10115
10116 <ol class="proc">
10117 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>formals</i> does not contain a rest parameter, any binding
10118 patterns, or any initializers. It may contain duplicate identifiers.</li>
10119 <li>Let <i>len</i> be the number of elements in <i>argumentsList</i>.</li>
10120 <li>Let <i>obj</i> be a newly created arguments exotic object with a [[ParameterMap]] <a
10121 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10122 <li>Set the [[GetOwnProperty]] internal method of <i>obj</i> as specified in <a
10123 href="#sec-arguments-exotic-objects-getownproperty-p">9.4.4.1</a>.</li>
10124 <li>Set the [[DefineOwnProperty]] internal method of <i>obj</i> as specified in <a
10125 href="#sec-arguments-exotic-objects-defineownproperty-p-desc">9.4.4.2</a>.</li>
10126 <li>Set the [[Get]] internal method of <i>obj</i> as specified in <a
10127 href="#sec-arguments-exotic-objects-get-p-receiver">9.4.4.3</a>.</li>
10128 <li>Set the [[Set]] internal method of <i>obj</i> as specified in <a
10129 href="#sec-arguments-exotic-objects-set-p-v-receiver">9.4.4.4</a>.</li>
10130 <li>Set the [[Delete]] internal method of <i>obj</i> as specified in <a
10131 href="#sec-arguments-exotic-objects-delete-p">9.4.4.5</a>.</li>
10132 <li>Set the remainder of <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions
10133 specified in <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
10134 <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
10135 %ObjectPrototype%.</li>
10136 <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i>
10137 to <b>true</b>.</li>
10138 <li>Let <i>parameterNames</i> be the BoundNames of <i>formals</i>.</li>
10139 <li>Let <i>numberOfParameters</i> be the number of elements in <i>parameterNames</i></li>
10140 <li>Let <i>index</i> be 0.</li>
10141 <li>Repeat while <i>index</i> &lt; <i>len</i> ,
10142 <ol class="block">
10143 <li>Let <i>val</i> be <i>argumentsList</i>[<i>index</i>].</li>
10144 <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <a
10145 href="#sec-tostring">ToString</a>(<i>index</i>), <i>val</i>).</li>
10146 <li>Let <i>index</i> be <i>index</i> + 1</li>
10147 </ol>
10148 </li>
10149 <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"length"</code>,
10150 PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
10151 [[Configurable]]: <b>true</b>}).</li>
10152 <li>Let <i>map</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<b>null</b>).</li>
10153 <li>Let <i>mappedNames</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
10154 <li>Let <i>index</i> be <i>numberOfParameters</i> &minus; 1.</li>
10155 <li>Repeat while <i>index</i> &ge; 0 ,
10156 <ol class="block">
10157 <li>Let <i>name</i> be <i>parameterNames</i>[<i>index</i>].</li>
10158 <li>If <i>name</i> is not an element of <i>mappedNames</i>, then
10159 <ol class="block">
10160 <li>Add <i>name</i> as an element of the list <i>mappedNames</i>.</li>
10161 <li>If <i>index</i> &lt; <i>len</i>, then
10162 <ol class="block">
10163 <li>Let <i>g</i> be <a href="#sec-makearggetter">MakeArgGetter</a>(<i>name</i>, <i>env</i>).</li>
10164 <li>Let <i>p</i> be <a href="#sec-makeargsetter">MakeArgSetter</a>(<i>name</i>, <i>env</i>).</li>
10165 <li><a href="#sec-call">Call</a> <i>map</i>.[[DefineOwnProperty]](<a
10166 href="#sec-tostring">ToString</a>(<i>index</i>), PropertyDescriptor{[[Set]]: <i>p</i>, [[Get]]:
10167 <i>g,</i> [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>true</b>}).</li>
10168 </ol>
10169 </li>
10170 </ol>
10171 </li>
10172 <li>Let <i>index</i> be <i>index</i> &minus; 1</li>
10173 </ol>
10174 </li>
10175 <li>Set the [[ParameterMap]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i>
10176 to <i>map</i>.</li>
10177 <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, @@iterator, PropertyDescriptor
10178 {[[Value]]:%ArrayProto_values%, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
10179 <b>true</b>}).</li>
10180 <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"callee"</code>,
10181 PropertyDescriptor {[[Value]]: <i>func</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
10182 [[Configurable]]: <b>true</b>}).</li>
10183 <li><a href="#sec-algorithm-conventions">Assert</a>: the above property definitions will not produce an <a
10184 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10185 <li>Return <i>obj</i></li>
10186 </ol>
10187 </div>
10188
10189 <section id="sec-makearggetter">
10190 <h1><span class="secnum" id="sec-9.4.4.7.1"><a href="#sec-makearggetter"
10191 title="link to this section">9.4.4.7.1</a></span> MakeArgGetter ( name, env)</h1>
10192
10193 <p>The abstract operation <span style="font-family: Times New Roman">MakeArgGetter</span> called with String
10194 <var>name</var> and <a href="#sec-environment-records">Environment Record</a> <var>env</var> creates a built-in function
10195 object that when executed returns the value bound for <var>name</var> in <var>env</var>. It performs the following
10196 steps:</p>
10197
10198 <ol class="proc">
10199 <li>Let <i>realm</i> be <a href="#sec-execution-contexts">the current Realm</a>.</li>
10200 <li>Let <i>steps</i> be the steps of an ArgGetter function as specified below.</li>
10201 <li>Let <i>getter</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realm</i>, <i>steps</i>,
10202 %FunctionPrototype%, &laquo;&zwj;[[name]], [[env]]&raquo; ).</li>
10203 <li>Set <i>getter&rsquo;s</i> [[name]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
10204 <i>name</i>.</li>
10205 <li>Set <i>getter&rsquo;s</i> [[env]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
10206 <i>env</i>.</li>
10207 <li>Return <i>getter</i>.</li>
10208 </ol>
10209
10210 <p>An ArgGetter function is an anonymous built-in function with [[name]] and [[env]] internal slots. When an ArgGetter
10211 function <var>f</var> that expects no arguments is called it performs the following steps:</p>
10212
10213 <ol class="proc">
10214 <li>Let <i>name</i> be the value of <i>f&rsquo;s</i> [[name]] <a
10215 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10216 <li>Let <i>env</i> be the value of <i>f&rsquo;s</i> [[env]] <a
10217 href="#sec-object-internal-methods-and-internal-slots">internal slot</a></li>
10218 <li>Return <i>env</i>.GetBindingValue(<i>name</i>, <b>false</b>).</li>
10219 </ol>
10220
10221 <div class="note">
10222 <p><span class="nh">NOTE</span> ArgGetter functions are never directly accessible to ECMAScript code.</p>
10223 </div>
10224 </section>
10225
10226 <section id="sec-makeargsetter">
10227 <h1><span class="secnum" id="sec-9.4.4.7.2"><a href="#sec-makeargsetter"
10228 title="link to this section">9.4.4.7.2</a></span> MakeArgSetter ( name, env)</h1>
10229
10230 <p>The abstract operation <span style="font-family: Times New Roman">MakeArgSetter</span> called with String
10231 <var>name</var> and <a href="#sec-environment-records">Environment Record</a> <var>env</var> creates a built-in function
10232 object that when executed sets the value bound for <var>name</var> in <var>env</var>. It performs the following
10233 steps:</p>
10234
10235 <ol class="proc">
10236 <li>Let <i>realm</i> be <a href="#sec-execution-contexts">the current Realm</a>.</li>
10237 <li>Let <i>steps</i> be the steps of an ArgSetter function as specified below.</li>
10238 <li>Let <i>setter</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realm</i>, <i>steps</i>,
10239 %FunctionPrototype%, &laquo;&zwj;[[name]], [[env]]&raquo; ).</li>
10240 <li>Set <i>setter&rsquo;s</i> [[name]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
10241 <i>name</i>.</li>
10242 <li>Set <i>setter&rsquo;s</i> [[env]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
10243 <i>env</i>.</li>
10244 <li>Return <i>setter</i>.</li>
10245 </ol>
10246
10247 <p>An ArgSetter function is an anonymous built-in function with [[name]] and [[env]] internal slots. When an ArgSetter
10248 function <var>f</var> is called with argument <var>value</var> it performs the following steps:</p>
10249
10250 <ol class="proc">
10251 <li>Let <i>name</i> be the value of <i>f&rsquo;s</i> [[name]] <a
10252 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10253 <li>Let <i>env</i> be the value of <i>f&rsquo;s</i> [[env]] <a
10254 href="#sec-object-internal-methods-and-internal-slots">internal slot</a></li>
10255 <li>Return <i>env</i>.SetMutableBinding(<i>name</i>, <i>value</i>, <b>false</b>).</li>
10256 </ol>
10257
10258 <div class="note">
10259 <p><span class="nh">NOTE</span> ArgSetter functions are never directly accessible to ECMAScript code.</p>
10260 </div>
10261 </section>
10262 </section>
10263 </section>
10264
10265 <section id="sec-integer-indexed-exotic-objects">
10266 <div class="front">
10267 <h1><span class="secnum" id="sec-9.4.5"><a href="#sec-integer-indexed-exotic-objects"
10268 title="link to this section">9.4.5</a></span> Integer Indexed Exotic Objects</h1>
10269
10270 <p>An <i>Integer Indexed object</i> is an exotic object that performs special handling of integer index property keys.</p>
10271
10272 <p>Integer Indexed exotic objects have the same internal slots as ordinary objects additionally [[ViewedArrayBuffer]],
10273 [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</p>
10274
10275 <p>Integer Indexed Exotic objects provide alternative definitions for the following internal methods. All of the other
10276 Integer Indexed exotic object essential internal methods that are not defined below are as specified in <a
10277 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
10278 </div>
10279
10280 <section id="sec-integer-indexed-exotic-objects-getownproperty-p">
10281 <h1><span class="secnum" id="sec-9.4.5.1"><a href="#sec-integer-indexed-exotic-objects-getownproperty-p"
10282 title="link to this section">9.4.5.1</a></span> [[GetOwnProperty]] ( P )</h1>
10283
10284 <p>When the [[GetOwnProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
10285 href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
10286
10287 <ol class="proc">
10288 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
10289 <b>true</b>.</li>
10290 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
10291 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10292 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
10293 <ol class="block">
10294 <li>Let <i>numericIndex</i> be <a
10295 href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>(<i>P</i>).</li>
10296 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
10297 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10298 <li>If <i>numericIndex</i> is not <b>undefined</b>, then
10299 <ol class="block">
10300 <li>Let <i>value</i> be <a href="#sec-integerindexedelementget">IntegerIndexedElementGet</a> (<i>O</i>,
10301 <i>numericIndex</i>).</li>
10302 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
10303 <li>If <i>value</i> is <b>undefined</b>, return <b>undefined</b>.</li>
10304 <li>Return a PropertyDescriptor{ [[Value]]: <i>value</i>, [[Enumerable]]: <b>true</b>, [[Writable]]:
10305 <b>true</b>, [[Configurable]]: <b>false</b> }.</li>
10306 </ol>
10307 </li>
10308 </ol>
10309 </li>
10310 <li>Return <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
10311 </ol>
10312 </section>
10313
10314 <section id="sec-integer-indexed-exotic-objects-hasproperty-p">
10315 <h1><span class="secnum" id="sec-9.4.5.2"><a href="#sec-integer-indexed-exotic-objects-hasproperty-p"
10316 title="link to this section">9.4.5.2</a></span> [[HasProperty]](P)</h1>
10317
10318 <p>When the [[HasProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
10319 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
10320
10321 <ol class="proc">
10322 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
10323 <b>true</b>.</li>
10324 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
10325 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10326 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
10327 <ol class="block">
10328 <li>Let <i>numericIndex</i> be <a
10329 href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>(<i>P</i>).</li>
10330 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
10331 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10332 <li>If <i>numericIndex</i> is not <b>undefined</b>, then
10333 <ol class="block">
10334 <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
10335 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10336 <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a
10337 <b>TypeError</b> exception.</li>
10338 <li>If <a href="#sec-isinteger">IsInteger</a>(<i>numericIndex</i>) is <b>false</b>, return <b>false</b></li>
10339 <li>If <i>numericIndex</i> = &minus;0, return <b>false</b>.</li>
10340 <li>If <i>numericIndex</i> &lt; 0, return <b>false</b>.</li>
10341 <li>If <i>numericIndex</i> &ge; the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
10342 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, return <b>false</b>.</li>
10343 <li>Return <b>true</b>.</li>
10344 </ol>
10345 </li>
10346 </ol>
10347 </li>
10348 <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
10349 </ol>
10350 </section>
10351
10352 <section id="sec-integer-indexed-exotic-objects-defineownproperty-p-desc">
10353 <h1><span class="secnum" id="sec-9.4.5.3"><a href="#sec-integer-indexed-exotic-objects-defineownproperty-p-desc"
10354 title="link to this section">9.4.5.3</a></span> [[DefineOwnProperty]] ( P, Desc)</h1>
10355
10356 <p>When the [[DefineOwnProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
10357 href="#sec-object-type">property key</a> <var>P</var>, and <a href="#sec-property-descriptor-specification-type">Property
10358 Descriptor</a> <span class="nt">Desc</span> the following steps are taken:</p>
10359
10360 <ol class="proc">
10361 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
10362 <b>true</b>.</li>
10363 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
10364 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10365 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
10366 <ol class="block">
10367 <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
10368 (<i>P</i>).</li>
10369 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
10370 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10371 <li>If <i>numericIndex</i> is not <b>undefined</b>, then
10372 <ol class="block">
10373 <li>If <a href="#sec-isinteger">IsInteger</a>(<i>numericIndex</i>) is <b>false</b>, return <b>false</b></li>
10374 <li>Let <i>intIndex</i> be <i>numericIndex</i>.</li>
10375 <li>If <i>intIndex</i> = &minus;0, return <b>false</b>.</li>
10376 <li>If <i>intIndex</i> &lt; 0, return <b>false</b>.</li>
10377 <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
10378 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10379 <li>If <i>intIndex</i> &ge; <i>length</i>, return <b>false</b>.</li>
10380 <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) is <b>true</b>, return
10381 <b>false.</b></li>
10382 <li>If <i>Desc</i> has a [[Configurable]] field and if <i>Desc</i>.[[Configurable]] is <b>true</b>, return
10383 <b>false<i>.</i></b></li>
10384 <li>If <i>Desc</i> has an [[Enumerable]] field and if <i>Desc</i>.[[Enumerable]] is <b>false</b>, return
10385 <b>false<i>.</i></b></li>
10386 <li>If <i>Desc</i> has a [[Writable]] field and if <i>Desc</i>.[[Writable]] is <b>false</b>, return
10387 <b>false</b>.</li>
10388 <li>If <i>Desc</i> has a [[Value]] field, then
10389 <ol class="block">
10390 <li>Let <i>value</i> be <i>Desc</i>.[[Value]].</li>
10391 <li>Return <a href="#sec-integerindexedelementset">IntegerIndexedElementSet</a> (<i>O</i>, <i>intIndex</i>,
10392 <i>value</i>).</li>
10393 </ol>
10394 </li>
10395 <li>Return <b>true</b>.</li>
10396 </ol>
10397 </li>
10398 </ol>
10399 </li>
10400 <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>O</i>, <i>P</i>, <i>Desc</i>).</li>
10401 </ol>
10402 </section>
10403
10404 <section id="sec-integer-indexed-exotic-objects-get-p-receiver">
10405 <h1><span class="secnum" id="sec-9.4.5.4"><a href="#sec-integer-indexed-exotic-objects-get-p-receiver"
10406 title="link to this section">9.4.5.4</a></span> [[Get]] (P, Receiver)</h1>
10407
10408 <p>When the [[Get]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
10409 href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language
10410 value</a> <span class="nt">Receiver</span> the following steps are taken:</p>
10411
10412 <ol class="proc">
10413 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
10414 <b>true</b>.</li>
10415 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and if <a
10416 href="#sec-samevalue">SameValue</a>(<i>O</i>, <i>Receiver</i>) is <b>true</b>, then
10417 <ol class="block">
10418 <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
10419 (<i>P</i>).</li>
10420 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
10421 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10422 <li>If <i>numericIndex</i> is not <b>undefined</b>, then
10423 <ol class="block">
10424 <li>Return <a href="#sec-integerindexedelementget">IntegerIndexedElementGet</a> (<i>O</i>,
10425 <i>numericIndex</i>).</li>
10426 </ol>
10427 </li>
10428 </ol>
10429 </li>
10430 <li>Return the result of calling the default ordinary object [[Get]] internal method (<a
10431 href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
10432 <i>P</i> and <i>Receiver</i> as arguments.</li>
10433 </ol>
10434 </section>
10435
10436 <section id="sec-integer-indexed-exotic-objects-set-p-v-receiver">
10437 <h1><span class="secnum" id="sec-9.4.5.5"><a href="#sec-integer-indexed-exotic-objects-set-p-v-receiver"
10438 title="link to this section">9.4.5.5</a></span> [[Set]] ( P, V, Receiver)</h1>
10439
10440 <p>When the [[Set]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
10441 href="#sec-object-type">property key</a> <var>P</var>, value <var>V</var>, and <a
10442 href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span>, the following steps
10443 are taken:</p>
10444
10445 <ol class="proc">
10446 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
10447 <b>true</b>.</li>
10448 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and if <a
10449 href="#sec-samevalue">SameValue</a>(<i>O</i>, <i>Receiver</i>) is <b>true</b>, then
10450 <ol class="block">
10451 <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
10452 (<i>P</i>).</li>
10453 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
10454 href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
10455 <li>If <i>numericIndex</i> is not <b>undefined</b>, then
10456 <ol class="block">
10457 <li>Return <a href="#sec-integerindexedelementset">IntegerIndexedElementSet</a> (<i>O</i>, <i>numericIndex</i>,
10458 <i>V</i>).</li>
10459 </ol>
10460 </li>
10461 </ol>
10462 </li>
10463 <li>Return the result of calling the default ordinary object [[Set]] internal method (<a
10464 href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
10465 <i>P</i>, <i>V</i>, and <i>Receiver</i> as arguments.</li>
10466 </ol>
10467 </section>
10468
10469 <section id="sec-integer-indexed-exotic-objects-ownpropertykeys">
10470 <h1><span class="secnum" id="sec-9.4.5.6"><a href="#sec-integer-indexed-exotic-objects-ownpropertykeys"
10471 title="link to this section">9.4.5.6</a></span> [[OwnPropertyKeys]] ()</h1>
10472
10473 <p>When the [[OwnPropertyKeys]] internal method of an Integer Indexed exotic object <var>O</var> is called the following
10474 steps are taken:</p>
10475
10476 <ol class="proc">
10477 <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
10478 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
10479 [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
10480 <li>Let <i>len</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
10481 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10482 <li>For each integer <i>i</i> starting with 0 such that <i>i</i> &lt; <i>len</i>, in ascending order,
10483 <ol class="block">
10484 <li>Add <a href="#sec-tostring">ToString</a>(<i>i</i>) as the last element of <i>keys</i>.</li>
10485 </ol>
10486 </li>
10487 <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
10488 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and <i>P</i> is not an integer index, in
10489 property creation order
10490 <ol class="block">
10491 <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
10492 </ol>
10493 </li>
10494 <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
10495 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, in property creation order
10496 <ol class="block">
10497 <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
10498 </ol>
10499 </li>
10500 <li>Return <i>keys</i>.</li>
10501 </ol>
10502 </section>
10503
10504 <section id="sec-integerindexedobjectcreate">
10505 <h1><span class="secnum" id="sec-9.4.5.7"><a href="#sec-integerindexedobjectcreate"
10506 title="link to this section">9.4.5.7</a></span> IntegerIndexedObjectCreate <span style="font-family:
10507 sans-serif">(prototype, internalSlotsList)</span></h1>
10508
10509 <p>The abstract operation IntegerIndexedObjectCreate with arguments <var>prototype</var> and <var>internalSlotsList</var>
10510 is used to specify the creation of new Integer Indexed exotic objects. The argument <var>internalSlotsList</var> is a <a
10511 href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
10512 part of the object. IntegerIndexedObjectCreate performs the following steps:</p>
10513
10514 <ol class="proc">
10515 <li>Let <i>A</i> be a newly created object with an <a href="#sec-object-internal-methods-and-internal-slots">internal
10516 slot</a> for each name in <i>internalSlotsList</i>.</li>
10517 <li>Set <i>A</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
10518 href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
10519 <li>Set the [[GetOwnProperty]] internal method of <i>A</i> as specified in <a
10520 href="#sec-integer-indexed-exotic-objects-getownproperty-p">9.4.5.1</a>.</li>
10521 <li>Set the [[HasProperty]] internal method of <i>A</i> as specified in <a
10522 href="#sec-integer-indexed-exotic-objects-hasproperty-p">9.4.5.2</a>.</li>
10523 <li>Set the [[DefineOwnProperty]] internal method of <i>A</i> as specified in <a
10524 href="#sec-integer-indexed-exotic-objects-defineownproperty-p-desc">9.4.5.3</a>.</li>
10525 <li>Set the [[Get]] internal method of <i>A</i> as specified in <a
10526 href="#sec-integer-indexed-exotic-objects-get-p-receiver">9.4.5.4</a>.</li>
10527 <li>Set the [[Set]] internal method of <i>A</i> as specified in <a
10528 href="#sec-integer-indexed-exotic-objects-set-p-v-receiver">9.4.5.5</a>.</li>
10529 <li>Set the [[OwnPropertyKeys]] internal method of <i>A</i> as specified in <a
10530 href="#sec-integer-indexed-exotic-objects-ownpropertykeys">9.4.5.6</a>.</li>
10531 <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
10532 <i>prototype</i>.</li>
10533 <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
10534 <b>true</b>.</li>
10535 <li>Return <i>A</i>.</li>
10536 </ol>
10537 </section>
10538
10539 <section id="sec-integerindexedelementget">
10540 <h1><span class="secnum" id="sec-9.4.5.8"><a href="#sec-integerindexedelementget"
10541 title="link to this section">9.4.5.8</a></span> IntegerIndexedElementGet ( O, index )</h1>
10542
10543 <p>The abstract operation IntegerIndexedElementGet with arguments <var>O</var> and <var>index</var> performs the following
10544 steps:</p>
10545
10546 <ol class="proc">
10547 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
10548 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>index</i>) is Number.</li>
10549 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
10550 [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
10551 <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
10552 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10553 <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a <b>TypeError</b>
10554 exception.</li>
10555 <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>undefined</b></li>
10556 <li>If <i>index</i> = &minus;0, return <b>undefined</b>.</li>
10557 <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
10558 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10559 <li>If <i>index</i> &lt; 0 or <i>index</i> &ge; <i>length</i>, return <b>undefined</b>.</li>
10560 <li>Let <i>offset</i> be the value of <i>O</i>&rsquo;s [[ByteOffset]] <a
10561 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10562 <li>Let <i>arrayTypeName</i> be the string value of <i>O</i>&rsquo;s [[TypedArrayName]] <a
10563 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10564 <li>Let <i>elementSize</i> be the Number value of the Element Size value specified in <a href="#table-49">Table 49</a>
10565 for <i>arrayTypeName</i>.</li>
10566 <li>Let <i>indexedPosition</i> = (<i>index</i> &times; <i>elementSize</i>) + <i>offset</i>.</li>
10567 <li>Let <i>elementType</i> be the string value of the Element Type value in <a href="#table-49">Table 49</a> for
10568 <i>arrayTypeName</i>.</li>
10569 <li>Return <a href="#sec-getvaluefrombuffer">GetValueFromBuffer</a>(<i>buffer</i>, <i>indexedPosition</i>,
10570 <i>elementType</i>).</li>
10571 </ol>
10572 </section>
10573
10574 <section id="sec-integerindexedelementset">
10575 <h1><span class="secnum" id="sec-9.4.5.9"><a href="#sec-integerindexedelementset"
10576 title="link to this section">9.4.5.9</a></span> IntegerIndexedElementSet ( O, index, value )</h1>
10577
10578 <p>The abstract operation IntegerIndexedElementSet with arguments <var>O</var>, <var>index</var>, and <var>value</var>
10579 performs the following steps:</p>
10580
10581 <ol class="proc">
10582 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
10583 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>index</i>) is Number.</li>
10584 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
10585 [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
10586 <li>Let <i>numValue</i> be <a href="#sec-tonumber">ToNumber</a>(<i>value</i>).</li>
10587 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>numValue</i>).</li>
10588 <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
10589 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10590 <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a <b>TypeError</b>
10591 exception.</li>
10592 <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>false</b></li>
10593 <li>If <i>index</i> = &minus;0, return <b>false</b>.</li>
10594 <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
10595 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10596 <li>If <i>index</i> &lt; 0 or <i>index</i> &ge; <i>length</i>, return <b>false</b>.</li>
10597 <li>Let <i>offset</i> be the value of <i>O</i>&rsquo;s [[ByteOffset]] <a
10598 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10599 <li>Let <i>arrayTypeName</i> be the string value of <i>O</i>&rsquo;s [[TypedArrayName]] <a
10600 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10601 <li>Let <i>elementSize</i> be the Number value of the Element Size value specified in <a href="#table-49">Table 49</a>
10602 for <i>arrayTypeName</i>.</li>
10603 <li>Let <i>indexedPosition</i> = (<i>index</i> &times; <i>elementSize</i>) + <i>offset</i>.</li>
10604 <li>Let <i>elementType</i> be the string value of the Element Type value in <a href="#table-49">Table 49</a> for
10605 <i>arrayTypeName</i>.</li>
10606 <li>Let <i>status</i> be <a href="#sec-setvalueinbuffer">SetValueInBuffer</a>(<i>buffer</i>, <i>indexedPosition</i>,
10607 <i>elementType</i>, <i>numValue</i>).</li>
10608 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
10609 <li>Return <b>true</b>.</li>
10610 </ol>
10611 </section>
10612 </section>
10613
10614 <section id="sec-module-namespace-exotic-objects">
10615 <div class="front">
10616 <h1><span class="secnum" id="sec-9.4.6"><a href="#sec-module-namespace-exotic-objects"
10617 title="link to this section">9.4.6</a></span> Module Namespace Exotic Objects</h1>
10618
10619 <p>A <i>module namespace object</i> is an exotic object that exposes the bindings exported from an ECMAScript <span
10620 class="nt">Module</span> <var>(See <a href="#sec-exports">15.2.3</a>)</var>. There is a one-to-one correspondence between
10621 the String-keyed own properties of a module namespace exotic object and the binding names exported by the <span
10622 class="nt">Module</span>. The exported bindings include any bindings that are indirectly exported using <code>export
10623 *</code> export items. Each String-valued own <a href="#sec-object-type">property key</a> is the StringValue of the
10624 corresponding exported binding name. These are the only String-keyed properties of a module namespace exotic object. Each
10625 such property has the attributes {[[Configurable]]: <span class="value">false</span>, [[Enumerable]]: <span
10626 class="value">true</span>}. Module namespace objects are not extensible.</p>
10627
10628 <p>Module namespace objects have the internal slots defined in <a href="#table-29">Table 29</a>.</p>
10629
10630 <figure>
10631 <figcaption><span id="table-29">Table 29</span> &mdash; Internal Slots of Module Namespace Exotic Objects</figcaption>
10632 <table class="real-table">
10633 <tr>
10634 <th>Internal Slot</th>
10635 <th>Type</th>
10636 <th>Description</th>
10637 </tr>
10638 <tr>
10639 <td>[[Module]]</td>
10640 <td>Module Record</td>
10641 <td>The Module Record whose exports this namespace exposes.</td>
10642 </tr>
10643 <tr>
10644 <td>[[Exports]]</td>
10645 <td><a href="#sec-list-and-record-specification-type">List</a> of String</td>
10646 <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>
10647 </tr>
10648 </table>
10649 </figure>
10650
10651 <p>Module namespace exotic objects provide alternative definitions for all of the internal methods.</p>
10652 </div>
10653
10654 <section id="sec-module-namespace-exotic-objects-getprototypeof">
10655 <h1><span class="secnum" id="sec-9.4.6.1"><a href="#sec-module-namespace-exotic-objects-getprototypeof"
10656 title="link to this section">9.4.6.1</a></span> [[GetPrototypeOf]] ( )</h1>
10657
10658 <p>When the [[GetPrototypeOf]] internal method of a module namespace exotic object <var>O</var> is called the following
10659 steps are taken:</p>
10660
10661 <ol class="proc">
10662 <li>Return <b>null</b>.</li>
10663 </ol>
10664 </section>
10665
10666 <section id="sec-module-namespace-exotic-objects-setprototypeof-v">
10667 <h1><span class="secnum" id="sec-9.4.6.2"><a href="#sec-module-namespace-exotic-objects-setprototypeof-v"
10668 title="link to this section">9.4.6.2</a></span> [[SetPrototypeOf]] (V)</h1>
10669
10670 <p>When the [[SetPrototypeOf]] internal method of a module namespace exotic object <var>O</var> is called with argument
10671 <var>V</var> the following steps are taken:</p>
10672
10673 <ol class="proc">
10674 <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
10675 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
10676 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
10677 <li>Return <b>false</b>.</li>
10678 </ol>
10679 </section>
10680
10681 <section id="sec-module-namespace-exotic-objects-isextensible">
10682 <h1><span class="secnum" id="sec-9.4.6.3"><a href="#sec-module-namespace-exotic-objects-isextensible"
10683 title="link to this section">9.4.6.3</a></span> [[IsExtensible]] ( )</h1>
10684
10685 <p>When the [[IsExtensible]] internal method of a module namespace exotic object <var>O</var> is called the following
10686 steps are taken:</p>
10687
10688 <ol class="proc">
10689 <li>Return <b>false</b>.</li>
10690 </ol>
10691 </section>
10692
10693 <section id="sec-module-namespace-exotic-objects-preventextensions">
10694 <h1><span class="secnum" id="sec-9.4.6.4"><a href="#sec-module-namespace-exotic-objects-preventextensions"
10695 title="link to this section">9.4.6.4</a></span> [[PreventExtensions]] ( )</h1>
10696
10697 <p>When the [[PreventExtensions]] internal method of a module namespace exotic object <var>O</var> is called the following
10698 steps are taken:</p>
10699
10700 <ol class="proc">
10701 <li>Return <b>true</b>.</li>
10702 </ol>
10703 </section>
10704
10705 <section id="sec-module-namespace-exotic-objects-getownproperty-p">
10706 <h1><span class="secnum" id="sec-9.4.6.5"><a href="#sec-module-namespace-exotic-objects-getownproperty-p"
10707 title="link to this section">9.4.6.5</a></span> [[GetOwnProperty]] (P)</h1>
10708
10709 <p>When the [[GetOwnProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
10710 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
10711
10712 <ol class="proc">
10713 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, return <a
10714 href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
10715 <li>Throw a <b>TypeError</b> exception.</li>
10716 </ol>
10717 </section>
10718
10719 <section id="sec-module-namespace-exotic-objects-defineownproperty-p-desc">
10720 <h1><span class="secnum" id="sec-9.4.6.6"><a href="#sec-module-namespace-exotic-objects-defineownproperty-p-desc"
10721 title="link to this section">9.4.6.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
10722
10723 <p>When the [[DefineOwnProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
10724 href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
10725 Descriptor</a> <span class="nt">Desc</span>, the following steps are taken:</p>
10726
10727 <ol class="proc">
10728 <li>Return <b>false</b>.</li>
10729 </ol>
10730 </section>
10731
10732 <section id="sec-module-namespace-exotic-objects-hasproperty-p">
10733 <h1><span class="secnum" id="sec-9.4.6.7"><a href="#sec-module-namespace-exotic-objects-hasproperty-p"
10734 title="link to this section">9.4.6.7</a></span> [[HasProperty]] (P)</h1>
10735
10736 <p>When the [[HasProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
10737 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
10738
10739 <ol class="proc">
10740 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, return <a
10741 href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
10742 <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
10743 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10744 <li>If <i>P</i> is an element of <i>exports</i>, return <b>true</b>.</li>
10745 <li>Return <b>false</b>.</li>
10746 </ol>
10747 </section>
10748
10749 <section id="sec-module-namespace-exotic-objects-get-p-receiver">
10750 <h1><span class="secnum" id="sec-9.4.6.8"><a href="#sec-module-namespace-exotic-objects-get-p-receiver"
10751 title="link to this section">9.4.6.8</a></span> [[Get]] (P, Receiver)</h1>
10752
10753 <p>When the [[Get]] internal method of a module namespace exotic object <var>O</var> is called with <a
10754 href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language
10755 value</a> <span class="nt">Receiver</span> the following steps are taken:</p>
10756
10757 <ol class="proc">
10758 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
10759 <b>true</b>.</li>
10760 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, then
10761 <ol class="block">
10762 <li>Return the result of calling the default ordinary object [[Get]] internal method (<a
10763 href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
10764 <i>P</i> and <i>Receiver</i> as arguments.</li>
10765 </ol>
10766 </li>
10767 <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
10768 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10769 <li>If <i>P</i> is not an element of <i>exports</i>, return <b>undefined</b>.</li>
10770 <li>Let <i>m</i> be the value of <i>O</i>&rsquo;s [[Module]] <a
10771 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10772 <li>Let <i>binding</i> be <i>m</i>.<a href="#sec-resolveexport">ResolveExport</a>(<i>P</i>, &laquo;&raquo;,
10773 &laquo;&raquo;).</li>
10774 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>binding</i>).</li>
10775 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>binding</i> is neither <b>null</b> nor
10776 <code>"ambiguous"</code>.</li>
10777 <li>Let <i>targetModule</i> be <i>binding</i>.[[module]],</li>
10778 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>targetModule</i> is not <b>undefined</b>.</li>
10779 <li>Let <i>targetEnv</i> be <i>targetModule</i>.[[Environment]].</li>
10780 <li>If <i>targetEnv</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
10781 <li>Let <i>targetEnvRec</i> be <i>targetEnv</i>&rsquo;s EnvironmentRecord.</li>
10782 <li>Return <i>targetEnvRec</i>.GetBindingValue(<i>binding.</i>[[bindingName]], <b>true</b>).</li>
10783 </ol>
10784
10785 <div class="note">
10786 <p><span class="nh">NOTE</span> <a href="#sec-resolveexport">ResolveExport</a> is idempotent and side-effect free. An
10787 implementation might choose to pre-compute or cache the <a href="#sec-resolveexport">ResolveExport</a> results for the
10788 [[Exports]] of each module namespace exotic object.</p>
10789 </div>
10790 </section>
10791
10792 <section id="sec-module-namespace-exotic-objects-set-p-v-receiver">
10793 <h1><span class="secnum" id="sec-9.4.6.9"><a href="#sec-module-namespace-exotic-objects-set-p-v-receiver"
10794 title="link to this section">9.4.6.9</a></span> [[Set]] ( P, V, Receiver)</h1>
10795
10796 <p>When the [[Set]] internal method of <span style="font-family: Times New Roman">a</span> module namespace exotic object
10797 <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>, value <var>V</var>, and <a
10798 href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span>, the following steps
10799 are taken:</p>
10800
10801 <ol class="proc">
10802 <li>Return <b>false</b>.</li>
10803 </ol>
10804 </section>
10805
10806 <section id="sec-module-namespace-exotic-objects-delete-p">
10807 <h1><span class="secnum" id="sec-9.4.6.10"><a href="#sec-module-namespace-exotic-objects-delete-p"
10808 title="link to this section">9.4.6.10</a></span> [[Delete]] (P)</h1>
10809
10810 <p>When the [[Delete]] internal method of a module namespace exotic object <var>O</var> is called with <a
10811 href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
10812
10813 <ol class="proc">
10814 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
10815 <b>true</b>.</li>
10816 <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
10817 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10818 <li>If <i>P</i> is an element of <i>exports</i>, return <b>false</b>.</li>
10819 <li>Return <b>true</b>.</li>
10820 </ol>
10821 </section>
10822
10823 <section id="sec-module-namespace-exotic-objects-enumerate">
10824 <h1><span class="secnum" id="sec-9.4.6.11"><a href="#sec-module-namespace-exotic-objects-enumerate"
10825 title="link to this section">9.4.6.11</a></span> [[Enumerate]] ()</h1>
10826
10827 <p>When the [[Enumerate]] internal method of a module namespace exotic object <var>O</var> is called the following steps
10828 are taken:</p>
10829
10830 <ol class="proc">
10831 <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
10832 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10833 <li>Return <a href="#sec-createlistiterator">CreateListIterator</a>(<i>exports</i>).</li>
10834 </ol>
10835 </section>
10836
10837 <section id="sec-module-namespace-exotic-objects-ownpropertykeys">
10838 <h1><span class="secnum" id="sec-9.4.6.12"><a href="#sec-module-namespace-exotic-objects-ownpropertykeys"
10839 title="link to this section">9.4.6.12</a></span> [[OwnPropertyKeys]] ( )</h1>
10840
10841 <p>When the [[OwnPropertyKeys]] internal method of a module namespace exotic object <var>O</var> is called the following
10842 steps are taken:</p>
10843
10844 <ol class="proc">
10845 <li>Let <i>exports</i> be a copy of the value of <i>O</i>&rsquo;s [[Exports]] <a
10846 href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
10847 <li>Let <i>symbolKeys</i> be the result of calling the default ordinary object [[OwnPropertyKeys]] internal method (<a
10848 href="#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys">9.1.12</a>) on <i>O</i> passing no
10849 arguments.</li>
10850 <li>Append all the entries of <i>symbolKeys</i> to the end of <i>exports</i>.</li>
10851 <li>Return <i>exports</i>.</li>
10852 </ol>
10853 </section>
10854
10855 <section id="sec-modulenamespacecreate">
10856 <h1><span class="secnum" id="sec-9.4.6.13"><a href="#sec-modulenamespacecreate"
10857 title="link to this section">9.4.6.13</a></span> ModuleNamespaceCreate (module, exports)</h1>
10858
10859 <p>The abstract operation ModuleNamespaceCreate with arguments <var>module</var>, and <var>exports</var> is used to
10860 specify the creation of new module namespace exotic objects. It performs the following steps:</p>
10861
10862 <ol class="proc">
10863 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>module</i> is a Module Record (<a
10864 href="#sec-abstract-module-records">see 15.2.1.14</a>).</li>
10865 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>module</i>.[[Namespace]] is <b>undefined</b>.</li>
10866 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>exports</i> is a <a
10867 href="#sec-list-and-record-specification-type">List</a> of string values.</li>
10868 <li>Let <i>M</i> be a newly created object.</li>
10869 <li>Set <i>M</i>&rsquo;s essential internal methods to the definitions specified in <a
10870 href="#sec-module-namespace-exotic-objects">9.4.6</a>.</li>
10871 <li>Set <i>M</i>&rsquo;s [[Module]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
10872 <i>module</i>.</li>
10873 <li>Set <i>M</i>&rsquo;s [[Exports]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
10874 <i>exports</i>.</li>
10875 <li>Create own properties of <i>M</i> corresponding to the definitions in <a
10876 href="#sec-module-namespace-objects">26.3</a>.</li>
10877 <li>Set <i>module</i>.[[Namespace]] to <i>M</i>.</li>
10878 <li>Return <i>M</i>.</li>
10879 </ol>
10880 </section>
10881 </section>
10882 </section>
10883
10884 <section id="sec-proxy-object-internal-methods-and-internal-slots">
10885 <div class="front">
10886 <h1><span class="secnum" id="sec-9.5"><a href="#sec-proxy-object-internal-methods-and-internal-slots"
10887 title="link to this section">9.5</a></span> Proxy Object Internal Methods and Internal Slots</h1>
10888
10889 <p>A proxy object is an exotic object whose essential internal methods are partially implemented using ECMAScript code.
10890 Every proxy objects has an <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called
10891 [[ProxyHandler]]. The value of [[ProxyHandler]] is an object, called the proxy&rsquo;s <i>handler object</i>, or <span
10892 class="value">null</span>. Methods (see <a href="#table-30">Table 30</a>) of a handler object may be used to augment the
10893 implementation for one or more of the proxy object&rsquo;s internal methods. Every proxy object also has an <a
10894 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called [[ProxyTarget]] whose value is either an
10895 object or the <b>null</b> value. This object is called the proxy&rsquo;s <i>target object</i>.</p>
10896
10897 <figure>
10898 <figcaption><span id="table-30">Table 30</span> &mdash; Proxy Handler Methods</figcaption>
10899 <table class="real-table">
10900 <tr>
10901 <th>Internal Method</th>
10902 <th>Handler Method</th>
10903 </tr>
10904 <tr>
10905 <td>[[GetPrototypeOf]]</td>
10906 <td><code>getPrototypeOf</code></td>
10907 </tr>
10908 <tr>
10909 <td>[[SetPrototypeOf]]</td>
10910 <td><code>setPrototypeOf</code></td>
10911 </tr>
10912 <tr>
10913 <td>[[IsExtensible]]</td>
10914 <td><code>isExtensible</code></td>
10915 </tr>
10916 <tr>
10917 <td>[[PreventExtensions]]</td>
10918 <td><code>preventExtensions</code></td>
10919 </tr>
10920 <tr>
10921 <td>[[GetOwnProperty]]</td>
10922 <td><code>getOwnPropertyDescriptor</code></td>
10923 </tr>
10924 <tr>
10925 <td>[[HasProperty]]</td>
10926 <td><code>has</code></td>
10927 </tr>
10928 <tr>
10929 <td>[[Get]]</td>
10930 <td><code>get</code></td>
10931 </tr>
10932 <tr>
10933 <td>[[Set]]</td>
10934 <td><code>set</code></td>
10935 </tr>
10936 <tr>
10937 <td>[[Delete]]</td>
10938 <td><code>deleteProperty</code></td>
10939 </tr>
10940 <tr>
10941 <td>[[DefineOwnProperty]]</td>
10942 <td><code>defineProperty</code></td>
10943 </tr>
10944 <tr>
10945 <td>[[Enumerate]]</td>
10946 <td><code>enumerate</code></td>
10947 </tr>
10948 <tr>
10949 <td>[[OwnPropertyKeys]]</td>
10950 <td><code>ownKeys</code></td>
10951 </tr>
10952 <tr>
10953 <td>[[Call]]</td>
10954 <td><code>apply</code></td>
10955 </tr>
10956 <tr>
10957 <td>[[Construct]]</td>
10958 <td><code>construct</code></td>
10959 </tr>
10960 </table>
10961 </figure>
10962
10963 <p>When a handler method is called to provide the implementation of a proxy object internal method, the handler method is
10964 passed the proxy&rsquo;s target object as a parameter. A proxy&rsquo;s handler object does not necessarily have a method
10965 corresponding to every essential internal method. Invoking an internal method on the proxy results in the invocation of the
10966 corresponding internal method on the proxy&rsquo;s target object if the handler object does not have a method corresponding
10967 to the internal trap.</p>
10968
10969 <p>The [[ProxyHandler]] and [[ProxyTarget]] internal slots of a proxy object are always initialized when the object is
10970 created and typically may not be modified. Some proxy objects are created in a manner that permits them to be subsequently
10971 <i>revoked</i>. When a proxy is revoked, its [[ProxyHander]] and [[ProxyTarget]] internal slots are set to <b>null</b>
10972 causing subsequent invocations of internal methods on that proxy object to throw a <span class="value">TypeError</span>
10973 exception.</p>
10974
10975 <p>Because proxy objects permit the implementation of internal methods to be provided by arbitrary ECMAScript code, it is
10976 possible to define a proxy object whose handler methods violates the invariants defined in <a
10977 href="#sec-invariants-of-the-essential-internal-methods">6.1.7.3</a>. Some of the internal method invariants defined in <a
10978 href="#sec-invariants-of-the-essential-internal-methods">6.1.7.3</a> are essential integrity invariants. These invariants
10979 are explicitly enforced by the proxy object internal methods specified in this section. An ECMAScript implementation must be
10980 robust in the presence of all possible invariant violations.</p>
10981
10982 <p>In the following algorithm descriptions, assume <var>O</var> is an ECMAScript proxy object, <var>P</var> is a <a
10983 href="#sec-object-type">property key value</a>, <var>V</var> is any <a href="#sec-ecmascript-language-types">ECMAScript
10984 language value</a> and <span style="font-family: Times New Roman">Desc</span> is a <a
10985 href="#sec-property-descriptor-specification-type">Property Descriptor</a> record.</p>
10986 </div>
10987
10988 <section id="sec-proxy-object-internal-methods-and-internal-slots-getprototypeof">
10989 <h1><span class="secnum" id="sec-9.5.1"><a href="#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof"
10990 title="link to this section">9.5.1</a></span> [[GetPrototypeOf]] ( )</h1>
10991
10992 <p>When the [[GetPrototypeOf]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
10993 taken:</p>
10994
10995 <ol class="proc">
10996 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
10997 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
10998 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
10999 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11000 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11001 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11002 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11003 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"getPrototypeOf"</code>).</li>
11004 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11005 <li>If <i>trap</i> is <b>undefined</b>, then
11006 <ol class="block">
11007 <li>Return <i>target</i>.[[GetPrototypeOf]]().</li>
11008 </ol>
11009 </li>
11010 <li>Let <i>handlerProto</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>,
11011 &laquo;<i>target</i>&raquo;).</li>
11012 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>handlerProto</i>).</li>
11013 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handlerProto</i>) is neither Object nor Null, throw a
11014 <b>TypeError</b> exception.</li>
11015 <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
11016 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
11017 <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>handlerProto</i>.</li>
11018 <li>Let <i>targetProto</i> be <i>target</i>.[[GetPrototypeOf]]().</li>
11019 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetProto</i>).</li>
11020 <li>If <a href="#sec-samevalue">SameValue</a>(<i>handlerProto</i>, <i>targetProto</i>) is <b>false</b>, throw a
11021 <b>TypeError</b> exception.</li>
11022 <li>Return <i>handlerProto</i>.</li>
11023 </ol>
11024
11025 <div class="note">
11026 <p><span class="nh">NOTE</span> [[GetPrototypeOf]] for proxy objects enforces the following invariant:</p>
11027
11028 <ul>
11029 <li>
11030 <p>The result of [[GetPrototypeOf]] must be either an Object or <b>null</b>.</p>
11031 </li>
11032
11033 <li>
11034 <p>If the target object is not extensible, [[GetPrototypeOf]] applied to the proxy object must return the same value
11035 as [[GetPrototypeOf]] applied to the proxy object&rsquo;s target object.</p>
11036 </li>
11037 </ul>
11038 </div>
11039 </section>
11040
11041 <section id="sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v">
11042 <h1><span class="secnum" id="sec-9.5.2"><a href="#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v"
11043 title="link to this section">9.5.2</a></span> [[SetPrototypeOf]] (V)</h1>
11044
11045 <p>When the [[SetPrototypeOf]] internal method of a Proxy exotic object <var>O</var> is called with argument <var>V</var>
11046 the following steps are taken:</p>
11047
11048 <ol class="proc">
11049 <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
11050 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
11051 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
11052 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11053 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11054 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11055 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11056 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11057 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11058 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11059 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"setPrototypeOf"</code>).</li>
11060 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11061 <li>If <i>trap</i> is <b>undefined</b>, then
11062 <ol class="block">
11063 <li>Return <i>target</i>.[[SetPrototypeOf]](<i>V</i>).</li>
11064 </ol>
11065 </li>
11066 <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
11067 <i>handler</i>, &laquo;<i>target</i>, <i>V</i>&raquo;)).</li>
11068 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
11069 <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
11070 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
11071 <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>booleanTrapResult</i>.</li>
11072 <li>Let <i>targetProto</i> be <i>target</i>.[[GetPrototypeOf]]().</li>
11073 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetProto</i>).</li>
11074 <li>If <i>booleanTrapResult</i> is <b>true</b> and <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>targetProto</i>) is
11075 <b>false</b>, throw a <b>TypeError</b> exception.</li>
11076 <li>Return <i>booleanTrapResult</i>.</li>
11077 </ol>
11078
11079 <div class="note">
11080 <p><span class="nh">NOTE</span> [[SetPrototypeOf]] for proxy objects enforces the following invariant:</p>
11081
11082 <ul>
11083 <li>
11084 <p>The result of [[SetPrototypeOf]] is a Boolean value.</p>
11085 </li>
11086
11087 <li>
11088 <p>If the target object is not extensible, the argument value must be the same as the result of [[GetPrototypeOf]]
11089 applied to target object.</p>
11090 </li>
11091 </ul>
11092 </div>
11093 </section>
11094
11095 <section id="sec-proxy-object-internal-methods-and-internal-slots-isextensible">
11096 <h1><span class="secnum" id="sec-9.5.3"><a href="#sec-proxy-object-internal-methods-and-internal-slots-isextensible"
11097 title="link to this section">9.5.3</a></span> [[IsExtensible]] ( )</h1>
11098
11099 <p>When the [[IsExtensible]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
11100 taken:</p>
11101
11102 <ol class="proc">
11103 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11104 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11105 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11106 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11107 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11108 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11109 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11110 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"isExtensible"</code>).</li>
11111 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11112 <li>If <i>trap</i> is <b>undefined</b>, then
11113 <ol class="block">
11114 <li>Return <i>target</i>.[[IsExtensible]]().</li>
11115 </ol>
11116 </li>
11117 <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
11118 <i>handler</i>, &laquo;<i>target</i>&raquo;)).</li>
11119 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
11120 <li>Let <i>targetResult</i> be <i>target</i>.[[IsExtensible]]().</li>
11121 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetResult</i>).</li>
11122 <li>If <a href="#sec-samevalue">SameValue</a>(<i>booleanTrapResult</i>, <i>targetResult</i>) is <b>false</b>, throw a
11123 <b>TypeError</b> exception.</li>
11124 <li>Return <i>booleanTrapResult</i>.</li>
11125 </ol>
11126
11127 <div class="note">
11128 <p><span class="nh">NOTE</span> [[IsExtensible]] for proxy objects enforces the following invariant:</p>
11129
11130 <ul>
11131 <li>
11132 <p>The result of [[IsExtensible]] is a Boolean value.</p>
11133 </li>
11134
11135 <li>
11136 <p>[[IsExtensible]] applied to the proxy object must return the same value as [[IsExtensible]] applied to the proxy
11137 object&rsquo;s target object with the same argument.</p>
11138 </li>
11139 </ul>
11140 </div>
11141 </section>
11142
11143 <section id="sec-proxy-object-internal-methods-and-internal-slots-preventextensions">
11144 <h1><span class="secnum" id="sec-9.5.4"><a href="#sec-proxy-object-internal-methods-and-internal-slots-preventextensions"
11145 title="link to this section">9.5.4</a></span> [[PreventExtensions]] ( )</h1>
11146
11147 <p>When the [[PreventExtensions]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
11148 taken:</p>
11149
11150 <ol class="proc">
11151 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11152 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11153 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11154 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11155 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11156 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11157 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11158 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"preventExtensions"</code>).</li>
11159 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11160 <li>If <i>trap</i> is <b>undefined</b>, then
11161 <ol class="block">
11162 <li>Return <i>target</i>.[[PreventExtensions]]().</li>
11163 </ol>
11164 </li>
11165 <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
11166 <i>handler</i>, &laquo;<i>target</i>&raquo;)).</li>
11167 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
11168 <li>If <i>booleanTrapResult</i> is <b>true</b>, then
11169 <ol class="block">
11170 <li>Let <i>targetIsExtensible</i> be <i>target</i>.[[IsExtensible]]().</li>
11171 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetIsExtensible</i>).</li>
11172 <li>If <i>targetIsExtensible</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
11173 </ol>
11174 </li>
11175 <li>Return <i>booleanTrapResult</i>.</li>
11176 </ol>
11177
11178 <div class="note">
11179 <p><span class="nh">NOTE</span> [[PreventExtensions]] for proxy objects enforces the following invariant:</p>
11180
11181 <ul>
11182 <li>
11183 <p>The result of [[PreventExtensions]] is a Boolean value.</p>
11184 </li>
11185
11186 <li>
11187 <p>[[PreventExtensions]] applied to the proxy object only returns <b>true</b> if [[IsExtensible]] applied to the proxy
11188 object&rsquo;s target object is <b>false</b>.</p>
11189 </li>
11190 </ul>
11191 </div>
11192 </section>
11193
11194 <section id="sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p">
11195 <h1><span class="secnum" id="sec-9.5.5"><a href="#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p"
11196 title="link to this section">9.5.5</a></span> [[GetOwnProperty]] (P)</h1>
11197
11198 <p>When the [[GetOwnProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
11199 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
11200
11201 <ol class="proc">
11202 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
11203 <b>true</b>.</li>
11204 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11205 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11206 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11207 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11208 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11209 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11210 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11211 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>,
11212 <code>"getOwnPropertyDescriptor"</code>).</li>
11213 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11214 <li>If <i>trap</i> is <b>undefined</b>, then
11215 <ol class="block">
11216 <li>Return <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
11217 </ol>
11218 </li>
11219 <li>Let <i>trapResultObj</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>,
11220 <i>P</i>&raquo;).</li>
11221 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResultObj</i>).</li>
11222 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>trapResultObj</i>) is neither Object nor Undefined,
11223 throw a <b>TypeError</b> exception.</li>
11224 <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
11225 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
11226 <li>If <i>trapResultObj</i> is <b>undefined</b>, then
11227 <ol class="block">
11228 <li>If <i>targetDesc</i> is <b>undefined</b>, return <b>undefined</b>.</li>
11229 <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
11230 <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
11231 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
11232 <li>If <a href="#sec-toboolean">ToBoolean</a>(<i>extensibleTarget</i>) is <b>false</b>, throw a <b>TypeError</b>
11233 exception.</li>
11234 <li>Return <b>undefined</b>.</li>
11235 </ol>
11236 </li>
11237 <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
11238 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
11239 <li>Let <i>resultDesc</i> be <a href="#sec-topropertydescriptor">ToPropertyDescriptor</a>(<i>trapResultObj</i>).</li>
11240 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>resultDesc</i>).</li>
11241 <li><a href="#sec-call">Call</a> <a
11242 href="#sec-completepropertydescriptor">CompletePropertyDescriptor</a>(<i>resultDesc</i>).</li>
11243 <li>Let <i>valid</i> be <a href="#sec-iscompatiblepropertydescriptor">IsCompatiblePropertyDescriptor</a>
11244 (<i>extensibleTarget</i>, <i>resultDesc</i>, <i>targetDesc</i>).</li>
11245 <li>If <i>valid</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
11246 <li>If <i>resultDesc</i>.[[Configurable]] is <b>false</b>, then
11247 <ol class="block">
11248 <li>If <i>targetDesc</i> is <b>undefined</b> or <i>targetDesc</i>.[[Configurable]] is <b>true</b><i>,</i> then
11249 <ol class="block">
11250 <li>Throw a <b>TypeError</b> exception.</li>
11251 </ol>
11252 </li>
11253 </ol>
11254 </li>
11255 <li>Return <i>resultDesc</i>.</li>
11256 </ol>
11257
11258 <div class="note">
11259 <p><span class="nh">NOTE</span> [[GetOwnProperty]] for proxy objects enforces the following invariants:</p>
11260
11261 <ul>
11262 <li>
11263 <p>The result of [[GetOwnProperty]] must be either an Object or <b>undefined</b>.</p>
11264 </li>
11265
11266 <li>
11267 <p>A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target
11268 object.</p>
11269 </li>
11270
11271 <li>
11272 <p>A property cannot be reported as non-existent, if it exists as an own property of the target object and the target
11273 object is not extensible.</p>
11274 </li>
11275
11276 <li>
11277 <p>A property cannot be reported as existent, if it does not exists as an own property of the target object and the
11278 target object is not extensible.</p>
11279 </li>
11280
11281 <li>
11282 <p>A property cannot be reported as non-configurable, if it does not exists as an own property of the target object or
11283 if it exists as a configurable own property of the target object.</p>
11284 </li>
11285 </ul>
11286 </div>
11287 </section>
11288
11289 <section id="sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc">
11290 <h1><span class="secnum" id="sec-9.5.6"><a
11291 href="#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc"
11292 title="link to this section">9.5.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
11293
11294 <p>When the [[DefineOwnProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
11295 href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
11296 Descriptor</a> <span class="nt">Desc</span>, the following steps are taken:</p>
11297
11298 <ol class="proc">
11299 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
11300 <b>true</b>.</li>
11301 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11302 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11303 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11304 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11305 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11306 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11307 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11308 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"defineProperty"</code>).</li>
11309 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11310 <li>If <i>trap</i> is <b>undefined</b>, then
11311 <ol class="block">
11312 <li>Return <i>target</i>.[[DefineOwnProperty]](<i>P</i>, <i>Desc</i>).</li>
11313 </ol>
11314 </li>
11315 <li>Let <i>descObj</i> be <a href="#sec-frompropertydescriptor">FromPropertyDescriptor</a>(<i>Desc</i>).</li>
11316 <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
11317 <i>handler</i>, &laquo;<i>target</i>, <i>P</i>, <i>descObj</i>&raquo;)).</li>
11318 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
11319 <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
11320 <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
11321 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
11322 <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
11323 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
11324 <li>If <i>Desc</i> has a [[Configurable]] field and if <i>Desc</i>.[[Configurable]] is <b>false,</b> then
11325 <ol class="block">
11326 <li>Let <i>settingConfigFalse</i> be <b>true</b>.</li>
11327 </ol>
11328 </li>
11329 <li>Else let <i>settingConfigFalse</i> be <b>false</b>.</li>
11330 <li>If <i>targetDesc</i> is <b>undefined</b>, then
11331 <ol class="block">
11332 <li>If <i>extensibleTarget</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
11333 <li>If <i>settingConfigFalse</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
11334 </ol>
11335 </li>
11336 <li>Else <i>targetDesc</i> is not <b>undefined<i>,</i></b>
11337 <ol class="block">
11338 <li>If <a href="#sec-iscompatiblepropertydescriptor">IsCompatiblePropertyDescriptor</a>(<i>extensibleTarget</i>,
11339 <i>Desc</i> , <i>targetDesc</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
11340 <li>If <i>settingConfigFalse</i> is <b>true</b> and <i>targetDesc</i>.[[Configurable]] is <b>true</b>, throw a
11341 <b>TypeError</b> exception.</li>
11342 </ol>
11343 </li>
11344 <li>Return <b>true</b>.</li>
11345 </ol>
11346
11347 <div class="note">
11348 <p><span class="nh">NOTE</span> [[DefineOwnProperty]] for proxy objects enforces the following invariants:</p>
11349
11350 <ul>
11351 <li>
11352 <p>The result of [[DefineOwnProperty]] is a Boolean value.</p>
11353 </li>
11354
11355 <li>
11356 <p>A property cannot be added, if the target object is not extensible.</p>
11357 </li>
11358
11359 <li>
11360 <p>A property cannot be non-configurable, unless there exists a corresponding non-configurable own property of the
11361 target object.</p>
11362 </li>
11363
11364 <li>
11365 <p>If a property has a corresponding target object property then applying the <a
11366 href="#sec-property-descriptor-specification-type">Property Descriptor</a> of the property to the target object using
11367 [[DefineOwnProperty]] will not throw an exception.</p>
11368 </li>
11369 </ul>
11370 </div>
11371 </section>
11372
11373 <section id="sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p">
11374 <h1><span class="secnum" id="sec-9.5.7"><a href="#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p"
11375 title="link to this section">9.5.7</a></span> [[HasProperty]] (P)</h1>
11376
11377 <p>When the [[HasProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
11378 href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
11379
11380 <ol class="proc">
11381 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
11382 <b>true</b>.</li>
11383 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11384 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11385 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11386 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11387 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11388 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11389 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11390 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"has"</code>).</li>
11391 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11392 <li>If <i>trap</i> is <b>undefined</b>, then
11393 <ol class="block">
11394 <li>Return <i>target</i>.[[HasProperty]](<i>P</i>).</li>
11395 </ol>
11396 </li>
11397 <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
11398 <i>handler</i>, &laquo;<i>target</i>, <i>P</i>&raquo;)).</li>
11399 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
11400 <li>If <i>booleanTrapResult</i> is <b>false</b>, then
11401 <ol class="block">
11402 <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
11403 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
11404 <li>If <i>targetDesc</i> is not <b>undefined</b>, then
11405 <ol class="block">
11406 <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
11407 <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
11408 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
11409 <li>If <i>extensibleTarget</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
11410 </ol>
11411 </li>
11412 </ol>
11413 </li>
11414 <li>Return <i>booleanTrapResult</i>.</li>
11415 </ol>
11416
11417 <div class="note">
11418 <p><span class="nh">NOTE</span> [[HasProperty]] for proxy objects enforces the following invariants:</p>
11419
11420 <ul>
11421 <li>
11422 <p>The result of [[HasProperty]] is a Boolean value.</p>
11423 </li>
11424
11425 <li>
11426 <p>A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target
11427 object.</p>
11428 </li>
11429
11430 <li>
11431 <p>A property cannot be reported as non-existent, if it exists as an own property of the target object and the target
11432 object is not extensible.</p>
11433 </li>
11434 </ul>
11435 </div>
11436 </section>
11437
11438 <section id="sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver">
11439 <h1><span class="secnum" id="sec-9.5.8"><a href="#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver"
11440 title="link to this section">9.5.8</a></span> [[Get]] (P, Receiver)</h1>
11441
11442 <p>When the [[Get]] internal method of a Proxy exotic object <var>O</var> is called with <a href="#sec-object-type">property
11443 key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
11444 class="nt">Receiver</span> the following steps are taken:</p>
11445
11446 <ol class="proc">
11447 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
11448 <b>true</b>.</li>
11449 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11450 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11451 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11452 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11453 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11454 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11455 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11456 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"get"</code>).</li>
11457 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11458 <li>If <i>trap</i> is <b>undefined</b>, then
11459 <ol class="block">
11460 <li>Return <i>target</i>.[[Get]](<i>P</i>, <i>Receiver</i>).</li>
11461 </ol>
11462 </li>
11463 <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>,
11464 <i>Receiver</i>&raquo;).</li>
11465 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
11466 <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
11467 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
11468 <li>If <i>targetDesc</i> is not <b>undefined</b>, then
11469 <ol class="block">
11470 <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>targetDesc</i>) and <i>targetDesc</i>.[[Configurable]]
11471 is <b>false</b> and <i>targetDesc</i>.[[Writable]] is <b>false</b>, then
11472 <ol class="block">
11473 <li>If <a href="#sec-samevalue">SameValue</a>(<i>trapResult</i>, <i>targetDesc</i>.[[Value]]) is <b>false</b>,
11474 throw a <b>TypeError</b> exception.</li>
11475 </ol>
11476 </li>
11477 <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>targetDesc</i>) and
11478 <i>targetDesc</i>.[[Configurable]] is <b>false</b> and <i>targetDesc</i>.[[Get]] is <b>undefined</b>, then
11479 <ol class="block">
11480 <li>If <i>trapResult</i> is not <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
11481 </ol>
11482 </li>
11483 </ol>
11484 </li>
11485 <li>Return <i>trapResult</i>.</li>
11486 </ol>
11487
11488 <div class="note">
11489 <p><span class="nh">NOTE</span> [[Get]] for proxy objects enforces the following invariants:</p>
11490
11491 <ul>
11492 <li>
11493 <p>The value reported for a property must be the same as the value of the corresponding target object property if the
11494 target object property is a non-writable, non-configurable own data property.</p>
11495 </li>
11496
11497 <li>
11498 <p>The value reported for a property must be <b>undefined</b> if the corresponding target object property is a
11499 non-configurable own accessor property that has <b>undefined</b> as its [[Get]] attribute.</p>
11500 </li>
11501 </ul>
11502 </div>
11503 </section>
11504
11505 <section id="sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver">
11506 <h1><span class="secnum" id="sec-9.5.9"><a href="#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver"
11507 title="link to this section">9.5.9</a></span> [[Set]] ( P, V, Receiver)</h1>
11508
11509 <p>When the [[Set]] internal method of a Proxy exotic object <var>O</var> is called with <a href="#sec-object-type">property
11510 key</a> <var>P</var>, value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
11511 class="nt">Receiver</span>, the following steps are taken:</p>
11512
11513 <ol class="proc">
11514 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
11515 <b>true</b>.</li>
11516 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11517 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11518 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11519 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11520 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11521 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11522 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11523 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"set"</code>).</li>
11524 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11525 <li>If <i>trap</i> is <b>undefined</b>, then
11526 <ol class="block">
11527 <li>Return <i>target</i>.[[Set]](<i>P</i>, <i>V</i>, <i>Receiver</i>).</li>
11528 </ol>
11529 </li>
11530 <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
11531 <i>handler</i>, &laquo;<i>target</i>, <i>P</i>, <i>V</i>, <i>Receiver</i>&raquo;)).</li>
11532 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
11533 <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
11534 <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
11535 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
11536 <li>If <i>targetDesc</i> is not <b>undefined</b>, then
11537 <ol class="block">
11538 <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>targetDesc</i>) and <i>targetDesc</i>.[[Configurable]]
11539 is <b>false</b> and <i>targetDesc</i>.[[Writable]] is <b>false</b>, then
11540 <ol class="block">
11541 <li>If <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>targetDesc</i>.[[Value]]) is <b>false</b>, throw a
11542 <b>TypeError</b> exception.</li>
11543 </ol>
11544 </li>
11545 <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>targetDesc</i>) and
11546 <i>targetDesc</i>.[[Configurable]] is <b>false</b>, then
11547 <ol class="block">
11548 <li>If <i>targetDesc</i>.[[Set]] is <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
11549 </ol>
11550 </li>
11551 </ol>
11552 </li>
11553 <li>Return <b>true</b>.</li>
11554 </ol>
11555
11556 <div class="note">
11557 <p><span class="nh">NOTE</span> [[Set]] for proxy objects enforces the following invariants:</p>
11558
11559 <ul>
11560 <li>
11561 <p>The result of [[Set]] is a Boolean value.</p>
11562 </li>
11563
11564 <li>
11565 <p>Cannot change the value of a property to be different from the value of the corresponding target object property if
11566 the corresponding target object property is a non-writable, non-configurable own data property.</p>
11567 </li>
11568
11569 <li>
11570 <p>Cannot set the value of a property if the corresponding target object property is a non-configurable own accessor
11571 property that has <b>undefined</b> as its [[Set]] attribute.</p>
11572 </li>
11573 </ul>
11574 </div>
11575 </section>
11576
11577 <section id="sec-proxy-object-internal-methods-and-internal-slots-delete-p">
11578 <h1><span class="secnum" id="sec-9.5.10"><a href="#sec-proxy-object-internal-methods-and-internal-slots-delete-p"
11579 title="link to this section">9.5.10</a></span> [[Delete]] (P)</h1>
11580
11581 <p>When the [[Delete]] internal method of a Proxy exotic object <var>O</var> is called with <a
11582 href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
11583
11584 <ol class="proc">
11585 <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
11586 <b>true</b>.</li>
11587 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11588 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11589 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11590 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11591 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11592 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11593 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11594 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"deleteProperty"</code>).</li>
11595 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11596 <li>If <i>trap</i> is <b>undefined</b>, then
11597 <ol class="block">
11598 <li>Return <i>target</i>.[[Delete]](<i>P</i>).</li>
11599 </ol>
11600 </li>
11601 <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
11602 <i>handler</i>, &laquo;<i>target</i>, <i>P</i>&raquo;)).</li>
11603 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
11604 <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
11605 <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
11606 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
11607 <li>If <i>targetDesc</i> is <b>undefined</b>, return <b>true</b>.</li>
11608 <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
11609 <li>Return <b>true</b>.</li>
11610 </ol>
11611
11612 <div class="note">
11613 <p><span class="nh">NOTE</span> [[Delete]] for proxy objects enforces the following invariant:</p>
11614
11615 <ul>
11616 <li>The result of [[Delete]] is a Boolean value.</li>
11617 <li>A property cannot be reported as deleted, if it exists as a non-configurable own property of the target object.</li>
11618 </ul>
11619 </div>
11620 </section>
11621
11622 <section id="sec-proxy-object-internal-methods-and-internal-slots-enumerate">
11623 <h1><span class="secnum" id="sec-9.5.11"><a href="#sec-proxy-object-internal-methods-and-internal-slots-enumerate"
11624 title="link to this section">9.5.11</a></span> [[Enumerate]] ()</h1>
11625
11626 <p>When the [[Enumerate]] internal method of a Proxy exotic object <var>O</var> is called the following steps are taken:</p>
11627
11628 <ol class="proc">
11629 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11630 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11631 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11632 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11633 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11634 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11635 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11636 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"enumerate"</code>).</li>
11637 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11638 <li>If <i>trap</i> is <b>undefined</b>, then
11639 <ol class="block">
11640 <li>Return <i>target</i>.[[Enumerate]]().</li>
11641 </ol>
11642 </li>
11643 <li>Let <i>trapResult</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>&raquo;).</li>
11644 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
11645 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>trapResult</i>) is not Object, throw a <b>TypeError</b>
11646 exception.</li>
11647 <li>Return <i>trapResult</i>.</li>
11648 </ol>
11649
11650 <div class="note">
11651 <p><span class="nh">NOTE</span> [[Enumerate]] for proxy objects enforces the following invariants:</p>
11652
11653 <ul>
11654 <li>The result of [[Enumerate]] must be an Object.</li>
11655 </ul>
11656 </div>
11657 </section>
11658
11659 <section id="sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys">
11660 <h1><span class="secnum" id="sec-9.5.12"><a href="#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys"
11661 title="link to this section">9.5.12</a></span> [[OwnPropertyKeys]] ( )</h1>
11662
11663 <p>When the [[OwnPropertyKeys]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
11664 taken:</p>
11665
11666 <ol class="proc">
11667 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11668 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11669 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11670 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11671 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11672 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11673 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11674 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"ownKeys"</code>).</li>
11675 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11676 <li>If <i>trap</i> is <b>undefined</b>, then
11677 <ol class="block">
11678 <li>Return <i>target</i>.[[OwnPropertyKeys]]().</li>
11679 </ol>
11680 </li>
11681 <li>Let <i>trapResultArray</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>,
11682 &laquo;<i>target</i>&raquo;).</li>
11683 <li>Let <i>trapResult</i> be <a href="#sec-createlistfromarraylike">CreateListFromArrayLike</a>(<i>trapResultArray</i>,
11684 &laquo;&zwj;String, Symbol&raquo;).</li>
11685 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
11686 <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
11687 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
11688 <li>Let <i>targetKeys</i> be <i>target</i>.[[OwnPropertyKeys]]().</li>
11689 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetKeys</i>).</li>
11690 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>targetKeys</i> is a <a
11691 href="#sec-list-and-record-specification-type">List</a> containing only String and Symbol values.</li>
11692 <li>Let <i>targetConfigurableKeys</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
11693 <li>Let <i>targetNonconfigurableKeys</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
11694 <li>Repeat, for each element <i>key</i> of <i>targetKeys</i>,
11695 <ol class="block">
11696 <li>Let <i>desc</i> be <i>target</i>.[[GetOwnProperty]](<i>key</i>).</li>
11697 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
11698 <li>If <i>desc</i> is not <b>undefined</b> and <i>desc.</i>[[Configurable]] is <b>false</b>, then
11699 <ol class="block">
11700 <li>Append <i>key</i> as an element of <i>targetNonconfigurableKeys</i>.</li>
11701 </ol>
11702 </li>
11703 <li>Else,
11704 <ol class="block">
11705 <li>Append <i>key</i> as an element of <i>targetConfigurableKeys</i>.</li>
11706 </ol>
11707 </li>
11708 </ol>
11709 </li>
11710 <li>If <i>extensibleTarget</i> is <b>true</b> and <i>targetNonconfigurableKeys</i> is empty, then
11711 <ol class="block">
11712 <li>Return <i>trapResult</i>.</li>
11713 </ol>
11714 </li>
11715 <li>Let <i>uncheckedResultKeys</i> be a new <a href="#sec-list-and-record-specification-type">List</a> which is a copy of
11716 <i>trapResult</i>.</li>
11717 <li>Repeat, for each <i>key</i> that is an element of <i>targetNonconfigurableKeys</i>,
11718 <ol class="block">
11719 <li>If <i>key</i> is not an element of <i>uncheckedResultKeys</i>, throw a <b>TypeError</b> exception.</li>
11720 <li>Remove <i>key</i> from <i>uncheckedResultKeys</i></li>
11721 </ol>
11722 </li>
11723 <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>trapResult</i>.</li>
11724 <li>Repeat, for each <i>key</i> that is an element of <i>targetConfigurableKeys</i>,
11725 <ol class="block">
11726 <li>If <i>key</i> is not an element of <i>uncheckedResultKeys</i>, throw a <b>TypeError</b> exception.</li>
11727 <li>Remove <i>key</i> from <i>uncheckedResultKeys</i></li>
11728 </ol>
11729 </li>
11730 <li>If <i>uncheckedResultKeys</i> is not empty, throw a <b>TypeError</b> exception.</li>
11731 <li>Return <i>trapResult</i>.</li>
11732 </ol>
11733
11734 <div class="note">
11735 <p><span class="nh">NOTE</span> [[OwnPropertyKeys]] for proxy objects enforces the following invariants:</p>
11736
11737 <ul>
11738 <li>
11739 <p>The result of [[OwnPropertyKeys]] is a <a href="#sec-list-and-record-specification-type">List</a>.</p>
11740 </li>
11741
11742 <li>
11743 <p>The Type of each result <a href="#sec-list-and-record-specification-type">List</a> element is either String or
11744 Symbol.</p>
11745 </li>
11746
11747 <li>
11748 <p>The result <a href="#sec-list-and-record-specification-type">List</a> must contain the keys of all non-configurable
11749 own properties of the target object.</p>
11750 </li>
11751
11752 <li>
11753 <p>If the target object is not extensible, then the result <a href="#sec-list-and-record-specification-type">List</a>
11754 must contain all the keys of the own properties of the target object and no other values.</p>
11755 </li>
11756 </ul>
11757 </div>
11758 </section>
11759
11760 <section id="sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist">
11761 <h1><span class="secnum" id="sec-9.5.13"><a
11762 href="#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist"
11763 title="link to this section">9.5.13</a></span> [[Call]] (thisArgument, argumentsList)</h1>
11764
11765 <p>The [[Call]] internal method of a Proxy exotic object <var>O</var> is called with parameters <var>thisArgument</var> and
11766 <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
11767 href="#sec-ecmascript-language-types">ECMAScript language values</a>. The following steps are taken:</p>
11768
11769 <ol class="proc">
11770 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11771 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11772 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11773 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11774 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11775 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11776 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11777 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"apply"</code>).</li>
11778 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11779 <li>If <i>trap</i> is <b>undefined</b>, then
11780 <ol class="block">
11781 <li>Return <a href="#sec-call">Call</a>(<i>target</i>, <i>thisArgument</i>, <i>argumentsList</i>).</li>
11782 </ol>
11783 </li>
11784 <li>Let <i>argArray</i> be <a href="#sec-createarrayfromlist">CreateArrayFromList</a>(<i>argumentsList</i>).</li>
11785 <li>Return <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>, <i>thisArgument</i>,
11786 <i>argArray</i>&raquo;).</li>
11787 </ol>
11788
11789 <div class="note">
11790 <p><span class="nh">NOTE</span> A Proxy exotic object only has a [[Call]] internal method if the initial value of its
11791 [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is an object that has a
11792 [[Call]] internal method.</p>
11793 </div>
11794 </section>
11795
11796 <section id="sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget">
11797 <h1><span class="secnum" id="sec-9.5.14"><a
11798 href="#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget"
11799 title="link to this section">9.5.14</a></span> [[Construct]] ( argumentsList, newTarget)</h1>
11800
11801 <p>The [[Construct]] internal method of a Proxy exotic object <var>O</var> is called with parameters
11802 <var>argumentsList</var> which is a possibly empty <a href="#sec-list-and-record-specification-type">List</a> of <a
11803 href="#sec-ecmascript-language-types">ECMAScript language values</a> and <var>newTarget</var>. The following steps are
11804 taken:</p>
11805
11806 <ol class="proc">
11807 <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
11808 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11809 <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
11810 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
11811 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
11812 <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
11813 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
11814 <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"construct"</code>).</li>
11815 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
11816 <li>If <i>trap</i> is <b>undefined</b>, then
11817 <ol class="block">
11818 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>target</i> has a [[Construct]] internal method.</li>
11819 <li>Return <a href="#sec-construct">Construct</a>(<i>target</i>, <i>argumentsList</i>, <i>newTarget</i>).</li>
11820 </ol>
11821 </li>
11822 <li>Let <i>argArray</i> be <a href="#sec-createarrayfromlist">CreateArrayFromList</a>(<i>argumentsList</i>).</li>
11823 <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>,
11824 <i>newTarget</i> &raquo;).</li>
11825 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newObj</i>).</li>
11826 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newObj</i>) is not Object, throw a <b>TypeError</b>
11827 exception.</li>
11828 <li>Return <i>newObj</i>.</li>
11829 </ol>
11830
11831 <div class="note">
11832 <p><span class="nh">NOTE 1</span> A Proxy exotic object only has a [[Construct]] internal method if the initial value of
11833 its [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is an object that has a
11834 [[Construct]] internal method.</p>
11835 </div>
11836
11837 <div class="note">
11838 <p><span class="nh">NOTE 2</span> [[Construct]] for proxy objects enforces the following invariants:</p>
11839
11840 <ul>
11841 <li>The result of [[Construct]] must be an Object.</li>
11842 </ul>
11843 </div>
11844 </section>
11845
11846 <section id="sec-proxycreate">
11847 <h1><span class="secnum" id="sec-9.5.15"><a href="#sec-proxycreate" title="link to this section">9.5.15</a></span>
11848 ProxyCreate(target, handler)</h1>
11849
11850 <p>The abstract operation ProxyCreate with arguments <var>target</var> and <var>handler</var> is used to specify the
11851 creation of new Proxy exotic objects. It performs the following steps:</p>
11852
11853 <ol class="proc">
11854 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>target</i>) is not Object, throw a <b>TypeError</b>
11855 Exception.</li>
11856 <li>If <i>target</i> is a Proxy exotic object and the value of the [[ProxyHandler]] <a
11857 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>target</i> is <b>null</b>, throw a
11858 <b>TypeError</b> exception.</li>
11859 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is not Object, throw a <b>TypeError</b>
11860 Exception.</li>
11861 <li>If <i>handler</i> is a Proxy exotic object and the value of the [[ProxyHandler]] <a
11862 href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>handler</i> is <b>null</b>, throw a
11863 <b>TypeError</b> exception.</li>
11864 <li>Let <i>P</i> be a newly created object.</li>
11865 <li>Set <i>P</i>&rsquo;s essential internal methods (except for [[Call]] and [[Construct]]) to the definitions specified
11866 in <a href="#sec-proxy-object-internal-methods-and-internal-slots">9.5</a>.</li>
11867 <li>If <a href="#sec-iscallable">IsCallable</a>(<i>target</i>) is <b>true</b>, then
11868 <ol class="block">
11869 <li>Set the [[Call]] internal method of <i>P</i> as specified in <a
11870 href="#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist">9.5.13</a>.</li>
11871 <li>If <i>target</i> has a [[Construct]] internal method, then
11872 <ol class="block">
11873 <li>Set the [[Construct]] internal method of <i>P</i> as specified in <a
11874 href="#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget">9.5.14</a>.</li>
11875 </ol>
11876 </li>
11877 </ol>
11878 </li>
11879 <li>Set the [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>P</i> to
11880 <i>target</i>.</li>
11881 <li>Set the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>P</i> to
11882 <i>handler</i>.</li>
11883 <li>Return <i>P</i>.</li>
11884 </ol>
11885 </section>
11886 </section>
11887 </section>
11888
11889 <section id="sec-ecmascript-language-source-code">
11890 <div class="front">
11891 <h1><span class="secnum" id="sec-10"><a href="#sec-ecmascript-language-source-code" title="link to this section">10</a></span>
11892 ECMAScript Language: Source Code</h1>
11893 </div>
11894
11895 <section id="sec-source-text">
11896 <div class="front">
11897 <h1><span class="secnum" id="sec-10.1"><a href="#sec-source-text" title="link to this section">10.1</a></span> Source
11898 Text</h1>
11899 <h2>Syntax</h2>
11900
11901 <div class="gp">
11902 <div class="lhs"><span class="nt">SourceCharacter</span> <span class="geq">::</span></div>
11903 <div class="rhs"><span class="gprose">any Unicode code point</span></div>
11904 </div>
11905
11906 <p>ECMAScript code is expressed using Unicode, version 5.1 or later. ECMAScript source text is a sequence of code points.
11907 All Unicode code point values from U+0000 to U+10FFFF, including surrogate code points, may occur in source text where
11908 permitted by the ECMAScript grammars. The actual encodings used to store and interchange ECMAScript source text is not
11909 relevant to this specification. Regardless of the external source text encoding, a conforming ECMAScript implementation
11910 processes the source text as if it was an equivalent sequence of <span class="nt">SourceCharacter</span> values. Each <span
11911 class="nt">SourceCharacter</span> being a Unicode code point. Conforming ECMAScript implementations are not required to
11912 perform any normalization of source text, or behave as though they were performing normalization of source text.</p>
11913
11914 <p>The components of a combining character sequence are treated as individual Unicode code points even though a user might
11915 think of the whole sequence as a single character.</p>
11916
11917 <div class="note">
11918 <p><span class="nh">NOTE</span> In string literals, regular expression literals, template literals and identifiers, any
11919 Unicode code point may also be expressed using Unicode escape sequences that explicitly express a code point&rsquo;s
11920 numeric value. Within a comment, such an escape sequence is effectively ignored as part of the comment.</p>
11921
11922 <p>ECMAScript differs from the Java programming language in the behaviour of Unicode escape sequences. In a Java program,
11923 if the Unicode escape sequence <code>\u000A</code>, for example, occurs within a single-line comment, it is interpreted as
11924 a line terminator (Unicode code point U+000A is line feed (lf)) and therefore the next code point is not part of the
11925 comment. Similarly, if the Unicode escape sequence <code>\u000A</code> occurs within a string literal in a Java program,
11926 it is likewise interpreted as a line terminator, which is not allowed within a string literal&mdash;one must write
11927 <code>\n</code> instead of <code>\u000A</code> to cause a line feed (lf) to be part of the string value of a string
11928 literal. In an ECMAScript program, a Unicode escape sequence occurring within a comment is never interpreted and therefore
11929 cannot contribute to termination of the comment. Similarly, a Unicode escape sequence occurring within a string literal in
11930 an ECMAScript program always contributes to the literal and is never interpreted as a line terminator or as a code point
11931 that might terminate the string literal.</p>
11932 </div>
11933 </div>
11934
11935 <section id="sec-utf16encoding">
11936 <h1><span class="secnum" id="sec-10.1.1"><a href="#sec-utf16encoding" title="link to this section">10.1.1</a></span> Static
11937 Semantics: <i>UTF16Encoding ( cp )</i></h1>
11938
11939 <p>The UTF16Encoding of a numeric code point value, <var>cp</var>, is determined as follows:</p>
11940
11941 <ol class="proc">
11942 <li><a href="#sec-algorithm-conventions">Assert</a>: 0 &le; <i>cp</i> &le; 0x10FFFF.</li>
11943 <li>If <i>cp</i> &le; 65535, return <i>cp</i>.</li>
11944 <li>Let <i>cu1</i> be <a href="#sec-algorithm-conventions">floor</a>((<i>cp</i> &ndash; 65536) / 1024) + 0xD800.</li>
11945 <li>Let <i>cu2</i> be ((<i>cp</i> &ndash; 65536) <a href="#sec-algorithm-conventions">modulo</a> 1024) + 0xDC00.</li>
11946 <li>Return the code unit sequence consisting of <i>cu1</i> followed by <i>cu2</i>.</li>
11947 </ol>
11948 </section>
11949
11950 <section id="sec-utf16decode">
11951 <h1><span class="secnum" id="sec-10.1.2"><a href="#sec-utf16decode" title="link to this section">10.1.2</a></span> Static
11952 Semantics: UTF16Decode( lead, trail )</h1>
11953
11954 <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
11955 performing the following steps:</p>
11956
11957 <ol class="proc">
11958 <li><a href="#sec-algorithm-conventions">Assert</a>: 0xD800 &le; <i>lead</i> &le; 0xDBFF and 0xDC00 &le; <i>trail</i> &le;
11959 0xDFFF.</li>
11960 <li>Let <i>cp</i> be (<i>lead</i> &ndash; 0xD800) &times; 1024 + (<i>trail</i> &ndash; 0xDC00) + 0x10000.</li>
11961 <li>Return the code point <i>cp</i>.</li>
11962 </ol>
11963 </section>
11964 </section>
11965
11966 <section id="sec-types-of-source-code">
11967 <div class="front">
11968 <h1><span class="secnum" id="sec-10.2"><a href="#sec-types-of-source-code" title="link to this section">10.2</a></span>
11969 Types of Source Code</h1>
11970
11971 <p>There are four types of ECMAScript code:</p>
11972
11973 <ul>
11974 <li>
11975 <p><i>Global code</i> is source text that is treated as an ECMAScript <i>Script</i>. The global code of a particular
11976 <i>Script</i> does not include any source text that is parsed as part of a <i>FunctionDeclaration</i>,
11977 <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>, <i>GeneratorExpression</i>, <i>MethodDefinition</i>,
11978 <i>ArrowFunction, ClassDeclaration</i>, or <i>ClassExpression</i>.</p>
11979 </li>
11980
11981 <li>
11982 <p><i>Eval code</i> is the source text supplied to the built-in <code>eval</code> function. More precisely, if the
11983 parameter to the built-in <code>eval</code> function is a String, it is treated as an ECMAScript <i>Script</i>. The eval
11984 code for a particular invocation of <code>eval</code> is the global code portion of that <i>Script</i>.</p>
11985 </li>
11986
11987 <li>
11988 <p><i>Function code</i> is source text that is parsed to supply the value of the [[ECMAScriptCode]] and
11989 [[FormalParameters]] internal slots (<a href="#sec-ecmascript-function-objects">see 9.2</a>) of an <a
11990 href="#sec-ecmascript-function-objects">ECMAScript function object</a>. The function code of a particular ECMAScript
11991 function does not include any source text that is parsed as the function code of a nested <i>FunctionDeclaration</i>,
11992 <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>, <i>GeneratorExpression</i>, <i>MethodDefinition</i>,
11993 <i>ArrowFunction, ClassDeclaration</i>, or <i>ClassExpression</i>.</p>
11994 </li>
11995
11996 <li>
11997 <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
11998 directly evaluated when a module is initialized. The module code of a particular module does not include any source text
11999 that is parsed as part of a nested <i>FunctionDeclaration</i>, <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>,
12000 <i>GeneratorExpression</i>, <i>MethodDefinition</i>, <i>ArrowFunction, ClassDeclaration</i>, or
12001 <i>ClassExpression</i>.</p>
12002 </li>
12003 </ul>
12004
12005 <div class="note">
12006 <p><span class="nh">NOTE</span> Function code is generally provided as the bodies of Function Definitions (<a
12007 href="#sec-function-definitions">14.1</a>), Arrow Function Definitions (<a
12008 href="#sec-arrow-function-definitions">14.2</a>), Method Definitions (<a href="#sec-method-definitions">14.3</a>) and
12009 Generator Definitions (<a href="#sec-generator-function-definitions">14.4</a>). Function code is also derived from the
12010 arguments to the <code>Function</code> constructor (<a href="#sec-function-p1-p2-pn-body">19.2.1.1</a>) and the
12011 GeneratorFunction constructor (<a href="#sec-generatorfunction">25.2.1.1</a>).</p>
12012 </div>
12013 </div>
12014
12015 <section id="sec-strict-mode-code">
12016 <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>
12017 Strict Mode Code</h1>
12018
12019 <p>An ECMAScript <span class="nt">Script</span> syntactic unit may be processed using either unrestricted or strict mode
12020 syntax and semantics. Code is interpreted as <i>strict mode code</i> in the following situations:</p>
12021
12022 <ul>
12023 <li>
12024 <p>Global code is strict mode code if it begins with a <a
12025 href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
12026 href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a> (see <a
12027 href="#sec-directive-prologues-and-the-use-strict-directive">14.1.1</a>).</p>
12028 </li>
12029
12030 <li>
12031 <p>Module code is always strict mode code.</p>
12032 </li>
12033
12034 <li>
12035 <p>All parts of a <span class="nt">ClassDeclaration</span> or a <span class="nt">ClassExpression</span> are strict mode
12036 code.</p>
12037 </li>
12038
12039 <li>
12040 <p>Eval code is strict mode code if it begins with a <a
12041 href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
12042 href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a> or if the call to eval is a direct
12043 eval (<a href="#sec-function-calls-runtime-semantics-evaluation">see 12.3.4.1</a>) that is contained in strict mode
12044 code.</p>
12045 </li>
12046
12047 <li>
12048 <p>Function code is strict mode code if the associated <span class="nt">FunctionDeclaration</span>, <span
12049 class="nt">FunctionExpression</span>, <span class="nt">GeneratorDeclaration</span>, <span
12050 class="nt">GeneratorExpression</span>, <span class="nt">MethodDefinition</span>, or <span
12051 class="nt">ArrowFunction</span> is contained in strict mode code or if the code that produces the value of the
12052 function&rsquo;s [[ECMAScriptCode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> begins
12053 with a <a href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
12054 href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a>.</p>
12055 </li>
12056
12057 <li>
12058 <p>Function code that is supplied as the arguments to the built-in <code>Function</code> and <code>Generator</code>
12059 constructors is strict mode code if the last argument is a String that when processed has a <span
12060 class="nt">FunctionBody</span> begins with a <a href="#sec-directive-prologues-and-the-use-strict-directive">Directive
12061 Prologue</a> that contains a <a href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict
12062 Directive</a>.</p>
12063 </li>
12064 </ul>
12065
12066 <p>ECMAScript code that is not strict mode code is called <i>non-strict code</i>.</p>
12067 </section>
12068
12069 <section id="sec-non-ecmascript-functions">
12070 <h1><span class="secnum" id="sec-10.2.2"><a href="#sec-non-ecmascript-functions"
12071 title="link to this section">10.2.2</a></span> Non-ECMAScript Functions</h1>
12072
12073 <p>An ECMAScript implementation may support the evaluation of exotic function objects whose evaluative behaviour is
12074 expressed in some implementation defined form of executable code other than via ECMAScript code. Whether a function object
12075 is an ECMAScript code function or a non-ECMAScript function is not semantically observable from the perspective of an
12076 ECMAScript code function that calls or is called by such a non-ECMAScript function.</p>
12077 </section>
12078 </section>
12079 </section>
12080
12081 <section id="sec-ecmascript-language-lexical-grammar">
12082 <div class="front">
12083 <h1><span class="secnum" id="sec-11"><a href="#sec-ecmascript-language-lexical-grammar"
12084 title="link to this section">11</a></span> ECMAScript Language: Lexical Grammar</h1>
12085
12086 <p>The source text of an ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span> is first converted into a
12087 sequence of input elements, which are tokens, line terminators, comments, or white space. The source text is scanned from left
12088 to right, repeatedly taking the longest possible sequence of code points as the next input element.</p>
12089
12090 <p>There are several situations where the identification of lexical input elements is sensitive to the syntactic grammar
12091 context that is consuming the input elements. This requires multiple goal symbols for the lexical grammar. The <span
12092 class="nt">InputElementRegExpOrTemplateTail</span> goal is used in syntactic grammar contexts where a
12093 <var>RegularExpressionLiteral,</var> a <var>TemplateMiddle,</var> or a <span class="nt">TemplateTail</span> is permitted. The
12094 <span class="nt">InputElementRegExp</span> goal symbol is used in all syntactic grammar contexts where a <span
12095 class="nt">RegularExpressionLiteral</span> is permitted but neither a <var>TemplateMiddle,</var> nor a <span
12096 class="nt">TemplateTail</span> is permitted. The <span class="nt">InputElementTemplateTail</span> goal is used in all
12097 syntactic grammar contexts where a <span class="nt">TemplateMiddle</span> or a <span class="nt">TemplateTail</span> is
12098 permitted but a <span class="nt">RegularExpressionLiteral</span> is not permitted. In all other contexts, <span
12099 class="nt">InputElementDiv</span> is used as the lexical goal symbol.</p>
12100
12101 <div class="note">
12102 <p><span class="nh">NOTE</span> The use of multiple lexical goals ensures that there are no lexical ambiguities that would
12103 affect <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>. For example, there are no syntactic
12104 grammar contexts where both a leading division or division-assignment, and a leading <i>RegularExpressionLiteral</i> are
12105 permitted. This is not affected by semicolon insertion (<a href="#sec-automatic-semicolon-insertion">see 11.9</a>); in
12106 examples such as the following:</p>
12107
12108 <pre>a = b<br>/hi/g.exec(c).map(d);</pre>
12109
12110 <p>where the first non-whitespace, non-comment code point after a <i>LineTerminator</i> is U+002F (SOLIDUS) and the
12111 syntactic context allows division or division-assignment, no semicolon is inserted at the <i>LineTerminator</i>. That is,
12112 the above example is interpreted in the same way as:</p>
12113
12114 <pre>a = b / hi / g.exec(c).map(d);</pre>
12115 </div>
12116
12117 <h2>Syntax</h2>
12118
12119 <div class="gp">
12120 <div class="lhs"><span class="nt">InputElementDiv</span> <span class="geq">::</span></div>
12121 <div class="rhs"><span class="nt">WhiteSpace</span></div>
12122 <div class="rhs"><span class="nt">LineTerminator</span></div>
12123 <div class="rhs"><span class="nt">Comment</span></div>
12124 <div class="rhs"><span class="nt">CommonToken</span></div>
12125 <div class="rhs"><span class="nt">DivPunctuator</span></div>
12126 <div class="rhs"><span class="nt">RightBracePunctuator</span></div>
12127 </div>
12128
12129 <div class="gp">
12130 <div class="lhs"><span class="nt">InputElementRegExp</span> <span class="geq">::</span></div>
12131 <div class="rhs"><span class="nt">WhiteSpace</span></div>
12132 <div class="rhs"><span class="nt">LineTerminator</span></div>
12133 <div class="rhs"><span class="nt">Comment</span></div>
12134 <div class="rhs"><span class="nt">CommonToken</span></div>
12135 <div class="rhs"><span class="nt">RightBracePunctuator</span></div>
12136 <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
12137 </div>
12138
12139 <div class="gp">
12140 <div class="lhs"><span class="nt">InputElementRegExpOrTemplateTail</span> <span class="geq">::</span></div>
12141 <div class="rhs"><span class="nt">WhiteSpace</span></div>
12142 <div class="rhs"><span class="nt">LineTerminator</span></div>
12143 <div class="rhs"><span class="nt">Comment</span></div>
12144 <div class="rhs"><span class="nt">CommonToken</span></div>
12145 <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
12146 <div class="rhs"><span class="nt">TemplateSubstitutionTail</span></div>
12147 </div>
12148
12149 <div class="gp">
12150 <div class="lhs"><span class="nt">InputElementTemplateTail</span> <span class="geq">::</span></div>
12151 <div class="rhs"><span class="nt">WhiteSpace</span></div>
12152 <div class="rhs"><span class="nt">LineTerminator</span></div>
12153 <div class="rhs"><span class="nt">Comment</span></div>
12154 <div class="rhs"><span class="nt">CommonToken</span></div>
12155 <div class="rhs"><span class="nt">DivPunctuator</span></div>
12156 <div class="rhs"><span class="nt">TemplateSubstitutionTail</span></div>
12157 </div>
12158 </div>
12159
12160 <section id="sec-unicode-format-control-characters">
12161 <h1><span class="secnum" id="sec-11.1"><a href="#sec-unicode-format-control-characters"
12162 title="link to this section">11.1</a></span> Unicode Format-Control Characters</h1>
12163
12164 <p>The Unicode format-control characters (i.e., the characters in category &ldquo;Cf&rdquo; in the Unicode Character Database
12165 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
12166 absence of higher-level protocols for this (such as mark-up languages).</p>
12167
12168 <p>It is useful to allow format-control characters in source text to facilitate editing and display. All format control
12169 characters may be used within comments, and within string literals, template literals, and regular expression literals.</p>
12170
12171 <p>U+200C <span style="font-family: Times New Roman">(</span>Zero width non-joiner<span style="font-family: Times New
12172 Roman">)</span> and U+200D <span style="font-family: Times New Roman">(</span>Zero width joiner<span style="font-family: Times
12173 New Roman">)</span> are format-control characters that are used to make necessary distinctions when forming words or phrases
12174 in certain languages. In ECMAScript source text these code points may also be used in an <span
12175 class="nt">IdentifierName</span> (<a href="#sec-identifier-names">see 11.6.1</a>) after the first character.</p>
12176
12177 <p>U+FEFF <span style="font-family: Times New Roman">(</span>Zero Width no-break space<span style="font-family: Times New
12178 Roman">)</span> is a format-control character used primarily at the start of a text to mark it as Unicode and to allow
12179 detection of the text's encoding and byte order. <span style="font-family: Times New Roman">&lt;ZWNBSP&gt;</span> characters
12180 intended for this purpose can sometimes also appear after the start of a text, for example as a result of concatenating files.
12181 In ECMAScript source text &lt;ZWNBSP&gt; code points are treated as white space characters (<a href="#sec-white-space">see
12182 11.2</a>).</p>
12183
12184 <p>The special treatment of certain format-control characters outside of comments, string literals, and regular expression
12185 literals is summarized in <a href="#table-31">Table 31</a>.</p>
12186
12187 <figure>
12188 <figcaption><span id="table-31">Table 31</span> &mdash; Format-Control Code Point Usage</figcaption>
12189 <table class="real-table">
12190 <tr>
12191 <th>Code Point</th>
12192 <th>Name</th>
12193 <th>Abbreviation</th>
12194 <th>Usage</th>
12195 </tr>
12196 <tr>
12197 <td><code>U+200C</code></td>
12198 <td>Zero width non-joiner</td>
12199 <td>&lt;ZWNJ&gt;</td>
12200 <td><i>IdentifierPart</i></td>
12201 </tr>
12202 <tr>
12203 <td><code>U+200D</code></td>
12204 <td>Zero width joiner</td>
12205 <td>&lt;ZWJ&gt;</td>
12206 <td><i>IdentifierPart</i></td>
12207 </tr>
12208 <tr>
12209 <td><code>U+FEFF</code></td>
12210 <td>ZERO WIDTH NO-BREAK SPACE</td>
12211 <td>&lt;ZWNBSP&gt;</td>
12212 <td><i>WhiteSpace</i></td>
12213 </tr>
12214 </table>
12215 </figure>
12216 </section>
12217
12218 <section id="sec-white-space">
12219 <h1><span class="secnum" id="sec-11.2"><a href="#sec-white-space" title="link to this section">11.2</a></span> White
12220 Space</h1>
12221
12222 <p>White space code points are used to improve source text readability and to separate tokens (indivisible lexical units) from
12223 each other, but are otherwise insignificant. White space code points may occur between any two tokens and at the start or end
12224 of input. White space code points may occur within a <span class="nt">StringLiteral</span>, a <span
12225 class="nt">RegularExpressionLiteral</span>, a <span class="nt">Template</span>, or a <span
12226 class="nt">TemplateSubstitutionTail</span> where they are considered significant code points forming part of a literal value.
12227 They may also occur within a <span class="nt">Comment</span>, but cannot appear within any other kind of token.</p>
12228
12229 <p>The ECMAScript white space code points are listed in <a href="#table-32">Table 32</a>.</p>
12230
12231 <figure>
12232 <figcaption><span id="table-32">Table 32</span> &mdash; White Space Code Points</figcaption>
12233 <table class="real-table">
12234 <tr>
12235 <th>Code Point</th>
12236 <th>Name</th>
12237 <th>Abbreviation</th>
12238 </tr>
12239 <tr>
12240 <td><code>U+0009</code></td>
12241 <td>Character Tabulation</td>
12242 <td>&lt;TAB&gt;</td>
12243 </tr>
12244 <tr>
12245 <td><code>U+000B</code></td>
12246 <td>LINE TABULATION</td>
12247 <td>&lt;VT&gt;</td>
12248 </tr>
12249 <tr>
12250 <td><code>U+000C</code></td>
12251 <td>Form Feed (ff)</td>
12252 <td>&lt;FF&gt;</td>
12253 </tr>
12254 <tr>
12255 <td><code>U+0020</code></td>
12256 <td>Space</td>
12257 <td>&lt;SP&gt;</td>
12258 </tr>
12259 <tr>
12260 <td><code>U+00A0</code></td>
12261 <td>No-break space</td>
12262 <td>&lt;NBSP&gt;</td>
12263 </tr>
12264 <tr>
12265 <td><code>U+FEFF</code></td>
12266 <td>ZERO wIDTH nO-bREAK SPACE</td>
12267 <td>&lt;ZWNBSP&gt;</td>
12268 </tr>
12269 <tr>
12270 <td>Other category &ldquo;Zs&rdquo;</td>
12271 <td>Any other Unicode &ldquo;Separator, space&rdquo; code point</td>
12272 <td>&lt;USP&gt;</td>
12273 </tr>
12274 </table>
12275 </figure>
12276
12277 <p>ECMAScript implementations must recognize as <span class="nt">WhiteSpace</span> code points listed in the &ldquo;Separator,
12278 space&rdquo; (Zs) category by Unicode 5.1. ECMAScript implementations may also recognize as <span class="nt">WhiteSpace</span>
12279 additional category Zs code points from subsequent editions of the Unicode Standard.</p>
12280
12281 <div class="note">
12282 <p><span class="nh">NOTE</span> Other than for the code points listed in <a href="#table-32">Table 32</a>, ECMAScript
12283 <i>WhiteSpace</i> intentionally excludes all code points that have the Unicode &ldquo;White_Space&rdquo; property but which
12284 are not classified in category &ldquo;Zs&rdquo;.</p>
12285 </div>
12286
12287 <h2>Syntax</h2>
12288
12289 <div class="gp">
12290 <div class="lhs"><span class="nt">WhiteSpace</span> <span class="geq">::</span></div>
12291 <div class="rhs">&lt;TAB&gt;</div>
12292 <div class="rhs">&lt;VT&gt;</div>
12293 <div class="rhs">&lt;FF&gt;</div>
12294 <div class="rhs">&lt;SP&gt;</div>
12295 <div class="rhs">&lt;NBSP&gt;</div>
12296 <div class="rhs">&lt;zwnbsp&gt;</div>
12297 <div class="rhs">&lt;USP&gt;</div>
12298 </div>
12299 </section>
12300
12301 <section id="sec-line-terminators">
12302 <h1><span class="secnum" id="sec-11.3"><a href="#sec-line-terminators" title="link to this section">11.3</a></span> Line
12303 Terminators</h1>
12304
12305 <p>Like white space code points, line terminator code points are used to improve source text readability and to separate
12306 tokens (indivisible lexical units) from each other. However, unlike white space code points, line terminators have some
12307 influence over the behaviour of the syntactic grammar. In general, line terminators may occur between any two tokens, but
12308 there are a few places where they are forbidden by the syntactic grammar. Line terminators also affect the process of <a
12309 href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a
12310 href="#sec-automatic-semicolon-insertion">11.9</a>). A line terminator cannot occur within any token except a <span
12311 class="nt">StringLiteral</span>, <span class="nt">Template</span>, or <span class="nt">TemplateSubstitutionTail</span>. Line
12312 terminators may only occur within a <span class="nt">StringLiteral</span> token as part of a <span
12313 class="nt">LineContinuation</span>.</p>
12314
12315 <p>A line terminator can occur within a <span class="nt">MultiLineComment</span> (<a href="#sec-comments">11.4</a>) but cannot
12316 occur within a <span class="nt">SingleLineComment</span>.</p>
12317
12318 <p>Line terminators are included in the set of white space code points that are matched by the <code>\s</code> class in
12319 regular expressions.</p>
12320
12321 <p>The ECMAScript line terminator code points are listed in <a href="#table-33">Table 33</a>.</p>
12322
12323 <figure>
12324 <figcaption><span id="table-33">Table 33</span> &mdash; Line Terminator Code Points</figcaption>
12325 <table class="real-table">
12326 <tr>
12327 <th>Code Point</th>
12328 <th>Unicode Name</th>
12329 <th>Abbreviation</th>
12330 </tr>
12331 <tr>
12332 <td><code>U+000A</code></td>
12333 <td>Line Feed (LF)</td>
12334 <td>&lt;LF&gt;</td>
12335 </tr>
12336 <tr>
12337 <td><code>U+000D</code></td>
12338 <td>Carriage Return (CR)</td>
12339 <td>&lt;CR&gt;</td>
12340 </tr>
12341 <tr>
12342 <td><code>U+2028</code></td>
12343 <td>Line separator</td>
12344 <td>&lt;LS&gt;</td>
12345 </tr>
12346 <tr>
12347 <td><code>U+2029</code></td>
12348 <td>Paragraph separator</td>
12349 <td>&lt;PS&gt;</td>
12350 </tr>
12351 </table>
12352 </figure>
12353
12354 <p>Only the Unicode code points in <a href="#table-33">Table 33</a> are treated as line terminators. Other new line or line
12355 breaking Unicode code points are not treated as line terminators but are treated as white space if they meet the requirements
12356 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
12357 be considered a single <span class="nt">SourceCharacter</span> for the purpose of reporting line numbers.</p>
12358
12359 <h2>Syntax</h2>
12360
12361 <div class="gp">
12362 <div class="lhs"><span class="nt">LineTerminator</span> <span class="geq">::</span></div>
12363 <div class="rhs">&lt;LF&gt;</div>
12364 <div class="rhs">&lt;CR&gt;</div>
12365 <div class="rhs">&lt;LS&gt;</div>
12366 <div class="rhs">&lt;PS&gt;</div>
12367 </div>
12368
12369 <div class="gp">
12370 <div class="lhs"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></div>
12371 <div class="rhs">&lt;LF&gt;</div>
12372 <div class="rhs">&lt;CR&gt; <span class="grhsannot">[lookahead &ne; &lt;LF&gt; ]</span></div>
12373 <div class="rhs">&lt;LS&gt;</div>
12374 <div class="rhs">&lt;PS&gt;</div>
12375 <div class="rhs">&lt;CR&gt; &lt;LF&gt;</div>
12376 </div>
12377 </section>
12378
12379 <section id="sec-comments">
12380 <h1><span class="secnum" id="sec-11.4"><a href="#sec-comments" title="link to this section">11.4</a></span> Comments</h1>
12381
12382 <p>Comments can be either single or multi-line. Multi-line comments cannot nest.</p>
12383
12384 <p>Because a single-line comment can contain any Unicode code point except a <span class="nt">LineTerminator</span> code
12385 point, and because of the general rule that a token is always as long as possible, a single-line comment always consists of
12386 all code points from the <code>//</code> marker to the end of the line. However, the <span class="nt">LineTerminator</span> at
12387 the end of the line is not considered to be part of the single-line comment; it is recognized separately by the lexical
12388 grammar and becomes part of the stream of input elements for the syntactic grammar. This point is very important, because it
12389 implies that the presence or absence of single-line comments does not affect the process of <a
12390 href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a href="#sec-automatic-semicolon-insertion">see
12391 11.9</a>).</p>
12392
12393 <p>Comments behave like white space and are discarded except that, if a <span class="nt">MultiLineComment</span> contains a
12394 line terminator code point, then the entire comment is considered to be a <span class="nt">LineTerminator</span> for purposes
12395 of parsing by the syntactic grammar.</p>
12396
12397 <h2>Syntax</h2>
12398
12399 <div class="gp">
12400 <div class="lhs"><span class="nt">Comment</span> <span class="geq">::</span></div>
12401 <div class="rhs"><span class="nt">MultiLineComment</span></div>
12402 <div class="rhs"><span class="nt">SingleLineComment</span></div>
12403 </div>
12404
12405 <div class="gp">
12406 <div class="lhs"><span class="nt">MultiLineComment</span> <span class="geq">::</span></div>
12407 <div class="rhs"><code class="t">/*</code> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub> <code class="t">*/</code></div>
12408 </div>
12409
12410 <div class="gp">
12411 <div class="lhs"><span class="nt">MultiLineCommentChars</span> <span class="geq">::</span></div>
12412 <div class="rhs"><span class="nt">MultiLineNotAsteriskChar</span> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub></div>
12413 <div class="rhs"><code class="t">*</code> <span class="nt">PostAsteriskCommentChars</span><sub class="g-opt">opt</sub></div>
12414 </div>
12415
12416 <div class="gp">
12417 <div class="lhs"><span class="nt">PostAsteriskCommentChars</span> <span class="geq">::</span></div>
12418 <div class="rhs"><span class="nt">MultiLineNotForwardSlashOrAsteriskChar</span> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub></div>
12419 <div class="rhs"><code class="t">*</code> <span class="nt">PostAsteriskCommentChars</span><sub class="g-opt">opt</sub></div>
12420 </div>
12421
12422 <div class="gp">
12423 <div class="lhs"><span class="nt">MultiLineNotAsteriskChar</span> <span class="geq">::</span></div>
12424 <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <code class="t">*</code></div>
12425 </div>
12426
12427 <div class="gp">
12428 <div class="lhs"><span class="nt">MultiLineNotForwardSlashOrAsteriskChar</span> <span class="geq">::</span></div>
12429 <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>
12430 </div>
12431
12432 <div class="gp">
12433 <div class="lhs"><span class="nt">SingleLineComment</span> <span class="geq">::</span></div>
12434 <div class="rhs"><code class="t">//</code> <span class="nt">SingleLineCommentChars</span><sub class="g-opt">opt</sub></div>
12435 </div>
12436
12437 <div class="gp">
12438 <div class="lhs"><span class="nt">SingleLineCommentChars</span> <span class="geq">::</span></div>
12439 <div class="rhs"><span class="nt">SingleLineCommentChar</span> <span class="nt">SingleLineCommentChars</span><sub class="g-opt">opt</sub></div>
12440 </div>
12441
12442 <div class="gp">
12443 <div class="lhs"><span class="nt">SingleLineCommentChar</span> <span class="geq">::</span></div>
12444 <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <span class="nt">LineTerminator</span></div>
12445 </div>
12446 </section>
12447
12448 <section id="sec-tokens">
12449 <h1><span class="secnum" id="sec-11.5"><a href="#sec-tokens" title="link to this section">11.5</a></span> Tokens</h1>
12450 <h2>Syntax</h2>
12451
12452 <div class="gp">
12453 <div class="lhs"><span class="nt">CommonToken</span> <span class="geq">::</span></div>
12454 <div class="rhs"><span class="nt">IdentifierName</span></div>
12455 <div class="rhs"><span class="nt">Punctuator</span></div>
12456 <div class="rhs"><span class="nt">NumericLiteral</span></div>
12457 <div class="rhs"><span class="nt">StringLiteral</span></div>
12458 <div class="rhs"><span class="nt">Template</span></div>
12459 </div>
12460
12461 <div class="note">
12462 <p><span class="nh">NOTE</span> The <i>DivPunctuator</i>, <i>RegularExpressionLiteral</i>, <i>RightBracePunctuator,</i> and
12463 <i>TemplateSubstitutionTail</i> productions derive additional tokens that are not included in the <i>CommonToken</i>
12464 production.</p>
12465 </div>
12466 </section>
12467
12468 <section id="sec-names-and-keywords">
12469 <div class="front">
12470 <h1><span class="secnum" id="sec-11.6"><a href="#sec-names-and-keywords" title="link to this section">11.6</a></span> Names
12471 and Keywords</h1>
12472
12473 <p><span class="nt">IdentifierName</span> and <span class="nt">ReservedWord</span> are tokens that are interpreted according
12474 to the Default Identifier Syntax given in Unicode Standard Annex #31, Identifier and Pattern Syntax, with some small
12475 modifications. <span class="nt">ReservedWord</span> is an enumerated subset of <span style="font-family: Times New
12476 Roman"><i>IdentifierName</i>.</span> The syntactic grammar defines <span class="nt">Identifier</span> as an <span
12477 class="nt">IdentifierName</span> that is not a <span class="nt">ReservedWord</span> (<a href="#sec-reserved-words">see
12478 11.6.2</a>). The Unicode identifier grammar is based on character properties specified by the Unicode Standard. The Unicode
12479 code points in the specified categories in version 5.1.0 of the Unicode standard must be treated as in those categories by
12480 all conforming ECMAScript implementations. ECMAScript implementations may recognize identifier code points defined in later
12481 editions of the Unicode Standard.</p>
12482
12483 <div class="note">
12484 <p><span class="nh">NOTE</span> This standard specifies specific code point additions: <span style="font-family:
12485 sans-serif">U+0024</span> (dollar sign) and <span style="font-family: sans-serif">U+005F</span> (<span style="font-family:
12486 sans-serif">LOW LINE</span>) are permitted anywhere in an <i>IdentifierName</i><span style="font-family: sans-serif">, and
12487 the code points</span> <span style="font-family: sans-serif">U+200C (zero-width non-joiner) and U+200D (zero-width joiner)
12488 are permitted anywhere after the first code point</span> <span style="font-family: sans-serif">of an</span>
12489 <i>IdentifierName</i>.</p>
12490 </div>
12491
12492 <p>Unicode escape sequences are permitted in an <span class="nt">IdentifierName</span>, where they contribute a single
12493 Unicode code point to the <span class="nt">IdentifierName</span>. The code point is expressed by the <span
12494 class="nt">HexDigits</span> of the <span class="nt">UnicodeEscapeSequence</span> (<a
12495 href="#sec-literals-string-literals">see 11.8.4</a>). The <code>\</code> preceding the <span
12496 class="nt">UnicodeEscapeSequence</span> and the <code>u</code> and <code>{ }</code> code units, if they appear, do not
12497 contribute code points to the <span class="nt">IdentifierName</span>. A <span class="nt">UnicodeEscapeSequence</span> cannot
12498 be used to put a code point into an <span class="nt">IdentifierName</span> that would otherwise be illegal. In other words,
12499 if a <code>\</code> <span class="nt">UnicodeEscapeSequence</span> sequence were replaced by the <span
12500 class="nt">SourceCharacter</span> it contributes, the result must still be a valid <span class="nt">IdentifierName</span>
12501 that has the exact same sequence of <span class="nt">SourceCharacter</span> elements as the original <span
12502 class="nt">IdentifierName</span>. All interpretations of <span class="nt">IdentifierName</span> within this specification
12503 are based upon their actual code points regardless of whether or not an escape sequence was used to contribute any
12504 particular code point.</p>
12505
12506 <p>Two <span class="nt">IdentifierName</span> that are canonically equivalent according to the Unicode standard are
12507 <i>not</i> equal unless, after replacement of each <span class="nt">UnicodeEscapeSequence</span>, they are represented by
12508 the exact same sequence of code points.</p>
12509
12510 <h2>Syntax</h2>
12511
12512 <div class="gp">
12513 <div class="lhs"><span class="nt">IdentifierName</span> <span class="geq">::</span></div>
12514 <div class="rhs"><span class="nt">IdentifierStart</span></div>
12515 <div class="rhs"><span class="nt">IdentifierName</span> <span class="nt">IdentifierPart</span></div>
12516 </div>
12517
12518 <div class="gp">
12519 <div class="lhs"><span class="nt">IdentifierStart</span> <span class="geq">::</span></div>
12520 <div class="rhs"><span class="nt">UnicodeIDStart</span></div>
12521 <div class="rhs"><code class="t">$</code></div>
12522 <div class="rhs"><code class="t">_</code></div>
12523 <div class="rhs"><code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
12524 </div>
12525
12526 <div class="gp">
12527 <div class="lhs"><span class="nt">IdentifierPart</span> <span class="geq">::</span></div>
12528 <div class="rhs"><span class="nt">UnicodeIDContinue</span></div>
12529 <div class="rhs"><code class="t">$</code></div>
12530 <div class="rhs"><code class="t">_</code></div>
12531 <div class="rhs"><code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
12532 <div class="rhs">&lt;ZWNJ&gt;</div>
12533 <div class="rhs">&lt;ZWJ&gt;</div>
12534 </div>
12535
12536 <div class="gp">
12537 <div class="lhs"><span class="nt">UnicodeIDStart</span> <span class="geq">::</span></div>
12538 <div class="rhs"><span class="gprose">any Unicode code point with the Unicode property &ldquo;ID_Start&rdquo;</span></div>
12539 </div>
12540
12541 <div class="gp">
12542 <div class="lhs"><span class="nt">UnicodeIDContinue</span> <span class="geq">::</span></div>
12543 <div class="rhs"><span class="gprose">any Unicode code point with the Unicode property &ldquo;ID_Continue&rdquo;</span></div>
12544 </div>
12545
12546 <p>The definitions of the nonterminal <span class="nt">UnicodeEscapeSequence</span> is given in <a
12547 href="#sec-literals-string-literals">11.8.4</a>.</p>
12548
12549 <div class="note">
12550 <p><span class="nh">NOTE</span> The sets of code points with Unicode properties &ldquo;ID_Start&rdquo; and
12551 &ldquo;ID_Continue&rdquo; include, respectively, the code points with Unicode properties &ldquo;Other_ID_Start&rdquo; and
12552 &ldquo;Other_ID_Continue&rdquo;.</p>
12553 </div>
12554 </div>
12555
12556 <section id="sec-identifier-names">
12557 <div class="front">
12558 <h1><span class="secnum" id="sec-11.6.1"><a href="#sec-identifier-names" title="link to this section">11.6.1</a></span>
12559 Identifier Names</h1>
12560 </div>
12561
12562 <section id="sec-identifier-names-static-semantics-early-errors">
12563 <h1><span class="secnum" id="sec-11.6.1.1"><a href="#sec-identifier-names-static-semantics-early-errors"
12564 title="link to this section">11.6.1.1</a></span> Static Semantics: Early Errors</h1>
12565 <div class="gp prod"><span class="nt">IdentifierStart</span> <span class="geq">::</span> <code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
12566 <ul>
12567 <li>
12568 <p>It is a Syntax Error if <span style="font-family: Times New Roman">SV(<i>UnicodeEscapeSequence</i>)</span> is none
12569 of <code>"$"</code>, or <code>"_"</code>, or the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
12570 href="#sec-utf16encoding">10.1.1</a>) of a code point that would be matched by the <span
12571 class="nt">UnicodeIDStart</span> lexical grammar production.</p>
12572 </li>
12573 </ul>
12574 <div class="gp prod"><span class="nt">IdentifierPart</span> <span class="geq">::</span> <code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
12575 <ul>
12576 <li>
12577 <p>It is a Syntax Error if <span style="font-family: Times New Roman">SV(<i>UnicodeEscapeSequence</i>)</span> is none
12578 of <code>"$"</code>, or <code>"_"</code>, or the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
12579 href="#sec-utf16encoding">10.1.1</a>) of either &lt;ZWNJ&gt; or &lt;ZWJ&gt;, or the <a
12580 href="#sec-utf16encoding">UTF16Encoding</a> of a Unicode code point that would be matched by the <span
12581 class="nt">UnicodeIDContinue</span> lexical grammar production.</p>
12582 </li>
12583 </ul>
12584 </section>
12585
12586 <section id="sec-identifier-names-static-semantics-stringvalue">
12587 <h1><span class="secnum" id="sec-11.6.1.2"><a href="#sec-identifier-names-static-semantics-stringvalue"
12588 title="link to this section">11.6.1.2</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
12589 <i>StringValue</i></h1>
12590
12591 <p>See also: <a href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>, <a
12592 href="#sec-identifiers-static-semantics-stringvalue">12.1.4</a>.</p>
12593
12594 <div class="gp">
12595 <div class="lhs"><span class="nt">IdentifierName</span> <span class="geq">::</span></div>
12596 <div class="rhs"><span class="nt">IdentifierStart</span></div>
12597 <div class="rhs"><span class="nt">IdentifierName</span> <span class="nt">IdentifierPart</span></div>
12598 </div>
12599
12600 <ol class="proc">
12601 <li>Return the String value consisting of the sequence of code units corresponding to <i>IdentifierName</i>. In
12602 determining the sequence any occurrences of <code>\</code> <i>UnicodeEscapeSequence</i> are first replaced with the
12603 code point represented by the <i>UnicodeEscapeSequence</i> and then the code points of the entire
12604 <i>IdentifierName</i> are converted to code units by <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
12605 href="#sec-utf16encoding">10.1.1</a>) each code point.</li>
12606 </ol>
12607 </section>
12608 </section>
12609
12610 <section id="sec-reserved-words">
12611 <div class="front">
12612 <h1><span class="secnum" id="sec-11.6.2"><a href="#sec-reserved-words" title="link to this section">11.6.2</a></span>
12613 Reserved Words</h1>
12614
12615 <p>A reserved word is an <span class="nt">IdentifierName</span> that cannot be used as an <span
12616 class="nt">Identifier</span>.</p>
12617
12618 <h2>Syntax</h2>
12619
12620 <div class="gp">
12621 <div class="lhs"><span class="nt">ReservedWord</span> <span class="geq">::</span></div>
12622 <div class="rhs"><span class="nt">Keyword</span></div>
12623 <div class="rhs"><span class="nt">FutureReservedWord</span></div>
12624 <div class="rhs"><span class="nt">NullLiteral</span></div>
12625 <div class="rhs"><span class="nt">BooleanLiteral</span></div>
12626 </div>
12627
12628 <div class="note">
12629 <p><span class="nh">NOTE</span> The <i>ReservedWord</i> definitions are specified as literal sequences of specific
12630 <i>SourceCharacter</i> elements. A code point in a <i>ReservedWord</i> cannot be expressed by a <code>\</code>
12631 <i>UnicodeEscapeSequence</i>.</p>
12632 </div>
12633 </div>
12634
12635 <section id="sec-keywords">
12636 <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>
12637 Keywords</h1>
12638
12639 <p>The following tokens are ECMAScript keywords and may not be used as <span class="nt">Identifiers</span> in ECMAScript
12640 programs.</p>
12641
12642 <h2>Syntax</h2>
12643 <div class="gp prod"><span class="nt">Keyword</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
12644
12645 <figure>
12646 <table class="lightweight-table">
12647 <tr>
12648 <td><code>break</code></td>
12649 <td><code>do</code></td>
12650 <td><code>in</code></td>
12651 <td><code>typeof</code></td>
12652 </tr>
12653 <tr>
12654 <td><code>case</code></td>
12655 <td><code>else</code></td>
12656 <td><code>instanceof</code></td>
12657 <td><code>var</code></td>
12658 </tr>
12659 <tr>
12660 <td><code>catch</code></td>
12661 <td><code>export</code></td>
12662 <td><code>new</code></td>
12663 <td><code>void</code></td>
12664 </tr>
12665 <tr>
12666 <td><code>class</code></td>
12667 <td><code>extends</code></td>
12668 <td><code>return</code></td>
12669 <td><code>while</code></td>
12670 </tr>
12671 <tr>
12672 <td><code>const</code></td>
12673 <td><code>finally</code></td>
12674 <td><code>super</code></td>
12675 <td><code>with</code></td>
12676 </tr>
12677 <tr>
12678 <td><code>continue</code></td>
12679 <td><code>for</code></td>
12680 <td><code>switch</code></td>
12681 <td><code>yield</code></td>
12682 </tr>
12683 <tr>
12684 <td><code>debugger</code></td>
12685 <td><code>function</code></td>
12686 <td><code>this</code></td>
12687 <td></td>
12688 </tr>
12689 <tr>
12690 <td><code>default</code></td>
12691 <td><code>if</code></td>
12692 <td><code>throw</code></td>
12693 <td></td>
12694 </tr>
12695 <tr>
12696 <td><code>delete</code></td>
12697 <td><code>import</code></td>
12698 <td><code>try</code></td>
12699 <td></td>
12700 </tr>
12701 </table>
12702 </figure>
12703
12704 <div class="note">
12705 <p><span class="nh">NOTE</span> In some contexts <code>yield</code> is given the semantics of an <i>Identifier</i>. See
12706 <a href="#sec-identifiers-static-semantics-early-errors">12.1.1</a>. In <a href="#sec-strict-mode-code">strict mode
12707 code</a>, <code>let</code> and <code>static</code> are treated as reserved keywords through static semantic restrictions
12708 (see <a href="#sec-identifiers-static-semantics-early-errors">12.1.1</a>, <a
12709 href="#sec-let-and-const-declarations-static-semantics-early-errors">13.2.1.1</a>, <a
12710 href="#sec-for-in-and-for-of-statements-static-semantics-early-errors">13.6.4.1</a>, and <a
12711 href="#sec-class-definitions-static-semantics-early-errors">14.5.1</a>) rather than the lexical grammar.</p>
12712 </div>
12713 </section>
12714
12715 <section id="sec-future-reserved-words">
12716 <h1><span class="secnum" id="sec-11.6.2.2"><a href="#sec-future-reserved-words"
12717 title="link to this section">11.6.2.2</a></span> Future Reserved Words</h1>
12718
12719 <p>The following tokens are reserved for used as keywords in future language extensions.</p>
12720
12721 <h2>Syntax</h2>
12722 <div class="gp prod"><span class="nt">FutureReservedWord</span> <span class="geq">::</span></div>
12723
12724 <figure>
12725 <table class="lightweight-table">
12726 <tr>
12727 <td><code>enum<br>await</code></td>
12728 <td></td>
12729 <td></td>
12730 <td></td>
12731 </tr>
12732 </table>
12733 </figure>
12734
12735 <p><code>await</code> is only treated as a <span class="nt">FutureReservedWord</span> when <span class="nt">Module</span>
12736 is the goal symbol of the syntactic grammar.</p>
12737
12738 <div class="note">
12739 <p><span class="nh">NOTE</span> Use of the following tokens within <a href="#sec-strict-mode-code">strict mode code</a>
12740 (<a href="#sec-strict-mode-code">see 10.2.1</a>) is also reserved. That usage is restricted using static semantic
12741 restrictions (<a href="#sec-identifiers-static-semantics-early-errors">see 12.1.1</a>) rather than the lexical
12742 grammar:</p>
12743 </div>
12744
12745 <figure>
12746 <table class="lightweight-table">
12747 <tr>
12748 <td><code>implements</code></td>
12749 <td><code>package</code></td>
12750 <td><code>protected</code></td>
12751 <td></td>
12752 </tr>
12753 <tr>
12754 <td><code>interface</code></td>
12755 <td><code>private</code></td>
12756 <td><code>public</code></td>
12757 <td></td>
12758 </tr>
12759 </table>
12760 </figure>
12761 </section>
12762 </section>
12763 </section>
12764
12765 <section id="sec-punctuators">
12766 <h1><span class="secnum" id="sec-11.7"><a href="#sec-punctuators" title="link to this section">11.7</a></span>
12767 Punctuators</h1>
12768 <h2>Syntax</h2>
12769 <div class="gp prod"><span class="nt">Punctuator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
12770
12771 <figure>
12772 <table class="lightweight-table">
12773 <tr>
12774 <td><code>{</code></td>
12775 <td><code>(</code></td>
12776 <td><code>)</code></td>
12777 <td><code>[</code></td>
12778 <td><code>]</code></td>
12779 <td><code>.</code></td>
12780 </tr>
12781 <tr>
12782 <td><code>...</code></td>
12783 <td><code>;</code></td>
12784 <td><code>,</code></td>
12785 <td><code>&lt;</code></td>
12786 <td><code>&gt;</code></td>
12787 <td><code>&lt;=</code></td>
12788 </tr>
12789 <tr>
12790 <td><code>&gt;=</code></td>
12791 <td><code>==</code></td>
12792 <td><code>!=</code></td>
12793 <td><code>===</code></td>
12794 <td><code>!==</code></td>
12795 <td></td>
12796 </tr>
12797 <tr>
12798 <td><code>+</code></td>
12799 <td><code>-</code></td>
12800 <td><code>*</code></td>
12801 <td><code>%</code></td>
12802 <td><code>++</code></td>
12803 <td><code>--</code></td>
12804 </tr>
12805 <tr>
12806 <td><code>&lt;&lt;</code></td>
12807 <td><code>&gt;&gt;</code></td>
12808 <td><code>&gt;&gt;&gt;</code></td>
12809 <td><code>&amp;</code></td>
12810 <td><code>|</code></td>
12811 <td><code>^</code></td>
12812 </tr>
12813 <tr>
12814 <td><code>!</code></td>
12815 <td><code>~</code></td>
12816 <td><code>&amp;&amp;</code></td>
12817 <td><code>||</code></td>
12818 <td><code>?</code></td>
12819 <td><code>:</code></td>
12820 </tr>
12821 <tr>
12822 <td><code>=</code></td>
12823 <td><code>+=</code></td>
12824 <td><code>-=</code></td>
12825 <td><code>*=</code></td>
12826 <td><code>%=</code></td>
12827 <td><code>&lt;&lt;=</code></td>
12828 </tr>
12829 <tr>
12830 <td><code>&gt;&gt;=</code></td>
12831 <td><code>&gt;&gt;&gt;=</code></td>
12832 <td><code>&amp;=</code></td>
12833 <td><code>|=</code></td>
12834 <td><code>^=</code></td>
12835 <td><code>=&gt;</code></td>
12836 </tr>
12837 </table>
12838 </figure>
12839
12840 <div class="gp prod"><span class="nt">DivPunctuator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
12841
12842 <figure>
12843 <table class="lightweight-table">
12844 <tr>
12845 <td><code>/</code></td>
12846 <td><code>/=</code></td>
12847 <td></td>
12848 <td></td>
12849 <td></td>
12850 <td></td>
12851 </tr>
12852 </table>
12853 </figure>
12854
12855 <div class="gp prod"><span class="nt">RightBracePunctuator</span> <span class="geq">::</span></div>
12856
12857 <figure>
12858 <table class="lightweight-table">
12859 <tr>
12860 <td><code>}</code></td>
12861 <td></td>
12862 <td></td>
12863 <td></td>
12864 <td></td>
12865 <td></td>
12866 </tr>
12867 </table>
12868 </figure>
12869 </section>
12870
12871 <section id="sec-ecmascript-language-lexical-grammar-literals">
12872 <div class="front">
12873 <h1><span class="secnum" id="sec-11.8"><a href="#sec-ecmascript-language-lexical-grammar-literals"
12874 title="link to this section">11.8</a></span> Literals</h1>
12875 </div>
12876
12877 <section id="sec-null-literals">
12878 <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
12879 Literals</h1>
12880 <h2>Syntax</h2>
12881
12882 <div class="gp">
12883 <div class="lhs"><span class="nt">NullLiteral</span> <span class="geq">::</span></div>
12884 <div class="rhs"><code class="t">null</code></div>
12885 </div>
12886 </section>
12887
12888 <section id="sec-boolean-literals">
12889 <h1><span class="secnum" id="sec-11.8.2"><a href="#sec-boolean-literals" title="link to this section">11.8.2</a></span>
12890 Boolean Literals</h1>
12891 <h2>Syntax</h2>
12892
12893 <div class="gp">
12894 <div class="lhs"><span class="nt">BooleanLiteral</span> <span class="geq">::</span></div>
12895 <div class="rhs"><code class="t">true</code></div>
12896 <div class="rhs"><code class="t">false</code></div>
12897 </div>
12898 </section>
12899
12900 <section id="sec-literals-numeric-literals">
12901 <div class="front">
12902 <h1><span class="secnum" id="sec-11.8.3"><a href="#sec-literals-numeric-literals"
12903 title="link to this section">11.8.3</a></span> Numeric Literals</h1>
12904 <h2>Syntax</h2>
12905
12906 <div class="gp">
12907 <div class="lhs"><span class="nt">NumericLiteral</span> <span class="geq">::</span></div>
12908 <div class="rhs"><span class="nt">DecimalLiteral</span></div>
12909 <div class="rhs"><span class="nt">BinaryIntegerLiteral</span></div>
12910 <div class="rhs"><span class="nt">OctalIntegerLiteral</span></div>
12911 <div class="rhs"><span class="nt">HexIntegerLiteral</span></div>
12912 </div>
12913
12914 <div class="gp">
12915 <div class="lhs"><span class="nt">DecimalLiteral</span> <span class="geq">::</span></div>
12916 <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>
12917 <div class="rhs"><code class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
12918 <div class="rhs"><span class="nt">DecimalIntegerLiteral</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
12919 </div>
12920
12921 <div class="gp">
12922 <div class="lhs"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span></div>
12923 <div class="rhs"><code class="t">0</code></div>
12924 <div class="rhs"><span class="nt">NonZeroDigit</span> <span class="nt">DecimalDigits</span><sub class="g-opt">opt</sub></div>
12925 </div>
12926
12927 <div class="gp">
12928 <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">::</span></div>
12929 <div class="rhs"><span class="nt">DecimalDigit</span></div>
12930 <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
12931 </div>
12932
12933 <div class="gp">
12934 <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
12935 <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>
12936 </div>
12937
12938 <div class="gp">
12939 <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
12940 <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>
12941 </div>
12942
12943 <div class="gp">
12944 <div class="lhs"><span class="nt">ExponentPart</span> <span class="geq">::</span></div>
12945 <div class="rhs"><span class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></div>
12946 </div>
12947
12948 <div class="gp">
12949 <div class="lhs"><span class="nt">ExponentIndicator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
12950 <div class="rhs"><code class="t">e</code> <code class="t">E</code></div>
12951 </div>
12952
12953 <div class="gp">
12954 <div class="lhs"><span class="nt">SignedInteger</span> <span class="geq">::</span></div>
12955 <div class="rhs"><span class="nt">DecimalDigits</span></div>
12956 <div class="rhs"><code class="t">+</code> <span class="nt">DecimalDigits</span></div>
12957 <div class="rhs"><code class="t">-</code> <span class="nt">DecimalDigits</span></div>
12958 </div>
12959
12960 <div class="gp">
12961 <div class="lhs"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span></div>
12962 <div class="rhs"><code class="t">0b</code> <span class="nt">BinaryDigits</span></div>
12963 <div class="rhs"><code class="t">0B</code> <span class="nt">BinaryDigits</span></div>
12964 </div>
12965
12966 <div class="gp">
12967 <div class="lhs"><span class="nt">BinaryDigits</span> <span class="geq">::</span></div>
12968 <div class="rhs"><span class="nt">BinaryDigit</span></div>
12969 <div class="rhs"><span class="nt">BinaryDigits</span> <span class="nt">BinaryDigit</span></div>
12970 </div>
12971
12972 <div class="gp">
12973 <div class="lhs"><span class="nt">BinaryDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
12974 <div class="rhs"><code class="t">0</code> <code class="t">1</code></div>
12975 </div>
12976
12977 <div class="gp">
12978 <div class="lhs"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span></div>
12979 <div class="rhs"><code class="t">0o</code> <span class="nt">OctalDigits</span></div>
12980 <div class="rhs"><code class="t">0O</code> <span class="nt">OctalDigits</span></div>
12981 </div>
12982
12983 <div class="gp">
12984 <div class="lhs"><span class="nt">OctalDigits</span> <span class="geq">::</span></div>
12985 <div class="rhs"><span class="nt">OctalDigit</span></div>
12986 <div class="rhs"><span class="nt">OctalDigits</span> <span class="nt">OctalDigit</span></div>
12987 </div>
12988
12989 <div class="gp">
12990 <div class="lhs"><span class="nt">OctalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
12991 <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>
12992 </div>
12993
12994 <div class="gp">
12995 <div class="lhs"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span></div>
12996 <div class="rhs"><code class="t">0x</code> <span class="nt">HexDigits</span></div>
12997 <div class="rhs"><code class="t">0X</code> <span class="nt">HexDigits</span></div>
12998 </div>
12999
13000 <div class="gp">
13001 <div class="lhs"><span class="nt">HexDigits</span> <span class="geq">::</span></div>
13002 <div class="rhs"><span class="nt">HexDigit</span></div>
13003 <div class="rhs"><span class="nt">HexDigits</span> <span class="nt">HexDigit</span></div>
13004 </div>
13005
13006 <div class="gp">
13007 <div class="lhs"><span class="nt">HexDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
13008 <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>
13009 </div>
13010
13011 <p>The <span class="nt">SourceCharacter</span> immediately following a <span class="nt">NumericLiteral</span> must not be
13012 an <span class="nt">IdentifierStart</span> or <span class="nt">DecimalDigit</span>.</p>
13013
13014 <div class="note">
13015 <p><span class="nh">NOTE</span> For example:</p>
13016
13017 <pre>3in</pre>
13018
13019 <p>is an error and not the two input elements <code>3</code> and <code>in</code>.</p>
13020 </div>
13021
13022 <p>A conforming implementation, when processing <a href="#sec-strict-mode-code">strict mode code</a> (<a
13023 href="#sec-strict-mode-code">see 10.2.1</a>), must not extend, as described in <a
13024 href="#sec-additional-syntax-numeric-literals">B.1.1</a>, the syntax of <span class="nt">NumericLiteral</span> to include
13025 <i>Legacy<span style="font-family: Times New Roman">OctalIntegerLiteral</span></i>, nor extend the syntax of <span
13026 class="nt">DecimalIntegerLiteral</span> to include <span class="nt">NonOctalDecimalIntegerLiteral</span>.</p>
13027 </div>
13028
13029 <section id="sec-static-semantics-mv-s">
13030 <h1><span class="secnum" id="sec-11.8.3.1"><a href="#sec-static-semantics-mv-s"
13031 title="link to this section">11.8.3.1</a></span> Static Semantics: MV&rsquo;s</h1>
13032
13033 <p>A numeric literal stands for a value of the Number type. This value is determined in two steps: first, a mathematical
13034 value (MV) is derived from the literal; second, this mathematical value is rounded as described below.</p>
13035
13036 <ul>
13037 <li>
13038 <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
13039 class="nt">DecimalLiteral</span></span> is the MV of <i>DecimalLiteral</i>.</p>
13040 </li>
13041
13042 <li>
13043 <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
13044 class="nt">BinaryIntegerLiteral</span></span> is the MV of <i>BinaryIntegerLiteral</i>.</p>
13045 </li>
13046
13047 <li>
13048 <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
13049 class="nt">OctalIntegerLiteral</span></span> is the MV of <i>OctalIntegerLiteral</i>.</p>
13050 </li>
13051
13052 <li>
13053 <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
13054 class="nt">HexIntegerLiteral</span></span> is the MV of <i>HexIntegerLiteral</i>.</p>
13055 </li>
13056
13057 <li>
13058 <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
13059 class="nt">DecimalIntegerLiteral</span> <code class="t">.</code></span> is the MV of <i>DecimalIntegerLiteral</i>.</p>
13060 </li>
13061
13062 <li>
13063 <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
13064 class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">DecimalDigits</span></span> is the
13065 MV of <i>DecimalIntegerLiteral</i> plus (the MV of <i>DecimalDigits</i> &times; 10<sup>&ndash;<i>n</i></sup>), where
13066 <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
13067 </li>
13068
13069 <li>
13070 <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
13071 class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">ExponentPart</span></span> is the MV
13072 of <i>DecimalIntegerLiteral</i> &times; 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
13073 </li>
13074
13075 <li>
13076 <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
13077 class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">DecimalDigits</span> <span
13078 class="nt">ExponentPart</span></span> is (the MV of <i>DecimalIntegerLiteral</i> plus (the MV of <i>DecimalDigits</i>
13079 &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
13080 <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
13081 </li>
13082
13083 <li>
13084 <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <code
13085 class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i> &times;
13086 10<sup>&ndash;<i>n</i></sup>, where <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
13087 </li>
13088
13089 <li>
13090 <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <code
13091 class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of
13092 <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
13093 <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
13094 </li>
13095
13096 <li>
13097 <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
13098 class="nt">DecimalIntegerLiteral</span></span> is the MV of <i>DecimalIntegerLiteral</i>.</p>
13099 </li>
13100
13101 <li>
13102 <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
13103 class="nt">DecimalIntegerLiteral</span> <span class="nt">ExponentPart</span></span> is the MV of
13104 <i>DecimalIntegerLiteral</i> &times; 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
13105 </li>
13106
13107 <li>
13108 <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <code
13109 class="t">0</code></span> is 0.</p>
13110 </li>
13111
13112 <li>
13113 <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <span
13114 class="nt">NonZeroDigit</span></span> is the MV of <i>NonZeroDigit.</i></p>
13115 </li>
13116
13117 <li>
13118 <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <span
13119 class="nt">NonZeroDigit</span> <span class="nt">DecimalDigits</span></span> is (the MV of <i>NonZeroDigit</i> &times;
13120 10<sup><i>n</i></sup>) plus the MV of <i>DecimalDigits</i>, where <i>n</i> is the number of code points in
13121 <i>DecimalDigits</i>.</p>
13122 </li>
13123
13124 <li>
13125 <p>The MV of <span class="prod"><span class="nt">DecimalDigits</span> <span class="geq">::</span> <span
13126 class="nt">DecimalDigit</span></span> is the MV of <i>DecimalDigit</i>.</p>
13127 </li>
13128
13129 <li>
13130 <p>The MV of <span class="prod"><span class="nt">DecimalDigits</span> <span class="geq">::</span> <span
13131 class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></span> is (the MV of <i>DecimalDigits</i> &times;
13132 10) plus the MV of <i>DecimalDigit</i>.</p>
13133 </li>
13134
13135 <li>
13136 <p>The MV of <span class="prod"><span class="nt">ExponentPart</span> <span class="geq">::</span> <span
13137 class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></span> is the MV of
13138 <i>SignedInteger</i>.</p>
13139 </li>
13140
13141 <li>
13142 <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <span
13143 class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
13144 </li>
13145
13146 <li>
13147 <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <code
13148 class="t">+</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
13149 </li>
13150
13151 <li>
13152 <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <code
13153 class="t">-</code> <span class="nt">DecimalDigits</span></span> is the negative of the MV of <i>DecimalDigits</i>.</p>
13154 </li>
13155
13156 <li>
13157 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13158 class="t">0</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13159 class="t">0</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span class="geq">::</span>
13160 <code class="t">0</code></span> or of <span class="prod"><span class="nt">BinaryDigit</span> <span
13161 class="geq">::</span> <code class="t">0</code></span> is 0.</p>
13162 </li>
13163
13164 <li>
13165 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13166 class="t">1</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13167 <code class="t">1</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13168 <code class="t">1</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
13169 class="geq">::</span> <code class="t">1</code></span> or<br>of <span class="prod"><span class="nt">BinaryDigit</span>
13170 <span class="geq">::</span> <code class="t">1</code></span> is 1.</p>
13171 </li>
13172
13173 <li>
13174 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13175 class="t">2</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13176 <code class="t">2</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13177 <code class="t">2</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
13178 class="geq">::</span> <code class="t">2</code></span> is 2.</p>
13179 </li>
13180
13181 <li>
13182 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13183 class="t">3</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13184 <code class="t">3</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13185 <code class="t">3</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
13186 class="geq">::</span> <code class="t">3</code></span> is 3.</p>
13187 </li>
13188
13189 <li>
13190 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13191 class="t">4</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13192 <code class="t">4</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13193 <code class="t">4</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
13194 class="geq">::</span> <code class="t">4</code></span> is 4.</p>
13195 </li>
13196
13197 <li>
13198 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13199 class="t">5</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13200 <code class="t">5</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13201 <code class="t">5</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
13202 class="geq">::</span> <code class="t">5</code></span> is 5.</p>
13203 </li>
13204
13205 <li>
13206 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13207 class="t">6</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13208 <code class="t">6</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13209 <code class="t">6</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
13210 class="geq">::</span> <code class="t">6</code></span> is 6.</p>
13211 </li>
13212
13213 <li>
13214 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13215 class="t">7</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13216 <code class="t">7</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13217 <code class="t">7</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
13218 class="geq">::</span> <code class="t">7</code></span> is 7.</p>
13219 </li>
13220
13221 <li>
13222 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13223 class="t">8</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13224 <code class="t">8</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13225 <code class="t">8</code></span> is 8.</p>
13226 </li>
13227
13228 <li>
13229 <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
13230 class="t">9</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
13231 <code class="t">9</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
13232 <code class="t">9</code></span> is 9.</p>
13233 </li>
13234
13235 <li>
13236 <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13237 class="t">a</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13238 class="t">A</code></span> is 10.</p>
13239 </li>
13240
13241 <li>
13242 <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13243 class="t">b</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13244 class="t">B</code></span> is 11.</p>
13245 </li>
13246
13247 <li>
13248 <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13249 class="t">c</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13250 class="t">C</code></span> is 12.</p>
13251 </li>
13252
13253 <li>
13254 <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13255 class="t">d</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13256 class="t">D</code></span> is 13.</p>
13257 </li>
13258
13259 <li>
13260 <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13261 class="t">e</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13262 class="t">E</code></span> is 14.</p>
13263 </li>
13264
13265 <li>
13266 <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13267 class="t">f</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
13268 class="t">F</code></span> is 15.</p>
13269 </li>
13270
13271 <li>
13272 <p>The MV of <span class="prod"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span> <code
13273 class="t">0b</code> <span class="nt">BinaryDigits</span></span> is the MV of <i>BinaryDigits</i>.</p>
13274 </li>
13275
13276 <li>
13277 <p>The MV of <span class="prod"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span> <code
13278 class="t">0B</code> <span class="nt">BinaryDigits</span></span> is the MV of <i>BinaryDigits</i>.</p>
13279 </li>
13280
13281 <li>
13282 <p>The MV of <span class="prod"><span class="nt">BinaryDigits</span> <span class="geq">::</span> <span
13283 class="nt">BinaryDigit</span></span> is the MV of <i>BinaryDigit</i>.</p>
13284 </li>
13285
13286 <li>
13287 <p>The MV of <span class="prod"><span class="nt">BinaryDigits</span> <span class="geq">::</span> <span
13288 class="nt">BinaryDigits</span> <span class="nt">BinaryDigit</span></span> is (the MV of <i>BinaryDigits</i> &times; 2)
13289 plus the MV of <i>BinaryDigit</i>.</p>
13290 </li>
13291
13292 <li>
13293 <p>The MV of <span class="prod"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span> <code
13294 class="t">0o</code> <span class="nt">OctalDigits</span></span> is the MV of <i>OctalDigits</i>.</p>
13295 </li>
13296
13297 <li>
13298 <p>The MV of <span class="prod"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span> <code
13299 class="t">0O</code> <span class="nt">OctalDigits</span></span> is the MV of <i>OctalDigits</i>.</p>
13300 </li>
13301
13302 <li>
13303 <p>The MV of <span class="prod"><span class="nt">OctalDigits</span> <span class="geq">::</span> <span
13304 class="nt">OctalDigit</span></span> is the MV of <i>OctalDigit</i>.</p>
13305 </li>
13306
13307 <li>
13308 <p>The MV of <span class="prod"><span class="nt">OctalDigits</span> <span class="geq">::</span> <span
13309 class="nt">OctalDigits</span> <span class="nt">OctalDigit</span></span> is (the MV of <i>OctalDigits</i> &times; 8)
13310 plus the MV of <i>OctalDigit</i>.</p>
13311 </li>
13312
13313 <li>
13314 <p>The MV of <span class="prod"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span> <code
13315 class="t">0x</code> <span class="nt">HexDigits</span></span> is the MV of <i>HexDigits</i>.</p>
13316 </li>
13317
13318 <li>
13319 <p>The MV of <span class="prod"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span> <code
13320 class="t">0X</code> <span class="nt">HexDigits</span></span> is the MV of <i>HexDigits</i>.</p>
13321 </li>
13322
13323 <li>
13324 <p>The MV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
13325 class="nt">HexDigit</span></span> is the MV of <i>HexDigit</i>.</p>
13326 </li>
13327
13328 <li>
13329 <p>The MV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
13330 class="nt">HexDigits</span> <span class="nt">HexDigit</span></span> is (the MV of <i>HexDigits</i> &times; 16) plus
13331 the MV of <i>HexDigit</i>.</p>
13332 </li>
13333 </ul>
13334
13335 <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
13336 MV is 0, then the rounded value is <span class="value">+0</span>; otherwise, the rounded value must be the Number value
13337 for the MV (as specified in <a href="#sec-ecmascript-language-types-number-type">6.1.6</a>), unless the literal is a <span
13338 class="nt">DecimalLiteral</span> and the literal has more than 20 significant digits, in which case the Number value may
13339 be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a
13340 <code>0</code> digit or the Number value for the MV of a literal produced by replacing each significant digit after the
13341 20th with a <code>0</code> digit and then incrementing the literal at the 20th significant digit position. A digit is
13342 <i>significant</i> if it is not part of an <span class="nt">ExponentPart</span> and</p>
13343
13344 <ul>
13345 <li>it is not <code>0</code>; or</li>
13346 <li>there is a nonzero digit to its left and there is a nonzero digit, not in the <i>ExponentPart</i>, to its
13347 right.</li>
13348 </ul>
13349 </section>
13350 </section>
13351
13352 <section id="sec-literals-string-literals">
13353 <div class="front">
13354 <h1><span class="secnum" id="sec-11.8.4"><a href="#sec-literals-string-literals"
13355 title="link to this section">11.8.4</a></span> String Literals</h1>
13356
13357 <div class="note">
13358 <p><span class="nh">NOTE</span> A string literal is zero or more Unicode code points enclosed in single or double
13359 quotes. Unicode code points may also be represented by an escape sequence. All <span style="font-family:
13360 sans-serif">code points</span> may appear literally in a string literal except for the closing quote <span
13361 style="font-family: sans-serif">code points</span>, U+005C (REVERSE SOLIDUS), U+000D (carriage return), U+2028 (line
13362 separator), U+2029 (paragraph separator), and U+000A (line feed). Any <span style="font-family: sans-serif">code
13363 points</span> may appear in the form of an escape sequence. String literals evaluate to ECMAScript String values. When
13364 generating these string values Unicode code points are UTF-16 encoded as defined in <a
13365 href="#sec-utf16encoding">10.1.1</a>. Code points belonging to the Basic Multilingual Plane are encoded as a single code
13366 unit element of the string. All other code points are encoded as two code unit elements of the string.</p>
13367 </div>
13368
13369 <h2>Syntax</h2>
13370
13371 <div class="gp">
13372 <div class="lhs"><span class="nt">StringLiteral</span> <span class="geq">::</span></div>
13373 <div class="rhs"><code class="t">"</code> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">"</code></div>
13374 <div class="rhs"><code class="t">'</code> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">'</code></div>
13375 </div>
13376
13377 <div class="gp">
13378 <div class="lhs"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span></div>
13379 <div class="rhs"><span class="nt">DoubleStringCharacter</span> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub></div>
13380 </div>
13381
13382 <div class="gp">
13383 <div class="lhs"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span></div>
13384 <div class="rhs"><span class="nt">SingleStringCharacter</span> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub></div>
13385 </div>
13386
13387 <div class="gp">
13388 <div class="lhs"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span></div>
13389 <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>
13390 <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
13391 <div class="rhs"><span class="nt">LineContinuation</span></div>
13392 </div>
13393
13394 <div class="gp">
13395 <div class="lhs"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span></div>
13396 <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>
13397 <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
13398 <div class="rhs"><span class="nt">LineContinuation</span></div>
13399 </div>
13400
13401 <div class="gp">
13402 <div class="lhs"><span class="nt">LineContinuation</span> <span class="geq">::</span></div>
13403 <div class="rhs"><code class="t">\</code> <span class="nt">LineTerminatorSequence</span></div>
13404 </div>
13405
13406 <div class="gp">
13407 <div class="lhs"><span class="nt">EscapeSequence</span> <span class="geq">::</span></div>
13408 <div class="rhs"><span class="nt">CharacterEscapeSequence</span></div>
13409 <div class="rhs"><code class="t">0</code> <span class="grhsannot">[lookahead &notin; <span class="nt">DecimalDigit</span>]</span></div>
13410 <div class="rhs"><span class="nt">HexEscapeSequence</span></div>
13411 <div class="rhs"><span class="nt">UnicodeEscapeSequence</span></div>
13412 </div>
13413
13414 <p>A conforming implementation, when processing <a href="#sec-strict-mode-code">strict mode code</a> (<a
13415 href="#sec-strict-mode-code">see 10.2.1</a>), must not extend the syntax of <span class="nt">EscapeSequence</span> to
13416 include <i>Legacy<span style="font-family: Times New Roman">OctalEscapeSequence</span></i> as described in <a
13417 href="#sec-additional-syntax-string-literals">B.1.2</a>.</p>
13418
13419 <div class="gp">
13420 <div class="lhs"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span></div>
13421 <div class="rhs"><span class="nt">SingleEscapeCharacter</span></div>
13422 <div class="rhs"><span class="nt">NonEscapeCharacter</span></div>
13423 </div>
13424
13425 <div class="gp">
13426 <div class="lhs"><span class="nt">SingleEscapeCharacter</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
13427 <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>
13428 </div>
13429
13430 <div class="gp">
13431 <div class="lhs"><span class="nt">NonEscapeCharacter</span> <span class="geq">::</span></div>
13432 <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>
13433 </div>
13434
13435 <div class="gp">
13436 <div class="lhs"><span class="nt">EscapeCharacter</span> <span class="geq">::</span></div>
13437 <div class="rhs"><span class="nt">SingleEscapeCharacter</span></div>
13438 <div class="rhs"><span class="nt">DecimalDigit</span></div>
13439 <div class="rhs"><code class="t">x</code></div>
13440 <div class="rhs"><code class="t">u</code></div>
13441 </div>
13442
13443 <div class="gp">
13444 <div class="lhs"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span></div>
13445 <div class="rhs"><code class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></div>
13446 </div>
13447
13448 <div class="gp">
13449 <div class="lhs"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span></div>
13450 <div class="rhs"><code class="t">u</code> <span class="nt">Hex4Digits</span></div>
13451 <div class="rhs"><code class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></div>
13452 </div>
13453
13454 <div class="gp">
13455 <div class="lhs"><span class="nt">Hex4Digits</span> <span class="geq">::</span></div>
13456 <div class="rhs"><span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></div>
13457 </div>
13458
13459 <p>The definition of the nonterminal <span class="nt">HexDigit</span> is given in <a
13460 href="#sec-literals-numeric-literals">11.8.3</a>. <span class="nt">SourceCharacter</span> is defined in <a
13461 href="#sec-source-text">10.1</a>.</p>
13462
13463 <div class="note">
13464 <p><span class="nh">NOTE</span> A line terminator <span style="font-family: sans-serif">code point</span> cannot appear
13465 in a string literal, except as part of a <i>LineContinuation</i> to produce the empty <span style="font-family:
13466 sans-serif">code points</span> sequence. The proper way to cause a line terminator <span style="font-family:
13467 sans-serif">code point</span> to be part of the String value of a string literal is to use an escape sequence such as
13468 <code>\n</code> or <code>\u000A</code>.</p>
13469 </div>
13470 </div>
13471
13472 <section id="sec-string-literals-static-semantics-early-errors">
13473 <h1><span class="secnum" id="sec-11.8.4.1"><a href="#sec-string-literals-static-semantics-early-errors"
13474 title="link to this section">11.8.4.1</a></span> Static Semantics: Early Errors</h1>
13475 <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>
13476 <ul>
13477 <li>It is a Syntax Error if the MV of <span class="nt">HexDigits</span> &gt; <span style="font-family: Times New
13478 Roman">1114111<i>.</i></span></li>
13479 </ul>
13480 </section>
13481
13482 <section id="sec-string-literals-static-semantics-stringvalue">
13483 <h1><span class="secnum" id="sec-11.8.4.2"><a href="#sec-string-literals-static-semantics-stringvalue"
13484 title="link to this section">11.8.4.2</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
13485 <i>StringValue</i></h1>
13486
13487 <p>See also: <a href="#sec-identifier-names-static-semantics-stringvalue">11.6.1.2</a>, <a
13488 href="#sec-identifiers-static-semantics-stringvalue">12.1.4</a>.</p>
13489
13490 <div class="gp">
13491 <div class="lhs"><span class="nt">StringLiteral</span> <span class="geq">::</span></div>
13492 <div class="rhs"><code class="t">"</code> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">"</code></div>
13493 <div class="rhs"><code class="t">'</code> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">'</code></div>
13494 </div>
13495
13496 <ol class="proc">
13497 <li>Return the String value whose elements are the SV of this <i>StringLiteral</i>.</li>
13498 </ol>
13499 </section>
13500
13501 <section id="sec-static-semantics-sv-s">
13502 <h1><span class="secnum" id="sec-11.8.4.3"><a href="#sec-static-semantics-sv-s"
13503 title="link to this section">11.8.4.3</a></span> Static Semantics: <i>SV&rsquo;s</i></h1>
13504
13505 <p>A string literal stands for a value of the String type. The String value (SV) of the literal is described in terms of
13506 code unit values contributed by the various parts of the string literal. As part of this process, some Unicode code points
13507 within the string literal are interpreted as having a mathematical value (MV), as described below or in <a
13508 href="#sec-literals-numeric-literals">11.8.3</a>.</p>
13509
13510 <ul>
13511 <li>
13512 <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
13513 class="t">""</code></span> is the empty code unit sequence.</p>
13514 </li>
13515
13516 <li>
13517 <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
13518 class="t">''</code></span> is the empty code unit sequence.</p>
13519 </li>
13520
13521 <li>
13522 <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
13523 class="t">"</code> <span class="nt">DoubleStringCharacters</span> <code class="t">"</code></span> is the SV of
13524 <i>DoubleStringCharacters</i>.</p>
13525 </li>
13526
13527 <li>
13528 <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
13529 class="t">'</code> <span class="nt">SingleStringCharacters</span> <code class="t">'</code></span> is the SV of
13530 <i>SingleStringCharacters</i>.</p>
13531 </li>
13532
13533 <li>
13534 <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span> <span
13535 class="nt">DoubleStringCharacter</span></span> is a sequence of one or two code units that is the SV of
13536 <i>DoubleStringCharacter</i>.</p>
13537 </li>
13538
13539 <li>
13540 <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span> <span
13541 class="nt">DoubleStringCharacter</span> <span class="nt">DoubleStringCharacters</span></span> is a sequence of one or
13542 two code units that is the SV of <i>DoubleStringCharacter</i> followed by all the code units in the SV of
13543 <i>DoubleStringCharacters</i> in order.</p>
13544 </li>
13545
13546 <li>
13547 <p>The SV of <span class="prod"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span> <span
13548 class="nt">SingleStringCharacter</span></span> is a sequence of one or two code units that is the SV of
13549 <i>SingleStringCharacter</i>.</p>
13550 </li>
13551
13552 <li>
13553 <p>The SV of <span class="prod"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span> <span
13554 class="nt">SingleStringCharacter</span> <span class="nt">SingleStringCharacters</span></span> is a sequence of one or
13555 two code units that is the SV of <i>SingleStringCharacter</i> followed by all the code units in the SV of
13556 <i>SingleStringCharacters</i> in order.</p>
13557 </li>
13558
13559 <li>
13560 <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <span
13561 class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">"</code> <span
13562 class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <span
13563 class="nt">LineTerminator</span></span> is the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
13564 href="#sec-utf16encoding">10.1.1</a>) of the code point value of <i>SourceCharacter</i>.</p>
13565 </li>
13566
13567 <li>
13568 <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <code
13569 class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of the <i>EscapeSequence</i>.</p>
13570 </li>
13571
13572 <li>
13573 <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <span
13574 class="nt">LineContinuation</span></span> is the empty code unit sequence.</p>
13575 </li>
13576
13577 <li>
13578 <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <span
13579 class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">'</code> <span
13580 class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <span
13581 class="nt">LineTerminator</span></span> is the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
13582 href="#sec-utf16encoding">10.1.1</a>) of the code point value of <i>SourceCharacter</i>.</p>
13583 </li>
13584
13585 <li>
13586 <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <code
13587 class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of the <i>EscapeSequence</i>.</p>
13588 </li>
13589
13590 <li>
13591 <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <span
13592 class="nt">LineContinuation</span></span> is the empty code unit sequence.</p>
13593 </li>
13594
13595 <li>
13596 <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
13597 class="nt">CharacterEscapeSequence</span></span> is the SV of the <i>CharacterEscapeSequence</i>.</p>
13598 </li>
13599
13600 <li>
13601 <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <code
13602 class="t">0</code></span> is the code unit value 0.</p>
13603 </li>
13604
13605 <li>
13606 <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
13607 class="nt">HexEscapeSequence</span></span> is the SV of the <i>HexEscapeSequence</i>.</p>
13608 </li>
13609
13610 <li>
13611 <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
13612 class="nt">UnicodeEscapeSequence</span></span> is the SV of the <i>UnicodeEscapeSequence</i>.</p>
13613 </li>
13614
13615 <li>
13616 <p>The SV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
13617 class="nt">SingleEscapeCharacter</span></span> is the code unit whose value is determined by the
13618 <i>SingleEscapeCharacter</i> according to { REF _Ref365803173 \h }<a href="#table-34">Table 34</a>.</p>
13619 </li>
13620 </ul>
13621
13622 <figure>
13623 <figcaption><span id="table-34">Table 34</span> &mdash; String Single Character Escape Sequences</figcaption>
13624 <table class="real-table">
13625 <tr>
13626 <th>Escape Sequence</th>
13627 <th>Code Unit Value</th>
13628 <th>Unicode Character Name</th>
13629 <th>Symbol</th>
13630 </tr>
13631 <tr>
13632 <td><code>\b</code></td>
13633 <td><code>0x0008</code></td>
13634 <td>BACKSPACE</td>
13635 <td>&lt;BS&gt;</td>
13636 </tr>
13637 <tr>
13638 <td><code>\t</code></td>
13639 <td><code>0x0009</code></td>
13640 <td>CHARACTER TABULATION</td>
13641 <td>&lt;HT&gt;</td>
13642 </tr>
13643 <tr>
13644 <td><code>\n</code></td>
13645 <td><code>0x000A</code></td>
13646 <td>line feed (lf)</td>
13647 <td>&lt;LF&gt;</td>
13648 </tr>
13649 <tr>
13650 <td><code>\v</code></td>
13651 <td><code>0x000B</code></td>
13652 <td>LINE TABULATION</td>
13653 <td>&lt;VT&gt;</td>
13654 </tr>
13655 <tr>
13656 <td><code>\f</code></td>
13657 <td><code>0x000C</code></td>
13658 <td>form feed (ff)</td>
13659 <td>&lt;FF&gt;</td>
13660 </tr>
13661 <tr>
13662 <td><code>\r</code></td>
13663 <td><code>0x000D</code></td>
13664 <td>carriage return (cr)</td>
13665 <td>&lt;CR&gt;</td>
13666 </tr>
13667 <tr>
13668 <td><code>\"</code></td>
13669 <td><code>0x0022</code></td>
13670 <td>quotation Mark</td>
13671 <td><code>"</code></td>
13672 </tr>
13673 <tr>
13674 <td><code>\'</code></td>
13675 <td><code>0x0027</code></td>
13676 <td>apostrophe</td>
13677 <td><code>'</code></td>
13678 </tr>
13679 <tr>
13680 <td><code>\\</code></td>
13681 <td><code>0x005C</code></td>
13682 <td>REverse Solidus</td>
13683 <td><code>\</code></td>
13684 </tr>
13685 </table>
13686 </figure>
13687
13688 <ul>
13689 <li>
13690 <p>The SV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
13691 class="nt">NonEscapeCharacter</span></span> is the SV of the <i>NonEscapeCharacter</i>.</p>
13692 </li>
13693
13694 <li>
13695 <p>The SV of <span class="prod"><span class="nt">NonEscapeCharacter</span> <span class="geq">::</span> <span
13696 class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <span class="nt">EscapeCharacter</span>
13697 <span class="grhsmod">or</span> <span class="nt">LineTerminator</span></span> is the <a
13698 href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
13699 <i>SourceCharacter</i>.</p>
13700 </li>
13701
13702 <li>
13703 <p>The SV of <span class="prod"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span> <code
13704 class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></span> is the code unit value
13705 that is (16 times the MV of the first <i>HexDigit</i>) plus the MV of the second <i>HexDigit</i>.</p>
13706 </li>
13707
13708 <li>
13709 <p>The SV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
13710 class="t">u</code> <span class="nt">Hex4Digits</span></span> is the SV of <var>Hex4Digits.</var></p>
13711 </li>
13712
13713 <li>
13714 <p>The SV of <span class="prod"><span class="nt">Hex4Digits</span> <span class="geq">::</span> <span
13715 class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span
13716 class="nt">HexDigit</span></span> is the code unit value that is (4096 times the MV of the first <i>HexDigit</i>) plus
13717 (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
13718 the fourth <i>HexDigit</i>.</p>
13719 </li>
13720
13721 <li>
13722 <p>The SV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
13723 class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></span> is the <a
13724 href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the MV of
13725 <i>HexDigits</i>.</p>
13726 </li>
13727 </ul>
13728 </section>
13729 </section>
13730
13731 <section id="sec-literals-regular-expression-literals">
13732 <div class="front">
13733 <h1><span class="secnum" id="sec-11.8.5"><a href="#sec-literals-regular-expression-literals"
13734 title="link to this section">11.8.5</a></span> Regular Expression Literals</h1>
13735
13736 <div class="note">
13737 <p><span class="nh">NOTE</span> A regular expression literal is an input element that is converted to a RegExp object
13738 (<a href="#sec-regexp-regular-expression-objects">see 21.2</a>) each time the literal is evaluated. Two regular
13739 expression literals in a program evaluate to regular expression objects that never compare as <code>===</code> to each
13740 other even if the two literals' contents are identical. A RegExp object may also be created at runtime by <code>new
13741 RegExp</code> or calling the <code>RegExp</code> constructor as a function (<a href="#sec-regexp-constructor">see
13742 21.2.3</a>).</p>
13743 </div>
13744
13745 <p>The productions below describe the syntax for a regular expression literal and are used by the input element scanner to
13746 find the end of the regular expression literal. The source text comprising the <span
13747 class="nt">RegularExpressionBody</span> and the <span class="nt">RegularExpressionFlags</span> are subsequently parsed
13748 again using the more stringent ECMAScript Regular Expression grammar (<a href="#sec-patterns">21.2.1</a>).</p>
13749
13750 <p>An implementation may extend the ECMAScript Regular Expression grammar defined in <a href="#sec-patterns">21.2.1</a>,
13751 but it must not extend the <span class="nt">RegularExpressionBody</span> and <span
13752 class="nt">RegularExpressionFlags</span> productions defined below or the productions used by these productions.</p>
13753
13754 <h2>Syntax</h2>
13755
13756 <div class="gp">
13757 <div class="lhs"><span class="nt">RegularExpressionLiteral</span> <span class="geq">::</span></div>
13758 <div class="rhs"><code class="t">/</code> <span class="nt">RegularExpressionBody</span> <code class="t">/</code> <span class="nt">RegularExpressionFlags</span></div>
13759 </div>
13760
13761 <div class="gp">
13762 <div class="lhs"><span class="nt">RegularExpressionBody</span> <span class="geq">::</span></div>
13763 <div class="rhs"><span class="nt">RegularExpressionFirstChar</span> <span class="nt">RegularExpressionChars</span></div>
13764 </div>
13765
13766 <div class="gp">
13767 <div class="lhs"><span class="nt">RegularExpressionChars</span> <span class="geq">::</span></div>
13768 <div class="rhs"><span class="grhsannot">[empty]</span></div>
13769 <div class="rhs"><span class="nt">RegularExpressionChars</span> <span class="nt">RegularExpressionChar</span></div>
13770 </div>
13771
13772 <div class="gp">
13773 <div class="lhs"><span class="nt">RegularExpressionFirstChar</span> <span class="geq">::</span></div>
13774 <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>
13775 <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
13776 <div class="rhs"><span class="nt">RegularExpressionClass</span></div>
13777 </div>
13778
13779 <div class="gp">
13780 <div class="lhs"><span class="nt">RegularExpressionChar</span> <span class="geq">::</span></div>
13781 <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>
13782 <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
13783 <div class="rhs"><span class="nt">RegularExpressionClass</span></div>
13784 </div>
13785
13786 <div class="gp">
13787 <div class="lhs"><span class="nt">RegularExpressionBackslashSequence</span> <span class="geq">::</span></div>
13788 <div class="rhs"><code class="t">\</code> <span class="nt">RegularExpressionNonTerminator</span></div>
13789 </div>
13790
13791 <div class="gp">
13792 <div class="lhs"><span class="nt">RegularExpressionNonTerminator</span> <span class="geq">::</span></div>
13793 <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <span class="nt">LineTerminator</span></div>
13794 </div>
13795
13796 <div class="gp">
13797 <div class="lhs"><span class="nt">RegularExpressionClass</span> <span class="geq">::</span></div>
13798 <div class="rhs"><code class="t">[</code> <span class="nt">RegularExpressionClassChars</span> <code class="t">]</code></div>
13799 </div>
13800
13801 <div class="gp">
13802 <div class="lhs"><span class="nt">RegularExpressionClassChars</span> <span class="geq">::</span></div>
13803 <div class="rhs"><span class="grhsannot">[empty]</span></div>
13804 <div class="rhs"><span class="nt">RegularExpressionClassChars</span> <span class="nt">RegularExpressionClassChar</span></div>
13805 </div>
13806
13807 <div class="gp">
13808 <div class="lhs"><span class="nt">RegularExpressionClassChar</span> <span class="geq">::</span></div>
13809 <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>
13810 <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
13811 </div>
13812
13813 <div class="gp">
13814 <div class="lhs"><span class="nt">RegularExpressionFlags</span> <span class="geq">::</span></div>
13815 <div class="rhs"><span class="grhsannot">[empty]</span></div>
13816 <div class="rhs"><span class="nt">RegularExpressionFlags</span> <span class="nt">IdentifierPart</span></div>
13817 </div>
13818
13819 <div class="note">
13820 <p><span class="nh">NOTE</span> Regular expression literals may not be empty; instead of representing an empty regular
13821 expression literal, the code unit sequence <code>//</code> starts a single-line comment. To specify an empty regular
13822 expression, use: <code>/(?:)/</code>.</p>
13823 </div>
13824 </div>
13825
13826 <section id="sec-literals-regular-expression-literals-static-semantics-early-errors">
13827 <h1><span class="secnum" id="sec-11.8.5.1"><a
13828 href="#sec-literals-regular-expression-literals-static-semantics-early-errors"
13829 title="link to this section">11.8.5.1</a></span> Static Semantics: Early Errors</h1>
13830 <div class="gp prod"><span class="nt">RegularExpressionFlags</span> <span class="geq">::</span> <span class="nt">RegularExpressionFlags</span> <span class="nt">IdentifierPart</span></div>
13831 <ul>
13832 <li>It is a Syntax Error if <span class="nt">IdentifierPart</span> contains a Unicode escape sequence<var>.</var></li>
13833 </ul>
13834 </section>
13835
13836 <section id="sec-static-semantics-bodytext">
13837 <h1><span class="secnum" id="sec-11.8.5.2"><a href="#sec-static-semantics-bodytext"
13838 title="link to this section">11.8.5.2</a></span> Static Semantics: <i>BodyText</i></h1>
13839 <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>
13840 <ol class="proc">
13841 <li>Return the source text that was recognized as <i>RegularExpressionBody</i>.</li>
13842 </ol>
13843 </section>
13844
13845 <section id="sec-static-semantics-flagtext">
13846 <h1><span class="secnum" id="sec-11.8.5.3"><a href="#sec-static-semantics-flagtext"
13847 title="link to this section">11.8.5.3</a></span> Static Semantics: <i>FlagText</i></h1>
13848 <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>
13849 <ol class="proc">
13850 <li>Return the source text that was recognized as <i>RegularExpressionFlags</i>.</li>
13851 </ol>
13852 </section>
13853 </section>
13854
13855 <section id="sec-template-literal-lexical-components">
13856 <div class="front">
13857 <h1><span class="secnum" id="sec-11.8.6"><a href="#sec-template-literal-lexical-components"
13858 title="link to this section">11.8.6</a></span> Template Literal Lexical Components</h1>
13859 <h2>Syntax</h2>
13860
13861 <div class="gp">
13862 <div class="lhs"><span class="nt">Template</span> <span class="geq">::</span></div>
13863 <div class="rhs"><span class="nt">NoSubstitutionTemplate</span></div>
13864 <div class="rhs"><span class="nt">TemplateHead</span></div>
13865 </div>
13866
13867 <div class="gp">
13868 <div class="lhs"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span></div>
13869 <div class="rhs"><code class="t">`</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">`</code></div>
13870 </div>
13871
13872 <div class="gp">
13873 <div class="lhs"><span class="nt">TemplateHead</span> <span class="geq">::</span></div>
13874 <div class="rhs"><code class="t">`</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">${</code></div>
13875 </div>
13876
13877 <div class="gp">
13878 <div class="lhs"><span class="nt">TemplateSubstitutionTail</span> <span class="geq">::</span></div>
13879 <div class="rhs"><span class="nt">TemplateMiddle</span></div>
13880 <div class="rhs"><span class="nt">TemplateTail</span></div>
13881 </div>
13882
13883 <div class="gp">
13884 <div class="lhs"><span class="nt">TemplateMiddle</span> <span class="geq">::</span></div>
13885 <div class="rhs"><code class="t">}</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">${</code></div>
13886 </div>
13887
13888 <div class="gp">
13889 <div class="lhs"><span class="nt">TemplateTail</span> <span class="geq">::</span></div>
13890 <div class="rhs"><code class="t">}</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">`</code></div>
13891 </div>
13892
13893 <div class="gp">
13894 <div class="lhs"><span class="nt">TemplateCharacters</span> <span class="geq">::</span></div>
13895 <div class="rhs"><span class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub></div>
13896 </div>
13897
13898 <div class="gp">
13899 <div class="lhs"><span class="nt">TemplateCharacter</span> <span class="geq">::</span></div>
13900 <div class="rhs"><code class="t">$</code> <span class="grhsannot">[lookahead &ne; { ]</span></div>
13901 <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
13902 <div class="rhs"><span class="nt">LineContinuation</span></div>
13903 <div class="rhs"><span class="nt">LineTerminatorSequence</span></div>
13904 <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>
13905 </div>
13906
13907 <p>A conforming implementation must not use the extended definition of <span class="nt">EscapeSequence</span> described in
13908 <a href="#sec-additional-syntax-string-literals">B.1.2</a> when parsing a <span class="nt">TemplateCharacter</span>.</p>
13909
13910 <div class="note">
13911 <p><span class="nh">NOTE</span> <i>TemplateSubstitutionTail</i> is used by the <i>InputElementTemplateTail</i>
13912 alternative lexical goal.</p>
13913 </div>
13914 </div>
13915
13916 <section id="sec-static-semantics-tv-s-and-trv-s">
13917 <h1><span class="secnum" id="sec-11.8.6.1"><a href="#sec-static-semantics-tv-s-and-trv-s"
13918 title="link to this section">11.8.6.1</a></span> Static Semantics: <i>TV&rsquo;s and TRV&rsquo;s</i></h1>
13919
13920 <p>A template literal component is interpreted as a sequence of Unicode code points. The Template Value (TV) of a literal
13921 component is described in terms of code unit values (SV, <a href="#sec-literals-string-literals">11.8.4</a>) contributed
13922 by the various parts of the template literal component. As part of this process, some Unicode code points within the
13923 template component are interpreted as having a mathematical value (MV, <a
13924 href="#sec-literals-numeric-literals">11.8.3</a>). In determining a TV, escape sequences are replaced by the UTF-16 code
13925 unit(s) of the Unicode code point represented by the escape sequence. The Template Raw Value (TRV) is similar to a
13926 Template Value with the difference that in TRVs escape sequences are interpreted literally.</p>
13927
13928 <ul>
13929 <li>
13930 <p>The TV and TRV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span>
13931 <code class="t">``</code></span> is the empty code unit sequence.</p>
13932 </li>
13933
13934 <li>
13935 <p>The TV and TRV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
13936 class="t">`${</code></span> is the empty code unit sequence.</p>
13937 </li>
13938
13939 <li>
13940 <p>The TV and TRV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
13941 class="t">}${</code></span> is the empty code unit sequence.</p>
13942 </li>
13943
13944 <li>
13945 <p>The TV and TRV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
13946 class="t">}`</code></span> is the empty code unit sequence.</p>
13947 </li>
13948
13949 <li>
13950 <p>The TV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span> <code
13951 class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TV of
13952 <i>TemplateCharacters</i>.</p>
13953 </li>
13954
13955 <li>
13956 <p>The TV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
13957 class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TV of
13958 <i>TemplateCharacters</i>.</p>
13959 </li>
13960
13961 <li>
13962 <p>The TV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
13963 class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TV of
13964 <i>TemplateCharacters</i>.</p>
13965 </li>
13966
13967 <li>
13968 <p>The TV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
13969 class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TV of
13970 <i>TemplateCharacters</i>.</p>
13971 </li>
13972
13973 <li>
13974 <p>The TV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
13975 class="nt">TemplateCharacter</span></span> is the TV of <i>TemplateCharacter</i>.</p>
13976 </li>
13977
13978 <li>
13979 <p>The TV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
13980 class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span></span> is a sequence consisting of the
13981 code units in the TV of <i>TemplateCharacter</i> followed by all the code units in the TV of <i>TemplateCharacters</i>
13982 in order.</p>
13983 </li>
13984
13985 <li>
13986 <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
13987 class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">`</code> <span
13988 class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <code class="t">$</code> <span
13989 class="grhsmod">or</span> <span class="nt">LineTerminator</span></span> is the <a
13990 href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
13991 <i>SourceCharacter</i>.</p>
13992 </li>
13993
13994 <li>
13995 <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
13996 class="t">$</code></span> is the code unit value 0x0024.</p>
13997 </li>
13998
13999 <li>
14000 <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
14001 class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of <i>EscapeSequence</i>.</p>
14002 </li>
14003
14004 <li>
14005 <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
14006 class="nt">LineContinuation</span></span> is the TV of <i>LineContinuation</i>.</p>
14007 </li>
14008
14009 <li>
14010 <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
14011 class="nt">LineTerminatorSequence</span></span> is the TRV of <i>LineTerminatorSequence</i>.</p>
14012 </li>
14013
14014 <li>
14015 <p>The TV of <span class="prod"><span class="nt">LineContinuation</span> <span class="geq">::</span> <code
14016 class="t">\</code> <span class="nt">LineTerminatorSequence</span></span> is the empty code unit sequence.</p>
14017 </li>
14018
14019 <li>
14020 <p>The TRV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span> <code
14021 class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TRV of
14022 <i>TemplateCharacters</i>.</p>
14023 </li>
14024
14025 <li>
14026 <p>The TRV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
14027 class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TRV of
14028 <i>TemplateCharacters</i>.</p>
14029 </li>
14030
14031 <li>
14032 <p>The TRV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
14033 class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TRV of
14034 <i>TemplateCharacters</i>.</p>
14035 </li>
14036
14037 <li>
14038 <p>The TRV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
14039 class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TRV of
14040 <i>TemplateCharacters</i>.</p>
14041 </li>
14042
14043 <li>
14044 <p>The TRV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
14045 class="nt">TemplateCharacter</span></span> is the TRV of <i>TemplateCharacter</i>.</p>
14046 </li>
14047
14048 <li>
14049 <p>The TRV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
14050 class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span></span> is a sequence consisting of the
14051 code units in the TRV of <i>TemplateCharacter</i> followed by all the code units in the TRV of
14052 <i>TemplateCharacters,</i> in order.</p>
14053 </li>
14054
14055 <li>
14056 <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
14057 class="nt">SourceCharacter</span> <span class="grhsmod">but not one of</span> <code class="t">`</code> <span
14058 class="grhsmod">or</span> <code class="t">\</code> <span class="grhsmod">or</span> <code class="t">$</code> <span
14059 class="grhsmod">or</span> <span class="nt">LineTerminator</span></span> is the <a
14060 href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
14061 <i>SourceCharacter</i>.</p>
14062 </li>
14063
14064 <li>
14065 <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
14066 class="t">$</code></span> is the code unit value 0x0024.</p>
14067 </li>
14068
14069 <li>
14070 <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
14071 class="t">\</code> <span class="nt">EscapeSequence</span></span> is the sequence consisting of the code unit value
14072 0x005C followed by the code units of TRV of <i>EscapeSequence</i>.</p>
14073 </li>
14074
14075 <li>
14076 <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
14077 class="nt">LineContinuation</span></span> is the TRV of <i>LineContinuation</i>.</p>
14078 </li>
14079
14080 <li>
14081 <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
14082 class="nt">LineTerminatorSequence</span></span> is the TRV of <i>LineTerminatorSequence</i>.</p>
14083 </li>
14084
14085 <li>
14086 <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
14087 class="nt">CharacterEscapeSequence</span></span> is the TRV of the <i>CharacterEscapeSequence</i>.</p>
14088 </li>
14089
14090 <li>
14091 <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <code
14092 class="t">0</code></span> is the code unit value 0x0030.</p>
14093 </li>
14094
14095 <li>
14096 <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
14097 class="nt">HexEscapeSequence</span></span> is the TRV of the <i>HexEscapeSequence</i>.</p>
14098 </li>
14099
14100 <li>
14101 <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
14102 class="nt">UnicodeEscapeSequence</span></span> is the TRV of the <i>UnicodeEscapeSequence</i>.</p>
14103 </li>
14104
14105 <li>
14106 <p>The TRV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
14107 class="nt">SingleEscapeCharacter</span></span> is the TRV of the <i>SingleEscapeCharacter</i>.</p>
14108 </li>
14109
14110 <li>
14111 <p>The TRV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
14112 class="nt">NonEscapeCharacter</span></span> is the SV of the <i>NonEscapeCharacter</i>.</p>
14113 </li>
14114
14115 <li>
14116 <p>The TRV of <span class="prod"><span class="nt">SingleEscapeCharacter</span> <span class="geq">::</span> <span
14117 class="grhsmod">one of</span> <code class="t">'</code> <code class="t">"</code> <code class="t">\</code> <code
14118 class="t">b</code> <code class="t">f</code> <code class="t">n</code> <code class="t">r</code> <code class="t">t</code>
14119 <code class="t">v</code></span> is the SV of the <i>SourceCharacter</i> that is that single code point.</p>
14120 </li>
14121
14122 <li>
14123 <p>The TRV of <span class="prod"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span> <code
14124 class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></span> is the sequence
14125 consisting of code unit value 0x0078 followed by TRV of the first <i>HexDigit</i> followed by the TRV of the second
14126 <i>HexDigit</i>.</p>
14127 </li>
14128
14129 <li>
14130 <p>The TRV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
14131 class="t">u</code> <span class="nt">Hex4Digits</span></span> is the sequence consisting of code unit value 0x0075
14132 followed by TRV of <span class="nt">Hex4Digits</span>.</p>
14133 </li>
14134
14135 <li>
14136 <p>The TRV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
14137 class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></span> is the sequence consisting of
14138 code unit value 0x0075 followed by code unit value 0x007B followed by TRV of <i>HexDigits</i> followed by code unit
14139 value 0x007D.</p>
14140 </li>
14141
14142 <li>
14143 <p>The TRV of <span class="prod"><span class="nt">Hex4Digits</span> <span class="geq">::</span> <span
14144 class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span
14145 class="nt">HexDigit</span></span> is the sequence consisting of the TRV of the first <i>HexDigit</i> followed by the
14146 TRV of the second <i>HexDigit</i> followed by the TRV of the third <i>HexDigit</i> followed by the TRV of the fourth
14147 <span class="nt">HexDigit</span>.</p>
14148 </li>
14149
14150 <li>
14151 <p>The TRV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
14152 class="nt">HexDigit</span></span> is the TRV of <i>HexDigit</i>.</p>
14153 </li>
14154
14155 <li>
14156 <p>The TRV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
14157 class="nt">HexDigits</span> <span class="nt">HexDigit</span></span> is the sequence consisting of TRV of
14158 <i>HexDigits</i> followed by TRV of <i>HexDigit</i>.</p>
14159 </li>
14160
14161 <li>
14162 <p>The TRV of a <i>HexDigit</i> is the SV of the <i>SourceCharacter</i> that is that <i>HexDigit</i>.</p>
14163 </li>
14164
14165 <li>
14166 <p>The TRV of <span class="prod"><span class="nt">LineContinuation</span> <span class="geq">::</span> <code
14167 class="t">\</code> <span class="nt">LineTerminatorSequence</span></span> is the sequence consisting of the code unit
14168 value 0x005C followed by the code units of TRV of <i>LineTerminatorSequence</i>.</p>
14169 </li>
14170
14171 <li>
14172 <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
14173 &lt;LF&gt; is the code unit value 0x000A.</p>
14174 </li>
14175
14176 <li>
14177 <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
14178 &lt;CR&gt; is the code unit value 0x000A.</p>
14179 </li>
14180
14181 <li>
14182 <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
14183 &lt;LS&gt; is the code unit value 0x2028.</p>
14184 </li>
14185
14186 <li>
14187 <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
14188 &lt;PS&gt; is the code unit value 0x2029.</p>
14189 </li>
14190
14191 <li>
14192 <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
14193 &lt;CR&gt;&lt;LF&gt; is the sequence consisting of the code unit value 0x000A.</p>
14194 </li>
14195 </ul>
14196
14197 <div class="note">
14198 <p><span class="nh">NOTE</span> TV excludes the code units of <i>LineContinuation</i> while TRV includes them.
14199 &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
14200 explicit <i>EscapeSequence</i> is needed to include a &lt;CR&gt; or &lt;CR&gt;&lt;LF&gt; sequence.</p>
14201 </div>
14202 </section>
14203 </section>
14204 </section>
14205
14206 <section id="sec-automatic-semicolon-insertion">
14207 <div class="front">
14208 <h1><span class="secnum" id="sec-11.9"><a href="#sec-automatic-semicolon-insertion"
14209 title="link to this section">11.9</a></span> Automatic Semicolon Insertion</h1>
14210
14211 <p>Certain ECMAScript statements (empty statement, <code>let</code>, <code>const</code>, <code>import</code>, and
14212 <code>export</code> declarations, variable statement, expression statement, <code>debugger</code> statement,
14213 <code>continue</code> statement, <code>break</code> statement, <code>return</code> statement, and <code>throw</code>
14214 statement) must be terminated with semicolons. Such semicolons may always appear explicitly in the source text. For
14215 convenience, however, such semicolons may be omitted from the source text in certain situations. These situations are
14216 described by saying that semicolons are automatically inserted into the source code token stream in those situations.</p>
14217 </div>
14218
14219 <section id="sec-rules-of-automatic-semicolon-insertion">
14220 <h1><span class="secnum" id="sec-11.9.1"><a href="#sec-rules-of-automatic-semicolon-insertion"
14221 title="link to this section">11.9.1</a></span> Rules of Automatic Semicolon Insertion</h1>
14222
14223 <p>In the following rules, &ldquo;token&rdquo; means the actual recognized lexical token determined using the current
14224 lexical goal symbol as described in <a href="#sec-ecmascript-language-lexical-grammar">clause 11</a>.</p>
14225
14226 <p>There are three basic rules of semicolon insertion:</p>
14227
14228 <ol class="proc">
14229 <li>When, as a <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
14230 right, a token (called the <i>offending token</i>) is encountered that is not allowed by any production of the
14231 grammar, then a semicolon is automatically inserted before the offending token if one or more of the following
14232 conditions is true:
14233 <ul>
14234 <li>
14235 <p>The offending token is separated from the previous token by at least one <i>LineTerminator</i>.</p>
14236 </li>
14237
14238 <li>
14239 <p>The offending token is <code>}</code>.</p>
14240 </li>
14241
14242 <li>
14243 <p>The previous token is <code>)</code> and the inserted semicolon would then be parsed as the terminating semicolon
14244 of a do-while statement (<a href="#sec-do-while-statement">13.6.1</a>).</p>
14245 </li>
14246 </ul>
14247 </li>
14248 <li>When, as the <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
14249 right, the end of the input stream of tokens is encountered and the parser is unable to parse the input token stream
14250 as a single complete ECMAScript <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span>, then
14251 a semicolon is automatically inserted at the end of the input stream.</li>
14252 <li>When, as the <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
14253 right, a token is encountered that is allowed by some production of the grammar, but the production is a <i>restricted
14254 production</i> and the token would be the first token for a terminal or nonterminal immediately following the
14255 annotation <span style="font-family: Times New Roman">&ldquo;</span>[no&nbsp;<span style="font-family: Times New
14256 Roman"><i>LineTerminator</i></span> here]&rdquo; within the restricted production (and therefore such a token is
14257 called a restricted token), and the restricted token is separated from the previous token by at least one <span
14258 class="nt">LineTerminator</span>, then a semicolon is automatically inserted before the restricted token.</li>
14259 </ol>
14260
14261 <p>However, there is an additional overriding condition on the preceding rules: a semicolon is never inserted automatically
14262 if the semicolon would then be parsed as an empty statement or if that semicolon would become one of the two semicolons in
14263 the header of a <code>for</code> statement (<a href="#sec-for-statement">see 13.6.3</a>).</p>
14264
14265 <div class="note">
14266 <p><span class="nh">NOTE</span> The following are the only restricted productions in the grammar:</p>
14267 </div>
14268
14269 <div class="gp">
14270 <div class="lhs"><span class="nt">PostfixExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14271 <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>
14272 <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>
14273 </div>
14274
14275 <div class="gp">
14276 <div class="lhs"><span class="nt">ContinueStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14277 <div class="rhs"><code class="t">continue;</code></div>
14278 <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>
14279 </div>
14280
14281 <div class="gp">
14282 <div class="lhs"><span class="nt">BreakStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14283 <div class="rhs"><code class="t">break</code> <code class="t">;</code></div>
14284 <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>
14285 </div>
14286
14287 <div class="gp">
14288 <div class="lhs"><span class="nt">ReturnStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14289 <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>
14290 <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>
14291 </div>
14292
14293 <div class="gp">
14294 <div class="lhs"><span class="nt">ThrowStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14295 <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>
14296 </div>
14297
14298 <div class="gp">
14299 <div class="lhs"><span class="nt">ArrowFunction</span><sub class="g-params">[In, Yield]</sub> <span class="geq">:</span></div>
14300 <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>
14301 </div>
14302
14303 <div class="gp">
14304 <div class="lhs"><span class="nt">YieldExpression</span><sub class="g-params">[In]</sub> <span class="geq">:</span></div>
14305 <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>
14306 <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>
14307 </div>
14308
14309 <p>The practical effect of these restricted productions is as follows:</p>
14310
14311 <p>When a <code>++</code> or <code>--</code> token is encountered where the parser would treat it as a postfix operator, and
14312 at least one <span class="nt">LineTerminator</span> occurred between the preceding token and the <code>++</code> or
14313 <code>--</code> token, then a semicolon is automatically inserted before the <code>++</code> or <code>--</code> token.</p>
14314
14315 <p>When a <code>continue</code>, <code>break</code>, <code>return</code>, <code>throw</code>, or <code>yield</code> token is
14316 encountered and a <span class="nt">LineTerminator</span> is encountered before the next token, a semicolon is automatically
14317 inserted after the <code>continue</code>, <code>break</code>, <code>return</code>, <code>throw</code>, or <code>yield</code>
14318 token.</p>
14319
14320 <p>The resulting practical advice to ECMAScript programmers is:</p>
14321
14322 <p>A postfix <code>++</code> or <code>--</code> operator should appear on the same line as its operand.</p>
14323
14324 <p>An <span class="nt">Expression</span> in a <code>return</code> or <code>throw</code> statement or an <span
14325 class="nt">AssignmentExpression</span> in a <code>yield</code> expression should start on the same line as the
14326 <code>return</code>, <code>throw</code>, or <code>yield</code> token.</p>
14327
14328 <p>An <span class="nt">IdentifierReference</span> in a <code>break</code> or <code>continue</code> statement should be on
14329 the same line as the <code>break</code> or <code>continue</code> token.</p>
14330 </section>
14331
14332 <section id="sec-examples-of-automatic-semicolon-insertion">
14333 <h1><span class="secnum" id="sec-11.9.2"><a href="#sec-examples-of-automatic-semicolon-insertion"
14334 title="link to this section">11.9.2</a></span> Examples of Automatic Semicolon Insertion</h1>
14335
14336 <p>The source</p>
14337
14338 <pre>{ 1 2 } 3</pre>
14339
14340 <p>is not a valid sentence in the ECMAScript grammar, even with the <a href="#sec-automatic-semicolon-insertion">automatic
14341 semicolon insertion</a> rules. In contrast, the source</p>
14342
14343 <pre>{ 1<br>2 } 3</pre>
14344
14345 <p>is also not a valid ECMAScript sentence, but is transformed by <a href="#sec-automatic-semicolon-insertion">automatic
14346 semicolon insertion</a> into the following:</p>
14347
14348 <pre>{ 1<br>;2 ;} 3;</pre>
14349
14350 <p>which is a valid ECMAScript sentence.</p>
14351
14352 <p>The source</p>
14353
14354 <pre>for (a; b<br>)</pre>
14355
14356 <p>is not a valid ECMAScript sentence and is not altered by <a href="#sec-automatic-semicolon-insertion">automatic semicolon
14357 insertion</a> because the semicolon is needed for the header of a <code>for</code> statement. Automatic semicolon insertion
14358 never inserts one of the two semicolons in the header of a <code>for</code> statement.</p>
14359
14360 <p>The source</p>
14361
14362 <pre>return<br>a + b</pre>
14363
14364 <p>is transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> into the following:</p>
14365
14366 <pre>return;<br>a + b;</pre>
14367
14368 <div class="note">
14369 <p><span class="nh">NOTE</span> The expression <code>a + b</code> is not treated as a value to be returned by the
14370 <code>return</code> statement, because a <i>LineTerminator</i> separates it from the token <code>return</code>.</p>
14371 </div>
14372
14373 <p>The source</p>
14374
14375 <pre>a = b<br>++c</pre>
14376
14377 <p>is transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> into the following:</p>
14378
14379 <pre>a = b;<br>++c;</pre>
14380
14381 <div class="note">
14382 <p><span class="nh">NOTE</span> The token <code>++</code> is not treated as a postfix operator applying to the variable
14383 <code>b</code>, because a <i>LineTerminator</i> occurs between <code>b</code> and <code>++</code>.</p>
14384 </div>
14385
14386 <p>The source</p>
14387
14388 <pre>if (a &gt; b)<br>else c = d</pre>
14389
14390 <p>is not a valid ECMAScript sentence and is not altered by <a href="#sec-automatic-semicolon-insertion">automatic semicolon
14391 insertion</a> before the <code>else</code> token, even though no production of the grammar applies at that point, because an
14392 automatically inserted semicolon would then be parsed as an empty statement.</p>
14393
14394 <p>The source</p>
14395
14396 <pre>a = b + c<br>(d + e).print()</pre>
14397
14398 <p>is <i>not</i> transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>, because the
14399 parenthesized expression that begins the second line can be interpreted as an argument list for a function call:</p>
14400
14401 <pre>a = b + c(d + e).print()</pre>
14402
14403 <p>In the circumstance that an assignment statement must begin with a left parenthesis, it is a good idea for the programmer
14404 to provide an explicit semicolon at the end of the preceding statement rather than to rely on <a
14405 href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>.</p>
14406 </section>
14407 </section>
14408 </section>
14409
14410 <section id="sec-ecmascript-language-expressions">
14411 <div class="front">
14412 <h1><span class="secnum" id="sec-12"><a href="#sec-ecmascript-language-expressions" title="link to this section">12</a></span>
14413 ECMAScript Language: Expressions</h1>
14414 </div>
14415
14416 <section id="sec-identifiers">
14417 <div class="front">
14418 <h1><span class="secnum" id="sec-12.1"><a href="#sec-identifiers" title="link to this section">12.1</a></span>
14419 Identifiers</h1>
14420
14421 <p><b>Syntax</b></p>
14422
14423 <div class="gp">
14424 <div class="lhs"><span class="nt">IdentifierReference</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14425 <div class="rhs"><span class="nt">Identifier</span></div>
14426 <div class="rhs"><span class="grhsannot">[~Yield]</span> <code class="t">yield</code></div>
14427 </div>
14428
14429 <p><i>BindingIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub></span> <b>:</b></p>
14430
14431 <p><span style="font-family: Times New Roman"><i>Identifier<br></i></span>[~Yield] <code>yield</code></p>
14432
14433 <div class="gp">
14434 <div class="lhs"><span class="nt">LabelIdentifier</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14435 <div class="rhs"><span class="nt">Identifier</span></div>
14436 <div class="rhs"><span class="grhsannot">[~Yield]</span> <code class="t">yield</code></div>
14437 </div>
14438
14439 <div class="gp">
14440 <div class="lhs"><span class="nt">Identifier</span> <span class="geq">:</span></div>
14441 <div class="rhs"><span class="nt">IdentifierName</span> <span class="grhsmod">but not</span> <span class="nt">ReservedWord</span></div>
14442 </div>
14443 </div>
14444
14445 <section id="sec-identifiers-static-semantics-early-errors">
14446 <h1><span class="secnum" id="sec-12.1.1"><a href="#sec-identifiers-static-semantics-early-errors"
14447 title="link to this section">12.1.1</a></span> Static Semantics: Early Errors</h1>
14448 <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
14449 <ul>
14450 <li>
14451 <p>It is a Syntax Error if the code matched by this production is contained in <a href="#sec-strict-mode-code">strict
14452 mode code</a> and the StringValue of <span class="nt">Identifier</span> is <code>"arguments"</code> or
14453 <code>"eval"</code>.</p>
14454 </li>
14455 </ul>
14456
14457 <p><span class="prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code
14458 class="t">yield</code></span></p>
14459
14460 <p><span class="prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code
14461 class="t">yield</code></span></p>
14462
14463 <div class="gp prod"><span class="nt">LabelIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
14464 <ul>
14465 <li>
14466 <p>It is a Syntax Error if the code matched by this production is contained in <a href="#sec-strict-mode-code">strict
14467 code</a><var>.</var></p>
14468 </li>
14469 </ul>
14470
14471 <p><i>IdentifierReference</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
14472
14473 <p><i>BindingIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
14474
14475 <p><i>LabelIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
14476
14477 <ul>
14478 <li>
14479 <p>It is a Syntax Error if this production has a <sub>[Yield]</sub> parameter and StringValue of <span
14480 class="nt">Identifier</span> is <code>"yield"</code>.</p>
14481 </li>
14482 </ul>
14483 <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>
14484 <ul>
14485 <li>
14486 <p>It is a Syntax Error if this phrase is contained in <a href="#sec-strict-mode-code">strict mode code</a> and the
14487 StringValue of <span class="nt">IdentifierName</span> is: <code>"implements"</code>, <code>"interface"</code>,
14488 <code>"let"</code>, <code>"package"</code>, <code>"private"</code>, <code>"protected"</code>, <code>"public"</code>,
14489 <code>"static"</code>, or <code>"yield"</code>.</p>
14490 </li>
14491
14492 <li>
14493 <p>It is a Syntax Error if StringValue of <span class="nt">IdentifierName</span> is the same string value as the
14494 StringValue of any <span class="nt">ReservedWord</span> except for <code>yield</code>.</p>
14495 </li>
14496 </ul>
14497
14498 <div class="note">
14499 <p><span class="nh">NOTE</span> <span style="font-family: sans-serif">StringValue of</span> <i>IdentifierName</i>
14500 normalizes any Unicode escape sequences in <i>IdentifierName</i> hence such escapes cannot be used to write an
14501 <i>Identifier</i> whose code point sequence is the same as a <i>ReservedWord</i>.</p>
14502 </div>
14503 </section>
14504
14505 <section id="sec-identifiers-static-semantics-boundnames">
14506 <h1><span class="secnum" id="sec-12.1.2"><a href="#sec-identifiers-static-semantics-boundnames"
14507 title="link to this section">12.1.2</a></span> Static Semantics: BoundNames</h1>
14508
14509 <p>See also: <a href="#sec-let-and-const-declarations-static-semantics-boundnames">13.2.1.2</a>, <a
14510 href="#sec-variable-statement-static-semantics-boundnames">13.2.2.1</a>, <a
14511 href="#sec-destructuring-binding-patterns-static-semantics-boundnames">13.2.3.1</a>, <a
14512 href="#sec-for-in-and-for-of-statements-static-semantics-boundnames">13.6.4.2</a>, <a
14513 href="#sec-function-definitions-static-semantics-boundnames">14.1.3</a>, <a
14514 href="#sec-arrow-function-definitions-static-semantics-boundnames">14.2.2</a>, <a
14515 href="#sec-generator-function-definitions-static-semantics-boundnames">14.4.2</a>, <a
14516 href="#sec-class-definitions-static-semantics-boundnames">14.5.2</a>, <a
14517 href="#sec-imports-static-semantics-boundnames">15.2.2.2</a>, <a
14518 href="#sec-exports-static-semantics-boundnames">15.2.3.2</a>.</p>
14519
14520 <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
14521 <ol class="proc">
14522 <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing the StringValue of
14523 <i>Identifier</i>.</li>
14524 </ol>
14525 <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
14526 <ol class="proc">
14527 <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing <code>"yield"</code>.</li>
14528 </ol>
14529 </section>
14530
14531 <section id="sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">
14532 <h1><span class="secnum" id="sec-12.1.3"><a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget"
14533 title="link to this section">12.1.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
14534
14535 <p>See also: <a href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
14536 href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
14537 href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
14538 href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
14539 href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
14540 href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
14541 href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
14542 href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
14543 href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
14544 href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
14545 href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
14546 href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
14547 href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
14548 href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
14549 href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
14550
14551 <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
14552 <ol class="proc">
14553 <li>If this <i>IdentifierReference</i> is contained in <a href="#sec-strict-mode-code">strict mode code</a> and
14554 StringValue of <i>Identifier</i> is <code>"eval"</code> or <code>"arguments"</code>, return <b>false</b>.</li>
14555 <li>Return <b>true</b>.</li>
14556 </ol>
14557 <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code class="t">yield</code></div>
14558 <ol class="proc">
14559 <li>Return <b>true</b>.</li>
14560 </ol>
14561 </section>
14562
14563 <section id="sec-identifiers-static-semantics-stringvalue">
14564 <h1><span class="secnum" id="sec-12.1.4"><a href="#sec-identifiers-static-semantics-stringvalue"
14565 title="link to this section">12.1.4</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
14566 <i>StringValue</i></h1>
14567
14568 <p>See also: <a href="#sec-identifier-names-static-semantics-stringvalue">11.6.1.2</a>, <a
14569 href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>.</p>
14570
14571 <p><span class="prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code
14572 class="t">yield</code></span></p>
14573
14574 <p><span class="prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code
14575 class="t">yield</code></span></p>
14576
14577 <div class="gp prod"><span class="nt">LabelIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
14578 <ol class="proc">
14579 <li>Return <code>"yield"</code>.</li>
14580 </ol>
14581 <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>
14582 <ol class="proc">
14583 <li>Return the StringValue of <i>IdentifierName</i>.</li>
14584 </ol>
14585 </section>
14586
14587 <section id="sec-identifiers-runtime-semantics-bindinginitialization">
14588 <div class="front">
14589 <h1><span class="secnum" id="sec-12.1.5"><a href="#sec-identifiers-runtime-semantics-bindinginitialization"
14590 title="link to this section">12.1.5</a></span> Runtime Semantics: BindingInitialization</h1>
14591
14592 <p>With arguments <var>value</var> and <var>environment</var>.</p>
14593
14594 <p>See also: <a href="#sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization">13.2.3.5</a>, <a
14595 href="#sec-for-in-and-for-of-statements-runtime-semantics-bindinginitialization">13.6.4.9</a>.</p>
14596
14597 <div class="note">
14598 <p><span class="nh">NOTE</span> <b>undefined</b> is passed for <var>environment</var> to indicate that a <a
14599 href="#sec-putvalue">PutValue</a> operation should be used to assign the initialization value. This is the case for
14600 <code>var</code> statements and formal parameter lists of some non-strict functions (See <a
14601 href="#sec-functiondeclarationinstantiation">9.2.12</a>). In those cases a lexical binding is hoisted and preinitialized
14602 prior to evaluation of its initializer.</p>
14603 </div>
14604
14605 <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
14606 <ol class="proc">
14607 <li>Let <i>name</i> be StringValue of <i>Identifier</i>.</li>
14608 <li>Return <a href="#sec-initializeboundname">InitializeBoundName</a>( <i>name</i>, <i>value</i>,
14609 <i>environment</i>).</li>
14610 </ol>
14611 <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
14612 <ol class="proc">
14613 <li>Return <a href="#sec-initializeboundname">InitializeBoundName</a>(<code>"yield"</code>, <i>value</i>,
14614 <i>environment</i>).</li>
14615 </ol>
14616 </div>
14617
14618 <section id="sec-initializeboundname">
14619 <h1><span class="secnum" id="sec-12.1.5.1"><a href="#sec-initializeboundname"
14620 title="link to this section">12.1.5.1</a></span> Runtime Semantics: InitializeBoundName(name, value, environment)</h1>
14621 <ol class="proc">
14622 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
14623 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>) is String.</li>
14624 <li>If <i>environment</i> is not <b>undefined</b>, then
14625 <ol class="block">
14626 <li>Let <i>env</i> be the EnvironmentRecord component of <i>environment</i>.</li>
14627 <li>Perform <i>env</i>.InitializeBinding(<i>name</i>, <i>value</i>).</li>
14628 <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
14629 </ol>
14630 </li>
14631 <li>Else
14632 <ol class="block">
14633 <li>Let <i>lhs</i> be <a href="#sec-resolvebinding">ResolveBinding</a>(<i>name</i>).</li>
14634 <li>Return <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>value</i>).</li>
14635 </ol>
14636 </li>
14637 </ol>
14638 </section>
14639 </section>
14640
14641 <section id="sec-identifiers-runtime-semantics-evaluation">
14642 <h1><span class="secnum" id="sec-12.1.6"><a href="#sec-identifiers-runtime-semantics-evaluation"
14643 title="link to this section">12.1.6</a></span> Runtime Semantics: Evaluation</h1>
14644 <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
14645 <ol class="proc">
14646 <li>Return <a href="#sec-resolvebinding">ResolveBinding</a>(StringValue of <i>Identifier</i>).</li>
14647 </ol>
14648 <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code class="t">yield</code></div>
14649 <ol class="proc">
14650 <li>Return <a href="#sec-resolvebinding">ResolveBinding</a>(<code>"yield"</code>).</li>
14651 </ol>
14652
14653 <div class="note">
14654 <p><span class="nh">NOTE 1:</span> The result of evaluating an <i>IdentifierReference</i> is always a value of type <a
14655 href="#sec-reference-specification-type">Reference</a>.</p>
14656 </div>
14657
14658 <div class="note">
14659 <p><span class="nh">NOTE 2:</span> In non-<a href="#sec-strict-mode-code">strict code</a>, the keyword <code>yield</code>
14660 may be used as an identifier. Evaluating the <i>IdentifierReference</i> production resolves the binding of
14661 <code>yield</code> as if it was an <i>Identifier</i>. Early Error restriction ensures that such an evaluation only can
14662 occur for non-<a href="#sec-strict-mode-code">strict code</a>. See <a href="#sec-let-and-const-declarations">13.2.1</a>
14663 for the handling of <code>yield</code> in binding creation contexts.</p>
14664 </div>
14665 </section>
14666 </section>
14667
14668 <section id="sec-primary-expression">
14669 <div class="front">
14670 <h1><span class="secnum" id="sec-12.2"><a href="#sec-primary-expression" title="link to this section">12.2</a></span>
14671 Primary Expression</h1>
14672 <h2>Syntax</h2>
14673
14674 <div class="gp">
14675 <div class="lhs"><span class="nt">PrimaryExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14676 <div class="rhs"><code class="t">this</code></div>
14677 <div class="rhs"><span class="nt">IdentifierReference</span><sub class="g-params">[?Yield]</sub></div>
14678 <div class="rhs"><span class="nt">Literal</span></div>
14679 <div class="rhs"><span class="nt">ArrayLiteral</span><sub class="g-params">[?Yield]</sub></div>
14680 <div class="rhs"><span class="nt">ObjectLiteral</span><sub class="g-params">[?Yield]</sub></div>
14681 <div class="rhs"><span class="nt">FunctionExpression</span></div>
14682 <div class="rhs"><span class="nt">ClassExpression</span></div>
14683 <div class="rhs"><span class="nt">GeneratorExpression</span></div>
14684 <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
14685 <div class="rhs"><span class="nt">TemplateLiteral</span><sub class="g-params">[?Yield]</sub></div>
14686 <div class="rhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub class="g-params">[?Yield]</sub></div>
14687 </div>
14688
14689 <div class="gp">
14690 <div class="lhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14691 <div class="rhs"><code class="t">(</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">)</code></div>
14692 <div class="rhs"><code class="t">(</code> <code class="t">)</code></div>
14693 <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>
14694 <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>
14695 </div>
14696
14697 <h2>Supplemental Syntax</h2>
14698
14699 <p>When processing the production</p>
14700
14701 <p><span class="nt">PrimaryExpression</span><sub>[Yield]</sub> <b>:</b> <span
14702 class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub>[?Yield]</sub><span style="font-family: Times New
14703 Roman"><i><br></i></span>the interpretation of <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> is
14704 refined using the following grammar:</p>
14705
14706 <div class="gp">
14707 <div class="lhs"><span class="nt">ParenthesizedExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14708 <div class="rhs"><code class="t">(</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">)</code></div>
14709 </div>
14710 </div>
14711
14712 <section id="sec-primary-expression-semantics">
14713 <div class="front">
14714 <h1><span class="secnum" id="sec-12.2.0"><a href="#sec-primary-expression-semantics"
14715 title="link to this section">12.2.0</a></span> Semantics</h1>
14716 </div>
14717
14718 <section id="sec-static-semantics-coveredparenthesizedexpression">
14719 <h1><span class="secnum" id="sec-12.2.0.1"><a href="#sec-static-semantics-coveredparenthesizedexpression"
14720 title="link to this section">12.2.0.1</a></span> Static Semantics: CoveredParenthesizedExpression</h1>
14721 <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>
14722 <ol class="proc">
14723 <li>Return the result of parsing the lexical token stream matched by
14724 <i>CoverParenthesizedExpressionAndArrowParameterList</i><sub>[Yield]</sub> using either
14725 <i>ParenthesizedExpression</i> or <i>ParenthesizedExpression</i><sub>[Yield]</sub> as the goal symbol depending upon
14726 whether the <sub>[Yield]</sub> grammar parameter was present when
14727 <i>CoverParenthesizedExpressionAndArrowParameterList was matched.</i></li>
14728 </ol>
14729 </section>
14730
14731 <section id="sec-semantics-static-semantics-isfunctiondefinition">
14732 <h1><span class="secnum" id="sec-12.2.0.2"><a href="#sec-semantics-static-semantics-isfunctiondefinition"
14733 title="link to this section">12.2.0.2</a></span> Static Semantics: IsFunctionDefinition</h1>
14734
14735 <p>See also: <a href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
14736 href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
14737 href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
14738 href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
14739 href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
14740 href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
14741 href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
14742 href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
14743 href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
14744 href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
14745 href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
14746 href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
14747 href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
14748 href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
14749 href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
14750 href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
14751 href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
14752
14753 <div class="gp">
14754 <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
14755 <div class="rhs"><code class="t">this</code></div>
14756 <div class="rhs"><span class="nt">IdentifierReference</span></div>
14757 <div class="rhs"><span class="nt">Literal</span></div>
14758 <div class="rhs"><span class="nt">ArrayLiteral</span></div>
14759 <div class="rhs"><span class="nt">ObjectLiteral</span></div>
14760 <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
14761 <div class="rhs"><span class="nt">TemplateLiteral</span></div>
14762 </div>
14763
14764 <ol class="proc">
14765 <li>Return <b>false</b>.</li>
14766 </ol>
14767 <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
14768 <ol class="proc">
14769 <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
14770 <li>Return IsFunctionDefinition of <i>expr</i>.</li>
14771 </ol>
14772 </section>
14773
14774 <section id="sec-semantics-static-semantics-isidentifierref">
14775 <h1><span class="secnum" id="sec-12.2.0.3"><a href="#sec-semantics-static-semantics-isidentifierref"
14776 title="link to this section">12.2.0.3</a></span> Static Semantics: IsIdentifierRef</h1>
14777
14778 <p>See also: <a href="#sec-static-semantics-static-semantics-isidentifierref">12.3.1.4</a>.</p>
14779
14780 <div class="gp">
14781 <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
14782 <div class="rhs"><span class="nt">IdentifierReference</span></div>
14783 </div>
14784
14785 <ol class="proc">
14786 <li>Return <b>true</b>.</li>
14787 </ol>
14788
14789 <div class="gp">
14790 <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
14791 <div class="rhs"><code class="t">this</code></div>
14792 <div class="rhs"><span class="nt">Literal</span></div>
14793 <div class="rhs"><span class="nt">ArrayLiteral</span></div>
14794 <div class="rhs"><span class="nt">ObjectLiteral</span></div>
14795 <div class="rhs"><span class="nt">FunctionExpression</span></div>
14796 <div class="rhs"><span class="nt">ClassExpression</span></div>
14797 <div class="rhs"><span class="nt">GeneratorExpression</span></div>
14798 <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
14799 <div class="rhs"><span class="nt">TemplateLiteral</span></div>
14800 <div class="rhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
14801 </div>
14802
14803 <ol class="proc">
14804 <li>Return <b>false</b>.</li>
14805 </ol>
14806 </section>
14807
14808 <section id="sec-semantics-static-semantics-isvalidsimpleassignmenttarget">
14809 <h1><span class="secnum" id="sec-12.2.0.4"><a href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget"
14810 title="link to this section">12.2.0.4</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
14811
14812 <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
14813 href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
14814 href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
14815 href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
14816 href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
14817 href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
14818 href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
14819 href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
14820 href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
14821 href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
14822 href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
14823 href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
14824 href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
14825 href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
14826 href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
14827
14828 <div class="gp">
14829 <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
14830 <div class="rhs"><code class="t">this</code></div>
14831 <div class="rhs"><span class="nt">Literal</span></div>
14832 <div class="rhs"><span class="nt">ArrayLiteral</span></div>
14833 <div class="rhs"><span class="nt">ObjectLiteral</span></div>
14834 <div class="rhs"><span class="nt">FunctionExpression</span></div>
14835 <div class="rhs"><span class="nt">ClassExpression</span></div>
14836 <div class="rhs"><span class="nt">GeneratorExpression</span></div>
14837 <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
14838 <div class="rhs"><span class="nt">TemplateLiteral</span></div>
14839 </div>
14840
14841 <ol class="proc">
14842 <li>Return <b>false</b>.</li>
14843 </ol>
14844 <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
14845 <ol class="proc">
14846 <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
14847 <li>Return IsValidSimpleAssignmentTarget of <i>expr</i>.</li>
14848 </ol>
14849 </section>
14850 </section>
14851
14852 <section id="sec-this-keyword">
14853 <div class="front">
14854 <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
14855 <code>this</code> Keyword</h1>
14856 </div>
14857
14858 <section id="sec-this-keyword-runtime-semantics-evaluation">
14859 <h1><span class="secnum" id="sec-12.2.1.1"><a href="#sec-this-keyword-runtime-semantics-evaluation"
14860 title="link to this section">12.2.1.1</a></span> Runtime Semantics: Evaluation</h1>
14861 <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <code class="t">this</code></div>
14862 <ol class="proc">
14863 <li>Return <a href="#sec-resolvethisbinding">ResolveThisBinding</a>( ) .</li>
14864 </ol>
14865 </section>
14866 </section>
14867
14868 <section id="sec-identifier-reference">
14869 <h1><span class="secnum" id="sec-12.2.2"><a href="#sec-identifier-reference" title="link to this section">12.2.2</a></span>
14870 Identifier Reference</h1>
14871
14872 <p>See <a href="#sec-identifiers">12.1</a> for <span class="nt">IdentifierReference</span>.</p>
14873 </section>
14874
14875 <section id="sec-primary-expression-literals">
14876 <div class="front">
14877 <h1><span class="secnum" id="sec-12.2.3"><a href="#sec-primary-expression-literals"
14878 title="link to this section">12.2.3</a></span> Literals</h1>
14879 <h2>Syntax</h2>
14880
14881 <div class="gp">
14882 <div class="lhs"><span class="nt">Literal</span> <span class="geq">:</span></div>
14883 <div class="rhs"><span class="nt">NullLiteral</span></div>
14884 <div class="rhs"><span class="nt">BooleanLiteral</span></div>
14885 <div class="rhs"><span class="nt">NumericLiteral</span></div>
14886 <div class="rhs"><span class="nt">StringLiteral</span></div>
14887 </div>
14888 </div>
14889
14890 <section id="sec-literals-runtime-semantics-evaluation">
14891 <h1><span class="secnum" id="sec-12.2.3.1"><a href="#sec-literals-runtime-semantics-evaluation"
14892 title="link to this section">12.2.3.1</a></span> Runtime Semantics: Evaluation</h1>
14893 <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">NullLiteral</span></div>
14894 <ol class="proc">
14895 <li>Return <b>null</b>.</li>
14896 </ol>
14897 <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">BooleanLiteral</span></div>
14898 <ol class="proc">
14899 <li>Return <b>false</b> if <i>BooleanLiteral</i> is the token <code>false</code>.</li>
14900 <li>Return <b>true</b> if <i>BooleanLiteral</i> is the token <code>true</code>.</li>
14901 </ol>
14902 <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
14903 <ol class="proc">
14904 <li>Return the number whose value is MV of <i>NumericLiteral</i> as defined in <a
14905 href="#sec-literals-numeric-literals">11.8.3</a>.</li>
14906 </ol>
14907 <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
14908 <ol class="proc">
14909 <li>Return the StringValue of <i>StringLiteral</i> as defined in <a
14910 href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>.</li>
14911 </ol>
14912 </section>
14913 </section>
14914
14915 <section id="sec-array-initializer">
14916 <div class="front">
14917 <h1><span class="secnum" id="sec-12.2.4"><a href="#sec-array-initializer" title="link to this section">12.2.4</a></span>
14918 Array Initializer</h1>
14919
14920 <div class="note">
14921 <p><span class="nh">NOTE</span> An <i>ArrayLiteral</i> is an expression describing the initialization of an Array
14922 object, using a list, of zero or more expressions each of which represents an array element, enclosed in square
14923 brackets. The elements need not be literals; they are evaluated each time the array initializer is evaluated.</p>
14924 </div>
14925
14926 <p>Array elements may be elided at the beginning, middle or end of the element list. Whenever a comma in the element list
14927 is not preceded by an <span class="nt">AssignmentExpression</span> (i.e., a comma at the beginning or after another
14928 comma), the missing array element contributes to the length of the Array and increases the index of subsequent elements.
14929 Elided array elements are not defined. If an element is elided at the end of an array, that element does not contribute to
14930 the length of the Array.</p>
14931
14932 <h2>Syntax</h2>
14933
14934 <div class="gp">
14935 <div class="lhs"><span class="nt">ArrayLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14936 <div class="rhs"><code class="t">[</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <code class="t">]</code></div>
14937 <div class="rhs"><code class="t">[</code> <span class="nt">ElementList</span><sub class="g-params">[?Yield]</sub> <code class="t">]</code></div>
14938 <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>
14939 </div>
14940
14941 <div class="gp">
14942 <div class="lhs"><span class="nt">ElementList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14943 <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>
14944 <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>
14945 <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>
14946 <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>
14947 </div>
14948
14949 <div class="gp">
14950 <div class="lhs"><span class="nt">Elision</span> <span class="geq">:</span></div>
14951 <div class="rhs"><code class="t">,</code></div>
14952 <div class="rhs"><span class="nt">Elision</span> <code class="t">,</code></div>
14953 </div>
14954
14955 <div class="gp">
14956 <div class="lhs"><span class="nt">SpreadElement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
14957 <div class="rhs"><code class="t">...</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
14958 </div>
14959 </div>
14960
14961 <section id="sec-static-semantics-elisionwidth">
14962 <h1><span class="secnum" id="sec-12.2.4.1"><a href="#sec-static-semantics-elisionwidth"
14963 title="link to this section">12.2.4.1</a></span> Static Semantics: ElisionWidth</h1>
14964 <div class="gp prod"><span class="nt">Elision</span> <span class="geq">:</span> <code class="t">,</code></div>
14965 <ol class="proc">
14966 <li>Return the numeric value 1.</li>
14967 </ol>
14968 <div class="gp prod"><span class="nt">Elision</span> <span class="geq">:</span> <span class="nt">Elision</span> <code class="t">,</code></div>
14969 <ol class="proc">
14970 <li>Let <i>preceding</i> be the ElisionWidth of <i>Elision</i>.</li>
14971 <li>Return <i>preceding</i>+1.</li>
14972 </ol>
14973 </section>
14974
14975 <section id="sec-runtime-semantics-arrayaccumulation">
14976 <h1><span class="secnum" id="sec-12.2.4.2"><a href="#sec-runtime-semantics-arrayaccumulation"
14977 title="link to this section">12.2.4.2</a></span> Runtime Semantics: ArrayAccumulation</h1>
14978
14979 <p>With parameters <var>array</var> and <var>nextIndex</var>.</p>
14980
14981 <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>
14982 <ol class="proc">
14983 <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
14984 zero.</li>
14985 <li>Let <i>initResult</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
14986 <li>Let <i>initValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>initResult</i>).</li>
14987 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initValue</i>).</li>
14988 <li>Let <i>created</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
14989 href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>nextIndex+padding</i>)),
14990 <i>initValue</i>).</li>
14991 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>created</i> is <b>true</b><i>.</i></li>
14992 <li>Return <i>nextIndex+padding+</i>1.</li>
14993 </ol>
14994 <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>
14995 <ol class="proc">
14996 <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
14997 zero.</li>
14998 <li>Return the result of performing ArrayAccumulation for <i>SpreadElement</i> with arguments <i>array</i> and
14999 <i>nextIndex</i>+<i>padding</i>.</li>
15000 </ol>
15001 <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>
15002 <ol class="proc">
15003 <li>Let <i>postIndex</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments
15004 <i>array</i> and <i>nextIndex</i>.</li>
15005 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>postIndex</i>).</li>
15006 <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
15007 zero.</li>
15008 <li>Let <i>initResult</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
15009 <li>Let <i>initValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>initResult</i>).</li>
15010 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initValue</i>).</li>
15011 <li>Let <i>created</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
15012 href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>postIndex</i>+<i>padding</i>)),
15013 <i>initValue</i>).</li>
15014 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>created</i> is <b>true</b>.</li>
15015 <li>Return <i>postIndex</i>+<i>padding+</i>1.</li>
15016 </ol>
15017 <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>
15018 <ol class="proc">
15019 <li>Let <i>postIndex</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments
15020 <i>array</i> and <i>nextIndex</i>.</li>
15021 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>postIndex</i>).</li>
15022 <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
15023 zero.</li>
15024 <li>Return the result of performing ArrayAccumulation for <i>SpreadElement</i> with arguments <i>array</i> and
15025 <i>postIndex</i>+<i>padding</i>.</li>
15026 </ol>
15027 <div class="gp prod"><span class="nt">SpreadElement</span> <span class="geq">:</span> <code class="t">...</code> <span class="nt">AssignmentExpression</span></div>
15028 <ol class="proc">
15029 <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
15030 <li>Let <i>spreadObj</i> be <a href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>).</li>
15031 <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<i>spreadObj</i>).</li>
15032 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
15033 <li>Repeat
15034 <ol class="block">
15035 <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
15036 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
15037 <li>If <i>next</i> is <b>false</b>, return <i>nextIndex</i>.</li>
15038 <li>Let <i>nextValue</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
15039 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextValue</i>).</li>
15040 <li>Let <i>status</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
15041 href="#sec-tostring">ToString</a>(<i>nextIndex</i>), <i>nextValue</i>).</li>
15042 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is <b>true</b> .</li>
15043 <li>Let <i>nextIndex</i> be <i>nextIndex</i> + 1.</li>
15044 </ol>
15045 </li>
15046 </ol>
15047
15048 <div class="note">
15049 <p><span class="nh">NOTE</span> <a href="#sec-createdataproperty">CreateDataProperty</a> is used to ensure that own
15050 properties are defined for the array even if the standard built-in Array prototype object has been modified in a manner
15051 that would preclude the creation of new own properties using [[Set]].</p>
15052 </div>
15053 </section>
15054
15055 <section id="sec-array-initializer-runtime-semantics-evaluation">
15056 <h1><span class="secnum" id="sec-12.2.4.3"><a href="#sec-array-initializer-runtime-semantics-evaluation"
15057 title="link to this section">12.2.4.3</a></span> Runtime Semantics: Evaluation</h1>
15058 <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>
15059 <ol class="proc">
15060 <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
15061 <li>Let <i>pad</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
15062 zero.</li>
15063 <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>
15064 <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
15065 href="#sec-arraycreate">ArrayCreate</a>.</li>
15066 <li>Return <i>array</i>.</li>
15067 </ol>
15068 <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>
15069 <ol class="proc">
15070 <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
15071 <li>Let <i>len</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments <i>array</i> and
15072 0.</li>
15073 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
15074 <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>
15075 <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
15076 href="#sec-arraycreate">ArrayCreate</a>.</li>
15077 <li>Return <i>array</i>.</li>
15078 </ol>
15079 <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>
15080 <ol class="proc">
15081 <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
15082 <li>Let <i>len</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments <i>array</i> and
15083 0.</li>
15084 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
15085 <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
15086 zero.</li>
15087 <li>Perform <a href="#sec-set-o-p-v-throw">Set</a>(<i>array</i>, <code>"length"</code>, <a
15088 href="#sec-touint32">ToUint32</a>(<i>padding</i>+<i>len</i>), <b>false</b>).</li>
15089 <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
15090 href="#sec-arraycreate">ArrayCreate</a>.</li>
15091 <li>Return <i>array</i>.</li>
15092 </ol>
15093 </section>
15094 </section>
15095
15096 <section id="sec-object-initializer">
15097 <div class="front">
15098 <h1><span class="secnum" id="sec-12.2.5"><a href="#sec-object-initializer" title="link to this section">12.2.5</a></span>
15099 Object Initializer</h1>
15100
15101 <div class="note">
15102 <p><span class="nh">NOTE 1</span> An object initializer is an expression describing the initialization of an Object,
15103 written in a form resembling a literal. It is a list of zero or more pairs of property keys and associated values,
15104 enclosed in curly brackets. The values need not be literals; they are evaluated each time the object initializer is
15105 evaluated.</p>
15106 </div>
15107
15108 <h2>Syntax</h2>
15109
15110 <div class="gp">
15111 <div class="lhs"><span class="nt">ObjectLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15112 <div class="rhs"><code class="t">{</code> <code class="t">}</code></div>
15113 <div class="rhs"><code class="t">{</code> <span class="nt">PropertyDefinitionList</span><sub class="g-params">[?Yield]</sub> <code class="t">}</code></div>
15114 <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>
15115 </div>
15116
15117 <div class="gp">
15118 <div class="lhs"><span class="nt">PropertyDefinitionList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15119 <div class="rhs"><span class="nt">PropertyDefinition</span><sub class="g-params">[?Yield]</sub></div>
15120 <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>
15121 </div>
15122
15123 <div class="gp">
15124 <div class="lhs"><span class="nt">PropertyDefinition</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15125 <div class="rhs"><span class="nt">IdentifierReference</span><sub class="g-params">[?Yield]</sub></div>
15126 <div class="rhs"><span class="nt">CoverInitializedName</span><sub class="g-params">[?Yield]</sub></div>
15127 <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>
15128 <div class="rhs"><span class="nt">MethodDefinition</span><sub class="g-params">[?Yield]</sub></div>
15129 </div>
15130
15131 <div class="gp">
15132 <div class="lhs"><span class="nt">PropertyName</span><sub class="g-params">[Yield,GeneratorParameter]</sub> <span class="geq">:</span></div>
15133 <div class="rhs"><span class="nt">LiteralPropertyName</span></div>
15134 <div class="rhs"><span class="grhsannot">[+GeneratorParameter]</span> <span class="nt">ComputedPropertyName</span></div>
15135 <div class="rhs"><span class="grhsannot">[~GeneratorParameter]</span> <span class="nt">ComputedPropertyName</span><sub class="g-params">[?Yield]</sub></div>
15136 </div>
15137
15138 <div class="gp">
15139 <div class="lhs"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span></div>
15140 <div class="rhs"><span class="nt">IdentifierName</span></div>
15141 <div class="rhs"><span class="nt">StringLiteral</span></div>
15142 <div class="rhs"><span class="nt">NumericLiteral</span></div>
15143 </div>
15144
15145 <div class="gp">
15146 <div class="lhs"><span class="nt">ComputedPropertyName</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15147 <div class="rhs"><code class="t">[</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">]</code></div>
15148 </div>
15149
15150 <div class="gp">
15151 <div class="lhs"><span class="nt">CoverInitializedName</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15152 <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>
15153 </div>
15154
15155 <div class="gp">
15156 <div class="lhs"><span class="nt">Initializer</span><sub class="g-params">[In, Yield]</sub> <span class="geq">:</span></div>
15157 <div class="rhs"><code class="t">=</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[?In, ?Yield]</sub></div>
15158 </div>
15159
15160 <div class="note">
15161 <p><span class="nh">NOTE 2</span> <i>MethodDefinition</i> is defined in <a href="#sec-method-definitions">14.3</a>.</p>
15162 </div>
15163
15164 <div class="note">
15165 <p><span class="nh">NOTE 3</span> In certain contexts, <i>ObjectLiteral</i> is used as a cover grammar for a more
15166 restricted secondary grammar. The <i>CoverInitializedName</i> production is necessary to fully cover these secondary
15167 grammars. However, use of this production results in an early Syntax Error in normal contexts where an actual
15168 <i>ObjectLiteral</i> is expected.</p>
15169 </div>
15170 </div>
15171
15172 <section id="sec-object-initializer-static-semantics-early-errors">
15173 <h1><span class="secnum" id="sec-12.2.5.1"><a href="#sec-object-initializer-static-semantics-early-errors"
15174 title="link to this section">12.2.5.1</a></span> Static Semantics: Early Errors</h1>
15175 <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">MethodDefinition</span></div>
15176 <ul>
15177 <li>It is a Syntax Error if HasDirectSuper of <span class="nt">MethodDefinition</span> is <span style="font-family:
15178 Times New Roman"><b><i>true</i></b></span>.</li>
15179 </ul>
15180
15181 <p>In addition to describing an actual object initializer the <span class="nt">ObjectLiteral</span> productions are also
15182 used as a cover grammar for <span class="nt">ObjectAssignmentPattern</span> (<a
15183 href="#sec-destructuring-assignment">12.14.5</a>). and may be recognized as part of a <span
15184 class="nt">CoverParenthesizedExpressionAndArrowParameterList</span>. When <span class="nt">ObjectLiteral</span> appears in
15185 a context where <span class="nt">ObjectAssignmentPattern</span> is required the following Early Error rules are <b>not</b>
15186 applied. In addition, they are not applied when initially parsing a
15187 <var>CoverParenthesizedExpressionAndArrowParameterList.</var></p>
15188
15189 <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">CoverInitializedName</span></div>
15190 <ul>
15191 <li>Always throw a Syntax Error if code matches <span style="font-family: Times New Roman">this production.</span></li>
15192 </ul>
15193
15194 <div class="note">
15195 <p><span class="nh">NOTE</span> This production exists so that <i>ObjectLiteral</i> can serve as a cover grammar for
15196 <i>ObjectAssignmentPattern</i> (<a href="#sec-destructuring-assignment">12.14.5</a>). It cannot occur in an actual
15197 object initializer.</p>
15198 </div>
15199 </section>
15200
15201 <section id="sec-object-initializer-static-semantics-computedpropertycontains">
15202 <h1><span class="secnum" id="sec-12.2.5.2"><a href="#sec-object-initializer-static-semantics-computedpropertycontains"
15203 title="link to this section">12.2.5.2</a></span> Static Semantics: ComputedPropertyContains</h1>
15204
15205 <p>With parameter <var>symbol</var>.</p>
15206
15207 <p>See also: <a href="#sec-method-definitions-static-semantics-computedpropertycontains">14.3.2</a>, <a
15208 href="#sec-generator-function-definitions-static-semantics-computedpropertycontains">14.4.3</a>, <a
15209 href="#sec-class-definitions-static-semantics-computedpropertycontains">14.5.5</a>.</p>
15210
15211 <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">LiteralPropertyName</span></div>
15212 <ol class="proc">
15213 <li>Return <b>false</b>.</li>
15214 </ol>
15215 <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">ComputedPropertyName</span></div>
15216 <ol class="proc">
15217 <li>Return the result of <i>ComputedPropertyName</i> Contains <i>symbol</i>.</li>
15218 </ol>
15219 </section>
15220
15221 <section id="sec-object-initializer-static-semantics-contains">
15222 <h1><span class="secnum" id="sec-12.2.5.3"><a href="#sec-object-initializer-static-semantics-contains"
15223 title="link to this section">12.2.5.3</a></span> Static Semantics: Contains</h1>
15224
15225 <p>With parameter <var>symbol</var>.</p>
15226
15227 <p>See also: <a href="#sec-static-semantic-rules">5.3</a>, <a
15228 href="#sec-static-semantics-static-semantics-contains">12.3.1.1</a>, <a
15229 href="#sec-function-definitions-static-semantics-contains">14.1.4</a>, <a
15230 href="#sec-arrow-function-definitions-static-semantics-contains">14.2.3</a>, <a
15231 href="#sec-generator-function-definitions-static-semantics-contains">14.4.4</a>, <a
15232 href="#sec-class-definitions-static-semantics-contains">14.5.4</a>.</p>
15233
15234 <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">MethodDefinition</span></div>
15235 <ol class="proc">
15236 <li>If <i>symbol</i> is <i>MethodDefinition</i>, return <b>true</b>.</li>
15237 <li>Return the result of ComputedPropertyContains for <i>MethodDefinition</i> with argument <i>symbol</i>.</li>
15238 </ol>
15239
15240 <div class="note">
15241 <p><span class="nh">NOTE</span> Static semantic rules that depend upon substructure generally do not look into function
15242 definitions.</p>
15243 </div>
15244
15245 <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
15246 <ol class="proc">
15247 <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
15248 <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
15249 <i>IdentifierName</i>, return <b>true</b>;</li>
15250 <li>Return <b>false</b>.</li>
15251 </ol>
15252 </section>
15253
15254 <section id="sec-object-initializer-static-semantics-hascomputedpropertykey">
15255 <h1><span class="secnum" id="sec-12.2.5.4"><a href="#sec-object-initializer-static-semantics-hascomputedpropertykey"
15256 title="link to this section">12.2.5.4</a></span> Static Semantics: HasComputedPropertyKey</h1>
15257
15258 <p>See also: <a href="#sec-method-definitions-static-semantics-hascomputedpropertykey">14.3.4</a>, <a
15259 href="#sec-generator-function-definitions-static-semantics-hascomputedpropertykey">14.4.5</a></p>
15260
15261 <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>
15262 <ol class="proc">
15263 <li>If HasComputedPropertyKey of <i>PropertyDefinitionList</i> is <b>true</b>, return <b>true</b>.</li>
15264 <li>Return HasComputedPropertyKey of <i>PropertyDefinition</i>.</li>
15265 </ol>
15266 <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
15267 <ol class="proc">
15268 <li>Return <b>false</b>.</li>
15269 </ol>
15270 <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>
15271 <ol class="proc">
15272 <li>Return IsComputedPropertyKey of <i>PropertyName</i>.</li>
15273 </ol>
15274 </section>
15275
15276 <section id="sec-static-semantics-iscomputedpropertykey">
15277 <h1><span class="secnum" id="sec-12.2.5.5"><a href="#sec-static-semantics-iscomputedpropertykey"
15278 title="link to this section">12.2.5.5</a></span> Static Semantics: IsComputedPropertyKey</h1>
15279 <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">LiteralPropertyName</span></div>
15280 <ol class="proc">
15281 <li>Return <b>false</b>.</li>
15282 </ol>
15283 <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">ComputedPropertyName</span></div>
15284 <ol class="proc">
15285 <li>Return <b>true</b>.</li>
15286 </ol>
15287 </section>
15288
15289 <section id="sec-object-initializer-static-semantics-propname">
15290 <h1><span class="secnum" id="sec-12.2.5.6"><a href="#sec-object-initializer-static-semantics-propname"
15291 title="link to this section">12.2.5.6</a></span> Static Semantics: <i>PropName</i></h1>
15292
15293 <p>See also: <a href="#sec-method-definitions-static-semantics-propname">14.3.6</a>, <a
15294 href="#sec-generator-function-definitions-static-semantics-propname">14.4.10</a>, <a
15295 href="#sec-class-definitions-static-semantics-propname">14.5.12</a></p>
15296
15297 <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
15298 <ol class="proc">
15299 <li>Return StringValue of <i>IdentifierReference</i>.</li>
15300 </ol>
15301 <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>
15302 <ol class="proc">
15303 <li>Return PropName of <i>PropertyName</i>.</li>
15304 </ol>
15305 <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
15306 <ol class="proc">
15307 <li>Return StringValue of <i>IdentifierName</i>.</li>
15308 </ol>
15309 <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
15310 <ol class="proc">
15311 <li>Return a String value whose code units are the SV of the <i>StringLiteral</i>.</li>
15312 </ol>
15313 <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
15314 <ol class="proc">
15315 <li>Let <i>nbr</i> be the result of forming the value of the <i>NumericLiteral</i>.</li>
15316 <li>Return <a href="#sec-tostring">ToString</a>(<i>nbr</i>).</li>
15317 </ol>
15318 <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>
15319 <ol class="proc">
15320 <li>Return <span style="font-family: sans-serif">empty</span>.</li>
15321 </ol>
15322 </section>
15323
15324 <section id="sec-static-semantics-propertynamelist">
15325 <h1><span class="secnum" id="sec-12.2.5.7"><a href="#sec-static-semantics-propertynamelist"
15326 title="link to this section">12.2.5.7</a></span> Static Semantics: PropertyNameList</h1>
15327 <div class="gp prod"><span class="nt">PropertyDefinitionList</span> <span class="geq">:</span> <span class="nt">PropertyDefinition</span></div>
15328 <ol class="proc">
15329 <li>If PropName of <i>PropertyDefinition</i> is <span style="font-family: sans-serif">empty</span>, return a new empty
15330 <a href="#sec-list-and-record-specification-type">List</a>.</li>
15331 <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing PropName of
15332 <i>PropertyDefinition</i>.</li>
15333 </ol>
15334 <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>
15335 <ol class="proc">
15336 <li>Let <i>list</i> be PropertyNameList of <i>PropertyDefinitionList.</i></li>
15337 <li>If PropName of <i>PropertyDefinition</i> is <span style="font-family: sans-serif">empty</span>, return
15338 <i>list</i>.</li>
15339 <li>Append PropName of <i>PropertyDefinition</i> to the end of <i>list</i>.</li>
15340 <li>Return <i>list</i>.</li>
15341 </ol>
15342 </section>
15343
15344 <section id="sec-object-initializer-runtime-semantics-evaluation">
15345 <h1><span class="secnum" id="sec-12.2.5.8"><a href="#sec-object-initializer-runtime-semantics-evaluation"
15346 title="link to this section">12.2.5.8</a></span> Runtime Semantics: Evaluation</h1>
15347 <div class="gp prod"><span class="nt">ObjectLiteral</span> <span class="geq">:</span> <code class="t">{</code> <code class="t">}</code></div>
15348 <ol class="proc">
15349 <li>Return <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
15350 sans-serif">%ObjectPrototype%</span>).</li>
15351 </ol>
15352
15353 <p><span class="prod"><span class="nt">ObjectLiteral</span> <span class="geq">:</span></span><br>&#x9;<code>{</code> <span
15354 class="nt">PropertyDefinitionList</span> <code>}</code><span style="font-family: Times New
15355 Roman"><i><br></i></span>&#x9;<code>{</code> <span class="nt">PropertyDefinitionList</span> <code>,</code>
15356 <code>}</code></p>
15357
15358 <ol class="proc">
15359 <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%ObjectPrototype%).</li>
15360 <li>Let <i>status</i> be the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinitionList</i> with
15361 arguments <i>obj</i> and <b>true</b>.</li>
15362 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
15363 <li>Return <i>obj</i>.</li>
15364 </ol>
15365 <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
15366 <ol class="proc">
15367 <li>Return StringValue of <i>IdentifierName</i>.</li>
15368 </ol>
15369 <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
15370 <ol class="proc">
15371 <li>Return a String value whose code units are the SV of the <i>StringLiteral</i>.</li>
15372 </ol>
15373 <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
15374 <ol class="proc">
15375 <li>Let <i>nbr</i> be the result of forming the value of the <i>NumericLiteral</i>.</li>
15376 <li>Return <a href="#sec-tostring">ToString</a>(<i>nbr</i>).</li>
15377 </ol>
15378 <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>
15379 <ol class="proc">
15380 <li>Let <i>exprValue</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
15381 <li>Let <i>propName</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValue</i>).</li>
15382 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propName</i>).</li>
15383 <li>Return <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propName</i>).</li>
15384 </ol>
15385 </section>
15386
15387 <section id="sec-object-initializer-runtime-semantics-propertydefinitionevaluation">
15388 <h1><span class="secnum" id="sec-12.2.5.9"><a
15389 href="#sec-object-initializer-runtime-semantics-propertydefinitionevaluation"
15390 title="link to this section">12.2.5.9</a></span> Runtime Semantics: PropertyDefinitionEvaluation</h1>
15391
15392 <p>With parameter <var>object</var> and <span style="font-family: Times New Roman"><i>enumerable</i>.</span></p>
15393
15394 <p>See also: <a href="#sec-method-definitions-runtime-semantics-propertydefinitionevaluation">14.3.9</a>, <a
15395 href="#sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation">14.4.13</a>, B.3.1</p>
15396
15397 <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>
15398 <ol class="proc">
15399 <li>Let <i>status</i> be the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinitionList</i> with
15400 arguments <i>object</i> and <i>enumerable</i>.</li>
15401 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
15402 <li>Return the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinition</i> with arguments
15403 <i>object</i> and <i>enumerable</i>.</li>
15404 </ol>
15405 <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
15406 <ol class="proc">
15407 <li>Let <i>propName</i> be StringValue of <i>IdentifierReference</i>.</li>
15408 <li>Let <i>exprValue</i> be the result of evaluating <i>IdentifierReference</i>.</li>
15409 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exprValue</i>).</li>
15410 <li>Let <i>propValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValue</i>).</li>
15411 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propValue</i>).</li>
15412 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>enumerable</i> is <b>true</b>.</li>
15413 <li>Return <a href="#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a>(<i>object</i>, <i>propName</i>,
15414 <i>propValue</i>).</li>
15415 </ol>
15416 <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>
15417 <ol class="proc">
15418 <li>Let <i>propKey</i> be the result of evaluating <i>PropertyName</i>.</li>
15419 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propKey</i>).</li>
15420 <li>Let <i>exprValueRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
15421 <li>Let <i>propValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValueRef</i>).</li>
15422 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propValue</i>).</li>
15423 <li>If <a href="#sec-isanonymousfunctiondefinition">IsAnonymousFunctionDefinition</a>(<i>AssignmentExpression)</i> is
15424 <b>true</b>, then
15425 <ol class="block">
15426 <li>Let <i>hasNameProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>propValue</i>,
15427 <code>"name"</code>).</li>
15428 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasNameProperty</i>).</li>
15429 <li>If <i>hasNameProperty</i> is <b>false</b>, perform <a
15430 href="#sec-setfunctionname">SetFunctionName</a>(<i>propValue</i>, <i>propKey</i>).</li>
15431 </ol>
15432 </li>
15433 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>enumerable</i> is <b>true</b>.</li>
15434 <li>Return <a href="#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a>(<i>object</i>, <i>propKey</i>,
15435 <i>propValue</i>).</li>
15436 </ol>
15437
15438 <p class="Note"><i>NOTE&#x9;An alternative semantics for this production is given in <a
15439 href="#sec-__proto__-property-names-in-object-initializers">B.3.1</a>.</i></p>
15440 </section>
15441 </section>
15442
15443 <section id="sec-function-defining-expressions">
15444 <h1><span class="secnum" id="sec-12.2.6"><a href="#sec-function-defining-expressions"
15445 title="link to this section">12.2.6</a></span> Function Defining Expressions</h1>
15446
15447 <p>See <a href="#sec-function-definitions">14.1</a> for <span class="prod"><span class="nt">PrimaryExpression</span> <span
15448 class="geq">:</span> <span class="nt">FunctionExpression</span></span> .</p>
15449
15450 <p>See <a href="#sec-generator-function-definitions">14.4</a> for <span class="prod"><span
15451 class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">GeneratorExpression</span></span> .</p>
15452
15453 <p>See <a href="#sec-class-definitions">14.5</a> for <span class="prod"><span class="nt">PrimaryExpression</span> <span
15454 class="geq">:</span> <span class="nt">ClassExpression</span></span> .</p>
15455 </section>
15456
15457 <section id="sec-primary-expression-regular-expression-literals">
15458 <div class="front">
15459 <h1><span class="secnum" id="sec-12.2.7"><a href="#sec-primary-expression-regular-expression-literals"
15460 title="link to this section">12.2.7</a></span> Regular Expression Literals</h1>
15461 <h2>Syntax</h2>
15462
15463 <p>See <a href="#sec-literals-string-literals">11.8.4</a>.</p>
15464 </div>
15465
15466 <section id="sec-primary-expression-regular-expression-literals-static-semantics-early-errors">
15467 <h1><span class="secnum" id="sec-12.2.7.1"><a
15468 href="#sec-primary-expression-regular-expression-literals-static-semantics-early-errors"
15469 title="link to this section">12.2.7.1</a></span> Static Semantics: Early Errors</h1>
15470 <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">RegularExpressionLiteral</span></div>
15471 <ul>
15472 <li>
15473 <p>It is a Syntax Error if <span style="font-family: Times New Roman">BodyText</span> of <span
15474 class="nt">RegularExpressionLiteral</span> cannot be recognized using the goal symbol <span class="nt">Pattern</span>
15475 of the ECMAScript RegExp grammar specified in <a href="#sec-patterns">21.2.1</a><var>.</var></p>
15476 </li>
15477
15478 <li>
15479 <p>It is a Syntax Error if <span style="font-family: Times New Roman">FlagText</span> of <span
15480 class="nt">RegularExpressionLiteral</span> contains any code points other than <code>"g"</code>, <code>"i"</code>,
15481 <code>"m"</code>, <code>"u"</code>, or <code>"y"</code>, or if it contains the same code point more than once.</p>
15482 </li>
15483 </ul>
15484 </section>
15485
15486 <section id="sec-regular-expression-literals-runtime-semantics-evaluation">
15487 <h1><span class="secnum" id="sec-12.2.7.2"><a href="#sec-regular-expression-literals-runtime-semantics-evaluation"
15488 title="link to this section">12.2.7.2</a></span> Runtime Semantics: Evaluation</h1>
15489 <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">RegularExpressionLiteral</span></div>
15490 <ol class="proc">
15491 <li>Let <i>pattern</i> be the string value consisting of the <a href="#sec-utf16encoding">UTF16Encoding</a> of each code
15492 point of BodyText of <i>RegularExpressionLiteral</i>.</li>
15493 <li>Let <i>flags</i> be the string value consisting of the <a href="#sec-utf16encoding">UTF16Encoding</a> of each code
15494 point of FlagText of <i>RegularExpressionLiteral</i>.</li>
15495 <li>Return <a href="#sec-regexpcreate">RegExpCreate</a>(<i>pattern</i>, <i>flags</i>).</li>
15496 </ol>
15497 </section>
15498 </section>
15499
15500 <section id="sec-template-literals">
15501 <div class="front">
15502 <h1><span class="secnum" id="sec-12.2.8"><a href="#sec-template-literals" title="link to this section">12.2.8</a></span>
15503 Template Literals</h1>
15504 <h2>Syntax</h2>
15505
15506 <div class="gp">
15507 <div class="lhs"><span class="nt">TemplateLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15508 <div class="rhs"><span class="nt">NoSubstitutionTemplate</span></div>
15509 <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>
15510 </div>
15511
15512 <div class="gp">
15513 <div class="lhs"><span class="nt">TemplateSpans</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15514 <div class="rhs"><span class="nt">TemplateTail</span></div>
15515 <div class="rhs"><span class="nt">TemplateMiddleList</span><sub class="g-params">[?Yield]</sub> <span class="nt">TemplateTail</span></div>
15516 </div>
15517
15518 <div class="gp">
15519 <div class="lhs"><span class="nt">TemplateMiddleList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15520 <div class="rhs"><span class="nt">TemplateMiddle</span> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub></div>
15521 <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>
15522 </div>
15523 </div>
15524
15525 <section id="sec-static-semantics-templatestrings">
15526 <h1><span class="secnum" id="sec-12.2.8.1"><a href="#sec-static-semantics-templatestrings"
15527 title="link to this section">12.2.8.1</a></span> Static Semantics: TemplateStrings</h1>
15528
15529 <p>With parameter <var>raw</var>.</p>
15530
15531 <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
15532 <ol class="proc">
15533 <li>If <i>raw</i> is <b>false</b>, then
15534 <ol class="block">
15535 <li>Let <i>string</i> be the TV of <i>NoSubstitutionTemplate</i>.</li>
15536 </ol>
15537 </li>
15538 <li>Else,
15539 <ol class="block">
15540 <li>Let <i>string</i> be the TRV of <i>NoSubstitutionTemplate</i>.</li>
15541 </ol>
15542 </li>
15543 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element,
15544 <i>string</i>.</li>
15545 </ol>
15546 <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>
15547 <ol class="proc">
15548 <li>If <i>raw</i> is <b>false</b>, then
15549 <ol class="block">
15550 <li>Let <i>head</i> be the TV of <i>TemplateHead</i>.</li>
15551 </ol>
15552 </li>
15553 <li>Else,
15554 <ol class="block">
15555 <li>Let <i>head</i> be the TRV of <i>TemplateHead</i>.</li>
15556 </ol>
15557 </li>
15558 <li>Let <i>tail</i> be TemplateStrings of <i>TemplateSpans</i> with argument <i>raw</i>.</li>
15559 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing <i>head</i> followed by the element,
15560 in order of <i>tail</i>.</li>
15561 </ol>
15562 <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
15563 <ol class="proc">
15564 <li>If <i>raw</i> is <b>false</b>, then
15565 <ol class="block">
15566 <li>Let <i>tail</i> be the TV of <i>TemplateTail</i>.</li>
15567 </ol>
15568 </li>
15569 <li>Else,
15570 <ol class="block">
15571 <li>Let <i>tail</i> be the TRV of <i>TemplateTail</i>.</li>
15572 </ol>
15573 </li>
15574 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element, <i>tail</i>.</li>
15575 </ol>
15576 <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
15577 <ol class="proc">
15578 <li>Let <i>middle</i> be TemplateStrings of <i>TemplateMiddleList</i> with argument <i>raw</i>.</li>
15579 <li>If <i>raw</i> is <b>false</b>, then
15580 <ol class="block">
15581 <li>Let <i>tail</i> be the TV of <i>TemplateTail</i>.</li>
15582 </ol>
15583 </li>
15584 <li>Else,
15585 <ol class="block">
15586 <li>Let <i>tail</i> be the TRV of <i>TemplateTail</i>.</li>
15587 </ol>
15588 </li>
15589 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the elements, in order, of
15590 <i>middle</i> followed by <i>tail</i>.</li>
15591 </ol>
15592 <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
15593 <ol class="proc">
15594 <li>If <i>raw</i> is <b>false</b>, then
15595 <ol class="block">
15596 <li>Let <i>string</i> be the TV of <i>TemplateMiddle</i>.</li>
15597 </ol>
15598 </li>
15599 <li>Else,
15600 <ol class="block">
15601 <li>Let <i>string</i> be the TRV of <i>TemplateMiddle</i>.</li>
15602 </ol>
15603 </li>
15604 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element,
15605 <i>string</i>.</li>
15606 </ol>
15607 <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>
15608 <ol class="proc">
15609 <li>Let <i>front</i> be TemplateStrings of <i>TemplateMiddleList</i> with argument <i>raw</i>.</li>
15610 <li>If <i>raw</i> is <b>false</b>, then
15611 <ol class="block">
15612 <li>Let <i>last</i> be the TV of <i>TemplateMiddle</i>.</li>
15613 </ol>
15614 </li>
15615 <li>Else,
15616 <ol class="block">
15617 <li>Let <i>last</i> be the TRV of <i>TemplateMiddle</i>.</li>
15618 </ol>
15619 </li>
15620 <li>Append <i>last</i> as the last element of the <a href="#sec-list-and-record-specification-type">List</a>
15621 <i>front</i>.</li>
15622 <li>Return <i>front</i>.</li>
15623 </ol>
15624 </section>
15625
15626 <section id="sec-template-literals-runtime-semantics-argumentlistevaluation">
15627 <h1><span class="secnum" id="sec-12.2.8.2"><a href="#sec-template-literals-runtime-semantics-argumentlistevaluation"
15628 title="link to this section">12.2.8.2</a></span> <span style="font-family: sans-serif">Runtime Semantics:</span>
15629 ArgumentListEvaluation</h1>
15630
15631 <p>See also: <a href="#sec-argument-lists-runtime-semantics-argumentlistevaluation">12.3.6.1</a></p>
15632
15633 <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
15634 <ol class="proc">
15635 <li>Let <i>templateLiteral</i> be this <i>TemplateLiteral.</i></li>
15636 <li>Let <i>siteObj</i> be <a href="#sec-gettemplateobject">GetTemplateObject</a>(<i>templateLiteral</i>).</li>
15637 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the one element which is
15638 <i>siteObj</i>.</li>
15639 </ol>
15640 <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>
15641 <ol class="proc">
15642 <li>Let <i>templateLiteral</i> be this <i>TemplateLiteral.</i></li>
15643 <li>Let <i>siteObj</i> be <a href="#sec-gettemplateobject">GetTemplateObject</a>(<i>templateLiteral</i>).</li>
15644 <li>Let <i>firstSub</i> be the result of evaluating <i>Expression</i>.</li>
15645 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>firstSub</i>).</li>
15646 <li>Let <i>restSub</i> be SubstitutionEvaluation of <i>TemplateSpans</i>.</li>
15647 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>restSub</i>).</li>
15648 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>restSub</i> is a <a
15649 href="#sec-list-and-record-specification-type">List</a>.</li>
15650 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> whose first element is <i>siteObj</i>, whose
15651 second elements is <i>firstSub</i>, and whose subsequent elements are the elements of <i>restSub</i>, in order.
15652 <i>restSub</i> may contain no elements.</li>
15653 </ol>
15654 </section>
15655
15656 <section id="sec-gettemplateobject">
15657 <h1><span class="secnum" id="sec-12.2.8.3"><a href="#sec-gettemplateobject"
15658 title="link to this section">12.2.8.3</a></span> Runtime Semantics: GetTemplateObject ( templateLiteral )</h1>
15659
15660 <p>The abstract operation <span style="font-family: Times New Roman">GetTemplateObject</span> is called with a grammar
15661 production, <var>templateLiteral</var>, as an argument. It performs the following steps:</p>
15662
15663 <ol class="proc">
15664 <li>Let <i>rawStrings</i> be TemplateStrings of <i>templateLiteral</i> with argument <b>true</b>.</li>
15665 <li>Let <i>ctx</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
15666 <li>Let <i>realm</i> be the <i>ctx</i>&rsquo;s <a href="#sec-code-realms">Realm</a>.</li>
15667 <li>Let <i>templateRegistry</i> be <i>realm</i>.[[templateMap]].</li>
15668 <li>For each element <i>e</i> of <i>templateRegistry</i>, do
15669 <ol class="block">
15670 <li>If <i>e</i>.[[strings]] and <i>rawStrings</i> contain the same values in the same order, then
15671 <ol class="block">
15672 <li>Return <i>e.</i>[[array]].</li>
15673 </ol>
15674 </li>
15675 </ol>
15676 </li>
15677 <li>Let <i>cookedStrings</i> be TemplateStrings of <i>templateLiteral</i> with argument <b>false</b>.</li>
15678 <li>Let <i>count</i> be the number of elements in the <a href="#sec-list-and-record-specification-type">List</a>
15679 <i>cookedStrings</i>.</li>
15680 <li>Let <i>template</i> be <a href="#sec-arraycreate">ArrayCreate</a>(<i>count</i>).</li>
15681 <li>Let <i>rawObj</i> be <a href="#sec-arraycreate">ArrayCreate</a>(<i>count</i>).</li>
15682 <li>Let <i>index</i> be 0.</li>
15683 <li>Repeat while <i>index</i> &lt; <i>count</i>
15684 <ol class="block">
15685 <li>Let <i>prop</i> be <a href="#sec-tostring">ToString</a>(<i>index</i>).</li>
15686 <li>Let <i>cookedValue</i> be the string value <i>cookedStrings</i>[<i>index</i>].</li>
15687 <li><a href="#sec-call">Call</a> <i>template</i>.[[DefineOwnProperty]](<i>prop</i>, PropertyDescriptor{[[Value]]:
15688 <i>cookedValue</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>, [[Configurable]]:
15689 <b>false</b>})<i>.</i></li>
15690 <li>Let <i>rawValue</i> be the string value <i>rawStrings</i>[<i>index</i>].</li>
15691 <li><a href="#sec-call">Call</a> <i>rawObj</i>.[[DefineOwnProperty]](<i>prop</i>, PropertyDescriptor{[[Value]]:
15692 <i>rawValue</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>, [[Configurable]]:
15693 <b>false</b>})<i>.</i></li>
15694 <li>Let <i>index</i> be <i>index</i>+1.</li>
15695 </ol>
15696 </li>
15697 <li>Perform <a href="#sec-setintegritylevel">SetIntegrityLevel</a>(<i>rawObj</i>, <code>"frozen"</code>).</li>
15698 <li><a href="#sec-call">Call</a> <i>template</i>.[[DefineOwnProperty]](<code>"raw"</code>, PropertyDescriptor{[[Value]]:
15699 <i>rawObj</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
15700 <b>false</b>})<i>.</i></li>
15701 <li>Perform <a href="#sec-setintegritylevel">SetIntegrityLevel</a>(<i>template</i>, <code>"frozen"</code>).</li>
15702 <li>Append the Record{[[strings]]: <i>rawStrings</i>, [[array]]: <i>template</i>} to <i>templateRegistry</i>.</li>
15703 <li>Return <i>template</i>.</li>
15704 </ol>
15705
15706 <div class="note">
15707 <p><span class="nh">NOTE 1</span> The creation of a template object cannot result in an <a
15708 href="#sec-completion-record-specification-type">abrupt completion</a>.</p>
15709 </div>
15710
15711 <div class="note">
15712 <p><span class="nh">NOTE 2</span> Each <i>TemplateLiteral</i> in the program code of a <a
15713 href="#sec-code-realms">Realm</a> is associated with a unique template object that is used in the evaluation of tagged
15714 Templates (<a href="#sec-template-literals-runtime-semantics-evaluation">12.2.8.5</a>). The template objects are frozen
15715 and the same template object is used each time a specific tagged Template is evaluated. Whether template objects are
15716 created lazily upon first evaluation of the <i>TemplateLiteral</i> or eagerly prior to first evaluation is an
15717 implementation choice that is not observable to ECMAScript code.</p>
15718 </div>
15719
15720 <div class="note">
15721 <p><span class="nh">NOTE 3</span> Future editions of this specification may define additional non-enumerable properties
15722 of template objects.</p>
15723 </div>
15724 </section>
15725
15726 <section id="sec-runtime-semantics-substitutionevaluation">
15727 <h1><span class="secnum" id="sec-12.2.8.4"><a href="#sec-runtime-semantics-substitutionevaluation"
15728 title="link to this section">12.2.8.4</a></span> Runtime Semantics: SubstitutionEvaluation</h1>
15729 <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
15730 <ol class="proc">
15731 <li>Return an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
15732 </ol>
15733 <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
15734 <ol class="proc">
15735 <li>Return the result of SubstitutionEvaluation of <i>TemplateMiddleList</i>.</li>
15736 </ol>
15737 <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
15738 <ol class="proc">
15739 <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
15740 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>sub</i>).</li>
15741 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing only <i>sub</i>.</li>
15742 </ol>
15743 <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>
15744 <ol class="proc">
15745 <li>Let <i>preceding</i> be the result of SubstitutionEvaluation of <i>TemplateMiddleList</i> .</li>
15746 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>preceding</i>).</li>
15747 <li>Let <i>next</i> be the result of evaluating <i>Expression</i>.</li>
15748 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
15749 <li>Append <i>next</i> as the last element of the <a href="#sec-list-and-record-specification-type">List</a>
15750 <i>preceding</i>.</li>
15751 <li>Return <i>preceding</i>.</li>
15752 </ol>
15753 </section>
15754
15755 <section id="sec-template-literals-runtime-semantics-evaluation">
15756 <h1><span class="secnum" id="sec-12.2.8.5"><a href="#sec-template-literals-runtime-semantics-evaluation"
15757 title="link to this section">12.2.8.5</a></span> Runtime Semantics: Evaluation</h1>
15758 <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
15759 <ol class="proc">
15760 <li>Return the string value whose code units are the elements of the TV of <i>NoSubstitutionTemplate</i> as defined in
15761 <a href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
15762 </ol>
15763 <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>
15764 <ol class="proc">
15765 <li>Let <i>head</i> be the TV of <i>TemplateHead</i> as defined in <a
15766 href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
15767 <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
15768 <li>Let <i>middle</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
15769 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>middle</i>).</li>
15770 <li>Let <i>tail</i> be the result of evaluating <i>TemplateSpans</i> .</li>
15771 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>tail</i>).</li>
15772 <li>Return the string value whose code units are the elements of <i>head</i> followed by the elements of <i>middle</i>
15773 followed by the elements of <i>tail</i>.</li>
15774 </ol>
15775
15776 <div class="note">
15777 <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
15778 href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
15779 </div>
15780
15781 <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
15782 <ol class="proc">
15783 <li>Let <i>tail</i> be the TV of <i>TemplateTail</i> as defined in <a
15784 href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
15785 <li>Return the string consisting of the code units of <i>tail</i>.</li>
15786 </ol>
15787 <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
15788 <ol class="proc">
15789 <li>Let <i>head</i> be the result of evaluating <i>TemplateMiddleList</i>.</li>
15790 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>head</i>).</li>
15791 <li>Let <i>tail</i> be the TV of <i>TemplateTail</i> as defined in <a
15792 href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
15793 <li>Return the string whose code units are the elements of <i>head</i> followed by the elements of <i>tail</i>.</li>
15794 </ol>
15795 <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
15796 <ol class="proc">
15797 <li>Let <i>head</i> be the TV of <i>TemplateMiddle</i> as defined in <a
15798 href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
15799 <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
15800 <li>Let <i>middle</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
15801 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>middle</i>).</li>
15802 <li>Return the sequence of code units consisting of the code units of <i>head</i> followed by the elements of
15803 <i>middle</i>.</li>
15804 </ol>
15805
15806 <div class="note">
15807 <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
15808 href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
15809 </div>
15810
15811 <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>
15812 <ol class="proc">
15813 <li>Let <i>rest</i> be the result of evaluating <i>TemplateMiddleList</i> .</li>
15814 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>rest</i>).</li>
15815 <li>Let <i>middle</i> be the TV of <i>TemplateMiddle</i> as defined in <a
15816 href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
15817 <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
15818 <li>Let <i>last</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
15819 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>last</i>).</li>
15820 <li>Return the sequence of code units consisting of the elements of <i>rest</i> followed by the code units of
15821 <i>middle</i> followed by the elements of <i>last</i>.</li>
15822 </ol>
15823
15824 <div class="note">
15825 <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
15826 href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
15827 </div>
15828 </section>
15829 </section>
15830
15831 <section id="sec-grouping-operator">
15832 <div class="front">
15833 <h1><span class="secnum" id="sec-12.2.9"><a href="#sec-grouping-operator" title="link to this section">12.2.9</a></span>
15834 The Grouping Operator</h1>
15835 </div>
15836
15837 <section id="sec-grouping-operator-static-semantics-early-errors">
15838 <h1><span class="secnum" id="sec-12.2.9.1"><a href="#sec-grouping-operator-static-semantics-early-errors"
15839 title="link to this section">12.2.9.1</a></span> Static Semantics: Early Errors</h1>
15840 <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
15841 <ul>
15842 <li>
15843 <p>It is a Syntax Error if the lexical token sequence matched by <span
15844 class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> cannot be parsed with no tokens left over using
15845 <span class="nt">ParenthesizedExpression</span> as the goal symbol.</p>
15846 </li>
15847
15848 <li>
15849 <p>All Early Errors rules for <span class="nt">ParenthesizedExpression</span> and its derived productions also apply
15850 to <span style="font-family: Times New Roman">CoveredParenthesizedExpression</span> of <span
15851 class="nt">CoverParenthesizedExpressionAndArrowParameterList</span>.</p>
15852 </li>
15853 </ul>
15854 </section>
15855
15856 <section id="sec-grouping-operator-static-semantics-isfunctiondefinition">
15857 <h1><span class="secnum" id="sec-12.2.9.2"><a href="#sec-grouping-operator-static-semantics-isfunctiondefinition"
15858 title="link to this section">12.2.9.2</a></span> Static Semantics: IsFunctionDefinition</h1>
15859
15860 <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
15861 href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
15862 href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
15863 href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
15864 href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
15865 href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
15866 href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
15867 href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
15868 href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
15869 href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
15870 href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
15871 href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
15872 href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
15873 href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
15874 href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
15875 href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
15876 href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
15877
15878 <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>
15879 <ol class="proc">
15880 <li>Return IsFunctionDefinition of <i>Expression</i>.</li>
15881 </ol>
15882 </section>
15883
15884 <section id="sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">
15885 <h1><span class="secnum" id="sec-12.2.9.3"><a href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget"
15886 title="link to this section">12.2.9.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
15887
15888 <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
15889 href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
15890 href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
15891 href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
15892 href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
15893 href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
15894 href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
15895 href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
15896 href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
15897 href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
15898 href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
15899 href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
15900 href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
15901 href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
15902 href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
15903
15904 <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>
15905 <ol class="proc">
15906 <li>Return IsValidSimpleAssignmentTarget of <i>Expression</i>.</li>
15907 </ol>
15908 </section>
15909
15910 <section id="sec-grouping-operator-runtime-semantics-evaluation">
15911 <h1><span class="secnum" id="sec-12.2.9.4"><a href="#sec-grouping-operator-runtime-semantics-evaluation"
15912 title="link to this section">12.2.9.4</a></span> Runtime Semantics: Evaluation</h1>
15913 <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
15914 <ol class="proc">
15915 <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
15916 <li>Return the result of evaluating <i>expr</i>.</li>
15917 </ol>
15918 <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>
15919 <ol class="proc">
15920 <li>Return the result of evaluating <i>Expression</i>. This may be of type <a
15921 href="#sec-reference-specification-type">Reference</a>.</li>
15922 </ol>
15923
15924 <div class="note">
15925 <p><span class="nh">NOTE</span> This algorithm does not apply <a href="#sec-getvalue">GetValue</a> to the result of
15926 evaluating <i>Expression</i>. The principal motivation for this is so that operators such as <code>delete</code> and
15927 <code>typeof</code> may be applied to parenthesized expressions.</p>
15928 </div>
15929 </section>
15930 </section>
15931 </section>
15932
15933 <section id="sec-left-hand-side-expressions">
15934 <div class="front">
15935 <h1><span class="secnum" id="sec-12.3"><a href="#sec-left-hand-side-expressions"
15936 title="link to this section">12.3</a></span> Left-Hand-Side Expressions</h1>
15937 <h2>Syntax</h2>
15938
15939 <div class="gp">
15940 <div class="lhs"><span class="nt">MemberExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15941 <div class="rhs"><span class="nt">PrimaryExpression</span><sub class="g-params">[?Yield]</sub></div>
15942 <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>
15943 <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
15944 <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>
15945 <div class="rhs"><span class="nt">SuperProperty</span><sub class="g-params">[?Yield]</sub></div>
15946 <div class="rhs"><span class="nt">MetaProperty</span></div>
15947 <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>
15948 </div>
15949
15950 <div class="gp">
15951 <div class="lhs"><span class="nt">SuperProperty</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15952 <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>
15953 <div class="rhs"><code class="t">super</code> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
15954 </div>
15955
15956 <div class="gp">
15957 <div class="lhs"><span class="nt">MetaProperty</span> <span class="geq">:</span></div>
15958 <div class="rhs"><span class="nt">NewTarget</span></div>
15959 </div>
15960
15961 <div class="gp">
15962 <div class="lhs"><span class="nt">NewTarget</span> <span class="geq">:</span></div>
15963 <div class="rhs"><code class="t">new</code> <code class="t">.</code> <code class="t">target</code></div>
15964 </div>
15965
15966 <div class="gp">
15967 <div class="lhs"><span class="nt">NewExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15968 <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub></div>
15969 <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span><sub class="g-params">[?Yield]</sub></div>
15970 </div>
15971
15972 <div class="gp">
15973 <div class="lhs"><span class="nt">CallExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15974 <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>
15975 <div class="rhs"><span class="nt">SuperCall</span><sub class="g-params">[?Yield]</sub></div>
15976 <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>
15977 <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>
15978 <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
15979 <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>
15980 </div>
15981
15982 <div class="gp">
15983 <div class="lhs"><span class="nt">SuperCall</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15984 <div class="rhs"><code class="t">super</code> <span class="nt">Arguments</span><sub class="g-params">[?Yield]</sub></div>
15985 </div>
15986
15987 <div class="gp">
15988 <div class="lhs"><span class="nt">Arguments</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15989 <div class="rhs"><code class="t">(</code> <code class="t">)</code></div>
15990 <div class="rhs"><code class="t">(</code> <span class="nt">ArgumentList</span><sub class="g-params">[?Yield]</sub> <code class="t">)</code></div>
15991 </div>
15992
15993 <div class="gp">
15994 <div class="lhs"><span class="nt">ArgumentList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
15995 <div class="rhs"><span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
15996 <div class="rhs"><code class="t">...</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
15997 <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>
15998 <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>
15999 </div>
16000
16001 <div class="gp">
16002 <div class="lhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
16003 <div class="rhs"><span class="nt">NewExpression</span><sub class="g-params">[?Yield]</sub></div>
16004 <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub></div>
16005 </div>
16006 </div>
16007
16008 <section id="sec-static-semantics">
16009 <div class="front">
16010 <h1><span class="secnum" id="sec-12.3.1"><a href="#sec-static-semantics" title="link to this section">12.3.1</a></span>
16011 Static Semantics</h1>
16012 </div>
16013
16014 <section id="sec-static-semantics-static-semantics-contains">
16015 <h1><span class="secnum" id="sec-12.3.1.1"><a href="#sec-static-semantics-static-semantics-contains"
16016 title="link to this section">12.3.1.1</a></span> Static Semantics: Contains</h1>
16017
16018 <p>With parameter <var>symbol</var>.</p>
16019
16020 <p>See also: <a href="#sec-static-semantic-rules">5.3</a>, <a
16021 href="#sec-object-initializer-static-semantics-contains">12.2.5.3</a>, <a
16022 href="#sec-function-definitions-static-semantics-contains">14.1.4</a>, <a
16023 href="#sec-arrow-function-definitions-static-semantics-contains">14.2.3</a>, <a
16024 href="#sec-generator-function-definitions-static-semantics-contains">14.4.4</a>, <a
16025 href="#sec-class-definitions-static-semantics-contains">14.5.4</a></p>
16026
16027 <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>
16028 <ol class="proc">
16029 <li>If <i>MemberExpression</i> Contains <i>symbol</i> is <b>true</b>, return <b>true</b>.</li>
16030 <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
16031 <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
16032 <i>IdentifierName</i>, return <b>true</b>;</li>
16033 <li>Return <b>false</b>.</li>
16034 </ol>
16035 <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>
16036 <ol class="proc">
16037 <li>If <i>symbol</i> is the <i>ReservedWord</i> <code>super</code>, return <b>true</b>.</li>
16038 <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
16039 <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
16040 <i>IdentifierName</i>, return <b>true</b>;</li>
16041 <li>Return <b>false</b>.</li>
16042 </ol>
16043 <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>
16044 <ol class="proc">
16045 <li>If <i>CallExpression</i> Contains <i>symbol</i> is <b>true</b>, return <b>true</b>.</li>
16046 <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
16047 <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
16048 <i>IdentifierName</i>, return <b>true</b>;</li>
16049 <li>Return <b>false</b>.</li>
16050 </ol>
16051 </section>
16052
16053 <section id="sec-static-semantics-static-semantics-isfunctiondefinition">
16054 <h1><span class="secnum" id="sec-12.3.1.2"><a href="#sec-static-semantics-static-semantics-isfunctiondefinition"
16055 title="link to this section">12.3.1.2</a></span> Static Semantics: IsFunctionDefinition</h1>
16056
16057 <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
16058 href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
16059 href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
16060 href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
16061 href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
16062 href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
16063 href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
16064 href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
16065 href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
16066 href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
16067 href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
16068 href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
16069 href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
16070 href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
16071 href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
16072 href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
16073 href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
16074
16075 <div class="gp">
16076 <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
16077 <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
16078 <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
16079 <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
16080 <div class="rhs"><span class="nt">SuperProperty</span></div>
16081 <div class="rhs"><span class="nt">MetaProperty</span></div>
16082 <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
16083 </div>
16084
16085 <div class="gp">
16086 <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
16087 <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
16088 </div>
16089
16090 <div class="gp">
16091 <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
16092 <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
16093 <div class="rhs"><span class="nt">SuperCall</span></div>
16094 <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
16095 <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
16096 <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
16097 <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
16098 </div>
16099
16100 <ol class="proc">
16101 <li>Return <b>false</b>.</li>
16102 </ol>
16103 </section>
16104
16105 <section id="sec-static-semantics-static-semantics-isdestructuring">
16106 <h1><span class="secnum" id="sec-12.3.1.3"><a href="#sec-static-semantics-static-semantics-isdestructuring"
16107 title="link to this section">12.3.1.3</a></span> Static Semantics: IsDestructuring</h1>
16108
16109 <p>See also: <a href="#sec-for-in-and-for-of-statements-static-semantics-isdestructuring">13.6.4.6</a>.</p>
16110
16111 <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">PrimaryExpression</span></div>
16112 <ol class="proc">
16113 <li>If <i>PrimaryExpression</i> is either an <i>ObjectLiteral</i> or an <i>ArrayLiteral</i>, return <b>true.</b></li>
16114 <li>Return <b>false</b>.</li>
16115 </ol>
16116
16117 <div class="gp">
16118 <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
16119 <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
16120 <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
16121 <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
16122 <div class="rhs"><span class="nt">SuperProperty</span></div>
16123 <div class="rhs"><span class="nt">MetaProperty</span></div>
16124 <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
16125 </div>
16126
16127 <div class="gp">
16128 <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
16129 <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
16130 </div>
16131
16132 <div class="gp">
16133 <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
16134 <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
16135 <div class="rhs"><span class="nt">SuperCall</span></div>
16136 <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
16137 <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
16138 <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
16139 <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
16140 </div>
16141
16142 <ol class="proc">
16143 <li>Return <b>false</b>.</li>
16144 </ol>
16145 </section>
16146
16147 <section id="sec-static-semantics-static-semantics-isidentifierref">
16148 <h1><span class="secnum" id="sec-12.3.1.4"><a href="#sec-static-semantics-static-semantics-isidentifierref"
16149 title="link to this section">12.3.1.4</a></span> Static Semantics: IsIdentifierRef</h1>
16150
16151 <p>See also: <a href="#sec-semantics-static-semantics-isidentifierref">12.2.0.3</a>.</p>
16152
16153 <div class="gp">
16154 <div class="lhs"><span class="nt">LeftHandSideExpression</span> <span class="geq">:</span></div>
16155 <div class="rhs"><span class="nt">CallExpression</span></div>
16156 </div>
16157
16158 <div class="gp">
16159 <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
16160 <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
16161 <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
16162 <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
16163 <div class="rhs"><span class="nt">SuperProperty</span></div>
16164 <div class="rhs"><span class="nt">MetaProperty</span></div>
16165 <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
16166 </div>
16167
16168 <div class="gp">
16169 <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
16170 <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
16171 </div>
16172
16173 <ol class="proc">
16174 <li>Return <b>false</b>.</li>
16175 </ol>
16176 </section>
16177
16178 <section id="sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">
16179 <h1><span class="secnum" id="sec-12.3.1.5"><a href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget"
16180 title="link to this section">12.3.1.5</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
16181
16182 <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
16183 href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
16184 href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
16185 href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
16186 href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
16187 href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
16188 href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
16189 href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
16190 href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
16191 href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
16192 href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
16193 href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
16194 href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
16195 href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
16196 href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
16197
16198 <div class="gp">
16199 <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
16200 <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
16201 <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
16202 </div>
16203
16204 <div class="gp">
16205 <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
16206 <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
16207 <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
16208 <div class="rhs"><span class="nt">SuperProperty</span></div>
16209 </div>
16210
16211 <ol class="proc">
16212 <li>Return <b>true</b>.</li>
16213 </ol>
16214
16215 <div class="gp">
16216 <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
16217 <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
16218 <div class="rhs"><span class="nt">SuperCall</span></div>
16219 <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
16220 <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
16221 </div>
16222
16223 <div class="gp">
16224 <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
16225 <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
16226 </div>
16227
16228 <div class="gp">
16229 <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
16230 <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
16231 <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
16232 </div>
16233
16234 <div class="gp">
16235 <div class="lhs"><span class="nt">NewTarget</span> <span class="geq">:</span></div>
16236 <div class="rhs"><code class="t">new</code> <code class="t">.</code> <code class="t">target</code></div>
16237 </div>
16238
16239 <ol class="proc">
16240 <li>Return <b>false</b>.</li>
16241 </ol>
16242 </section>
16243 </section>
16244
16245 <section id="sec-property-accessors">
16246 <div class="front">
16247 <h1><span class="secnum" id="sec-12.3.2"><a href="#sec-property-accessors" title="link to this section">12.3.2</a></span>
16248 Property Accessors</h1>
16249
16250 <div class="note">
16251 <p><span class="nh">NOTE</span> Properties are accessed by name, using either the dot notation:</p>
16252 </div>
16253
16254 <div class="lhs">MemberExpression <code>.</code> IdentifierName<br>CallExpression <code>.</code> IdentifierName</div>
16255
16256 <p>or the bracket notation:</p>
16257
16258 <div class="lhs">MemberExpression <code>[</code> Expression <code>]</code><br>CallExpression <code>[</code> Expression <code>]</code></div>
16259
16260 <p>The dot notation is explained by the following syntactic conversion:</p>
16261
16262 <div class="lhs">MemberExpression <code>.</code> IdentifierName</div>
16263
16264 <p>is identical in its behaviour to</p>
16265
16266 <div class="lhs">MemberExpression <code>[</code> &lt;identifier-name-string&gt; <code>]</code></div>
16267
16268 <p>and similarly</p>
16269
16270 <div class="lhs">CallExpression <code>.</code> IdentifierName</div>
16271
16272 <p>is identical in its behaviour to</p>
16273
16274 <div class="lhs">CallExpression <code>[</code> &lt;identifier-name-string&gt; <code>]</code></div>
16275
16276 <p>where <var>&lt;identifier-name-string&gt;</var> is the result of evaluating <span style="font-family: Times New
16277 Roman">StringValue of</span> <span class="nt">IdentifierName</span>.</p>
16278 </div>
16279
16280 <section id="sec-property-accessors-runtime-semantics-evaluation">
16281 <h1><span class="secnum" id="sec-12.3.2.1"><a href="#sec-property-accessors-runtime-semantics-evaluation"
16282 title="link to this section">12.3.2.1</a></span> Runtime Semantics: Evaluation</h1>
16283 <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>
16284 <ol class="proc">
16285 <li>Let <i>baseReference</i> be the result of evaluating <i>MemberExpression</i>.</li>
16286 <li>Let <i>baseValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>baseReference</i>).</li>
16287 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>baseValue</i>).</li>
16288 <li>Let <i>propertyNameReference</i> be the result of evaluating <i>Expression</i>.</li>
16289 <li>Let <i>propertyNameValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>propertyNameReference</i>).</li>
16290 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyNameValue</i>).</li>
16291 <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
16292 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
16293 <li>Let <i>propertyKey</i> be <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propertyNameValue</i>).</li>
16294 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyKey</i>).</li>
16295 <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
16296 mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
16297 <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i> and
16298 whose referenced name is <i>propertyKey</i>, and whose strict reference flag is <i>strict</i>.</li>
16299 </ol>
16300 <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>
16301 <ol class="proc">
16302 <li>Let <i>baseReference</i> be the result of evaluating <i>MemberExpression</i>.</li>
16303 <li>Let <i>baseValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>baseReference</i>).</li>
16304 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>baseValue</i>).</li>
16305 <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
16306 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
16307 <li>Let <i>propertyNameString</i> be StringValue of <i>IdentifierName</i></li>
16308 <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
16309 mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
16310 <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i> and
16311 whose referenced name is <i>propertyNameString</i>, and whose strict reference flag is <i>strict</i>.</li>
16312 </ol>
16313 <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>
16314
16315 <p>Is evaluated in exactly the same manner as <span class="prod"><span class="nt">MemberExpression</span> <span
16316 class="geq">:</span> <span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span>
16317 <code class="t">]</code></span> except that the contained <span class="nt">CallExpression</span> is evaluated in step
16318 1.</p>
16319
16320 <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>
16321
16322 <p>Is evaluated in exactly the same manner as <span class="prod"><span class="nt">MemberExpression</span> <span
16323 class="geq">:</span> <span class="nt">MemberExpression</span> <code class="t">.</code> <span
16324 class="nt">IdentifierName</span></span> except that the contained <span class="nt">CallExpression</span> is evaluated in
16325 step 1.</p>
16326 </section>
16327 </section>
16328
16329 <section id="sec-new-operator">
16330 <div class="front">
16331 <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
16332 <code>new</code> Operator</h1>
16333 </div>
16334
16335 <section id="sec-new-operator-runtime-semantics-evaluation">
16336 <div class="front">
16337 <h1><span class="secnum" id="sec-12.3.3.1"><a href="#sec-new-operator-runtime-semantics-evaluation"
16338 title="link to this section">12.3.3.1</a></span> Runtime Semantics: Evaluation</h1>
16339 <div class="gp prod"><span class="nt">NewExpression</span> <span class="geq">:</span> <code class="t">new</code> <span class="nt">NewExpression</span></div>
16340 <ol class="proc">
16341 <li>Return <a href="#sec-evaluatenew">EvaluateNew</a>(<i>NewExpression</i>, <span style="font-family:
16342 sans-serif">empty</span>).</li>
16343 </ol>
16344 <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>
16345 <ol class="proc">
16346 <li>Return <a href="#sec-evaluatenew">EvaluateNew</a>(<i>MemberExpression</i>, <i>Arguments</i>).</li>
16347 </ol>
16348 </div>
16349
16350 <section id="sec-evaluatenew">
16351 <h1><span class="secnum" id="sec-12.3.3.1.1"><a href="#sec-evaluatenew"
16352 title="link to this section">12.3.3.1.1</a></span> Runtime Semantics: EvaluateNew(constructProduction,
16353 arguments)</h1>
16354
16355 <p>The abstract operation EvaluateNew with arguments <span style="font-family: Times New
16356 Roman"><i>constructProduction</i>,</span> and <var>arguments</var> performs the following steps:</p>
16357
16358 <ol class="proc">
16359 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>constructProduction</i> is either a <i>NewExpression</i> or a
16360 <i>MemberExpression</i>.</li>
16361 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>arguments</i> is either <span style="font-family:
16362 sans-serif">empty</span> or an <i>Arguments</i> production.</li>
16363 <li>Let <i>ref</i> be the result of evaluating <i>constructProduction</i>.</li>
16364 <li>Let <i>constructor</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
16365 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>constructor</i>).</li>
16366 <li>If <i>arguments</i> is <span style="font-family: sans-serif">empty</span>, let <i>argList</i> be an empty <a
16367 href="#sec-list-and-record-specification-type">List</a>.</li>
16368 <li>Else,
16369 <ol class="block">
16370 <li>Let <i>argList</i> be ArgumentListEvaluation of <i>arguments</i>.</li>
16371 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
16372 </ol>
16373 </li>
16374 <li>If <a href="#sec-isconstructor">IsConstructor</a> (<i>constructor</i>) is <b>false</b>, throw a <b>TypeError</b>
16375 exception.</li>
16376 <li>Return <a href="#sec-construct">Construct</a>(<i>constructor</i>, <i>argList</i>).</li>
16377 </ol>
16378 </section>
16379 </section>
16380 </section>
16381
16382 <section id="sec-function-calls">
16383 <div class="front">
16384 <h1><span class="secnum" id="sec-12.3.4"><a href="#sec-function-calls" title="link to this section">12.3.4</a></span>
16385 Function Calls</h1>
16386 </div>
16387
16388 <section id="sec-function-calls-runtime-semantics-evaluation">
16389 <h1><span class="secnum" id="sec-12.3.4.1"><a href="#sec-function-calls-runtime-semantics-evaluation"
16390 title="link to this section">12.3.4.1</a></span> Runtime Semantics: Evaluation</h1>
16391 <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
16392 <ol class="proc">
16393 <li>Let <i>ref</i> be the result of evaluating <i>MemberExpression</i>.</li>
16394 <li>Let <i>func</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
16395 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
16396 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
16397 href="#sec-reference-specification-type">Reference</a> and <a
16398 href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>false</b> and <a
16399 href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>) <i>is</i> <code>"eval"</code>, then
16400 <ol class="block">
16401 <li>If <a href="#sec-samevalue">SameValue</a>(<i>func</i>, %eval%) is <b>true</b>, then
16402 <ol class="block">
16403 <li>Let <i>argList</i> be ArgumentListEvaluation(<i>Arguments</i>).</li>
16404 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
16405 <li>If <i>argList</i> has no elements, return <b>undefined.</b></li>
16406 <li>Let <i>evalText</i> be the first element of <i>argList</i>.</li>
16407 <li>If the source code matching this <i>CallExpression</i> is <a href="#sec-strict-mode-code">strict code</a>,
16408 let <i>strictCaller</i> be <b>true.</b> Otherwise let <i>strictCaller</i> be <b>false.</b></li>
16409 <li>Let <i>evalRealm</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
16410 href="#sec-code-realms">Realm</a>.</li>
16411 <li>Return <a href="#sec-performeval">PerformEval</a>(<i>evalText</i>, <i>evalRealm</i>, <i>strictCaller</i>,
16412 <b>true</b>). .</li>
16413 </ol>
16414 </li>
16415 </ol>
16416 </li>
16417 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
16418 href="#sec-reference-specification-type">Reference</a>, then
16419 <ol class="block">
16420 <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
16421 <ol class="block">
16422 <li>Let <i>thisValue</i> be <a href="#sec-getthisvalue">GetThisValue</a>(<i>ref</i>).</li>
16423 </ol>
16424 </li>
16425 <li>Else, the base of <i>ref</i> is an <a href="#sec-environment-records">Environment Record</a>
16426 <ol class="block">
16427 <li>Let <i>refEnv</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
16428 <li>Let <i>thisValue</i> be <i>refEnv</i>.WithBaseObject().</li>
16429 </ol>
16430 </li>
16431 </ol>
16432 </li>
16433 <li>Else <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
16434 href="#sec-reference-specification-type">Reference</a>,
16435 <ol class="block">
16436 <li>Let <i>thisValue</i> be <b>undefined</b>.</li>
16437 </ol>
16438 </li>
16439 <li>Let <i>thisCall</i> be this <i>CallExpression</i>.</li>
16440 <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
16441 href="#sec-isintailposition">14.6.1</a>)</li>
16442 <li>Return <a href="#sec-evaluatedirectcall">EvaluateDirectCall</a>(<i>func</i>, <i>thisValue</i>, <i>Arguments</i>,
16443 <i>tailCall</i>).</li>
16444 </ol>
16445
16446 <p>A <span class="nt">CallExpression</span> whose evaluation executes step 4.a.vii is a <i>direct eval</i>.</p>
16447
16448 <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
16449 <ol class="proc">
16450 <li>Let <i>ref</i> be the result of evaluating <i>CallExpression</i>.</li>
16451 <li>Let <i>thisCall</i> be this <i>CallExpression</i></li>
16452 <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
16453 href="#sec-isintailposition">14.6.1</a>)</li>
16454 <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>ref</i>, <i>Arguments</i>, <i>tailCall</i>).</li>
16455 </ol>
16456 </section>
16457
16458 <section id="sec-evaluatecall">
16459 <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>
16460 Runtime Semantics: EvaluateCall( ref, arguments, tailPosition )</h1>
16461
16462 <p>The abstract operation EvaluateCall takes as arguments a value <var>ref</var>, a syntactic grammar production
16463 <var>arguments</var>, and a Boolean argument <var>tailPosition</var>. It performs the following steps:</p>
16464
16465 <ol class="proc">
16466 <li>Let <i>func</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
16467 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
16468 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
16469 href="#sec-reference-specification-type">Reference</a>, then
16470 <ol class="block">
16471 <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
16472 <ol class="block">
16473 <li>Let <i>thisValue</i> be <a href="#sec-getthisvalue">GetThisValue</a>(<i>ref</i>).</li>
16474 </ol>
16475 </li>
16476 <li>Else, the base of <i>ref</i> is an <a href="#sec-environment-records">Environment Record</a>
16477 <ol class="block">
16478 <li>Let <i>refEnv</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
16479 <li>Let <i>thisValue</i> be <i>refEnv</i>.WithBaseObject().</li>
16480 </ol>
16481 </li>
16482 </ol>
16483 </li>
16484 <li>Else <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
16485 href="#sec-reference-specification-type">Reference</a>,
16486 <ol class="block">
16487 <li>Let <i>thisValue</i> be <b>undefined</b>.</li>
16488 </ol>
16489 </li>
16490 <li>Return <a href="#sec-evaluatedirectcall">EvaluateDirectCall</a>(<i>func</i>, <i>thisValue</i>, <i>arguments</i>,
16491 <i>tailPosition</i>).</li>
16492 </ol>
16493 </section>
16494
16495 <section id="sec-evaluatedirectcall">
16496 <h1><span class="secnum" id="sec-12.3.4.3"><a href="#sec-evaluatedirectcall"
16497 title="link to this section">12.3.4.3</a></span> Runtime Semantics: EvaluateDirectCall( func, thisValue, arguments,
16498 tailPosition )</h1>
16499
16500 <p>The abstract operation EvaluateDirectCall takes as arguments a value <var>func</var>, a value <var>thisValue</var>, a
16501 syntactic grammar production <var>arguments</var>, and a Boolean argument <var>tailPosition</var>. It performs the
16502 following steps:</p>
16503
16504 <ol class="proc">
16505 <li>Let <i>argList</i> be ArgumentListEvaluation(<i>arguments</i>).</li>
16506 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
16507 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>func</i>) is not Object, throw a <b>TypeError</b>
16508 exception.</li>
16509 <li>If <a href="#sec-iscallable">IsCallable</a>(<i>func</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
16510 <li>If <i>tailPosition</i> is <b>true</b>, perform <a href="#sec-preparefortailcall">PrepareForTailCall</a>().</li>
16511 <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>func</i>, <i>thisValue</i>, <i>argList</i>).</li>
16512 <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>tailPosition</i> is <b>true</b>, the above call will not
16513 return here, but instead evaluation will continue as if the following return has already occurred.</li>
16514 <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>result</i> is not an <a
16515 href="#sec-completion-record-specification-type">abrupt completion</a> then <a
16516 href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is an <a
16517 href="#sec-ecmascript-language-types">ECMAScript language type</a>.</li>
16518 <li>Return <i>result</i>.</li>
16519 </ol>
16520 </section>
16521 </section>
16522
16523 <section id="sec-super-keyword">
16524 <div class="front">
16525 <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
16526 <code>super</code> Keyword</h1>
16527 </div>
16528
16529 <section id="sec-super-keyword-runtime-semantics-evaluation">
16530 <h1><span class="secnum" id="sec-12.3.5.1"><a href="#sec-super-keyword-runtime-semantics-evaluation"
16531 title="link to this section">12.3.5.1</a></span> Runtime Semantics: Evaluation</h1>
16532 <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>
16533 <ol class="proc">
16534 <li>Let <i>propertyNameReference</i> be the result of evaluating <i>Expression</i>.</li>
16535 <li>Let <i>propertyNameValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>propertyNameReference</i>).</li>
16536 <li>Let <i>propertyKey</i> be <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propertyNameValue</i>).</li>
16537 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyKey</i>).</li>
16538 <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
16539 mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
16540 <li>Return <a href="#sec-makesuperpropertyreference">MakeSuperPropertyReference</a>(<i>propertyKey</i>,
16541 <i>strict</i>).</li>
16542 </ol>
16543 <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>
16544 <ol class="proc">
16545 <li>Let <i>propertyKey</i> be StringValue of <i>IdentifierName</i>.</li>
16546 <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
16547 mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
16548 <li>Return <a href="#sec-makesuperpropertyreference">MakeSuperPropertyReference</a>(<i>propertyKey</i>,
16549 <i>strict</i>).</li>
16550 </ol>
16551 <div class="gp prod"><span class="nt">SuperCall</span> <span class="geq">:</span> <code class="t">super</code> <span class="nt">Arguments</span></div>
16552 <ol class="proc">
16553 <li>Let <i>newTarget</i> be <a href="#sec-getnewtarget">GetNewTarget</a>().</li>
16554 <li>If <i>newTarget</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
16555 <li>Let <i>func</i> be <a href="#sec-getsuperconstructor">GetSuperConstructor</a>().</li>
16556 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
16557 <li>Let <i>argList</i> be ArgumentListEvaluation of <i>Arguments</i>.</li>
16558 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
16559 <li>Let <i>result</i> be <a href="#sec-construct">Construct</a>(<i>func</i>, <i>argList</i>, <i>newTarget</i>).</li>
16560 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
16561 <li>Let <i>thisER</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
16562 <li>Return <i>thisER</i>.<a href="#sec-bindthisvalue">BindThisValue</a>(<i>result</i>).</li>
16563 </ol>
16564 </section>
16565
16566 <section id="sec-getsuperconstructor">
16567 <h1><span class="secnum" id="sec-12.3.5.2"><a href="#sec-getsuperconstructor"
16568 title="link to this section">12.3.5.2</a></span> Runtime Semantics: GetSuperConstructor ( )</h1>
16569
16570 <p>The abstract operation GetSuperConstructor performs the following steps:</p>
16571
16572 <ol class="proc">
16573 <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
16574 <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> is a function <a
16575 href="#sec-environment-records">Environment Record</a>.</li>
16576 <li>Let <i>activeFunction</i> be <i>envRec</i>.[[FunctionObject]].</li>
16577 <li>Let <i>superConstructor</i> be <i>activeFunction</i>.[[GetPrototypeOf]]().</li>
16578 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>superConstructor</i>).</li>
16579 <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>superConstructor</i>) is <b>false</b>, throw a <b>TypeError</b>
16580 exception.</li>
16581 <li>Return <i>superConstructor</i>.</li>
16582 </ol>
16583 </section>
16584
16585 <section id="sec-makesuperpropertyreference">
16586 <h1><span class="secnum" id="sec-12.3.5.3"><a href="#sec-makesuperpropertyreference"
16587 title="link to this section">12.3.5.3</a></span> Runtime Semantics: MakeSuperPropertyReference(propertyKey,
16588 strict)</h1>
16589
16590 <p>The abstract operation MakeSuperPropertyReference with arguments <var>propertyKey</var> and <var>strict</var> performs
16591 the following steps:</p>
16592
16593 <ol class="proc">
16594 <li>Let <i>env</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
16595 <li>If <i>env</i>.HasSuperBinding() is <b>false</b>, throw a <b>ReferenceError</b> exception.</li>
16596 <li>Let <i>actualThis</i> be <i>env</i>.GetThisBinding().</li>
16597 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>actualThis</i>).</li>
16598 <li>Let <i>baseValue</i> be <i>env</i>.<a href="#sec-getsuperbase">GetSuperBase</a>().</li>
16599 <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
16600 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
16601 <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> that is a Super <a
16602 href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i>, whose referenced name is
16603 <i>propertyKey</i>, whose thisValue is <i>actualThis</i>, and whose strict reference flag is <i>strict</i>.</li>
16604 </ol>
16605 </section>
16606 </section>
16607
16608 <section id="sec-argument-lists">
16609 <div class="front">
16610 <h1><span class="secnum" id="sec-12.3.6"><a href="#sec-argument-lists" title="link to this section">12.3.6</a></span>
16611 Argument Lists</h1>
16612
16613 <div class="note">
16614 <p><span class="nh">NOTE</span> The evaluation of an argument list produces a <a
16615 href="#sec-list-and-record-specification-type">List</a> of values (<a href="#sec-list-and-record-specification-type">see
16616 6.2.1</a>).</p>
16617 </div>
16618 </div>
16619
16620 <section id="sec-argument-lists-runtime-semantics-argumentlistevaluation">
16621 <h1><span class="secnum" id="sec-12.3.6.1"><a href="#sec-argument-lists-runtime-semantics-argumentlistevaluation"
16622 title="link to this section">12.3.6.1</a></span> <span style="font-family: sans-serif">Runtime Semantics:</span>
16623 ArgumentListEvaluation</h1>
16624
16625 <p>See also: <a href="#sec-template-literals-runtime-semantics-argumentlistevaluation">12.2.8.2</a></p>
16626
16627 <div class="gp prod"><span class="nt">Arguments</span> <span class="geq">:</span> <code class="t">(</code> <code class="t">)</code></div>
16628 <ol class="proc">
16629 <li>Return an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
16630 </ol>
16631 <div class="gp prod"><span class="nt">ArgumentList</span> <span class="geq">:</span> <span class="nt">AssignmentExpression</span></div>
16632 <ol class="proc">
16633 <li>Let <i>ref</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
16634 <li>Let <i>arg</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
16635 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>arg</i>).</li>
16636 <li>Return a <a href="#sec-list-and-record-specification-type">List</a> whose sole item is <i>arg</i>.</li>
16637 </ol>
16638 <div class="gp prod"><span class="nt">ArgumentList</span> <span class="geq">:</span> <code class="t">...</code> <span class="nt">AssignmentExpression</span></div>
16639 <ol class="proc">
16640 <li>Let <i>list</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
16641 <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
16642 <li>Let <i>spreadObj</i> be <a href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>).</li>
16643 <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<i>spreadObj</i>).</li>
16644 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
16645 <li>Repeat
16646 <ol class="block">
16647 <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
16648 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
16649 <li>If <i>next</i> is <b>false</b>, return <i>list</i>.</li>
16650 <li>Let <i>nextArg</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
16651 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextArg</i>).</li>
16652 <li>Append <i>nextArg</i> as the last element of <i>list</i>.</li>
16653 </ol>
16654 </li>
16655 </ol>
16656 <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>
16657 <ol class="proc">
16658 <li>Let <i>precedingArgs</i> be the result of evaluating <i>ArgumentList</i>.</li>
16659 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>precedingArgs</i>).</li>
16660 <li>Let <i>ref</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
16661 <li>Let <i>arg</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
16662 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>arg</i>).</li>
16663 <li>Append <i>arg</i> to the end of <i>precedingArgs</i>.</li>
16664 <li>Return <i>precedingArgs</i>.</li>
16665 </ol>
16666 <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>
16667 <ol class="proc">
16668 <li>Let <i>precedingArgs</i> be the result of evaluating <i>ArgumentList</i>.</li>
16669 <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
16670 <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<a
16671 href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>) ).</li>
16672 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
16673 <li>Repeat
16674 <ol class="block">
16675 <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
16676 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
16677 <li>If <i>next</i> is <b>false</b>, return <i>precedingArgs</i>.</li>
16678 <li>Let <i>nextArg</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
16679 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextArg</i>).</li>
16680 <li>Append <i>nextArg</i> as the last element of <i>precedingArgs</i>.</li>
16681 </ol>
16682 </li>
16683 </ol>
16684 </section>
16685 </section>
16686
16687 <section id="sec-tagged-templates">
16688 <div class="front">
16689 <h1><span class="secnum" id="sec-12.3.7"><a href="#sec-tagged-templates" title="link to this section">12.3.7</a></span>
16690 Tagged Templates</h1>
16691
16692 <div class="note">
16693 <p><span class="nh">NOTE</span> A tagged template is a function call where the arguments of the call are derived from a
16694 <i>TemplateLiteral</i> (<a href="#sec-template-literals">12.2.8</a>). The actual arguments include a template object (<a
16695 href="#sec-gettemplateobject">12.2.8.3</a>) and the values produced by evaluating the expressions embedded within the
16696 <i>TemplateLiteral</i>.</p>
16697 </div>
16698 </div>
16699
16700 <section id="sec-tagged-templates-runtime-semantics-evaluation">
16701 <h1><span class="secnum" id="sec-12.3.7.1"><a href="#sec-tagged-templates-runtime-semantics-evaluation"
16702 title="link to this section">12.3.7.1</a></span> Runtime Semantics: Evaluation</h1>
16703 <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
16704 <ol class="proc">
16705 <li>Let <i>tagRef</i> be the result of evaluating <i>MemberExpression</i>.</li>
16706 <li>Let <i>thisCall</i> be this <i>MemberExpression</i>.</li>
16707 <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
16708 href="#sec-isintailposition">14.6.1</a>)</li>
16709 <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>tagRef</i>, <i>TemplateLiteral</i>, <i>tailCall</i>).</li>
16710 </ol>
16711 <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
16712 <ol class="proc">
16713 <li>Let <i>tagRef</i> be the result of evaluating <i>CallExpression</i>.</li>
16714 <li>Let <i>thisCall</i> be this <i>CallExpression</i>.</li>
16715 <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
16716 href="#sec-isintailposition">14.6.1</a>)</li>
16717 <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>tagRef</i>, <i>TemplateLiteral</i>, <i>tailCall</i>).</li>
16718 </ol>
16719 </section>
16720 </section>
16721
16722 <section id="sec-meta-properties">
16723 <div class="front">
16724 <h1><span class="secnum" id="sec-12.3.8"><a href="#sec-meta-properties" title="link to this section">12.3.8</a></span>
16725 Meta Properties</h1>
16726 </div>
16727
16728 <section id="sec-meta-properties-runtime-semantics-evaluation">
16729 <h1><span class="secnum" id="sec-12.3.8.1"><a href="#sec-meta-properties-runtime-semantics-evaluation"
16730 title="link to this section">12.3.8.1</a></span> Runtime Semantics: Evaluation</h1>
16731 <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>
16732 <ol class="proc">
16733 <li>Return <a href="#sec-getnewtarget">GetNewTarget</a>().</li>
16734 </ol>
16735 </section>
16736 </section>
16737 </section>
16738
16739 <section id="sec-postfix-expressions">
16740 <div class="front">
16741 <h1><span class="secnum" id="sec-12.4"><a href="#sec-postfix-expressions" title="link to this section">12.4</a></span>
16742 Postfix Expressions</h1>
16743 <h2>Syntax</h2>
16744
16745 <div class="gp">
16746 <div class="lhs"><span class="nt">PostfixExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
16747 <div class="rhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[?Yield]</sub></div>
16748 <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>
16749 <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>
16750 </div>
16751 </div>
16752
16753 <section id="sec-postfix-expressions-static-semantics-early-errors">
16754 <h1><span class="secnum" id="sec-12.4.1"><a href="#sec-postfix-expressions-static-semantics-early-errors"
16755 title="link to this section">12.4.1</a></span> Static Semantics: Early Errors</h1>
16756
16757 <div class="gp">
16758 <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
16759 <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
16760 <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
16761 </div>
16762
16763 <ul>
16764 <li>
16765 <p>It is an early <a href="#sec-reference-specification-type">Reference</a> Error if <span style="font-family: Times New
16766 Roman">IsValidSimpleAssignmentTarget</span> of <span class="nt">LeftHandSideExpression</span> is <span
16767 class="value">false</span>.</p>
16768 </li>
16769 </ul>
16770 </section>
16771
16772 <section id="sec-postfix-expressions-static-semantics-isfunctiondefinition">
16773 <h1><span class="secnum" id="sec-12.4.2"><a href="#sec-postfix-expressions-static-semantics-isfunctiondefinition"
16774 title="link to this section">12.4.2</a></span> Static Semantics: IsFunctionDefinition</h1>
16775
16776 <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
16777 href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
16778 href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
16779 href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
16780 href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
16781 href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
16782 href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
16783 href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
16784 href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
16785 href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
16786 href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
16787 href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
16788 href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
16789 href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
16790 href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
16791 href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
16792 href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a></p>
16793
16794 <div class="gp">
16795 <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
16796 <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
16797 <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
16798 </div>
16799
16800 <ol class="proc">
16801 <li>Return <b>false</b>.</li>
16802 </ol>
16803 </section>
16804
16805 <section id="sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">
16806 <h1><span class="secnum" id="sec-12.4.3"><a href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget"
16807 title="link to this section">12.4.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
16808
16809 <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
16810 href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
16811 href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
16812 href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
16813 href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
16814 href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
16815 href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
16816 href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
16817 href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
16818 href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
16819 href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
16820 href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
16821 href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
16822 href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
16823 href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
16824
16825 <div class="gp">
16826 <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
16827 <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
16828 <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
16829 </div>
16830
16831 <ol class="proc">
16832 <li>Return <b>false</b>.</li>
16833 </ol>
16834 </section>
16835
16836 <section id="sec-postfix-increment-operator">
16837 <div class="front">
16838 <h1><span class="secnum" id="sec-12.4.4"><a href="#sec-postfix-increment-operator"
16839 title="link to this section">12.4.4</a></span> Postfix Increment Operator</h1>
16840 </div>
16841
16842 <section id="sec-postfix-increment-operator-runtime-semantics-evaluation">
16843 <h1><span class="secnum" id="sec-12.4.4.1"><a href="#sec-postfix-increment-operator-runtime-semantics-evaluation"
16844 title="link to this section">12.4.4.1</a></span> Runtime Semantics: Evaluation</h1>
16845 <div class="gp prod"><span class="nt">PostfixExpression</span> <span class="geq">:</span> <span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
16846 <ol class="proc">
16847 <li>Let <i>lhs</i> be the result of evaluating <i>LeftHandSideExpression</i>.</li>
16848 <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>lhs</i>)).</li>
16849 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
16850 <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
16851 the <code>+</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see 12.7.5</a>).</li>
16852 <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>newValue</i>).</li>
16853 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
16854 <li>Return <i>oldValue</i>.</li>
16855 </ol>
16856 </section>
16857 </section>
16858
16859 <section id="sec-postfix-decrement-operator">
16860 <div class="front">
16861 <h1><span class="secnum" id="sec-12.4.5"><a href="#sec-postfix-decrement-operator"
16862 title="link to this section">12.4.5</a></span> Postfix Decrement Operator</h1>
16863 </div>
16864
16865 <section id="sec-postfix-decrement-operator-runtime-semantics-evaluation">
16866 <h1><span class="secnum" id="sec-12.4.5.1"><a href="#sec-postfix-decrement-operator-runtime-semantics-evaluation"
16867 title="link to this section">12.4.5.1</a></span> Runtime Semantics: Evaluation</h1>
16868 <div class="gp prod"><span class="nt">PostfixExpression</span> <span class="geq">:</span> <span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
16869 <ol class="proc">
16870 <li>Let <i>lhs</i> be the result of evaluating <i>LeftHandSideExpression</i>.</li>
16871 <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>lhs</i>)).</li>
16872 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
16873 <li>Let <i>newValue</i> be the result of subtracting the value <code>1</code> from <i>oldValue</i>, using the same rules
16874 as for the <code>-</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">12.7.5</a>).</li>
16875 <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>newValue</i>).</li>
16876 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
16877 <li>Return <i>oldValue</i>.</li>
16878 </ol>
16879 </section>
16880 </section>
16881 </section>
16882
16883 <section id="sec-unary-operators">
16884 <div class="front">
16885 <h1><span class="secnum" id="sec-12.5"><a href="#sec-unary-operators" title="link to this section">12.5</a></span> Unary
16886 Operators</h1>
16887 <h2>Syntax</h2>
16888
16889 <div class="gp">
16890 <div class="lhs"><span class="nt">UnaryExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
16891 <div class="rhs"><span class="nt">PostfixExpression</span><sub class="g-params">[?Yield]</sub></div>
16892 <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16893 <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16894 <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16895 <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16896 <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16897 <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16898 <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16899 <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16900 <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
16901 </div>
16902 </div>
16903
16904 <section id="sec-unary-operators-static-semantics-early-errors">
16905 <h1><span class="secnum" id="sec-12.5.1"><a href="#sec-unary-operators-static-semantics-early-errors"
16906 title="link to this section">12.5.1</a></span> Static Semantics: Early Errors</h1>
16907
16908 <div class="gp">
16909 <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
16910 <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
16911 <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
16912 </div>
16913
16914 <ul>
16915 <li>
16916 <p>It is an early <a href="#sec-reference-specification-type">Reference</a> Error if <span style="font-family: Times New
16917 Roman">IsValidSimpleAssignmentTarget</span> of <span class="nt">UnaryExpression</span> is <span
16918 class="value">false</span>.</p>
16919 </li>
16920 </ul>
16921 </section>
16922
16923 <section id="sec-unary-operators-static-semantics-isfunctiondefinition">
16924 <h1><span class="secnum" id="sec-12.5.2"><a href="#sec-unary-operators-static-semantics-isfunctiondefinition"
16925 title="link to this section">12.5.2</a></span> Static Semantics: IsFunctionDefinition</h1>
16926
16927 <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
16928 href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
16929 href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
16930 href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
16931 href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
16932 href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
16933 href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
16934 href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
16935 href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
16936 href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
16937 href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
16938 href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
16939 href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
16940 href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
16941 href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
16942 href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
16943 href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
16944
16945 <div class="gp">
16946 <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
16947 <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
16948 <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span></div>
16949 <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
16950 <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
16951 <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
16952 <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span></div>
16953 <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span></div>
16954 <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span></div>
16955 <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span></div>
16956 </div>
16957
16958 <ol class="proc">
16959 <li>Return <b>false</b>.</li>
16960 </ol>
16961 </section>
16962
16963 <section id="sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">
16964 <h1><span class="secnum" id="sec-12.5.3"><a href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget"
16965 title="link to this section">12.5.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
16966
16967 <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
16968 href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
16969 href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
16970 href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
16971 href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
16972 href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
16973 href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
16974 href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
16975 href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
16976 href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
16977 href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
16978 href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
16979 href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
16980 href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
16981 href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
16982
16983 <div class="gp">
16984 <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
16985 <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
16986 <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span></div>
16987 <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
16988 <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
16989 <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
16990 <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span></div>
16991 <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span></div>
16992 <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span></div>
16993 <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span></div>
16994 </div>
16995
16996 <ol class="proc">
16997 <li>Return <b>false</b>.</li>
16998 </ol>
16999 </section>
17000
17001 <section id="sec-delete-operator">
17002 <div class="front">
17003 <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
17004 <code>delete</code> Operator</h1>
17005 </div>
17006
17007 <section id="sec-delete-operator-static-semantics-early-errors">
17008 <h1><span class="secnum" id="sec-12.5.4.1"><a href="#sec-delete-operator-static-semantics-early-errors"
17009 title="link to this section">12.5.4.1</a></span> Static Semantics: Early Errors</h1>
17010 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
17011 <ul>
17012 <li>
17013 <p>It is a Syntax Error if the <span class="nt">UnaryExpression</span> is contained in <a
17014 href="#sec-strict-mode-code">strict mode code</a> and the derived <span class="nt">UnaryExpression</span> is <span
17015 class="prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></span>
17016 <var>IdentifierReference.</var></p>
17017 </li>
17018
17019 <li>
17020 <p>It is a Syntax Error if the derived <span class="nt">UnaryExpression</span> is<br> <span style="font-family:
17021 Times New Roman"><i>PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList<br></i></span>and <span
17022 class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> ultimately derives a phrase that, if used in place
17023 of <var>UnaryExpression,</var> would produce a Syntax Error according to these rules. This rule is recursively
17024 applied.</p>
17025 </li>
17026 </ul>
17027
17028 <div class="note">
17029 <p><span class="nh">NOTE</span> The last rule means that expressions such as<br>&#x9;&#x9;<code>delete
17030 (((foo)))</code><br>produce early errors because of recursive application of the first rule.</p>
17031 </div>
17032 </section>
17033
17034 <section id="sec-delete-operator-runtime-semantics-evaluation">
17035 <h1><span class="secnum" id="sec-12.5.4.2"><a href="#sec-delete-operator-runtime-semantics-evaluation"
17036 title="link to this section">12.5.4.2</a></span> Runtime Semantics: Evaluation</h1>
17037 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
17038 <ol class="proc">
17039 <li>Let <i>ref</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17040 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ref</i>).</li>
17041 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
17042 href="#sec-reference-specification-type">Reference</a>, return <b>true</b>.</li>
17043 <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>ref</i>) is <b>true</b>, then
17044 <ol class="block">
17045 <li><a href="#sec-algorithm-conventions">Assert</a>: <a
17046 href="#sec-reference-specification-type">IsStrictReference</a>(<i>ref</i>) is <b>false</b>.</li>
17047 <li>Return <b>true</b>.</li>
17048 </ol>
17049 </li>
17050 <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
17051 <ol class="block">
17052 <li>If <a href="#sec-reference-specification-type">IsSuperReference</a>(<i>ref</i>), throw a <b>ReferenceError</b>
17053 exception.</li>
17054 <li>Let <i>baseObj</i> be <a href="#sec-toobject">ToObject</a>(<a
17055 href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>)).</li>
17056 <li>Let <i>deleteStatus</i> be <i>baseObj</i>.[[Delete]](<a
17057 href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>)).</li>
17058 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>deleteStatus</i>).</li>
17059 <li>If <i>deleteStatus</i> is <b>false</b> and <a
17060 href="#sec-reference-specification-type">IsStrictReference</a>(<i>ref</i>) is <b>true</b>, throw a
17061 <b>TypeError</b> exception.</li>
17062 <li>Return <i>deleteStatus</i>.</li>
17063 </ol>
17064 </li>
17065 <li>Else <i>ref</i> is a <a href="#sec-reference-specification-type">Reference</a> to an <a
17066 href="#sec-environment-records">Environment Record</a> binding,
17067 <ol class="block">
17068 <li>Let <i>bindings</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
17069 <li>Return <i>bindings</i>.DeleteBinding(<a
17070 href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>)).</li>
17071 </ol>
17072 </li>
17073 </ol>
17074
17075 <div class="note">
17076 <p><span class="nh">NOTE</span> When a <code>delete</code> operator occurs within <a href="#sec-strict-mode-code">strict
17077 mode code</a>, a <b>SyntaxError</b> exception is thrown if its <i>UnaryExpression</i> is a direct reference to a
17078 variable, function argument, or function name. In addition, if a <code>delete</code> operator occurs within <a
17079 href="#sec-strict-mode-code">strict mode code</a> and the property to be deleted has the attribute { [[Configurable]]:
17080 <b>false</b> }, a <b>TypeError</b> exception is thrown.</p>
17081 </div>
17082 </section>
17083 </section>
17084
17085 <section id="sec-void-operator">
17086 <div class="front">
17087 <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
17088 <code>void</code> Operator</h1>
17089 </div>
17090
17091 <section id="sec-void-operator-runtime-semantics-evaluation">
17092 <h1><span class="secnum" id="sec-12.5.5.1"><a href="#sec-void-operator-runtime-semantics-evaluation"
17093 title="link to this section">12.5.5.1</a></span> Runtime Semantics: Evaluation</h1>
17094 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">void</code> <span class="nt">UnaryExpression</span></div>
17095 <ol class="proc">
17096 <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17097 <li>Let <i>status</i> be <a href="#sec-getvalue">GetValue</a>(<i>expr</i>).</li>
17098 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
17099 <li>Return <b>undefined</b>.</li>
17100 </ol>
17101
17102 <div class="note">
17103 <p><span class="nh">NOTE</span> <a href="#sec-getvalue">GetValue</a> must be called even though its value is not used
17104 because it may have observable side-effects.</p>
17105 </div>
17106 </section>
17107 </section>
17108
17109 <section id="sec-typeof-operator">
17110 <div class="front">
17111 <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
17112 <code>typeof</code> Operator</h1>
17113 </div>
17114
17115 <section id="sec-typeof-operator-runtime-semantics-evaluation">
17116 <h1><span class="secnum" id="sec-12.5.6.1"><a href="#sec-typeof-operator-runtime-semantics-evaluation"
17117 title="link to this section">12.5.6.1</a></span> Runtime Semantics: Evaluation</h1>
17118 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
17119 <ol class="proc">
17120 <li>Let <i>val</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17121 <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>val</i>) is <a
17122 href="#sec-reference-specification-type">Reference</a>, then
17123 <ol class="block">
17124 <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>val</i>) is <b>true</b>, return
17125 <code>"undefined"</code>.</li>
17126 </ol>
17127 </li>
17128 <li>Let <i>val</i> be <a href="#sec-getvalue">GetValue</a>(<i>val</i>).</li>
17129 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>val</i>).</li>
17130 <li>Return a String according to <a href="#table-35">Table 35</a>.</li>
17131 </ol>
17132
17133 <figure>
17134 <figcaption><span id="table-35">Table 35</span> &mdash; typeof Operator Results</figcaption>
17135 <table class="real-table">
17136 <tr>
17137 <th><b>Type of</b> <span style="font-family: Times New Roman">val</span></th>
17138 <th>Result</th>
17139 </tr>
17140 <tr>
17141 <td>Undefined</td>
17142 <td><code>"undefined"</code></td>
17143 </tr>
17144 <tr>
17145 <td>Null</td>
17146 <td><code>"object"</code></td>
17147 </tr>
17148 <tr>
17149 <td>Boolean</td>
17150 <td><code>"boolean"</code></td>
17151 </tr>
17152 <tr>
17153 <td>Number</td>
17154 <td><code>"number"</code></td>
17155 </tr>
17156 <tr>
17157 <td>String</td>
17158 <td><code>"string"</code></td>
17159 </tr>
17160 <tr>
17161 <td>Symbol</td>
17162 <td><code>"symbol"</code></td>
17163 </tr>
17164 <tr>
17165 <td>Object (ordinary and does not implement [[Call]])</td>
17166 <td><code>"object"</code></td>
17167 </tr>
17168 <tr>
17169 <td>Object (standard exotic and does not implement [[Call]])</td>
17170 <td><code>"object"</code></td>
17171 </tr>
17172 <tr>
17173 <td>Object (implements [[Call]])</td>
17174 <td><code>"function"</code></td>
17175 </tr>
17176 <tr>
17177 <td>Object (non-standard exotic and does not implement [[Call]])</td>
17178 <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>
17179 </tr>
17180 </table>
17181 </figure>
17182
17183 <div class="note">
17184 <p><span class="nh">NOTE</span> Implementations are discouraged from defining new <code>typeof</code> result values for
17185 non-standard exotic objects. If possible <code>"object"</code>should be used for such objects.</p>
17186 </div>
17187 </section>
17188 </section>
17189
17190 <section id="sec-prefix-increment-operator">
17191 <div class="front">
17192 <h1><span class="secnum" id="sec-12.5.7"><a href="#sec-prefix-increment-operator"
17193 title="link to this section">12.5.7</a></span> Prefix Increment Operator</h1>
17194 </div>
17195
17196 <section id="sec-prefix-increment-operator-runtime-semantics-evaluation">
17197 <h1><span class="secnum" id="sec-12.5.7.1"><a href="#sec-prefix-increment-operator-runtime-semantics-evaluation"
17198 title="link to this section">12.5.7.1</a></span> Runtime Semantics: Evaluation</h1>
17199 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">++</code> <span class="nt">UnaryExpression</span></div>
17200 <ol class="proc">
17201 <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17202 <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
17203 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
17204 <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
17205 the <code>+</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see 12.7.5</a>).</li>
17206 <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>expr</i>, <i>newValue</i>).</li>
17207 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
17208 <li>Return <i>newValue</i>.</li>
17209 </ol>
17210 </section>
17211 </section>
17212
17213 <section id="sec-prefix-decrement-operator">
17214 <div class="front">
17215 <h1><span class="secnum" id="sec-12.5.8"><a href="#sec-prefix-decrement-operator"
17216 title="link to this section">12.5.8</a></span> Prefix Decrement Operator</h1>
17217 </div>
17218
17219 <section id="sec-prefix-decrement-operator-runtime-semantics-evaluation">
17220 <h1><span class="secnum" id="sec-12.5.8.1"><a href="#sec-prefix-decrement-operator-runtime-semantics-evaluation"
17221 title="link to this section">12.5.8.1</a></span> Runtime Semantics: Evaluation</h1>
17222 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">--</code> <span class="nt">UnaryExpression</span></div>
17223 <ol class="proc">
17224 <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17225 <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
17226 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
17227 <li>Let <i>newValue</i> be the result of subtracting the value <code>1</code> from <i>oldValue</i>, using the same
17228 rules as for the <code>-</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see
17229 12.7.5</a>).</li>
17230 <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>expr</i>, <i>newValue</i>).</li>
17231 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
17232 <li>Return <i>newValue</i>.</li>
17233 </ol>
17234 </section>
17235 </section>
17236
17237 <section id="sec-unary-plus-operator">
17238 <div class="front">
17239 <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>
17240 Unary <code>+</code> Operator</h1>
17241
17242 <div class="note">
17243 <p><span class="nh">NOTE</span> The unary + operator converts its operand to Number type.</p>
17244 </div>
17245 </div>
17246
17247 <section id="sec-unary-plus-operator-runtime-semantics-evaluation">
17248 <h1><span class="secnum" id="sec-12.5.9.1"><a href="#sec-unary-plus-operator-runtime-semantics-evaluation"
17249 title="link to this section">12.5.9.1</a></span> Runtime Semantics: Evaluation</h1>
17250 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">+</code> <span class="nt">UnaryExpression</span></div>
17251 <ol class="proc">
17252 <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17253 <li>Return <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
17254 </ol>
17255 </section>
17256 </section>
17257
17258 <section id="sec-unary-minus-operator">
17259 <div class="front">
17260 <h1><span class="secnum" id="sec-12.5.10"><a href="#sec-unary-minus-operator"
17261 title="link to this section">12.5.10</a></span> Unary <code>-</code> Operator</h1>
17262
17263 <div class="note">
17264 <p><span class="nh">NOTE</span> The unary <code>-</code> operator converts its operand to Number type and then negates
17265 it. Negating <b>+0</b> produces <b>&minus;0</b>, and negating <b>&minus;0</b> produces <b>+0</b>.</p>
17266 </div>
17267 </div>
17268
17269 <section id="sec-unary-minus-operator-runtime-semantics-evaluation">
17270 <h1><span class="secnum" id="sec-12.5.10.1"><a href="#sec-unary-minus-operator-runtime-semantics-evaluation"
17271 title="link to this section">12.5.10.1</a></span> Runtime Semantics: Evaluation</h1>
17272 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">-</code> <span class="nt">UnaryExpression</span></div>
17273 <ol class="proc">
17274 <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17275 <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
17276 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
17277 <li>If <i>oldValue</i> is <b>NaN</b>, return <b>NaN</b>.</li>
17278 <li>Return the result of negating <i>oldValue</i>; that is, compute a Number with the same magnitude but opposite
17279 sign.</li>
17280 </ol>
17281 </section>
17282 </section>
17283
17284 <section id="sec-bitwise-not-operator">
17285 <div class="front">
17286 <h1><span class="secnum" id="sec-12.5.11"><a href="#sec-bitwise-not-operator"
17287 title="link to this section">12.5.11</a></span> Bitwise NOT Operator ( <code>~</code> )</h1>
17288 </div>
17289
17290 <section id="sec-bitwise-not-operator-runtime-semantics-evaluation">
17291 <h1><span class="secnum" id="sec-12.5.11.1"><a href="#sec-bitwise-not-operator-runtime-semantics-evaluation"
17292 title="link to this section">12.5.11.1</a></span> Runtime Semantics: Evaluation</h1>
17293 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">~</code> <span class="nt">UnaryExpression</span></div>
17294 <ol class="proc">
17295 <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17296 <li>Let <i>oldValue</i> be <a href="#sec-toint32">ToInt32</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
17297 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
17298 <li>Return the result of applying bitwise complement to <i>oldValue</i>. The result is a signed 32-bit integer.</li>
17299 </ol>
17300 </section>
17301 </section>
17302
17303 <section id="sec-logical-not-operator">
17304 <div class="front">
17305 <h1><span class="secnum" id="sec-12.5.12"><a href="#sec-logical-not-operator"
17306 title="link to this section">12.5.12</a></span> Logical NOT Operator ( <code>!</code> )</h1>
17307 </div>
17308
17309 <section id="sec-logical-not-operator-runtime-semantics-evaluation">
17310 <h1><span class="secnum" id="sec-12.5.12.1"><a href="#sec-logical-not-operator-runtime-semantics-evaluation"
17311 title="link to this section">12.5.12.1</a></span> Runtime Semantics: Evaluation</h1>
17312 <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">!</code> <span class="nt">UnaryExpression</span></div>
17313 <ol class="proc">
17314 <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17315 <li>Let <i>oldValue</i> be <a href="#sec-toboolean">ToBoolean</a>(<a
17316 href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
17317 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
17318 <li>If <i>oldValue</i> is <b>true</b>, return <b>false</b>.</li>
17319 <li>Return <b>true</b>.</li>
17320 </ol>
17321 </section>
17322 </section>
17323 </section>
17324
17325 <section id="sec-multiplicative-operators">
17326 <div class="front">
17327 <h1><span class="secnum" id="sec-12.6"><a href="#sec-multiplicative-operators" title="link to this section">12.6</a></span>
17328 Multiplicative Operators</h1>
17329 <h2>Syntax</h2>
17330
17331 <div class="gp">
17332 <div class="lhs"><span class="nt">MultiplicativeExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
17333 <div class="rhs"><span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
17334 <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>
17335 </div>
17336
17337 <div class="gp">
17338 <div class="lhs"><span class="nt">MultiplicativeOperator</span> <span class="geq">:</span> <span class="grhsmod">one of</span></div>
17339 <div class="rhs"><code class="t">*</code> <code class="t">/</code> <code class="t">%</code></div>
17340 </div>
17341 </div>
17342
17343 <section id="sec-multiplicative-operators-static-semantics-isfunctiondefinition">
17344 <h1><span class="secnum" id="sec-12.6.1"><a href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition"
17345 title="link to this section">12.6.1</a></span> Static Semantics: IsFunctionDefinition</h1>
17346
17347 <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
17348 href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
17349 href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
17350 href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
17351 href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
17352 href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
17353 href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
17354 href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
17355 href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
17356 href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
17357 href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
17358 href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
17359 href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
17360 href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
17361 href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
17362 href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
17363 href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
17364
17365 <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
17366 <i>UnaryExpression</i></p>
17367
17368 <ol class="proc">
17369 <li>Return <b>false</b>.</li>
17370 </ol>
17371 </section>
17372
17373 <section id="sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">
17374 <h1><span class="secnum" id="sec-12.6.2"><a
17375 href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget"
17376 title="link to this section">12.6.2</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
17377
17378 <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
17379 href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
17380 href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
17381 href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
17382 href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
17383 href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
17384 href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
17385 href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
17386 href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
17387 href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
17388 href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
17389 href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
17390 href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
17391 href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
17392 href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
17393
17394 <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
17395 <i>UnaryExpression</i></p>
17396
17397 <ol class="proc">
17398 <li>Return <b>false</b>.</li>
17399 </ol>
17400 </section>
17401
17402 <section id="sec-multiplicative-operators-runtime-semantics-evaluation">
17403 <div class="front">
17404 <h1><span class="secnum" id="sec-12.6.3"><a href="#sec-multiplicative-operators-runtime-semantics-evaluation"
17405 title="link to this section">12.6.3</a></span> Runtime Semantics: Evaluation</h1>
17406
17407 <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
17408 <i>UnaryExpression</i></p>
17409
17410 <ol class="proc">
17411 <li>Let <i>left</i> be the result of evaluating <i>MultiplicativeExpression</i>.</li>
17412 <li>Let <i>leftValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>left</i>).</li>
17413 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>leftValue</i>).</li>
17414 <li>Let <i>right</i> be the result of evaluating <i>UnaryExpression</i>.</li>
17415 <li>Let <i>rightValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>right</i>).</li>
17416 <li>Let <i>lnum</i> be <a href="#sec-tonumber">ToNumber</a>(<i>leftValue</i>).</li>
17417 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>lnum</i>).</li>
17418 <li>Let <i>rnum</i> be <a href="#sec-tonumber">ToNumber</a>(<i>rightValue</i>).</li>
17419 <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>rnum</i>).</li>
17420 <li>Return the result of applying the <i>MultiplicativeOperator</i> (*, /, or %) to <i>lnum</i> and <i>rnum</i> as
17421 specified in <a href="#sec-applying-the-mul-operator">12.6.3.1</a>, <a
17422 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>
17423 </ol>
17424 </div>
17425
17426 <section id="sec-applying-the-mul-operator">
17427 <h1><span class="secnum" id="sec-12.6.3.1"><a href="#sec-applying-the-mul-operator"
17428 title="link to this section">12.6.3.1</a></span> Applying the <code>*</code> Operator</h1>
17429
17430 <p>The <code>*</code> <span class="nt">MultiplicativeOperator</span> performs multiplication, producing the product of its
17431 operands. Multiplication is commutative. Multiplication is not always associative in ECMAScript, because of finite
17432 precision.</p>
17433
17434 <p>The result of a floating-point multiplication is governed by the rules of IEEE 754 binary double-precision
17435 arithmetic:</p>
17436
17437 <ul>
17438 <li>
17439 <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
17440 </li>
17441
17442 <li>
17443 <p>The sign of the result is positive if both operands have the same sign, negative if the operands have different
17444 signs.</p>
17445 </li>
17446
17447 <li>
17448 <p>Multiplication of an infinity by a zero results in <b>NaN</b>.</p>
17449 </li>
17450
17451 <li>
17452 <p>Multiplication of an infinity by an infinity results in an infinity. The sign is determined by the rule already
17453 stated above.</p>
17454 </li>
17455
17456 <li>
17457 <p>Multiplication of an infinity by a finite nonzero value results in a signed infinity. The sign is determined by the
17458 rule already stated above.</p>
17459 </li>
17460
17461 <li>
17462 <p>In the remaining cases, where neither an infinity nor NaN is involved, the product is computed and rounded to the
17463 nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too large to represent, the
17464 result is then an infinity of appropriate sign. If the magnitude is too small to represent, the result is then a zero
17465 of appropriate sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754.</p>
17466 </li>
17467 </ul>
17468 </section>
17469
17470 <section id="sec-applying-the-div-operator">
17471 <h1><span class="secnum" id="sec-12.6.3.2"><a href="#sec-applying-the-div-operator"
17472 title="link to this section">12.6.3.2</a></span> Applying the <code>/</code> Operator</h1>
17473
17474 <p>The <code>/</code> <span class="nt">MultiplicativeOperator</span> performs division, producing the quotient of its
17475 operands. The left operand is the dividend and the right operand is the divisor. ECMAScript does not perform integer
17476 division. The operands and result of all division operations are double-precision floating-point numbers. The result of
17477 division is determined by the specification of IEEE 754 arithmetic:</p>
17478
17479 <ul>
17480 <li>
17481 <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
17482 </li>
17483
17484 <li>
17485 <p>The sign of the result is positive if both operands have the same sign, negative if the operands have different
17486 signs.</p>
17487 </li>
17488
17489 <li>
17490 <p>Division of an infinity by an infinity results in <b>NaN</b>.</p>
17491 </li>
17492
17493 <li>
17494 <p>Division of an infinity by a zero results in an infinity. The sign is determined by the rule already stated
17495 above.</p>
17496 </li>
17497
17498 <li>
17499 <p>Division of an infinity by a nonzero finite value results in a signed infinity. The sign is determined by the rule
17500 already stated above.</p>
17501 </li>
17502
17503 <li>
17504 <p>Division of a finite value by an infinity results in zero. The sign is determined by the rule already stated
17505 above.</p>
17506 </li>
17507
17508 <li>
17509 <p>Division of a zero by a zero results in <b>NaN</b>; division of zero by any other finite value results in zero,
17510 with the sign determined by the rule already stated above.</p>
17511 </li>
17512
17513 <li>
17514 <p>Division of a nonzero finite value by a zero results in a signed infinity. The sign is determined by the rule
17515 already stated above.</p>
17516 </li>
17517
17518 <li>
17519 <p>In the remaining cases, where neither an infinity, nor a zero, nor <b>NaN</b> is involved, the quotient is computed
17520 and rounded to the nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too large to
17521 represent, the operation overflows; the result is then an infinity of appropriate sign. If the magnitude is too small
17522 to represent, the operation underflows and the result is a zero of the appropriate sign. The ECMAScript language
17523 requires support of gradual underflow as defined by IEEE 754.</p>
17524 </li>
17525 </ul>
17526 </section>
17527
17528 <section id="sec-applying-the-mod-operator">
17529 <h1><span class="secnum" id="sec-12.6.3.3"><a href="#sec-applying-the-mod-operator"
17530 title="link to this section">12.6.3.3</a></span> Applying the <code>%</code> Operator</h1>
17531
17532 <p>The <code>%</code> <span class="nt">MultiplicativeOperator</span> yields the remainder of its operands from an implied
17533 division; the left operand is the dividend and the right operand is the divisor.</p>
17534
17535 <div class="note">
17536 <p><span class="nh">NOTE</span> In C and C++, the remainder operator accepts only integral operands; in ECMAScript, it
17537 also accepts floating-point operands.</p>
17538 </div>
17539
17540 <p>The result of a floating-point remainder operation as computed by the <code>%</code> operator is not the same as the
17541 &ldquo;remainder&rdquo; operation defined by IEEE 754. The IEEE 754 &ldquo;remainder&rdquo; operation computes the
17542 remainder from a rounding division, not a truncating division, and so its behaviour is not analogous to that of the usual
17543 integer remainder operator. Instead the ECMAScript language defines <code>%</code> on floating-point operations to behave
17544 in a manner analogous to that of the Java integer remainder operator; this may be compared with the C library function
17545 fmod.</p>
17546
17547 <p>The result of an ECMAScript floating-point remainder operation is determined by the rules of IEEE arithmetic:</p>
17548
17549 <ul>
17550 <li>
17551 <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
17552 </li>
17553
17554 <li>
17555 <p>The sign of the result equals the sign of the dividend.</p>
17556 </li>
17557
17558 <li>
17559 <p>If the dividend is an infinity, or the divisor is a zero, or both, the result is <b>NaN</b>.</p>
17560 </li>
17561
17562 <li>
17563 <p>If the dividend is finite and the divisor is an infinity, the result equals the dividend.</p>
17564 </li>
17565
17566 <li>
17567 <p>If the dividend is a zero and the divisor is nonzero and finite, the result is the same as the dividend.</p>
17568 </li>
17569
17570 <li>
17571 <p>In the remaining cases, where neither an infinity, nor a zero, nor <b>NaN</b> is involved, the floating-point
17572 remainder r from a dividend n and a divisor d is defined by the mathematical relation r = n &minus; (d &times; q)
17573 where q is an integer that is negative only if n/d is negative and positive only if n/d is positive, and whose
17574 magnitude is as large as possible without exceeding the magnitude of the true mathematical quotient of n and d. r is
17575 computed and rounded to the nearest representable value using IEEE 754 round-to-nearest mode.</p>
17576 </li>
17577 </ul>
17578 </section>
17579 </section>
17580 </section>
17581 </section>
17582 </body>
17583 </html>