aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/tdewolff/minify/benchmarks/sample_es6.html
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/tdewolff/minify/benchmarks/sample_es6.html')
-rw-r--r--vendor/github.com/tdewolff/minify/benchmarks/sample_es6.html17583
1 files changed, 0 insertions, 17583 deletions
diff --git a/vendor/github.com/tdewolff/minify/benchmarks/sample_es6.html b/vendor/github.com/tdewolff/minify/benchmarks/sample_es6.html
deleted file mode 100644
index 8056245..0000000
--- a/vendor/github.com/tdewolff/minify/benchmarks/sample_es6.html
+++ /dev/null
@@ -1,17583 +0,0 @@
-
-<!doctype html>
-<html lang="en-GB">
-<head>
- <meta charset="utf-8">
- <title>ECMAScript Language Specification ECMA-262 6th Edition &ndash; DRAFT</title>
- <link href="es6-draft.css" rel="stylesheet">
- <script src="es6-draft-sections.js"></script>
-</head>
-<body>
-<div id="unofficial">
- <p><strong>This is <em>not</em> the official ECMAScript Language Specification.</strong></p>
-
- <p>This is a draft of the next edition of the standard. See also:</p>
-
- <ul>
- <li><a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">ECMAScript Language Specification,
- Edition 5.1 (PDF)</a>, the most recent official, final standard.</li>
- <li><a href="http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts">The ES specification drafts archive</a> for
- PDF and Word versions of this document, and older drafts.</li>
- <li><a href="https://github.com/jorendorff/es-spec-html">The script that produced this web page</a>, and especially the <a
- href="https://github.com/jorendorff/es-spec-html/issues?state=open">issue tracker &mdash; please file bugs when you find
- them</a>. Patches are welcome too.</li>
- </ul>
-
- <p>For copyright information, see Ecma International&rsquo;s legal disclaimer in the document itself.</p>
-</div>
-
-<hgroup>
- <h1>Draft</h1>
- <h1>ECMA-262</h1>
- <h1>6<sup>th</sup> Edition / Draft March 17, 2015</h1>
- <h1>Ecma/TC39/2015/0XX</h1>
-</hgroup>
-<hgroup>
- <h1>ECMAScript 2015</h1>
- <h1>Language Specification</h1>
-
- <p>Draft<br>Release Candidate #3</p>
-
- <p>Report Errors and Issues at: https://bugs.ecmascript.org</p>
-
- <p>Product: Draft for 6th Edition</p>
-
- <p>Component: choose an appropriate one</p>
-
- <p>Version: Rev 36, March 17, 2015 Draft</p>
-</hgroup>
-
-<section id="contents">
- <h1>Contents</h1>
-</section>
-
-<section>
- <h1>Introduction</h1>
-
- <p>This is the sixth edition of ECMAScript Language Specification. Since publication of the first edition in 1997, ECMAScript
- has grown to be one of the world&rsquo;s most widely used general purpose programming languages. It is best known as the
- language embedded in web browsers but has also been widely adopted for server and embedded applications. The sixth edition is
- the most extensive update to ECMAScript since the publication of the first edition in 1997.</p>
-
- <p>Goals for the sixth edition include providing better support for large applications, library creation, and for use of
- ECMAScript as a compilation target for other languages. Some of its major enhancements include modules, class declarations,
- lexical block scoping, iterators and generators, promises for asynchronous programming, destructuring patterns, and proper tail
- calls. The ECMAScript library of built-ins has been expanded to support additional data abstractions including maps, sets, and
- arrays of binary numeric values as well as additional support for Unicode supplemental characters in strings and regular
- expressions. The built-ins are now extensible via subclassing.</p>
-
- <p>Focused development of the sixth edition started in 2009, as the fifth edition was being prepared for publication. However,
- this was preceded by significant experimentation and language enhancement design efforts dating to the publication of the third
- edition in 1999. In a very real sense, the completion of the sixth edition is the culmination of a fifteen year effort. Dozens
- of individuals representing many organizations have made very significant contributions within TC39 to the development of this
- edition and to the prior editions. In addition, a vibrant informal community has emerged supporting TC39&rsquo;s ECMAScript
- efforts. This community has reviewed numerous drafts, filed thousands of bug reports, performed implementation experiments,
- contributed test suites, and educated the world-wide developer community about ECMAScript. Unfortunately, it is impossible to
- identify and acknowledge every person and organization who has contributed to this effort.</p>
-
- <p>New uses and requirements for ECMAScript continue to emerge. The sixth edition provides the foundation for regular,
- incremental language and library enhancements.</p>
-
- <p>Allen Wirfs-Brock<br>ECMA-262, 6<sup>th</sup> Edition Project Editor</p>
-
- <p>This Ecma Standard has been adopted by the General Assembly of &lt;month&gt; &lt;year&gt;.</p>
-
- <p><b>ECMA-262 Edition History</b></p>
-
- <p>This Ecma Standard is based on several originating technologies, the most well-known being JavaScript (Netscape) and JScript
- (Microsoft). The language was invented by Brendan Eich at Netscape and first appeared in that company&rsquo;s Navigator 2.0
- browser. It has appeared in all subsequent browsers from Netscape and in all browsers from Microsoft starting with Internet
- Explorer 3.0.</p>
-
- <p>The development of this Standard started in November 1996. The first edition of this Ecma Standard was adopted by the Ecma
- General Assembly of June 1997.</p>
-
- <p>That Ecma Standard was submitted to ISO/IEC JTC 1 for adoption under the fast-track procedure, and approved as international
- standard ISO/IEC 16262, in April 1998. The Ecma General Assembly of June 1998 approved the second edition of ECMA-262 to keep it
- fully aligned with ISO/IEC 16262. Changes between the first and the second edition are editorial in nature.</p>
-
- <p>The third edition of the Standard introduced powerful regular expressions, better string handling, new control statements,
- try/catch exception handling, tighter definition of errors, formatting for numeric output and minor changes in anticipation
- future language growth. The third edition of the ECMAScript standard was adopted by the Ecma General Assembly of December 1999
- and published as ISO/IEC 16262:2002 in June 2002.</p>
-
- <p>After publication of the third edition, ECMAScript achieved massive adoption in conjunction with the World Wide Web where it
- has become the programming language that is supported by essentially all web browsers. Significant work was done to develop a
- fourth edition of ECMAScript. However, that work was not completed and not published as the fourth edition of ECMAScript but
- some of it was incorporated into the development of the sixth edition.</p>
-
- <p>The fifth edition of ECMAScript (published as ECMA-262 5<sup>th</sup> edition) codified de facto interpretations of the
- language specification that have become common among browser implementations and added support for new features that had emerged
- since the publication of the third edition. Such features include accessor properties, reflective creation and inspection of
- objects, program control of property attributes, additional array manipulation functions, support for the JSON object encoding
- format, and a strict mode that provides enhanced error checking and program security. The Fifth Edition was adopted by the Ecma
- General Assembly of December 2009.</p>
-
- <p>The Fifth Edition was submitted to ISO/IEC JTC 1 for adoption under the fast-track procedure, and approved as international
- standard ISO/IEC 16262:2011. Edition 5.1 of the ECMAScript Standard incorporated minor corrections and is the same text as
- ISO/IEC 16262:2011. The 5.1 Edition was adopted by the Ecma General Assembly of June 2011.</p>
-
- <p><i>"DISCLAIMER</i></p>
-
- <p><i>This draft document may be copied and furnished to others, and derivative works that comment on or otherwise explain it or
- assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of
- any kind, provided that the above copyright notice and this section are included on all such copies and derivative works.
- However, this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma
- International, except as needed for the purpose of developing any document or deliverable produced by Ecma
- International.</i></p>
-
- <p><i>This disclaimer is valid only prior to final version of this document. After approval all rights on the standard are
- reserved by Ecma International.</i></p>
-
- <p><i>The limited permissions are granted through the standardization phase and will not be revoked by Ecma International or its
- successors or assigns during this time.</i></p>
-
- <p><i>This document and the information contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL DISCLAIMS ALL
- WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT
- INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE."</i></p>
-</section>
-
-<div class="inner-title">ECMAScript 2015 Language Specification</div>
-
-<section id="sec-scope">
- <h1><span class="secnum" id="sec-1"><a href="#sec-scope" title="link to this section">1</a></span> Scope</h1>
-
- <p>This Standard defines the ECMAScript 2015 general purpose programming language.</p>
-</section>
-
-<section id="sec-conformance">
- <h1><span class="secnum" id="sec-2"><a href="#sec-conformance" title="link to this section">2</a></span> Conformance</h1>
-
- <p>A conforming implementation of ECMAScript must provide and support all the types, values, objects, properties, functions, and
- program syntax and semantics described in this specification.</p>
-
- <p>A conforming implementation of ECMAScript must interpret source text input in conformance with the Unicode Standard, Version
- 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
- Unicode set, collection 10646.</p>
-
- <p>A conforming implementation of ECMAScript that provides an application programming interface that supports programs that need
- to adapt to the linguistic and cultural conventions used by different human languages and countries must implement the interface
- defined by the most recent edition of ECMA-402 that is compatible with this specification.</p>
-
- <p>A conforming implementation of ECMAScript may provide additional types, values, objects, properties, and functions beyond
- those described in this specification. In particular, a conforming implementation of ECMAScript may provide properties not
- described in this specification, and values for those properties, for objects that are described in this specification.</p>
-
- <p>A conforming implementation of ECMAScript may support program and regular expression syntax not described in this
- specification. In particular, a conforming implementation of ECMAScript may support program syntax that makes use of the
- &ldquo;future reserved words&rdquo; listed in <a href="#sec-future-reserved-words">subclause 11.6.2.2</a> of this
- specification.</p>
-
- <p>A conforming implementation of ECMAScript must not implement any extension that is listed as a Forbidden Extension in <a
- href="#sec-forbidden-extensions">subclause 16.1</a>.</p>
-</section>
-
-<section id="sec-normative-references">
- <h1><span class="secnum" id="sec-3"><a href="#sec-normative-references" title="link to this section">3</a></span> Normative
- references</h1>
-
- <p>The following referenced documents are indispensable for the application of this document. For dated references, only the
- edition cited applies. For undated references, the latest edition of the referenced document (including any amendments)
- applies.</p>
-
- <p class="formal-reference">IEEE Std 754-2008: <i>IEEE Standard for Floating-Point Arithmetic</i>. Institute of Electrical and
- Electronic Engineers, New York (2008)</p>
-
- <p class="formal-reference">ISO/IEC 10646:2003: <i>Information Technology &ndash; Universal Multiple-Octet Coded Character Set
- (UCS) plus Amendment 1:2005, Amendment 2:2006, Amendment 3:2008, and Amendment 4:2008</i>, plus additional amendments and
- corrigenda, or successor</p>
-
- <p class="formal-reference"><i>The Unicode Standard, Version 5.0</i>, as amended by Unicode 5.1.0, or successor.<br><a
- href="http://www.unicode.org/versions/latest">http://www.unicode.org/versions/latest</a></p>
-
- <p class="formal-reference"><i>Unicode Standard Annex #15, Unicode Normalization Forms, version Unicode 5.1.0</i>, or
- successor.<br><a href="http://www.unicode.org/reports/tr15/">http://www.unicode.org/reports/tr15/</a></p>
-
- <p class="formal-reference"><i>Unicode Standard Annex #31, Unicode Identifiers and Pattern Syntax, version Unicode 5.1.0</i>, or
- successor. <a href="http://www.unicode.org/reports/tr31/">http://www.unicode.org/reports/tr31/</a></p>
-
- <p>ECMA-402, <i>ECMAScript 2015 Internationalization API Specification</i>.<br><a
- href="http://www.ecma-international.org/publications/standards/Ecma-402.htm">http://www.ecma-international.org/publications/standards/Ecma-402.htm</a></p>
-
- <p>ECMA-404, <i>The JSON Data Interchange Format</i>.<br><a
- href="http://www.ecma-international.org/publications/standards/Ecma-404.htm">http://www.ecma-international.org/publications/standards/Ecma-404.htm</a></p>
-</section>
-
-<section id="sec-overview">
- <div class="front">
- <h1><span class="secnum" id="sec-4"><a href="#sec-overview" title="link to this section">4</a></span> Overview</h1>
-
- <p>This section contains a non-normative overview of the ECMAScript language.</p>
-
- <p>ECMAScript is an object-oriented programming language for performing computations and manipulating computational objects
- within a host environment. ECMAScript as defined here is not intended to be computationally self-sufficient; indeed, there are
- no provisions in this specification for input of external data or output of computed results. Instead, it is expected that the
- computational environment of an ECMAScript program will provide not only the objects and other facilities described in this
- specification but also certain environment-specific objects, whose description and behaviour are beyond the scope of this
- specification except to indicate that they may provide certain properties that can be accessed and certain functions that can
- be called from an ECMAScript program.</p>
-
- <p>ECMAScript was originally designed to be used as a scripting language, but has become widely used as a general purpose
- programming language. A <b><i>scripting language</i></b> is a programming language that is used to manipulate, customize, and
- automate the facilities of an existing system. In such systems, useful functionality is already available through a user
- interface, and the scripting language is a mechanism for exposing that functionality to program control. In this way, the
- existing system is said to provide a host environment of objects and facilities, which completes the capabilities of the
- scripting language. A scripting language is intended for use by both professional and non-professional programmers.</p>
-
- <p>ECMAScript was originally designed to be a <b><i>Web scripting language</i></b>, providing a mechanism to enliven Web pages
- in browsers and to perform server computation as part of a Web-based client-server architecture. ECMAScript is now used to
- provide core scripting capabilities for a variety of host environments. Therefore the core language is specified in this
- document apart from any particular host environment.</p>
-
- <p>ECMAScript usage has moved beyond simple scripting and it is now used for the full spectrum of programming tasks in many
- different environments and scales. As the usage of ECMAScript has expanded, so has the features and facilities it provides.
- ECMAScript is now a fully featured general propose programming language.</p>
-
- <p>Some of the facilities of ECMAScript are similar to those used in other programming languages; in particular C,
- Java&trade;, Self, and Scheme as described in:</p>
-
- <p>ISO/IEC&nbsp;9899:1996, Programming Languages &ndash; C.</p>
-
- <p class="formal-reference">Gosling, James, Bill Joy and Guy Steele. <span class="book-title">The Java&trade; Language
- Specification</span>. Addison Wesley Publishing Co., 1996.</p>
-
- <p class="formal-reference">Ungar, David, and Smith, Randall B. <span class="book-title">Self: The Power of Simplicity</span>.
- OOPSLA '87 Conference Proceedings, pp. 227&ndash;241, Orlando, FL, October 1987.</p>
-
- <p class="formal-reference"><span class="book-title">IEEE Standard for the Scheme Programming Language</span>. IEEE Std
- 1178-1990.</p>
- </div>
-
- <section id="sec-web-scripting">
- <h1><span class="secnum" id="sec-4.1"><a href="#sec-web-scripting" title="link to this section">4.1</a></span> Web
- Scripting</h1>
-
- <p>A web browser provides an ECMAScript host environment for client-side computation including, for instance, objects that
- represent windows, menus, pop-ups, dialog boxes, text areas, anchors, frames, history, cookies, and input/output. Further, the
- host environment provides a means to attach scripting code to events such as change of focus, page and image loading,
- unloading, error and abort, selection, form submission, and mouse actions. Scripting code appears within the HTML and the
- displayed page is a combination of user interface elements and fixed and computed text and images. The scripting code is
- reactive to user interaction and there is no need for a main program.</p>
-
- <p>A web server provides a different host environment for server-side computation including objects representing requests,
- clients, and files; and mechanisms to lock and share data. By using browser-side and server-side scripting together, it is
- possible to distribute computation between the client and server while providing a customized user interface for a Web-based
- application.</p>
-
- <p>Each Web browser and server that supports ECMAScript supplies its own host environment, completing the ECMAScript execution
- environment.</p>
- </section>
-
- <section id="sec-ecmascript-overview">
- <div class="front">
- <h1><span class="secnum" id="sec-4.2"><a href="#sec-ecmascript-overview" title="link to this section">4.2</a></span>
- ECMAScript Overview</h1>
-
- <p>The following is an informal overview of ECMAScript&mdash;not all parts of the language are described. This overview is
- not part of the standard proper.</p>
-
- <p>ECMAScript is object-based: basic language and host facilities are provided by objects, and an ECMAScript program is a
- cluster of communicating objects. In ECMAScript, an <b><i>object</i></b> is a collection of zero or more
- <b><i>properties</i></b> each with <b><i>attributes</i></b> that determine how each property can be used&mdash;for example,
- when the Writable attribute for a property is set to <b>false</b>, any attempt by executed ECMAScript code to assign a
- different value to the property fails. Properties are containers that hold other objects, <b><i>primitive values</i></b>, or
- <b><i>functions</i></b>. A primitive value is a member of one of the following built-in types: <b>Undefined</b>,
- <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
- <b>Object</b>; and a function is a callable object. A function that is associated with an object via a property is called a
- <b><i>method</i></b>.</p>
-
- <p>ECMAScript defines a collection of <b><i>built-in objects</i></b> that round out the definition of ECMAScript entities.
- These built-in objects include the global object; objects that are fundamental to the runtime semantics of the language
- including <b>Object</b>, <b>Function</b>, <b>Boolean</b>, <b>Symbol</b>, and various <b>Error</b> objects; objects that
- represent and manipulate numeric values including <b>Math</b>, <b>Number</b>, and <b>Date</b>; the text processing objects
- <b>String</b> and <b>RegExp</b>; objects that are indexed collections of values including <b>Array</b> and nine different
- kinds of Typed Arrays whose elements all have a specific numeric data representation; keyed collections including <b>Map</b>
- and <b>Set</b> objects; objects supporting structured data including the <b>JSON</b> object, <b>ArrayBuffer</b>, and
- <b>DataView</b>; objects supporting control abstractions including generator functions and <b>Promise</b> objects;
- and<b>,</b> reflection objects including <b>Proxy</b> and <b>Reflect</b>.</p>
-
- <p>ECMAScript also defines a set of built-in <b><i>operators</i></b>. ECMAScript operators include various unary operations,
- multiplicative operators, additive operators, bitwise shift operators, relational operators, equality operators, binary
- bitwise operators, binary logical operators, assignment operators, and the comma operator.</p>
-
- <p>Large ECMAScript programs are supported by <b><i>modules</i></b> which allow a program to be divided into multiple
- sequences of statements and declarations. Each module explicitly identifies declarations it uses that need to be provided by
- other modules and which of its declarations are available for use by other modules.</p>
-
- <p>ECMAScript syntax intentionally resembles Java syntax. ECMAScript syntax is relaxed to enable it to serve as an
- easy-to-use scripting language. For example, a variable is not required to have its type declared nor are types associated
- with properties, and defined functions are not required to have their declarations appear textually before calls to
- them.</p>
- </div>
-
- <section id="sec-objects">
- <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>
-
- <p>Even though ECMAScript includes syntax for class definitions, ECMAScript objects are not fundamentally class-based such
- as those in C++, Smalltalk, or Java. Instead objects may be created in various ways including via a literal notation or via
- <b><i>constructors</i></b> which create objects and then execute code that initializes all or part of them by assigning
- initial values to their properties. Each constructor is a function that has a property named <code>"prototype"</code> that
- is used to implement <b><i>prototype-based inheritance</i></b> and <b><i>shared properties</i></b>. Objects are created by
- using constructors in <b>new</b> expressions; for example, <code>new Date(2009,11)</code> creates a new Date object.
- Invoking a constructor without using <b>new</b> has consequences that depend on the constructor. For example,
- <code>Date()</code> produces a string representation of the current date and time rather than an object.</p>
-
- <p>Every object created by a constructor has an implicit reference (called the object&rsquo;s <i>prototype</i>) to the value
- of its constructor&rsquo;s <code>"prototype"</code> property. Furthermore, a prototype may have a non-null implicit
- reference to its prototype, and so on; this is called the <i>prototype chain</i>. When a reference is made to a property in
- an object, that reference is to the property of that name in the first object in the prototype chain that contains a
- property of that name. In other words, first the object mentioned directly is examined for such a property; if that object
- contains the named property, that is the property to which the reference refers; if that object does not contain the named
- property, the prototype for that object is examined next; and so on.</p>
-
- <figure>
- <object data="figure-1.svg" height="354" type="image/svg+xml" width="719">
- <img alt="An image of lots of boxes and arrows." height="354" src="figure-1.png" width="719">
- </object>
- <figcaption>Figure 1 &mdash; Object/Prototype Relationships</figcaption>
- </figure>
-
- <p>In a class-based object-oriented language, in general, state is carried by instances, methods are carried by classes, and
- inheritance is only of structure and behaviour. In ECMAScript, the state and methods are carried by objects, while
- structure, behaviour, and state are all inherited.</p>
-
- <p>All objects that do not directly contain a particular property that their prototype contains share that property and its
- value. Figure 1 illustrates this:</p>
-
- <p><b>CF</b> is a constructor (and also an object). Five objects have been created by using <code>new</code> expressions:
- <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
- of these objects contains properties named <code>q1</code> and <code>q2</code>. The dashed lines represent the implicit
- prototype relationship; so, for example, <b>cf<sub>3</sub></b>&rsquo;s prototype is <b>CF<sub>p</sub></b>. The constructor,
- <b>CF</b>, has two properties itself, named <code>P1</code> and <code>P2</code>, which are not visible to
- <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
- <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>,
- <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
- are any properties found in <b>CF<sub>p</sub></b>&rsquo;s implicit prototype chain that are not named <code>q1</code>,
- <code>q2</code>, or <code>CFP1</code>. Notice that there is no implicit prototype link between <b>CF</b> and
- <b>CF<sub>p</sub></b>.</p>
-
- <p>Unlike most class-based object languages, properties can be added to objects dynamically by assigning values to them.
- That is, constructors are not required to name or assign values to all or any of the constructed object&rsquo;s properties.
- In the above diagram, one could add a new shared property for <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> by assigning a new value to the property in
- <b>CF<sub>p</sub></b>.</p>
-
- <p>Although ECMAScript objects are not inherently class-based, it is often convenient to define class-like abstractions
- based upon a common pattern of constructor functions, prototype objects, and methods. The ECMAScript built-in objects
- themselves follow such a class-like pattern. Beginning with the sixth edition, the ECMAScript language includes syntactic
- class definitions that permit programmers to concisely define objects that conform to the same class-like abstraction
- pattern used by the built-in objects.</p>
- </section>
-
- <section id="sec-strict-variant-of-ecmascript">
- <h1><span class="secnum" id="sec-4.2.2"><a href="#sec-strict-variant-of-ecmascript"
- title="link to this section">4.2.2</a></span> The Strict Variant of ECMAScript</h1>
-
- <p>The ECMAScript Language recognizes the possibility that some users of the language may wish to restrict their usage of
- some features available in the language. They might do so in the interests of security, to avoid what they consider to be
- error-prone features, to get enhanced error checking, or for other reasons of their choosing. In support of this
- possibility, ECMAScript defines a strict variant of the language. The strict variant of the language excludes some specific
- syntactic and semantic features of the regular ECMAScript language and modifies the detailed semantics of some features. The
- strict variant also specifies additional error conditions that must be reported by throwing error exceptions in situations
- that are not specified as errors by the non-strict form of the language.</p>
-
- <p>The strict variant of ECMAScript is commonly referred to as the <i>strict mode</i> of the language. Strict mode selection
- and use of the strict mode syntax and semantics of ECMAScript is explicitly made at the level of individual ECMAScript
- source text units. Because strict mode is selected at the level of a syntactic source text unit, strict mode only imposes
- restrictions that have local effect within such a source text unit. Strict mode does not restrict or modify any aspect of
- the ECMAScript semantics that must operate consistently across multiple source text units. A complete ECMAScript program may
- be composed of both strict mode and non-strict mode ECMAScript source text units. In this case, strict mode only applies
- when actually executing code that is defined within a strict mode source text unit.</p>
-
- <p>In order to conform to this specification, an ECMAScript implementation must implement both the full unrestricted
- ECMAScript language and the strict variant of the ECMAScript language as defined by this specification. In addition, an
- implementation must support the combination of unrestricted and strict mode source text units into a single composite
- program.</p>
- </section>
- </section>
-
- <section id="sec-terms-and-definitions">
- <div class="front">
- <h1><span class="secnum" id="sec-4.3"><a href="#sec-terms-and-definitions" title="link to this section">4.3</a></span> Terms
- and definitions</h1>
-
- <p>For the purposes of this document, the following terms and definitions apply.</p>
- </div>
-
- <section id="sec-type">
- <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>
-
- <p>set of data values as defined in <a href="#sec-ecmascript-data-types-and-values">clause 6</a> of this specification</p>
- </section>
-
- <section id="sec-primitive-value">
- <h1><span class="secnum" id="sec-4.3.2"><a href="#sec-primitive-value" title="link to this section">4.3.2</a></span>
- primitive value</h1>
-
- <p>member of one of the types Undefined, Null, Boolean, Number, Symbol, or String as defined in <a
- href="#sec-ecmascript-data-types-and-values">clause 6</a></p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A primitive value is a datum that is represented directly at the lowest level of the
- language implementation.</p>
- </div>
- </section>
-
- <section id="sec-terms-and-definitions-object">
- <h1><span class="secnum" id="sec-4.3.3"><a href="#sec-terms-and-definitions-object"
- title="link to this section">4.3.3</a></span> object</h1>
-
- <p>member of the type Object</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> An object is a collection of properties and has a single prototype object. The prototype
- may be the null value.</p>
- </div>
- </section>
-
- <section id="sec-constructor">
- <h1><span class="secnum" id="sec-4.3.4"><a href="#sec-constructor" title="link to this section">4.3.4</a></span>
- constructor</h1>
-
- <p>function object that creates and initializes objects</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The value of a constructor&rsquo;s <code>prototype</code> property is a prototype object
- that is used to implement inheritance and shared properties.</p>
- </div>
- </section>
-
- <section id="sec-terms-and-definitions-prototype">
- <h1><span class="secnum" id="sec-4.3.5"><a href="#sec-terms-and-definitions-prototype"
- title="link to this section">4.3.5</a></span> prototype</h1>
-
- <p>object that provides shared properties for other objects</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> When a constructor creates an object, that object implicitly references the
- constructor&rsquo;s <code>prototype</code> property for the purpose of resolving property references. The
- constructor&rsquo;s <code>prototype</code> property can be referenced by the program expression
- <code><i>constructor</i><b>.prototype</b></code>, and properties added to an object&rsquo;s prototype are shared, through
- inheritance, by all objects sharing the prototype. Alternatively, a new object may be created with an explicitly specified
- prototype by using the <code><a href="#sec-object.create">Object.create</a></code> built-in function.</p>
- </div>
- </section>
-
- <section id="sec-ordinary-object">
- <h1><span class="secnum" id="sec-4.3.6"><a href="#sec-ordinary-object" title="link to this section">4.3.6</a></span>
- ordinary object</h1>
-
- <p>object that has the default behaviour for the essential internal methods that must be supported by all objects.</p>
- </section>
-
- <section id="sec-exotic-object">
- <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
- object</h1>
-
- <p>object that does not have the default behaviour for one or more of the essential internal methods that must be supported
- by all objects.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Any object that is not an ordinary object is an exotic object.</p>
- </div>
- </section>
-
- <section id="sec-standard-object">
- <h1><span class="secnum" id="sec-4.3.8"><a href="#sec-standard-object" title="link to this section">4.3.8</a></span>
- standard object</h1>
-
- <p>object whose semantics are defined by this specification</p>
- </section>
-
- <section id="sec-built-in-object">
- <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>
- built-in object</h1>
-
- <p>object specified and supplied by an ECMAScript implementation</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Standard built-in objects are defined in this specification. An ECMAScript implementation
- may specify and supply additional kinds of built-in objects. A <i>built-in constructor</i> is a built-in object that is
- also a constructor.</p>
- </div>
- </section>
-
- <section id="sec-undefined-value">
- <h1><span class="secnum" id="sec-4.3.10"><a href="#sec-undefined-value" title="link to this section">4.3.10</a></span>
- undefined value</h1>
-
- <p>primitive value used when a variable has not been assigned a value</p>
- </section>
-
- <section id="sec-terms-and-definitions-undefined-type">
- <h1><span class="secnum" id="sec-4.3.11"><a href="#sec-terms-and-definitions-undefined-type"
- title="link to this section">4.3.11</a></span> Undefined type</h1>
-
- <p>type whose sole value is the <b>undefined</b> value</p>
- </section>
-
- <section id="sec-null-value">
- <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
- value</h1>
-
- <p>primitive value that represents the intentional absence of any object value</p>
- </section>
-
- <section id="sec-terms-and-definitions-null-type">
- <h1><span class="secnum" id="sec-4.3.13"><a href="#sec-terms-and-definitions-null-type"
- title="link to this section">4.3.13</a></span> Null type</h1>
-
- <p>type whose sole value is the null value</p>
- </section>
-
- <section id="sec-terms-and-definitions-boolean-value">
- <h1><span class="secnum" id="sec-4.3.14"><a href="#sec-terms-and-definitions-boolean-value"
- title="link to this section">4.3.14</a></span> Boolean value</h1>
-
- <p>member of the Boolean type</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> There are only two Boolean values, <b>true</b> and <b>false</b></p>
- </div>
- </section>
-
- <section id="sec-terms-and-definitions-boolean-type">
- <h1><span class="secnum" id="sec-4.3.15"><a href="#sec-terms-and-definitions-boolean-type"
- title="link to this section">4.3.15</a></span> Boolean type</h1>
-
- <p>type consisting of the primitive values <b>true</b> and <b>false</b></p>
- </section>
-
- <section id="sec-boolean-object">
- <h1><span class="secnum" id="sec-4.3.16"><a href="#sec-boolean-object" title="link to this section">4.3.16</a></span>
- Boolean object</h1>
-
- <p>member of the Object type that is an instance of the standard built-in <code>Boolean</code> constructor</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A Boolean object is created by using the <code>Boolean</code> constructor in a
- <code>new</code> expression, supplying a Boolean value as an argument. The resulting object has an <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the Boolean value. A Boolean
- object can be coerced to a Boolean value.</p>
- </div>
- </section>
-
- <section id="sec-terms-and-definitions-string-value">
- <h1><span class="secnum" id="sec-4.3.17"><a href="#sec-terms-and-definitions-string-value"
- title="link to this section">4.3.17</a></span> String value</h1>
-
- <p>primitive value that is a finite ordered sequence of zero or more 16-bit unsigned integer</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A String value is a member of the String type. Each integer value in the sequence usually
- represents a single 16-bit unit of UTF-16 text. However, ECMAScript does not place any restrictions or requirements on the
- values except that they must be 16-bit unsigned integers.</p>
- </div>
- </section>
-
- <section id="sec-terms-and-definitions-string-type">
- <h1><span class="secnum" id="sec-4.3.18"><a href="#sec-terms-and-definitions-string-type"
- title="link to this section">4.3.18</a></span> String type</h1>
-
- <p>set of all possible String values</p>
- </section>
-
- <section id="sec-string-object">
- <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
- object</h1>
-
- <p>member of the Object type that is an instance of the standard built-in <code>String</code> constructor</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A String object is created by using the <code>String</code> constructor in a
- <code>new</code> expression, supplying a String value as an argument. The resulting object has an <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the String value. A String object
- can be coerced to a String value by calling the <code>String</code> constructor as a function (<a
- href="#sec-string-constructor-string-value">21.1.1.1</a>).</p>
- </div>
- </section>
-
- <section id="sec-terms-and-definitions-number-value">
- <h1><span class="secnum" id="sec-4.3.20"><a href="#sec-terms-and-definitions-number-value"
- title="link to this section">4.3.20</a></span> Number value</h1>
-
- <p>primitive value corresponding to a double-precision 64-bit binary format IEEE 754 value</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A Number value is a member of the Number type and is a direct representation of a
- number.</p>
- </div>
- </section>
-
- <section id="sec-terms-and-definitions-number-type">
- <h1><span class="secnum" id="sec-4.3.21"><a href="#sec-terms-and-definitions-number-type"
- title="link to this section">4.3.21</a></span> Number type</h1>
-
- <p>set of all possible Number values including the special &ldquo;Not-a-Number&rdquo; (NaN) value, positive infinity, and
- negative infinity</p>
- </section>
-
- <section id="sec-number-object">
- <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
- object</h1>
-
- <p>member of the Object type that is an instance of the standard built-in <code>Number</code> constructor</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A Number object is created by using the <code>Number</code> constructor in a
- <code>new</code> expression, supplying a Number value as an argument. The resulting object has an <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> whose value is the Number value. A Number object
- can be coerced to a Number value by calling the <code>Number</code> constructor as a function (<a
- href="#sec-number-constructor-number-value">20.1.1.1</a>).</p>
- </div>
- </section>
-
- <section id="sec-terms-and-definitions-infinity">
- <h1><span class="secnum" id="sec-4.3.23"><a href="#sec-terms-and-definitions-infinity"
- title="link to this section">4.3.23</a></span> Infinity</h1>
-
- <p>number value that is the positive infinite Number value</p>
- </section>
-
- <section id="sec-terms-and-definitions-nan">
- <h1><span class="secnum" id="sec-4.3.24"><a href="#sec-terms-and-definitions-nan"
- title="link to this section">4.3.24</a></span> NaN</h1>
-
- <p>number value that is an IEEE 754 &ldquo;Not-a-Number&rdquo; value</p>
- </section>
-
- <section id="sec-symbol-value">
- <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
- value</h1>
-
- <p>primitive value that represents a unique, non-String Object <a href="#sec-object-type">property key</a></p>
- </section>
-
- <section id="sec-terms-and-definitions-symbol-type">
- <h1><span class="secnum" id="sec-4.3.26"><a href="#sec-terms-and-definitions-symbol-type"
- title="link to this section">4.3.26</a></span> Symbol type</h1>
-
- <p>set of all possible Symbol values</p>
- </section>
-
- <section id="sec-symbol-object">
- <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
- object</h1>
-
- <p>member of the Object type that is an instance of the standard built-in <code>Symbol</code> constructor</p>
- </section>
-
- <section id="sec-terms-and-definitions-function">
- <h1><span class="secnum" id="sec-4.3.28"><a href="#sec-terms-and-definitions-function"
- title="link to this section">4.3.28</a></span> function</h1>
-
- <p>member of the Object type that may be invoked as a subroutine</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> In addition to its properties, a function contains executable code and state that
- determine how it behaves when invoked. A function&rsquo;s code may or may not be written in ECMAScript.</p>
- </div>
- </section>
-
- <section id="sec-built-in-function">
- <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>
- built-in function</h1>
-
- <p>built-in object that is a function</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Examples of built-in functions include <code>parseInt</code> and <code><a
- href="#sec-math.exp">Math.exp</a></code>. An implementation may provide implementation-dependent built-in functions that
- are not described in this specification.</p>
- </div>
- </section>
-
- <section id="sec-property">
- <h1><span class="secnum" id="sec-4.3.30"><a href="#sec-property" title="link to this section">4.3.30</a></span>
- property</h1>
-
- <p>part of an object that associates a key (either a String value or a Symbol value) and a value.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Depending upon the form of the property the value may be represented either directly as a
- data value (a primitive value, an object, or a function object) or indirectly by a pair of accessor functions.</p>
- </div>
- </section>
-
- <section id="sec-method">
- <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>
-
- <p>function that is the value of a property</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> When a function is called as a method of an object, the object is passed to the function
- as its <b>this</b> value.</p>
- </div>
- </section>
-
- <section id="sec-built-in-method">
- <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>
- built-in method</h1>
-
- <p>method that is a built-in function</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Standard built-in methods are defined in this specification, and an ECMAScript
- implementation may specify and provide other additional built-in methods.</p>
- </div>
- </section>
-
- <section id="sec-attribute">
- <h1><span class="secnum" id="sec-4.3.33"><a href="#sec-attribute" title="link to this section">4.3.33</a></span>
- attribute</h1>
-
- <p>internal value that defines some characteristic of a property</p>
- </section>
-
- <section id="sec-own-property">
- <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
- property</h1>
-
- <p>property that is directly contained by its object</p>
- </section>
-
- <section id="sec-inherited-property">
- <h1><span class="secnum" id="sec-4.3.35"><a href="#sec-inherited-property" title="link to this section">4.3.35</a></span>
- inherited property</h1>
-
- <p>property of an object that is not an own property but is a property (either own or inherited) of the object&rsquo;s
- prototype</p>
- </section>
- </section>
-
- <section id="sec-organization-of-this-specification">
- <h1><span class="secnum" id="sec-4.4"><a href="#sec-organization-of-this-specification"
- title="link to this section">4.4</a></span> Organization of This Specification</h1>
-
- <p>The remainder of this specification is organized as follows:</p>
-
- <p>Clause 5 defines the notational conventions used throughout the specification.</p>
-
- <p>Clauses 6&minus;9 define the execution environment within which ECMAScript programs operate.</p>
-
- <p>Clauses 10&minus;16 define the actual ECMAScript programming language including its syntactic encoding and the execution
- semantics of all language features.</p>
-
- <p>Clauses 17&minus;26 define the ECMAScript standard library. It includes the definitions of all of the standard objects that
- are available for use by ECMAScript programs as they execute.</p>
- </section>
-</section>
-
-<section id="sec-notational-conventions">
- <div class="front">
- <h1><span class="secnum" id="sec-5"><a href="#sec-notational-conventions" title="link to this section">5</a></span> Notational
- Conventions</h1>
- </div>
-
- <section id="sec-syntactic-and-lexical-grammars">
- <div class="front">
- <h1><span class="secnum" id="sec-5.1"><a href="#sec-syntactic-and-lexical-grammars"
- title="link to this section">5.1</a></span> Syntactic and Lexical Grammars</h1>
- </div>
-
- <section id="sec-context-free-grammars">
- <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>
- Context-Free Grammars</h1>
-
- <p>A <i>context-free grammar</i> consists of a number of <i>productions</i>. Each production has an abstract symbol called a
- <i>nonterminal</i> as its <i>left-hand side</i>, and a sequence of zero or more nonterminal and <i>terminal</i> symbols as
- its <i>right-hand side</i>. For each grammar, the terminal symbols are drawn from a specified alphabet.</p>
-
- <p>A <i>chain production</i> is a production that has exactly one nonterminal symbol on its right-hand side along with zero
- or more terminal symbols.</p>
-
- <p>Starting from a sentence consisting of a single distinguished nonterminal, called the <i>goal symbol</i>, a given
- context-free grammar specifies a <i>language</i>, namely, the (perhaps infinite) set of possible sequences of terminal
- symbols that can result from repeatedly replacing any nonterminal in the sequence with a right-hand side of a production for
- which the nonterminal is the left-hand side.</p>
- </section>
-
- <section id="sec-lexical-and-regexp-grammars">
- <h1><span class="secnum" id="sec-5.1.2"><a href="#sec-lexical-and-regexp-grammars"
- title="link to this section">5.1.2</a></span> The Lexical and RegExp Grammars</h1>
-
- <p>A <i>lexical grammar</i> for ECMAScript is given in <a href="#sec-ecmascript-language-lexical-grammar">clause 11</a>.
- This grammar has as its terminal symbols Unicode code points that conform to the rules for <span
- class="nt">SourceCharacter</span> defined in <a href="#sec-source-text">10.1</a>. It defines a set of productions, starting
- from the goal symbol <var>InputElementDiv,</var> <var>InputElementTemplateTail,</var> or <span
- class="nt">InputElementRegExp</span>, or <var>InputElementRegExpOrTemplateTail,</var> that describe how sequences of such
- code points are translated into a sequence of input elements.</p>
-
- <p>Input elements other than white space and comments form the terminal symbols for the syntactic grammar for ECMAScript and
- are called ECMAScript <i>tokens</i>. These tokens are the reserved words, identifiers, literals, and punctuators of the
- ECMAScript language. Moreover, line terminators, although not considered to be tokens, also become part of the stream of
- input elements and guide the process of <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a
- href="#sec-automatic-semicolon-insertion">11.9</a>). Simple white space and single-line comments are discarded and do not
- appear in the stream of input elements for the syntactic grammar. A <span class="nt">MultiLineComment</span> (that is, a
- comment of the form <code>/*</code>&hellip;<code>*/</code> regardless of whether it spans more than one line) is likewise
- simply discarded if it contains no line terminator; but if a <span class="nt">MultiLineComment</span> contains one or more
- line terminators, then it is replaced by a single line terminator, which becomes part of the stream of input elements for
- the syntactic grammar.</p>
-
- <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
- terminal symbols the code points as defined by <span class="nt">SourceCharacter</span>. It defines a set of productions,
- starting from the goal symbol <span class="nt">Pattern</span>, that describe how sequences of code points are translated
- into regular expression patterns.</p>
-
- <p>Productions of the lexical and RegExp grammars are distinguished by having two colons &ldquo;<b>::</b>&rdquo; as
- separating punctuation. The lexical and RegExp grammars share some productions.</p>
- </section>
-
- <section id="sec-numeric-string-grammar">
- <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>
- The Numeric String Grammar</h1>
-
- <p>Another grammar is used for translating Strings into numeric values. This grammar is similar to the part of the lexical
- grammar having to do with numeric literals and has as its terminal symbols <span class="nt">SourceCharacter</span>. This
- grammar appears in <a href="#sec-tonumber-applied-to-the-string-type">7.1.3.1</a>.</p>
-
- <p>Productions of the numeric string grammar are distinguished by having three colons &ldquo;<b>:::</b>&rdquo; as
- punctuation.</p>
- </section>
-
- <section id="sec-syntactic-grammar">
- <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
- Syntactic Grammar</h1>
-
- <p>The <i>syntactic grammar</i> for ECMAScript is given in clauses 11, 12, 13, 14, and 15. This grammar has ECMAScript
- tokens defined by the lexical grammar as its terminal symbols (<a href="#sec-lexical-and-regexp-grammars">5.1.2</a>). It
- defines a set of productions, starting from two alternative goal symbols <span class="nt">Script</span> and <span
- class="nt">Module</span>, that describe how sequences of tokens form syntactically correct independent components of
- ECMAScript programs.</p>
-
- <p>When a stream of code points is to be parsed as an ECMAScript <span class="nt">Script</span> or <span
- class="nt">Module</span>, it is first converted to a stream of input elements by repeated application of the lexical
- grammar; this stream of input elements is then parsed by a single application of the syntactic grammar. The input stream is
- syntactically in error if the tokens in the stream of input elements cannot be parsed as a single instance of the goal
- nonterminal (<span class="nt">Script</span> or <span class="nt">Module</span>), with no tokens left over.</p>
-
- <p>Productions of the syntactic grammar are distinguished by having just one colon &ldquo;<b>:</b>&rdquo; as
- punctuation.</p>
-
- <p>The syntactic grammar as presented in clauses 12, 13, 14 and 15 is not a complete account of which token sequences are
- accepted as a correct ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span>. Certain additional token
- sequences are also accepted, namely, those that would be described by the grammar if only semicolons were added to the
- sequence in certain places (such as before line terminator characters). Furthermore, certain token sequences that are
- described by the grammar are not considered acceptable if a line terminator character appears in certain
- &ldquo;awkward&rdquo; places.</p>
-
- <p>In certain cases in order to avoid ambiguities the syntactic grammar uses generalized productions that permit token
- sequences that do not form a valid ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span>. For example,
- this technique is used for object literals and object destructuring patterns. In such cases a more restrictive
- <i>supplemental grammar</i> is provided that further restricts the acceptable token sequences. In certain contexts, when
- explicitly specified, the input elements corresponding to such a production are parsed again using a goal symbol of a
- supplemental grammar. The input stream is syntactically in error if the tokens in the stream of input elements parsed by a
- cover grammar cannot be parsed as a single instance of the corresponding supplemental goal symbol, with no tokens left
- over.</p>
- </section>
-
- <section id="sec-grammar-notation">
- <h1><span class="secnum" id="sec-5.1.5"><a href="#sec-grammar-notation" title="link to this section">5.1.5</a></span>
- Grammar Notation</h1>
-
- <p>Terminal symbols of the lexical, RegExp, and numeric string grammars are shown in <code>fixed width</code> font, both in
- the productions of the grammars and throughout this specification whenever the text directly refers to such a terminal
- symbol. These are to appear in a script exactly as written. All terminal symbol code points specified in this way are to be
- understood as the appropriate Unicode code points from the Basic Latin range, as opposed to any similar-looking code points
- from other Unicode ranges.</p>
-
- <p>Nonterminal symbols are shown in <var>italic</var> type. The definition of a nonterminal (also called a
- &ldquo;production&rdquo;) is introduced by the name of the nonterminal being defined followed by one or more colons. (The
- number of colons indicates to which grammar the production belongs.) One or more alternative right-hand sides for the
- nonterminal then follow on succeeding lines. For example, the syntactic definition:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">WhileStatement</span> <span class="geq">:</span></div>
- <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>
- </div>
-
- <p>states that the nonterminal <span class="nt">WhileStatement</span> represents the token <code>while</code>, followed by a
- left parenthesis token, followed by an <span class="nt">Expression</span>, followed by a right parenthesis token, followed
- by a <span class="nt">Statement</span>. The occurrences of <span class="nt">Expression</span> and <span
- class="nt">Statement</span> are themselves nonterminals. As another example, the syntactic definition:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ArgumentList</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">AssignmentExpression</span></div>
- <div class="rhs"><span class="nt">ArgumentList</span> <code class="t">,</code> <span class="nt">AssignmentExpression</span></div>
- </div>
-
- <p>states that an <span class="nt">ArgumentList</span> may represent either a single <span
- class="nt">AssignmentExpression</span> or an <span class="nt">ArgumentList</span>, followed by a comma, followed by an <span
- class="nt">AssignmentExpression</span>. This definition of <span class="nt">ArgumentList</span> is recursive, that is, it is
- defined in terms of itself. The result is that an <span class="nt">ArgumentList</span> may contain any positive number of
- arguments, separated by commas, where each argument expression is an <span class="nt">AssignmentExpression</span>. Such
- recursive definitions of nonterminals are common.</p>
-
- <p>The subscripted suffix &ldquo;<sub>opt</sub>&rdquo;, which may appear after a terminal or nonterminal, indicates an
- optional symbol. The alternative containing the optional symbol actually specifies two right-hand sides, one that omits the
- optional element and one that includes it. This means that:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <p>is a convenient abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">BindingIdentifier</span></div>
- <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span></div>
- </div>
-
- <p>and that:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
- <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>
- </div>
-
- <p>is a convenient abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
- <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>
- <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>
- </div>
-
- <p>which in turn is an abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">IterationStatement</span> <span class="geq">:</span></div>
- <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>
- <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>
- <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>
- <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>
- </div>
-
- <p>so, in this example, the nonterminal <span class="nt">IterationStatement</span> actually has four alternative right-hand
- sides.</p>
-
- <p>A production may be parameterized by a subscripted annotation of the form &ldquo;<sub>[parameters]</sub>&rdquo;, which
- may appear as a suffix to the nonterminal symbol defined by the production. &ldquo;<sub>parameters</sub>&rdquo; may be
- either a single name or a comma separated list of names. A parameterized production is shorthand for a set of productions
- defining all combinations of the parameter names, preceded by an underscore, appended to the parameterized nonterminal
- symbol. This means that:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <p>is a convenient abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <p>and that:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return, In]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <p>is an abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList_In</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList_Return_In</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <p>Multiple parameters produce a combinatory number of productions, not all of which are necessarily referenced in a
- complete grammar.</p>
-
- <p>References to nonterminals on the right-hand side of a production can also be parameterized. For example:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span><sub class="g-params">[In]</sub></div>
- </div>
-
- <p>is equivalent to saying:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement_In</span></div>
- </div>
-
- <p>A nonterminal reference may have both a parameter list and an &ldquo;<sub>opt</sub>&rdquo; suffix. For example:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
- <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>
- </div>
-
- <p>is an abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">BindingIdentifier</span></div>
- <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer_In</span></div>
- </div>
-
- <p>Prefixing a parameter name with &ldquo;<sub>?</sub>&rdquo; on a right-hand side nonterminal reference makes that
- parameter value dependent upon the occurrence of the parameter name on the reference to the current production&rsquo;s
- left-hand side symbol. For example:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">VariableDeclaration</span><sub class="g-params">[In]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span><sub class="g-params">[?In]</sub></div>
- </div>
-
- <p>is an abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">VariableDeclaration</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">VariableDeclaration_In</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">BindingIdentifier</span> <span class="nt">Initializer_In</span></div>
- </div>
-
- <p>If a right-hand side alternative is prefixed with &ldquo;[+parameter]&rdquo; that alternative is only available if the
- named parameter was used in referencing the production&rsquo;s nonterminal symbol. If a right-hand side alternative is
- prefixed with &ldquo;[~parameter]&rdquo; that alternative is only available if the named parameter was <i>not</i> used in
- referencing the production&rsquo;s nonterminal symbol. This means that:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="grhsannot">[+Return]</span> <span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <p>is an abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <p>and that</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span><sub class="g-params">[Return]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="grhsannot">[~Return]</span> <span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <p>is an abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ReturnStatement</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StatementList_Return</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">ExpressionStatement</span></div>
- </div>
-
- <p>When the words &ldquo;<b>one of</b>&rdquo; follow the colon(s) in a grammar definition, they signify that each of the
- terminal symbols on the following line or lines is an alternative definition. For example, the lexical grammar for
- ECMAScript contains the production:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <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>
- </div>
-
- <p>which is merely a convenient abbreviation for:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">1</code></div>
- <div class="rhs"><code class="t">2</code></div>
- <div class="rhs"><code class="t">3</code></div>
- <div class="rhs"><code class="t">4</code></div>
- <div class="rhs"><code class="t">5</code></div>
- <div class="rhs"><code class="t">6</code></div>
- <div class="rhs"><code class="t">7</code></div>
- <div class="rhs"><code class="t">8</code></div>
- <div class="rhs"><code class="t">9</code></div>
- </div>
-
- <p>If the phrase &ldquo;[empty]&rdquo; appears as the right-hand side of a production, it indicates that the production's
- right-hand side contains no terminals or nonterminals.</p>
-
- <p>If the phrase &ldquo;[lookahead &notin; <var>set</var>]&rdquo; appears in the right-hand side of a production, it
- indicates that the production may not be used if the immediately following input token is a member of the given
- <var>set</var>. The <var>set</var> can be written as a list of terminals enclosed in curly brackets. For convenience, the
- set can also be written as a nonterminal, in which case it represents the set of all terminals to which that nonterminal
- could expand. If the <var>set</var> consists of a single terminal the phrase &ldquo;[lookahead &ne;
- <var>terminal</var>]&rdquo; may be used.</p>
-
- <p>For example, given the definitions</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">DecimalDigit</span></div>
- <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
- </div>
-
- <p>the definition</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">LookaheadExample</span> <span class="geq">::</span></div>
- <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>
- <div class="rhs"><span class="nt">DecimalDigit</span> <span class="grhsannot">[lookahead &notin; <span class="nt">DecimalDigit</span>]</span></div>
- </div>
-
- <p>matches either the letter <code>n</code> followed by one or more decimal digits the first of which is even, or a decimal
- digit not followed by another decimal digit.</p>
-
- <p>If the phrase &ldquo;[no <span class="nt">LineTerminator</span> here]&rdquo; appears in the right-hand side of a
- production of the syntactic grammar, it indicates that the production is <i>a restricted production</i>: it may not be used
- if a <span class="nt">LineTerminator</span> occurs in the input stream at the indicated position. For example, the
- production:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ThrowStatement</span> <span class="geq">:</span></div>
- <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>
- </div>
-
- <p>indicates that the production may not be used if a <span class="nt">LineTerminator</span> occurs in the script between
- the <code>throw</code> token and the <span class="nt">Expression</span>.</p>
-
- <p>Unless the presence of a <span class="nt">LineTerminator</span> is forbidden by a restricted production, any number of
- occurrences of <span class="nt">LineTerminator</span> may appear between any two consecutive tokens in the stream of input
- elements without affecting the syntactic acceptability of the script.</p>
-
- <p>When an alternative in a production of the lexical grammar or the numeric string grammar appears to be a multi-code point
- token, it represents the sequence of code points that would make up such a token.</p>
-
- <p>The right-hand side of a production may specify that certain expansions are not permitted by using the phrase
- &ldquo;<b>but not</b>&rdquo; and then indicating the expansions to be excluded. For example, the production:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Identifier</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">IdentifierName</span> <span class="grhsmod">but not</span> <span class="nt">ReservedWord</span></div>
- </div>
-
- <p>means that the nonterminal <span class="nt">Identifier</span> may be replaced by any sequence of code points that could
- replace <span class="nt">IdentifierName</span> provided that the same sequence of code points could not replace <span
- class="nt">ReservedWord</span>.</p>
-
- <p>Finally, a few nonterminal symbols are described by a descriptive phrase in sans-serif type in cases where it would be
- impractical to list all the alternatives:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SourceCharacter</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="gprose">any Unicode code point</span></div>
- </div>
- </section>
- </section>
-
- <section id="sec-algorithm-conventions">
- <h1><span class="secnum" id="sec-5.2"><a href="#sec-algorithm-conventions" title="link to this section">5.2</a></span>
- Algorithm Conventions</h1>
-
- <p>The specification often uses a numbered list to specify steps in an algorithm. These algorithms are used to precisely
- specify the required semantics of ECMAScript language constructs. The algorithms are not intended to imply the use of any
- specific implementation technique. In practice, there may be more efficient algorithms available to implement a given
- feature.</p>
-
- <p>Algorithms may be explicitly parameterized, in which case the names and usage of the parameters must be provided as part of
- the algorithm&rsquo;s definition. In order to facilitate their use in multiple parts of this specification, some algorithms,
- called <i>abstract</i> <i>operations</i>, are named and written in parameterized functional form so that they may be
- referenced by name from within other algorithms. Abstract operations are typically referenced using a functional application
- style such as <span style="font-family: Times New Roman">operationName(<i>arg1</i>, <i>arg2</i>)</span>. Some abstract
- operations are treated as polymorphically dispatched methods of class-like specification abstractions. Such method-like
- abstract operations are typically referenced using a method application style such as <span style="font-family: Times New
- Roman"><i>someValue</i>.operationName(<i>arg1</i>, <i>arg2</i>)</span>.</p>
-
- <p>Algorithms may be associated with productions of one of the ECMAScript grammars. A production that has multiple alternative
- definitions will typically have a distinct algorithm for each alternative. When an algorithm is associated with a grammar
- production, it may reference the terminal and nonterminal symbols of the production alternative as if they were parameters of
- the algorithm. When used in this manner, nonterminal symbols refer to the actual alternative definition that is matched when
- parsing the source text.</p>
-
- <p>When an algorithm is associated with a production alternative, the alternative is typically shown without any &ldquo;[
- ]&rdquo; grammar annotations. Such annotations should only affect the syntactic recognition of the alternative and have no
- effect on the associated semantics for the alternative.</p>
-
- <p>Unless explicitly specified otherwise, all <a href="#sec-context-free-grammars">chain productions</a> have an implicit
- definition for every algorithm that might be applied to that production&rsquo;s left-hand side nonterminal. The implicit
- definition simply reapplies the same algorithm name with the same parameters, if any, to the <a
- href="#sec-context-free-grammars">chain production</a>&rsquo;s sole right-hand side nonterminal and then returns the result.
- For example, assume there is a production:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Block</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">{</code> <span class="nt">StatementList</span> <code class="t">}</code></div>
- </div>
-
- <p>but there is no corresponding Evaluation algorithm that is explicitly specified for that production. If in some algorithm
- there is a statement of the form: &ldquo;<span style="font-family: Times New Roman">Return the result of evaluating
- <i>Block</i></span>&rdquo; it is implicit that an Evaluation algorithm exists of the form:</p>
-
- <p><b>Runtime Semantics: Evaluation</b></p>
-
- <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>
- <ol class="proc">
- <li>Return the result of evaluating <i>StatementList</i>.</li>
- </ol>
-
- <p>For clarity of expression, algorithm steps may be subdivided into sequential substeps. Substeps are indented and may
- themselves be further divided into indented substeps. Outline numbering conventions are used to identify substeps with the
- first level of substeps labelled with lower case alphabetic characters and the second level of substeps labelled with lower
- case roman numerals. If more than three levels are required these rules repeat with the fourth level using numeric labels. For
- example:</p>
-
- <ol class="proc">
- <li>Top-level step
- <ol class="block">
- <li>Substep.</li>
- <li>Substep.
- <ol class="block">
- <li>Subsubstep.
- <ol class="block">
- <li>Subsubsubstep
- <ol class="block">
- <li>Subsubsubsubstep
- <ol class="block">
- <li>Subsubsubsubsubstep</li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
-
- <p>A step or substep may be written as an &ldquo;if&rdquo; predicate that conditions its substeps. In this case, the substeps
- are only applied if the predicate is true. If a step or substep begins with the word &ldquo;else&rdquo;, it is a predicate
- that is the negation of the preceding &ldquo;if&rdquo; predicate step at the same level.</p>
-
- <p>A step may specify the iterative application of its substeps.</p>
-
- <p>A step that begins with &ldquo;Assert:&rdquo; asserts an invariant condition of its algorithm. Such assertions are used to
- make explicit algorithmic invariants that would otherwise be implicit. Such assertions add no additional semantic requirements
- and hence need not be checked by an implementation. They are used simply to clarify algorithms.</p>
-
- <p>Mathematical operations such as addition, subtraction, negation, multiplication, division, and the mathematical functions
- defined later in this clause should always be understood as computing exact mathematical results on mathematical real numbers,
- which unless otherwise noted do not include infinities and do not include a negative zero that is distinguished from positive
- zero. Algorithms in this standard that model floating-point arithmetic include explicit steps, where necessary, to handle
- infinities and signed zero and to perform rounding. If a mathematical operation or function is applied to a floating-point
- number, it should be understood as being applied to the exact mathematical value represented by that floating-point number;
- such a floating-point number must be finite, and if it is <span class="value">+0</span> or <span class="value">&minus;0</span>
- then the corresponding mathematical value is simply <span class="value">0</span>.</p>
-
- <p>The mathematical function <span style="font-family: Times New Roman">abs(<i>x</i>)</span> produces the absolute value of
- <var>x</var>, which is <span style="font-family: Times New Roman">&minus;<i>x</i></span> if <var>x</var> is negative (less
- than zero) and otherwise is <var>x</var> itself.</p>
-
- <p>The mathematical function <span style="font-family: Times New Roman">sign(<i>x</i>)</span> produces <span
- style="font-family: Times New Roman">1</span> if <var>x</var> is positive and <span style="font-family: Times New
- 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>
- is zero.</p>
-
- <p>The mathematical function <span style="font-family: Times New Roman">min(<i>x</i><sub>1</sub>,</span> <span
- style="font-family: Times New Roman"><i>x</i><sub>2</sub>, ..., <i>x</i><sub>n</sub>)</span> produces the mathematically
- smallest of <span style="font-family: Times New Roman"><i>x</i><sub>1</sub></span> through <span style="font-family: Times New
- Roman"><i>x</i><sub>n</sub></span>. The mathematical function <span style="font-family: Times New
- Roman">max(<i>x</i><sub>1</sub>,</span> <span style="font-family: Times New Roman"><i>x</i><sub>2</sub>, ...,
- <i>x</i><sub>n</sub>)</span> produces the mathematically largest of <span style="font-family: Times New
- 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
- and range of these mathematical functions include +<b>&infin;</b> and <b>&minus;&infin;</b>.</p>
-
- <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
- finite and nonzero) computes a value <var>k</var> of the same sign as <var>y</var> (or zero) such that <span
- 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
- style="font-family: Times New Roman">&times;</span> <var>y</var> for some integer <var>q</var>.</p>
-
- <p>The mathematical function <span style="font-family: Times New Roman">floor(<i>x</i>)</span> produces the largest integer
- (closest to positive infinity) that is not larger than <var>x</var>.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> floor(<i>x</i>) = <i>x</i>&minus;(<i>x</i> modulo 1).</p>
- </div>
- </section>
-
- <section id="sec-static-semantic-rules">
- <h1><span class="secnum" id="sec-5.3"><a href="#sec-static-semantic-rules" title="link to this section">5.3</a></span> Static
- Semantic Rules</h1>
-
- <p>Context-free grammars are not sufficiently powerful to express all the rules that define whether a stream of input elements
- form a valid ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span> that may be evaluated. In some
- situations additional rules are needed that may be expressed using either ECMAScript algorithm conventions or prose
- requirements. Such rules are always associated with a production of a grammar and are called the <i>static semantics</i> of
- the production.</p>
-
- <p>Static Semantic Rules have names and typically are defined using an algorithm. Named Static Semantic Rules are associated
- with grammar productions and a production that has multiple alternative definitions will typically have for each alternative a
- distinct algorithm for each applicable named static semantic rule.</p>
-
- <p>Unless otherwise specified every grammar production alternative in this specification implicitly has a definition for a
- static semantic rule named <span style="font-family: Times New Roman">Contains</span> which takes an argument named
- <var>symbol</var> whose value is a terminal or nonterminal of the grammar that includes the associated production. The default
- definition of <span style="font-family: Times New Roman">Contains</span> is:</p>
-
- <ol class="proc">
- <li>For each terminal and nonterminal grammar symbol, <i>sym</i>, in the definition of this production do
- <ol class="block">
- <li>If <i>sym</i> is the same grammar symbol as <i>symbol</i>, return <b>true</b>.</li>
- <li>If <i>sym</i> is a nonterminal, then
- <ol class="block">
- <li>Let <i>contained</i> be the result of <i>sym</i> Contains <i>symbol</i>.</li>
- <li>If <i>contained</i> is <b>true</b>, return <b>true</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <b>false</b>.</li>
- </ol>
-
- <p>The above definition is explicitly over-ridden for specific productions.</p>
-
- <p>A special kind of static semantic rule is an Early Error Rule. Early error rules define early error conditions (see <a
- href="#sec-error-handling-and-language-extensions">clause 16</a>) that are associated with specific grammar productions.
- Evaluation of most early error rules are not explicitly invoked within the algorithms of this specification. A conforming
- implementation must, prior to the first evaluation of a <span class="nt">Script</span>, validate all of the early error rules
- of the productions used to parse that <span class="nt">Script</span>. If any of the early error rules are violated the <span
- class="nt">Script</span> is invalid and cannot be evaluated.</p>
- </section>
-</section>
-
-<section id="sec-ecmascript-data-types-and-values">
- <div class="front">
- <h1><span class="secnum" id="sec-6"><a href="#sec-ecmascript-data-types-and-values" title="link to this section">6</a></span>
- ECMAScript Data Types and Values</h1>
-
- <p>Algorithms within this specification manipulate values each of which has an associated type. The possible value types are
- exactly those defined in this clause. Types are further subclassified into ECMAScript language types and specification
- types.</p>
-
- <p>Within this specification, the notation &ldquo;<span style="font-family: Times New Roman">Type(<i>x</i>)</span>&rdquo; is
- used as shorthand for &ldquo;<span style="font-family: Times New Roman">the type of <i>x</i></span>&rdquo; where &ldquo;<span
- style="font-family: Times New Roman">type</span>&rdquo; refers to the ECMAScript language and specification types defined in
- 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
- of any type&rdquo;.</p>
- </div>
-
- <section id="sec-ecmascript-language-types">
- <div class="front">
- <h1><span class="secnum" id="sec-6.1"><a href="#sec-ecmascript-language-types" title="link to this section">6.1</a></span>
- ECMAScript Language Types</h1>
-
- <p>An ECMAScript language type corresponds to values that are directly manipulated by an ECMAScript programmer using the
- ECMAScript language. The ECMAScript language types are Undefined, Null, Boolean, String, Symbol, Number, and Object. An
- ECMAScript language value is a value that is characterized by an ECMAScript language type.</p>
- </div>
-
- <section id="sec-ecmascript-language-types-undefined-type">
- <h1><span class="secnum" id="sec-6.1.1"><a href="#sec-ecmascript-language-types-undefined-type"
- title="link to this section">6.1.1</a></span> The Undefined Type</h1>
-
- <p>The Undefined type has exactly one value, called <b>undefined</b>. Any variable that has not been assigned a value has
- the value <b>undefined</b>.</p>
- </section>
-
- <section id="sec-ecmascript-language-types-null-type">
- <h1><span class="secnum" id="sec-6.1.2"><a href="#sec-ecmascript-language-types-null-type"
- title="link to this section">6.1.2</a></span> The Null Type</h1>
-
- <p>The Null type has exactly one value, called <b>null</b>.</p>
- </section>
-
- <section id="sec-ecmascript-language-types-boolean-type">
- <h1><span class="secnum" id="sec-6.1.3"><a href="#sec-ecmascript-language-types-boolean-type"
- title="link to this section">6.1.3</a></span> The Boolean Type</h1>
-
- <p>The Boolean type represents a logical entity having two values, called <b>true</b> and <b>false</b>.</p>
- </section>
-
- <section id="sec-ecmascript-language-types-string-type">
- <h1><span class="secnum" id="sec-6.1.4"><a href="#sec-ecmascript-language-types-string-type"
- title="link to this section">6.1.4</a></span> The String Type</h1>
-
- <p>The String type is the set of all finite ordered sequences of zero or more 16-bit unsigned integer values
- (&ldquo;elements&rdquo;). The String type is generally used to represent textual data in a running ECMAScript program, in
- which case each element in the String is treated as a UTF-16 code unit value. Each element is regarded as occupying a
- position within the sequence. These positions are indexed with nonnegative integers. The first element (if any) is at index
- 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)
- within it. The empty String has length zero and therefore contains no elements.</p>
-
- <p>Where ECMAScript operations interpret String values, each element is interpreted as a single UTF-16 code unit. However,
- ECMAScript does not place any restrictions or requirements on the sequence of code units in a String value, so they may be
- ill-formed when interpreted as UTF-16 code unit sequences. Operations that do not interpret String contents treat them as
- sequences of undifferentiated 16-bit unsigned integers. The function <code><a
- href="#sec-string.prototype.normalize">String.prototype.normalize</a></code> (<a href="#sec-string.prototype.normalize">see
- 21.1.3.12</a>) can be used to explicitly normalize a string value. <code><a
- href="#sec-string.prototype.localecompare">String.prototype.localeCompare</a></code> (<a
- href="#sec-string.prototype.localecompare">see 21.1.3.10</a>) internally normalizes strings values, but no other operations
- implicitly normalize the strings upon which they operate. Only operations that are explicitly specified to be language or
- locale sensitive produce language-sensitive results.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The rationale behind this design was to keep the implementation of Strings as simple and
- high-performing as possible. If ECMAScript source text is in Normalized Form C, string literals are guaranteed to also be
- normalized, as long as they do not contain any Unicode escape sequences.</p>
- </div>
-
- <p>Some operations interpret String contents as UTF-16 encoded Unicode code points. In that case the interpretation is:</p>
-
- <ul>
- <li>
- <p>A code unit in the range <span style="font-family: Times New Roman">0</span> to <span style="font-family: Times New
- Roman">0xD7FF</span> or in the range <span style="font-family: Times New Roman">0xE000</span> to <span
- style="font-family: Times New Roman">0xFFFF</span> is interpreted as a code point with the same value.</p>
- </li>
-
- <li>
- <p>A sequence of two code units, where the first code unit <var>c1</var> is in the range <span style="font-family: Times
- New Roman">0xD800</span> to <span style="font-family: Times New Roman">0xDBFF</span> and the second code unit
- <var>c2</var> is in the range <span style="font-family: Times New Roman">0xDC00</span> to <span style="font-family:
- Times New Roman">0xDFFF</span>, is a surrogate pair and is interpreted as a code point with the value (<var>c1</var> -
- <span style="font-family: Times New Roman">0xD800</span>) &times; <span style="font-family: Times New
- Roman">0x400</span> + (<var>c2</var> &ndash; <span style="font-family: Times New Roman">0xDC00</span>) + <span
- style="font-family: Times New Roman">0x10000</span>. (See <a href="#sec-utf16decode">10.1.2</a>)</p>
- </li>
-
- <li>
- <p>A code unit that is in the range <span style="font-family: Times New Roman">0xD800</span> to <span
- style="font-family: Times New Roman">0xDFFF</span>, but is not part of a surrogate pair, is interpreted as a code point
- with the same value.</p>
- </li>
- </ul>
- </section>
-
- <section id="sec-ecmascript-language-types-symbol-type">
- <div class="front">
- <h1><span class="secnum" id="sec-6.1.5"><a href="#sec-ecmascript-language-types-symbol-type"
- title="link to this section">6.1.5</a></span> The Symbol Type</h1>
-
- <p>The Symbol type is the set of all non-String values that may be used as the key of an Object property (<a
- href="#sec-object-type">6.1.7</a>).</p>
-
- <p>Each possible Symbol value is unique and immutable.</p>
-
- <p>Each Symbol value immutably holds an associated value called [[Description]] that is either <span
- class="value">undefined</span> or a String value.</p>
- </div>
-
- <section id="sec-well-known-symbols">
- <h1><span class="secnum" id="sec-6.1.5.1"><a href="#sec-well-known-symbols"
- title="link to this section">6.1.5.1</a></span> Well-Known Symbols</h1>
-
- <p>Well-known symbols are built-in Symbol values that are explicitly referenced by algorithms of this specification. They
- are typically used as the keys of properties whose values serve as extension points of a specification algorithm. Unless
- otherwise specified, well-known symbols values are shared by all Code Realms (<a href="#sec-code-realms">8.2</a>).</p>
-
- <p>Within this specification a well-known symbol is referred to by using a notation of the form @@name, where
- &ldquo;name&rdquo; is one of the values listed in <a href="#table-1">Table 1</a>.</p>
-
- <figure>
- <figcaption><span id="table-1">Table 1</span>&mdash; Well-known Symbols</figcaption>
- <table class="real-table">
- <tr>
- <th>Specification Name</th>
- <th>[[Description]]</th>
- <th>Value and Purpose</th>
- </tr>
- <tr>
- <td>@@hasInstance</td>
- <td><code>"Symbol.hasInstance"</code></td>
- <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>
- </tr>
- <tr>
- <td>@@isConcatSpreadable</td>
- <td><code>"Symbol.isConcatSpreadable"</code></td>
- <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>
- </tr>
- <tr>
- <td>@@iterator</td>
- <td><code>"Symbol.iterator"</code></td>
- <td>A method that returns the default Iterator for an object. Called by the semantics of the for-of statement.</td>
- </tr>
- <tr>
- <td>@@match</td>
- <td><code>"Symbol.match"</code></td>
- <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>
- </tr>
- <tr>
- <td>@@replace</td>
- <td><code>"Symbol.replace"</code></td>
- <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>
- </tr>
- <tr>
- <td>@@search</td>
- <td><code>"Symbol.search"</code></td>
- <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>
- </tr>
- <tr>
- <td>@@species</td>
- <td><code>"Symbol.species"</code></td>
- <td>A function valued property that is the constructor function that is used to create derived objects.</td>
- </tr>
- <tr>
- <td>@@split</td>
- <td><code>"Symbol.split"</code></td>
- <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>
- </tr>
- <tr>
- <td>@@toPrimitive</td>
- <td><code>"Symbol.toPrimitive"</code></td>
- <td>A method that converts an object to a corresponding primitive value. Called by the <a href="#sec-toprimitive">ToPrimitive</a> abstract operation.</td>
- </tr>
- <tr>
- <td>@@toStringTag</td>
- <td><code>"Symbol.toStringTag"</code></td>
- <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>
- </tr>
- <tr>
- <td>@@unscopables</td>
- <td><code>"Symbol.unscopables"</code></td>
- <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>
- </tr>
- </table>
- </figure>
- </section>
- </section>
-
- <section id="sec-ecmascript-language-types-number-type">
- <h1><span class="secnum" id="sec-6.1.6"><a href="#sec-ecmascript-language-types-number-type"
- title="link to this section">6.1.6</a></span> The Number Type</h1>
-
- <p>The Number type has exactly <span style="font-family: Times New Roman">18437736874454810627</span> (that is, <span
- style="font-family: Times New Roman">2<sup>64</sup>&minus;2<sup>53</sup>+3</span>) values, representing the double-precision
- 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic, except that the <span
- style="font-family: Times New Roman">9007199254740990</span> (that is, <span style="font-family: Times New
- Roman">2<sup>53</sup>&minus;2</span>) distinct &ldquo;Not-a-Number&rdquo; values of the IEEE Standard are represented in
- ECMAScript as a single special <b>NaN</b> value. (Note that the <b>NaN</b> value is produced by the program expression
- <code>NaN</code>.) In some implementations, external code might be able to detect a difference between various Not-a-Number
- values, but such behaviour is implementation-dependent; to ECMAScript code, all NaN values are indistinguishable from each
- other.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The bit pattern that might be observed in an ArrayBuffer (<a
- href="#sec-arraybuffer-objects">see 24.1</a>) after a Number value has been stored into it is not necessarily the same as
- the internal representation of that Number value used by the ECMAScript implementation.</p>
- </div>
-
- <p>There are two other special values, called <b>positive Infinity</b> and <b>negative Infinity</b>. For brevity, these
- values are also referred to for expository purposes by the symbols <span class="value">+&infin;</span> and <span
- class="value">&minus;&infin;</span>, respectively. (Note that these two infinite Number values are produced by the program
- expressions <code>+Infinity</code> (or simply <code>Infinity</code>) and <code>-Infinity</code>.)</p>
-
- <p>The other <span style="font-family: Times New Roman">18437736874454810624</span> (that is, <span style="font-family:
- Times New Roman">2<sup>64</sup>&minus;2<sup>53</sup></span>) values are called the finite numbers. Half of these are
- positive numbers and half are negative numbers; for every finite positive Number value there is a corresponding negative
- value having the same magnitude.</p>
-
- <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
- for expository purposes by the symbols <span class="value">+0</span> and <span class="value">&minus;0</span>, respectively.
- (Note that these two different zero Number values are produced by the program expressions <code>+0</code> (or simply
- <code>0</code>) and <code>-0</code>.)</p>
-
- <p>The <span style="font-family: Times New Roman">18437736874454810622</span> (that is, <span style="font-family: Times New
- Roman">2<sup>64</sup>&minus;2<sup>53</sup>&minus;2</span>) finite nonzero values are of two kinds:</p>
-
- <p><span style="font-family: Times New Roman">18428729675200069632</span> (that is, <span style="font-family: Times New
- Roman">2<sup>64</sup>&minus;2<sup>54</sup></span>) of them are normalized, having the form</p>
-
- <div class="math-display"><i>s</i> &times; <i>m</i> &times; 2<sup><i>e</i></sup></div>
-
- <p>where <var>s</var> is <span style="font-family: Times New Roman">+1</span> or <span style="font-family: Times New
- Roman">&minus;1</span>, <var>m</var> is a positive integer less than <span style="font-family: Times New
- Roman">2<sup>53</sup></span> but not less than <span style="font-family: Times New Roman">2<sup>52</sup></span>, and
- <var>e</var> is an integer ranging from <span style="font-family: Times New Roman">&minus;1074</span> to <span
- style="font-family: Times New Roman">971</span>, inclusive.</p>
-
- <p>The remaining <span style="font-family: Times New Roman">9007199254740990</span> (that is, <span style="font-family:
- Times New Roman">2<sup>53</sup>&minus;2</span>) values are denormalized, having the form</p>
-
- <div class="math-display"><i>s</i> &times; <i>m</i> &times; 2<sup><i>e</i></sup></div>
-
- <p>where <var>s</var> is <span style="font-family: Times New Roman">+1</span> or <span style="font-family: Times New
- Roman">&minus;1</span>, <var>m</var> is a positive integer less than <span style="font-family: Times New
- Roman">2<sup>52</sup></span>, and <var>e</var> is <span style="font-family: Times New Roman">&minus;1074</span>.</p>
-
- <p>Note that all the positive and negative integers whose magnitude is no greater than <span style="font-family: Times New
- Roman">2<sup>53</sup></span> are representable in the Number type (indeed, the integer <span style="font-family: Times New
- Roman">0</span> has two representations, <code>+0</code> and <code>-0</code>).</p>
-
- <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
- the two forms shown above) is odd. Otherwise, it has an <i>even significand</i>.</p>
-
- <p>In this specification, the phrase &ldquo;<span style="font-family: Times New Roman">the Number value for
- <i>x</i></span>&rdquo; where <var>x</var> represents an exact nonzero real mathematical quantity (which might even be an
- irrational number such as <span style="font-family: Times New Roman">&pi;</span>) means a Number value chosen in the
- following manner. Consider the set of all finite values of the Number type, with <span class="value">&minus;0</span> removed
- and with two additional values added to it that are not representable in the Number type, namely <span style="font-family:
- Times New Roman">2<sup>1024</sup></span> (which is <span style="font-family: Times New Roman">+1 &times;
- 2<sup>53</sup></span> <span style="font-family: Times New Roman">&times; 2<sup>971</sup></span>) and <span
- style="font-family: Times New Roman">&minus;2<sup>1024</sup></span> (which is <span style="font-family: Times New
- Roman">&minus;1 &times; 2<sup>53</sup></span> <span style="font-family: Times New Roman">&times; 2<sup>971</sup></span>).
- 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
- one with an even significand is chosen; for this purpose, the two extra values <span style="font-family: Times New
- Roman">2<sup>1024</sup></span> and <span style="font-family: Times New Roman">&minus;2<sup>1024</sup></span> are considered
- to have even significands. Finally, if <span style="font-family: Times New Roman">2<sup>1024</sup></span> was chosen,
- replace it with <span class="value">+&infin;</span>; if <span style="font-family: Times New
- Roman">&minus;2<sup>1024</sup></span> was chosen, replace it with <span class="value">&minus;&infin;</span>; if <span
- class="value">+0</span> was chosen, replace it with <span class="value">&minus;0</span> if and only if <var>x</var> is less
- than zero; any other chosen value is used unchanged. The result is the Number value for <var>x</var>. (This procedure
- corresponds exactly to the behaviour of the IEEE 754 &ldquo;round to nearest, ties to even&rdquo; mode.)</p>
-
- <p>Some ECMAScript operators deal only with integers in specific ranges such as <span style="font-family: Times New
- Roman">&minus;2<sup>31</sup></span> through <span style="font-family: Times New Roman">2<sup>31</sup>&minus;1</span>,
- inclusive, or in the range <span style="font-family: Times New Roman">0</span> through <span style="font-family: Times New
- Roman">2<sup>16</sup>&minus;1</span>, inclusive. These operators accept any value of the Number type but first convert each
- such value to an integer value in the expected range. See the descriptions of the numeric conversion operations in <a
- href="#sec-type-conversion">7.1</a>.</p>
- </section>
-
- <section id="sec-object-type">
- <div class="front">
- <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
- Object Type</h1>
-
- <p>An Object is logically a collection of properties. Each property is either a data property, or an accessor
- property:</p>
-
- <ul>
- <li>
- <p>A <i>data property</i> associates a key value with an <a href="#sec-ecmascript-language-types">ECMAScript language
- value</a> and a set of Boolean attributes.</p>
- </li>
-
- <li>
- <p>An <i>accessor property</i> associates a key value with one or two accessor functions, and a set of Boolean
- attributes. The accessor functions are used to store or retrieve an <a
- href="#sec-ecmascript-language-types">ECMAScript language value</a> that is associated with the property.</p>
- </li>
- </ul>
-
- <p>Properties are identified using key values. A property key value is either an ECMAScript String value or a Symbol
- value. All String and Symbol values, including the empty string, are valid as property keys. A <i>property name</i> is a
- property key that is a String value.</p>
-
- <p>An <i>integer index</i> is a String-valued property key that is a canonical numeric String (<a
- href="#sec-canonicalnumericindexstring">see 7.1.16</a>) and whose numeric value is either <span style="font-family: Times
- 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
- numeric value <var>i</var> is in the range <span style="font-family: Times New Roman">+0 &le; <i>i</i></span> <span
- style="font-family: Times New Roman">&lt; 2<sup>32</sup>&minus;1.</span></p>
-
- <p>Property keys are used to access properties and their values. There are two kinds of access for properties: <i>get</i>
- and <i>set</i>, corresponding to value retrieval and assignment, respectively. The properties accessible via get and set
- access includes both <i>own properties</i> that are a direct part of an object and <i>inherited properties</i> which are
- provided by another associated object via a property inheritance relationship. Inherited properties may be either own or
- inherited properties of the associated object. Each own property of an object must each have a key value that is distinct
- from the key values of the other own properties of that object.</p>
-
- <p>All objects are logically collections of properties, but there are multiple forms of objects that differ in their
- semantics for accessing and manipulating their properties. O<i>rdinary objects</i> are the most common form of objects and
- have the default object semantics. An <i>exotic object</i> is any form of object whose property semantics differ in any
- way from the default semantics.</p>
- </div>
-
- <section id="sec-property-attributes">
- <h1><span class="secnum" id="sec-6.1.7.1"><a href="#sec-property-attributes"
- title="link to this section">6.1.7.1</a></span> Property Attributes</h1>
-
- <p>Attributes are used in this specification to define and explain the state of Object properties. A data property
- associates a key value with the attributes listed in <a href="#table-2">Table 2</a>.</p>
-
- <figure>
- <figcaption><span id="table-2">Table 2</span> &mdash; Attributes of a Data Property</figcaption>
- <table class="real-table">
- <tr>
- <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>
- <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>
- <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Description</th>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Value]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">Any <a href="#sec-ecmascript-language-types">ECMAScript language type</a></td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">The value retrieved by a get access of the property.</td>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Writable]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
- <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>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Enumerable]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
- <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>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black">[[Configurable]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>An accessor property associates a key value with the attributes listed in <a href="#table-3">Table 3</a>.</p>
-
- <figure>
- <figcaption><span id="table-3">Table 3</span> &mdash; Attributes of an Accessor Property</figcaption>
- <table class="real-table">
- <tr>
- <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>
- <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>
- <th style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">Description</th>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000">[[Get]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">Object <i>or</i> Undefined</td>
- <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>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Set]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">Object <i>or</i> Undefined</td>
- <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>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Enumerable]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
- <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>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Configurable]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black">Boolean</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>If the initial values of a property&rsquo;s attributes are not explicitly specified by this specification, the default
- value defined in <a href="#table-4">Table 4</a> is used.</p>
-
- <figure>
- <figcaption><span id="table-4">Table 4</span> &mdash; Default Attribute Values</figcaption>
- <table class="real-table">
- <tr>
- <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>
- <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>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Value]]</td>
- <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>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000">[[Get]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>undefined</b></td>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Set]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>undefined</b></td>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Writable]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Enumerable]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
- </tr>
- <tr>
- <td style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid #000000; border-top: 1px solid black">[[Configurable]]</td>
- <td style="border-bottom: 1px solid black; border-right: 1px solid black"><b>false</b></td>
- </tr>
- </table>
- </figure>
- </section>
-
- <section id="sec-object-internal-methods-and-internal-slots">
- <h1><span class="secnum" id="sec-6.1.7.2"><a href="#sec-object-internal-methods-and-internal-slots"
- title="link to this section">6.1.7.2</a></span> Object Internal Methods and Internal Slots</h1>
-
- <p>The actual semantics of objects, in ECMAScript, are specified via algorithms called <i>internal methods</i>. Each
- object in an ECMAScript engine is associated with a set of internal methods that defines its runtime behaviour. These
- internal methods are not part of the ECMAScript language. They are defined by this specification purely for expository
- purposes. However, each object within an implementation of ECMAScript must behave as specified by the internal methods
- associated with it. The exact manner in which this is accomplished is determined by the implementation.</p>
-
- <p>Internal method names are polymorphic. This means that different object values may perform different algorithms when a
- common internal method name is invoked upon them. That actual object upon which an internal method is invoked is the
- &ldquo;target&rdquo; of the invocation. If, at runtime, the implementation of an algorithm attempts to use an internal
- method of an object that the object does not support, a <b>TypeError</b> exception is thrown.</p>
-
- <p>Internal slots correspond to internal state that is associated with objects and used by various ECMAScript
- specification algorithms. Internal slots are not object properties and they are not inherited. Depending upon the specific
- internal slot specification, such state may consist of values of any <a href="#sec-ecmascript-language-types">ECMAScript
- language type</a> or of specific ECMAScript specification type values. Unless explicitly specified otherwise, internal
- slots are allocated as part of the process of creating an object and may not be dynamically added to an object. Unless
- specified otherwise, the initial value of an internal slot is the value <span class="value">undefined</span>. Various
- algorithms within this specification create objects that have internal slots. However, the ECMAScript language provides no
- direct way to associate internal slots with an object.</p>
-
- <p>Internal methods and internal slots are identified within this specification using names enclosed in double square
- brackets [[ ]].</p>
-
- <p><a href="#table-5">Table 5</a> summarizes the <i>essential internal methods</i> used by this specification that are
- applicable to all objects created or manipulated by ECMAScript code. Every object must have algorithms for all of the
- essential internal methods. However, all objects do not necessarily use the same algorithms for those methods.</p>
-
- <p>The &ldquo;Signature&rdquo; column of <a href="#table-5">Table 5</a> and other similar tables describes the invocation
- pattern for each internal method. The invocation pattern always includes a parenthesized list of descriptive parameter
- names. If a parameter name is the same as an ECMAScript type name then the name describes the required type of the
- parameter value. If an internal method explicitly returns a value, its parameter list is followed by the symbol
- &ldquo;&rarr;&rdquo; and the type name of the returned value. The type names used in signatures refer to the types defined
- in <a href="#sec-ecmascript-data-types-and-values">clause 6</a> augmented by the following additional names.
- &ldquo;<i>any</i>&rdquo; means the value may be any <a href="#sec-ecmascript-language-types">ECMAScript language type</a>.
- An internal method implicitly returns a <a href="#sec-completion-record-specification-type">Completion Record</a> as
- described in <a href="#sec-completion-record-specification-type">6.2.2</a>. In addition to its parameters, an internal
- method always has access to the object that is the target of the method invocation.</p>
-
- <figure>
- <figcaption><span id="table-5">Table 5</span> &mdash; Essential Internal Methods</figcaption>
- <table class="real-table">
- <tr>
- <th>Internal Method</th>
- <th>Signature</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>[[GetPrototypeOf]]</td>
- <td>() <b><i>&rarr;</i></b> Object or Null</td>
- <td>Determine the object that provides inherited properties for this object. A <b>null</b> value indicates that there are no inherited properties.</td>
- </tr>
- <tr>
- <td>[[SetPrototypeOf]]</td>
- <td>(<i>Object</i> or Null) <b><i>&rarr;</i></b> Boolean</td>
- <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>
- </tr>
- <tr>
- <td>[[IsExtensible]]</td>
- <td>( ) <b><i>&rarr;</i></b> Boolean</td>
- <td>Determine whether it is permitted to add additional properties to this object.</td>
- </tr>
- <tr>
- <td>[[PreventExtensions]]</td>
- <td>( ) <b><i>&rarr;</i></b> Boolean</td>
- <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>
- </tr>
- <tr>
- <td>[[GetOwnProperty]]</td>
- <td>(<i>propertyKey</i>) &rarr; Undefined or <a href="#sec-property-descriptor-specification-type">Property Descriptor</a></td>
- <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>
- </tr>
- <tr>
- <td>[[HasProperty]]</td>
- <td>(<i>propertyKey</i>) <b><i>&rarr;</i></b> Boolean</td>
- <td>Return a Boolean value indicating whether this object already has either an own or inherited property whose key is <i>propertyKey</i>.</td>
- </tr>
- <tr>
- <td>[[Get]]</td>
- <td>(<i>propertyKey</i>, <i>Receiver</i>) <i><b>&rarr;</b> any</i></td>
- <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>
- </tr>
- <tr>
- <td>[[Set]]</td>
- <td>(<i>propertyKey</i>,<i>value</i>, <i>Receiver</i>) <br><i><b>&rarr;</b> Boolean</i></td>
- <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>
- </tr>
- <tr>
- <td>[[Delete]]</td>
- <td>(<i>propertyKey</i>) <b><i>&rarr;</i></b> Boolean</td>
- <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>
- </tr>
- <tr>
- <td>[[DefineOwnProperty]]</td>
- <td>(<i>propertyKey,PropertyDescriptor</i>)<b><i><br>&rarr;</i></b> Boolean</td>
- <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>
- </tr>
- <tr>
- <td>[[Enumerate]]</td>
- <td>()<b><i>&rarr;</i></b>Object</td>
- <td>Return an iterator object that produces the keys of the string-keyed enumerable properties of the object.</td>
- </tr>
- <tr>
- <td>[[OwnPropertyKeys]]</td>
- <td>()<b><i>&rarr;</i></b><a href="#sec-list-and-record-specification-type">List</a> of propertyKey</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p><a href="#table-6">Table 6</a> summarizes additional essential internal methods that are supported by objects that may
- be called as functions. A <i>function object</i> is an object that supports the [[Call]] internal methods. A
- <i>constructor</i> (also referred to as a <i>constructor function</i>) is a function object that supports the
- [[Construct]] internal method.</p>
-
- <figure>
- <figcaption><span id="table-6">Table 6</span> &mdash; Additional Essential Internal Methods of Function Objects</figcaption>
- <table class="real-table">
- <tr>
- <th>Internal Method</th>
- <th>Signature</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>[[Call]]</td>
- <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>
- <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>
- </tr>
- <tr>
- <td>[[Construct]]</td>
- <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>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>The semantics of the essential internal methods for ordinary objects and standard exotic objects are specified in <a
- href="#sec-ordinary-and-exotic-objects-behaviours">clause 9</a>. If any specified use of an internal method of an exotic
- object is not supported by an implementation, that usage must throw a <b>TypeError</b> exception when attempted.</p>
- </section>
-
- <section id="sec-invariants-of-the-essential-internal-methods">
- <h1><span class="secnum" id="sec-6.1.7.3"><a href="#sec-invariants-of-the-essential-internal-methods"
- title="link to this section">6.1.7.3</a></span> Invariants of the Essential Internal Methods</h1>
-
- <p>The Internal Methods of Objects of an ECMAScript engine must conform to the list of invariants specified below.
- Ordinary ECMAScript Objects as well as all standard exotic objects in this specification maintain these invariants.
- ECMAScript Proxy objects maintain these invariants by means of runtime checks on the result of traps invoked on the
- [[ProxyHandler]] object.</p>
-
- <p>Any implementation provided exotic objects must also maintain these invariants for those objects. Violation of these
- invariants may cause ECMAScript code to have unpredictable behaviour and create security issues. However, violation of
- these invariants must never compromise the memory safety of an implementation.</p>
-
- <p>An implementation must not allow these invariants to be circumvented in any manner such as by providing alternative
- interfaces that implement the functionality of the essential internal methods without enforcing their invariants.</p>
-
- <p>Definitions:</p>
-
- <p>&#x25cf;&emsp;The <i>target</i> of an internal method is the object upon which the internal method is called.</p>
-
- <p>&#x25cf;&emsp;A target is <i>non-extensible</i> if it has been observed to return false from its [[IsExtensible]]
- internal method, or true from its [[PreventExtensions]] internal method.</p>
-
- <p>&#x25cf;&emsp;A <i>non-existent</i> property is a property that does not exist as an own property on a non-extensible
- target.</p>
-
- <p>&#x25cf;&emsp;All references to <i><a href="#sec-samevalue">SameValue</a></i> are according to the definition of <a
- href="#sec-samevalue">SameValue</a> algorithm specified in <a href="#sec-samevalue">7.2.9</a>.</p>
-
- <p><b>[[GetPrototypeOf]] ( )</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be either Object or Null.</p>
-
- <p>&#x25cf;&emsp;If target is non-extensible, and [[GetPrototypeOf]] returns a value v, then any future calls to
- [[GetPrototypeOf]] should return the <a href="#sec-samevalue">SameValue</a> as v.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> An object&rsquo;s prototype chain should have finite length (that is, starting from any
- object, recursively applying the [[GetPrototypeOf]] internal method to its result should eventually lead to the value
- null). However, this requirement is not enforceable as an object level invariant if the prototype chain includes any
- exotic objects that do not use the ordinary object definition of [[GetPrototypeOf]]. Such a circular prototype chain may
- result in infinite loops when accessing object properties.</p>
- </div>
-
- <p><b>[[SetPrototypeOf]] (V)</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
-
- <p>&#x25cf;&emsp;If target is non-extensible, [[SetPrototypeOf]] must return false, unless V is the <a
- href="#sec-samevalue">SameValue</a> as the target&rsquo;s observed [[GetPrototypeOf]] value.</p>
-
- <p><b>[[PreventExtensions]] ( )</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
-
- <p>&#x25cf;&emsp;If [[PreventExtensions]] returns true, all future calls to [[IsExtensible]] on the target must return
- false and the target is now considered non-extensible.</p>
-
- <p><b>[[GetOwnProperty]] (P)</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be either <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> or Undefined.</p>
-
- <p>&#x25cf;&emsp;If the Type of the return value is <a href="#sec-property-descriptor-specification-type">Property
- Descriptor</a>, the return value must be a complete property descriptor (<a href="#sec-completepropertydescriptor">see
- 6.2.4.6</a>).</p>
-
- <p>&#x25cf;&emsp;If a property P is described as a data property with Desc.[[Value]] equal to v and Desc.[[Writable]] and
- Desc.[[Configurable]] are both false, then the <a href="#sec-samevalue">SameValue</a> must be returned for the
- Desc.[[Value]] attribute of the property on all future calls to [[GetOwnProperty]] ( P ).</p>
-
- <p>&#x25cf;&emsp;If P&rsquo;s attributes other than [[Writable]] may change over time or if the property might disappear,
- then P&rsquo;s [[Configurable]] attribute must be true.</p>
-
- <p>&#x25cf;&emsp;If the [[Writable]] attribute may change from false to true, then the [[Configurable]] attribute must be
- true.</p>
-
- <p>&#x25cf;&emsp;If the target is non-extensible and P is non-existent, then all future calls to [[GetOwnProperty]] (P)
- on the target must describe P as non-existent (i.e. [[GetOwnProperty]] (P) must return undefined).</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> As a consequence of the third invariant, if a property is described as a data property
- and it may return different values over time, then either or both of the Desc.[[Writable]] and Desc.[[Configurable]]
- attributes must be true even if no mechanism to change the value is exposed via the other internal methods.</p>
- </div>
-
- <p><b>[[DefineOwnProperty]] (P, Desc)</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
-
- <p>&#x25cf;&emsp;[[DefineOwnProperty]] must return false if P has previously been observed as a non-configurable own
- property of the target, unless either:</p>
-
- <p>1.&#x9;P is a non-configurable writable own data property. A non-configurable writable data property can be changed
- into a non-configurable non-writable data property.</p>
-
- <p>2.&#x9;All attributes in Desc are the <a href="#sec-samevalue">SameValue</a> as P&rsquo;s attributes.</p>
-
- <p>&#x25cf;&emsp;[[DefineOwnProperty]] (P, Desc) must return false if target is non-extensible and P is a non-existent own
- property. That is, a non-extensible target object cannot be extended with new properties.</p>
-
- <p><b>[[HasProperty]] ( P )</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
-
- <p>&#x25cf;&emsp;If P was previously observed as a non-configurable data or accessor own property of the target,
- [[HasProperty]] must return true.</p>
-
- <p><b>[[Get]] (P, Receiver)</b></p>
-
- <p>&#x25cf;&emsp;If P was previously observed as a non-configurable, non-writable own data property of the target with
- value v, then [[Get]] must return the <a href="#sec-samevalue">SameValue</a>.</p>
-
- <p>&#x25cf;&emsp;If P was previously observed as a non-configurable own accessor property of the target whose [[Get]]
- attribute is undefined, the [[Get]] operation must return undefined.</p>
-
- <p><b>[[Set]] ( P, V, Receiver)</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
-
- <p>&#x25cf;&emsp;If P was previously observed as a non-configurable, non-writable own data property of the target, then
- [[Set]] must return false unless V is the <a href="#sec-samevalue">SameValue</a> as P&rsquo;s [[Value]] attribute.</p>
-
- <p>&#x25cf;&emsp;If P was previously observed as a non-configurable own accessor property of the target whose [[Set]]
- attribute is undefined, the [[Set]] operation must return false.</p>
-
- <p><b>[[Delete]] ( P )</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be Boolean.</p>
-
- <p>&#x25cf;&emsp;If P was previously observed to be a non-configurable own data or accessor property of the target,
- [[Delete]] must return false.</p>
-
- <p><b>[[Enumerate]] ( )</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be Object.</p>
-
- <p><b>[[OwnPropertyKeys]] ( )</b></p>
-
- <p>&#x25cf;&emsp;The return value must be a <a href="#sec-list-and-record-specification-type">List</a>.</p>
-
- <p>&#x25cf;&emsp; The Type of each element of the returned <a href="#sec-list-and-record-specification-type">List</a> is
- either String or Symbol.</p>
-
- <p>&#x25cf;&emsp;The returned <a href="#sec-list-and-record-specification-type">List</a> must contain at least the keys of
- all non-configurable own properties that have previously been observed.</p>
-
- <p>&#x25cf;&emsp;If the object is non-extensible, the returned <a href="#sec-list-and-record-specification-type">List</a>
- must contain only the keys of all own properties of the object that are observable using [[GetOwnProperty]].</p>
-
- <p><b>[[Construct]] ( )</b></p>
-
- <p>&#x25cf;&emsp;The Type of the return value must be Object.</p>
- </section>
-
- <section id="sec-well-known-intrinsic-objects">
- <h1><span class="secnum" id="sec-6.1.7.4"><a href="#sec-well-known-intrinsic-objects"
- title="link to this section">6.1.7.4</a></span> Well-Known Intrinsic Objects</h1>
-
- <p>Well-known intrinsics are built-in objects that are explicitly referenced by the algorithms of this specification and
- which usually have <a href="#sec-code-realms">Realm</a> specific identities. Unless otherwise specified each intrinsic
- object actually corresponds to a set of similar objects, one per <a href="#sec-code-realms">Realm</a>.</p>
-
- <p>Within this specification a reference such as %name% means the intrinsic object, associated with <a
- href="#sec-execution-contexts">the current Realm</a>, corresponding to the name. Determination of <a
- href="#sec-execution-contexts">the current Realm</a> and its intrinsics is described in <a
- href="#sec-newglobalenvironment">8.1.2.5</a>. The well-known intrinsics are listed in <a href="#table-7">Table 7</a>.</p>
-
- <figure>
- <figcaption><span id="table-7">Table 7</span> &mdash; Well-known Intrinsic Objects</figcaption>
- <table class="real-table">
- <tr>
- <th>Intrinsic Name</th>
- <th>Global Name</th>
- <th>ECMAScript Language Association</th>
- </tr>
- <tr>
- <td>%Array%</td>
- <td><code>Array</code></td>
- <td>The <code>Array</code> constructor (<a href="#sec-array-constructor">22.1.1</a>)</td>
- </tr>
- <tr>
- <td>%ArrayBuffer%</td>
- <td><code>ArrayBuffer</code></td>
- <td>The <code>ArrayBuffer</code> constructor (<a href="#sec-arraybuffer-constructor">24.1.2</a>)</td>
- </tr>
- <tr>
- <td>%ArrayBufferPrototype%</td>
- <td><code><a href="#sec-arraybuffer.prototype">ArrayBuffer.prototype</a></code></td>
- <td>The initial value of the <code>prototype</code> data property of %ArrayBuffer%.</td>
- </tr>
- <tr>
- <td>%ArrayIteratorPrototype%</td>
- <td></td>
- <td>The prototype of Array iterator objects (<a href="#sec-array-iterator-objects">22.1.5</a>)</td>
- </tr>
- <tr>
- <td>%ArrayPrototype%</td>
- <td><code>Array.prototype</code></td>
- <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>
- </tr>
- <tr>
- <td>%ArrayProto_values%</td>
- <td><code><a href="#sec-array.prototype.values">Array.prototype.values</a></code></td>
- <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>
- </tr>
- <tr>
- <td>%Boolean%</td>
- <td><code>Boolean</code></td>
- <td>The <code>Boolean</code> constructor (<a href="#sec-boolean-constructor">19.3.1</a>)</td>
- </tr>
- <tr>
- <td>%BooleanPrototype%</td>
- <td><code>Boolean.prototype</code></td>
- <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>
- </tr>
- <tr>
- <td>%DataView%</td>
- <td><code>DataView</code></td>
- <td>The <code>DataView</code> constructor (<a href="#sec-dataview-constructor">24.2.2</a>)</td>
- </tr>
- <tr>
- <td>%DataViewPrototype%</td>
- <td><code><a href="#sec-dataview.prototype">DataView.prototype</a></code></td>
- <td>The initial value of the <code>prototype</code> data property of %DataView%</td>
- </tr>
- <tr>
- <td>%Date%</td>
- <td><code>Date</code></td>
- <td>The <code>Date</code> constructor (<a href="#sec-date-constructor">20.3.2</a>)</td>
- </tr>
- <tr>
- <td>%DatePrototype%</td>
- <td><code>Date.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Date%.</td>
- </tr>
- <tr>
- <td>%decodeURI%</td>
- <td><code>decodeURI</code></td>
- <td>The <code>decodeURI</code> function (<a href="#sec-decodeuri-encodeduri">18.2.6.2</a>)</td>
- </tr>
- <tr>
- <td>%decodeURIComponent%</td>
- <td><code>decodeURIComponent</code></td>
- <td>The <code>decodeURIComponent</code> function (<a href="#sec-decodeuricomponent-encodeduricomponent">18.2.6.3</a>)</td>
- </tr>
- <tr>
- <td>%encodeURI%</td>
- <td><code>encodeURI</code></td>
- <td>The <code>encodeURI</code> function (<a href="#sec-encodeuri-uri">18.2.6.4</a>)</td>
- </tr>
- <tr>
- <td>%encodeURIComponent%</td>
- <td><code>encodeURIComponent</code></td>
- <td>The <code>encodeURIComponent</code> function (<a href="#sec-encodeuricomponent-uricomponent">18.2.6.5</a>)</td>
- </tr>
- <tr>
- <td>%Error%</td>
- <td><code>Error</code></td>
- <td>The <code>Error</code> constructor (<a href="#sec-error-constructor">19.5.1</a>)</td>
- </tr>
- <tr>
- <td>%ErrorPrototype%</td>
- <td><code>Error.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Error%</td>
- </tr>
- <tr>
- <td>%eval%</td>
- <td><code>eval</code></td>
- <td>The <code>eval</code> function (<a href="#sec-eval-x">18.2.1</a>)</td>
- </tr>
- <tr>
- <td>%EvalError%</td>
- <td><code>EvalError</code></td>
- <td>The <code>EvalError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-evalerror">19.5.5.1</a>)</td>
- </tr>
- <tr>
- <td>%EvalErrorPrototype%</td>
- <td><code>EvalError.prototype</code></td>
- <td>The initial value of the <code>prototype</code> property of %EvalError%</td>
- </tr>
- <tr>
- <td>%Float32Array%</td>
- <td><code><a href="#sec-float32array">Float32Array</a></code></td>
- <td>The <code><a href="#sec-float32array">Float32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Float32ArrayPrototype%</td>
- <td><code>Float32Array.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Float32Array%.</td>
- </tr>
- <tr>
- <td>%Float64Array%</td>
- <td><code><a href="#sec-float64array">Float64Array</a></code></td>
- <td>The <code><a href="#sec-float64array">Float64Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Float64ArrayPrototype%</td>
- <td><code>Float64Array.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Float64Array%</td>
- </tr>
- <tr>
- <td>%Function%</td>
- <td><code>Function</code></td>
- <td>The <code>Function</code> constructor (<a href="#sec-function-constructor">19.2.1</a>)</td>
- </tr>
- <tr>
- <td>%FunctionPrototype%</td>
- <td><code>Function.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Function%</td>
- </tr>
- <tr>
- <td>%Generator%</td>
- <td></td>
- <td>The initial value of the <code>prototype</code> property of %GeneratorFunction%</td>
- </tr>
- <tr>
- <td>%GeneratorFunction%</td>
- <td></td>
- <td>The constructor of generator objects (<a href="#sec-generatorfunction-constructor">25.2.1</a>)</td>
- </tr>
- <tr>
- <td>%GeneratorPrototype%</td>
- <td></td>
- <td>The initial value of the <code>prototype</code> property of %Generator%</td>
- </tr>
- <tr>
- <td>%Int8Array%</td>
- <td><code><a href="#sec-int8array">Int8Array</a></code></td>
- <td>The <code><a href="#sec-int8array">Int8Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Int8ArrayPrototype%</td>
- <td><code>Int8Array.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Int8Array%</td>
- </tr>
- <tr>
- <td>%Int16Array%</td>
- <td><code><a href="#sec-int16array">Int16Array</a></code></td>
- <td>The <code><a href="#sec-int16array">Int16Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Int16ArrayPrototype%</td>
- <td><code>Int16Array.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Int16Array%</td>
- </tr>
- <tr>
- <td>%Int32Array%</td>
- <td><code><a href="#sec-int32array">Int32Array</a></code></td>
- <td>The <code><a href="#sec-int32array">Int32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Int32ArrayPrototype%</td>
- <td><code>Int32Array.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Int32Array%</td>
- </tr>
- <tr>
- <td>%isFinite%</td>
- <td><code>isFinite</code></td>
- <td>The <code>isFinite</code> function (<a href="#sec-isfinite-number">18.2.2</a>)</td>
- </tr>
- <tr>
- <td>%isNaN%</td>
- <td><code>isNaN</code></td>
- <td>The <code>isNaN</code> function (<a href="#sec-isnan-number">18.2.3</a>)</td>
- </tr>
- <tr>
- <td>%IteratorPrototype%</td>
- <td></td>
- <td>An object that all standard built-in iterator objects indirectly inherit from</td>
- </tr>
- <tr>
- <td>%JSON%</td>
- <td><code>JSON</code></td>
- <td>The <code>JSON</code> object (<a href="#sec-json-object">24.3</a>)</td>
- </tr>
- <tr>
- <td>%Map%</td>
- <td><code>Map</code></td>
- <td>The <code>Map</code> constructor (<a href="#sec-map-constructor">23.1.1</a>)</td>
- </tr>
- <tr>
- <td>%MapIteratorPrototype%</td>
- <td></td>
- <td>The prototype of Map iterator objects (<a href="#sec-map-iterator-objects">23.1.5</a>)</td>
- </tr>
- <tr>
- <td>%MapPrototype%</td>
- <td><code>Map.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Map%</td>
- </tr>
- <tr>
- <td>%Math%</td>
- <td><code>Math</code></td>
- <td>The <code>Math</code> object (<a href="#sec-math-object">20.2</a>)</td>
- </tr>
- <tr>
- <td>%Number%</td>
- <td><code>Number</code></td>
- <td>The <code>Number</code> constructor (<a href="#sec-number-constructor">20.1.1</a>)</td>
- </tr>
- <tr>
- <td>%NumberPrototype%</td>
- <td><code>Number.prototype</code></td>
- <td>The initial value of the <code>prototype</code> property of %Number%</td>
- </tr>
- <tr>
- <td>%Object%</td>
- <td><code>Object</code></td>
- <td>The <code>Object</code> constructor (<a href="#sec-object-constructor">19.1.1</a>)</td>
- </tr>
- <tr>
- <td>%ObjectPrototype%</td>
- <td><code>Object.prototype</code></td>
- <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>
- </tr>
- <tr>
- <td>%ObjProto_toString%</td>
- <td><code>Object.prototype.<br>toString</code></td>
- <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>
- </tr>
- <tr>
- <td>%parseFloat%</td>
- <td><code>parseFloat</code></td>
- <td>The <code>parseFloat</code> function (<a href="#sec-parsefloat-string">18.2.4</a>)</td>
- </tr>
- <tr>
- <td>%parseInt%</td>
- <td><code>parseInt</code></td>
- <td>The <code>parseInt</code> function (<a href="#sec-parseint-string-radix">18.2.5</a>)</td>
- </tr>
- <tr>
- <td>%Promise%</td>
- <td><code>Promise</code></td>
- <td>The <code>Promise</code> constructor (<a href="#sec-promise-constructor">25.4.3</a>)</td>
- </tr>
- <tr>
- <td>%PromisePrototype%</td>
- <td><code>Promise.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Promise%</td>
- </tr>
- <tr>
- <td>%Proxy%</td>
- <td><code>Proxy</code></td>
- <td>The <code>Proxy</code> constructor (<a href="#sec-proxy-constructor">26.2.1</a>)</td>
- </tr>
- <tr>
- <td>%RangeError%</td>
- <td><code>RangeError</code></td>
- <td>The <code>RangeError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-rangeerror">19.5.5.2</a>)</td>
- </tr>
- <tr>
- <td>%RangeErrorPrototype%</td>
- <td><code>RangeError.prototype</code></td>
- <td>The initial value of the <code>prototype</code> property of %RangeError%</td>
- </tr>
- <tr>
- <td>%ReferenceError%</td>
- <td><code>ReferenceError</code></td>
- <td>The <code>ReferenceError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-referenceerror">19.5.5.3</a>)</td>
- </tr>
- <tr>
- <td>%ReferenceErrorPrototype%</td>
- <td><code>ReferenceError.<br>prototype</code></td>
- <td>The initial value of the <code>prototype</code> property of %ReferenceError%</td>
- </tr>
- <tr>
- <td>%Reflect%</td>
- <td><code>Reflect</code></td>
- <td>The <code>Reflect</code> object (<a href="#sec-reflect-object">26.1</a>)</td>
- </tr>
- <tr>
- <td>%RegExp%</td>
- <td><code>RegExp</code></td>
- <td>The <code>RegExp</code> constructor (<a href="#sec-regexp-constructor">21.2.3</a>)</td>
- </tr>
- <tr>
- <td>%RegExpPrototype%</td>
- <td><code><a href="#sec-regexp.prototype">RegExp.prototype</a></code></td>
- <td>The initial value of the <code>prototype</code> data property of %RegExp%</td>
- </tr>
- <tr>
- <td>%Set%</td>
- <td><code>Set</code></td>
- <td>The <code>Set</code> constructor (<a href="#sec-set-constructor">23.2.1</a>)</td>
- </tr>
- <tr>
- <td>%SetIteratorPrototype%</td>
- <td></td>
- <td>The prototype of Set iterator objects (<a href="#sec-set-iterator-objects">23.2.5</a>)</td>
- </tr>
- <tr>
- <td>%SetPrototype%</td>
- <td><code>Set.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Set%</td>
- </tr>
- <tr>
- <td>%String%</td>
- <td><code>String</code></td>
- <td>The <code>String</code> constructor (<a href="#sec-string-constructor">21.1.1</a>)</td>
- </tr>
- <tr>
- <td>%StringIteratorPrototype%</td>
- <td></td>
- <td>The prototype of String iterator objects (<a href="#sec-string-iterator-objects">21.1.5</a>)</td>
- </tr>
- <tr>
- <td>%StringPrototype%</td>
- <td><code>String.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %String%</td>
- </tr>
- <tr>
- <td>%Symbol%</td>
- <td><code>Symbol</code></td>
- <td>The <code>Symbol</code> constructor (<a href="#sec-symbol-constructor">19.4.1</a>)</td>
- </tr>
- <tr>
- <td>%SymbolPrototype%</td>
- <td><code>Symbol.prototype</code></td>
- <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>
- </tr>
- <tr>
- <td>%SyntaxError%</td>
- <td><code>SyntaxError</code></td>
- <td>The <code>SyntaxError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-syntaxerror">19.5.5.4</a>)</td>
- </tr>
- <tr>
- <td>%SyntaxErrorPrototype%</td>
- <td><code>SyntaxError.prototype</code></td>
- <td>The initial value of the <code>prototype</code> property of %SyntaxError%</td>
- </tr>
- <tr>
- <td><a href="#sec-%throwtypeerror%">%ThrowTypeError%</a></td>
- <td></td>
- <td>A function object that unconditionally throws a new instance of %TypeError%</td>
- </tr>
- <tr>
- <td>%TypedArray%</td>
- <td></td>
- <td>The super class of all typed Array constructors (<a href="#sec-%typedarray%-intrinsic-object">22.2.1</a>)</td>
- </tr>
- <tr>
- <td>%TypedArrayPrototype%</td>
- <td></td>
- <td>The initial value of the <code>prototype</code> property of %TypedArray%</td>
- </tr>
- <tr>
- <td>%TypeError%</td>
- <td><code>TypeError</code></td>
- <td>The <code>TypeError</code> constructor (<a href="#sec-native-error-types-used-in-this-standard-typeerror">19.5.5.5</a>)</td>
- </tr>
- <tr>
- <td>%TypeErrorPrototype%</td>
- <td><code>TypeError.prototype</code></td>
- <td>The initial value of the <code>prototype</code> property of %TypeError%</td>
- </tr>
- <tr>
- <td>%Uint8Array%</td>
- <td><code><a href="#sec-uint8array">Uint8Array</a></code></td>
- <td>The <code><a href="#sec-uint8array">Uint8Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Uint8ArrayPrototype%</td>
- <td><code>Uint8Array.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Uint8Array%</td>
- </tr>
- <tr>
- <td>%Uint8ClampedArray%</td>
- <td><code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a></code></td>
- <td>The <code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Uint8ClampedArrayPrototype%</td>
- <td><code><a href="#sec-uint8clampedarray">Uint8ClampedArray</a>.<br>prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Uint8ClampedArray%</td>
- </tr>
- <tr>
- <td>%Uint16Array%</td>
- <td><code><a href="#sec-uint16array">Uint16Array</a></code></td>
- <td>The <code><a href="#sec-uint16array">Uint16Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Uint16ArrayPrototype%</td>
- <td><code>Uint16Array.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Uint16Array%</td>
- </tr>
- <tr>
- <td>%Uint32Array%</td>
- <td><code><a href="#sec-uint32array">Uint32Array</a></code></td>
- <td>The <code><a href="#sec-uint32array">Uint32Array</a></code> constructor (<a href="#sec-typedarray-objects">22.2</a>)</td>
- </tr>
- <tr>
- <td>%Uint32ArrayPrototype%</td>
- <td><code>Uint32Array.prototype</code></td>
- <td>The initial value of the <code>prototype</code> data property of %Uint32Array%</td>
- </tr>
- <tr>
- <td>%URIError%</td>
- <td><code><a href="#sec-constructor-properties-of-the-global-object-urierror">URIError</a></code></td>
- <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>
- </tr>
- <tr>
- <td>%URIErrorPrototype%</td>
- <td><code>URIError.prototype</code></td>
- <td>The initial value of the <code>prototype</code> property of %URIError%</td>
- </tr>
- <tr>
- <td>%WeakMap%</td>
- <td><code>WeakMap</code></td>
- <td>The <code>WeakMap</code> constructor (<a href="#sec-weakmap-constructor">23.3.1</a>)</td>
- </tr>
- <tr>
- <td>%WeakMapPrototype%</td>
- <td><code><a href="#sec-weakmap.prototype">WeakMap.prototype</a></code></td>
- <td>The initial value of the <code>prototype</code> data property of %WeakMap%</td>
- </tr>
- <tr>
- <td>%WeakSet%</td>
- <td><code>WeakSet</code></td>
- <td>The <code>WeakSet</code> constructor (<a href="#sec-weakset-constructor">23.4.1</a>)</td>
- </tr>
- <tr>
- <td>%WeakSetPrototype%</td>
- <td><code><a href="#sec-weakset.prototype">WeakSet.prototype</a></code></td>
- <td>The initial value of the <code>prototype</code> data property of %WeakSet%</td>
- </tr>
- </table>
- </figure>
- </section>
- </section>
- </section>
-
- <section id="sec-ecmascript-specification-types">
- <div class="front">
- <h1><span class="secnum" id="sec-6.2"><a href="#sec-ecmascript-specification-types"
- title="link to this section">6.2</a></span> ECMAScript Specification Types</h1>
-
- <p>A specification type corresponds to meta-values that are used within algorithms to describe the semantics of ECMAScript
- language constructs and ECMAScript language types. The specification types are <a
- href="#sec-reference-specification-type">Reference</a>, <a href="#sec-list-and-record-specification-type">List</a>, <a
- href="#sec-completion-record-specification-type">Completion</a>, <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a>, <a href="#sec-lexical-environments">Lexical
- Environment</a>, <a href="#sec-environment-records">Environment Record</a>, and <a href="#sec-data-blocks">Data Block</a>.
- Specification type values are specification artefacts that do not necessarily correspond to any specific entity within an
- ECMAScript implementation. Specification type values may be used to describe intermediate results of ECMAScript expression
- evaluation but such values cannot be stored as properties of objects or values of ECMAScript language variables.</p>
- </div>
-
- <section id="sec-list-and-record-specification-type">
- <h1><span class="secnum" id="sec-6.2.1"><a href="#sec-list-and-record-specification-type"
- title="link to this section">6.2.1</a></span> The List and Record Specification Type</h1>
-
- <p>The List type is used to explain the evaluation of argument lists (<a href="#sec-argument-lists">see 12.3.6</a>) in
- <code>new</code> expressions, in function calls, and in other algorithms where a simple ordered list of values is needed.
- Values of the List type are simply ordered sequences of list elements containing the individual values. These sequences may
- be of any length. The elements of a list may be randomly accessed using 0-origin indices. For notational convenience an
- array-like syntax can be used to access List elements. For example, <i>arguments</i>[2] is shorthand for saying the
- 3<sup>rd</sup> element of the List <i>arguments</i>.</p>
-
- <p>For notational convenience within this specification, a literal syntax can be used to express a new List value. For
- example, &laquo;1, 2&raquo; defines a List value that has two elements each of which is initialized to a specific value. A
- new empty List can be expressed as &laquo;&raquo;.</p>
-
- <p>The Record type is used to describe data aggregations within the algorithms of this specification. A Record type value
- consists of one or more named fields. The value of each field is either an ECMAScript value or an abstract value represented
- by a name associated with the Record type. Field names are always enclosed in double brackets, for example [[value]].</p>
-
- <p>For notational convenience within this specification, an object literal-like syntax can be used to express a Record
- value. For example, {[[field1]]: 42, [[field2]]: <b>false</b>, [[field3]]: <b>empty</b>} defines a Record value that has
- three fields, each of which is initialized to a specific value. Field name order is not significant. Any fields that are not
- explicitly listed are considered to be absent.</p>
-
- <p>In specification text and algorithms, dot notation may be used to refer to a specific field of a Record value. For
- example, if R is the record shown in the previous paragraph then R.[[field2]] is shorthand for &ldquo;the field of R named
- [[field2]]&rdquo;.</p>
-
- <p>Schema for commonly used Record field combinations may be named, and that name may be used as a prefix to a literal
- Record value to identify the specific kind of aggregations that is being described. For example:
- PropertyDescriptor{[[Value]]: 42, [[Writable]]: <b>false</b>, [[Configurable]]: <b>true</b>}.</p>
- </section>
-
- <section id="sec-completion-record-specification-type">
- <div class="front">
- <h1><span class="secnum" id="sec-6.2.2"><a href="#sec-completion-record-specification-type"
- title="link to this section">6.2.2</a></span> The Completion Record Specification Type</h1>
-
- <p>The Completion type is a Record used to explain the runtime propagation of values and control flow such as the
- behaviour of statements (<code>break</code>, <code>continue</code>, <code>return</code> and <code>throw</code>) that
- perform nonlocal transfers of control.</p>
-
- <p>Values of the Completion type are Record values whose fields are defined as by <a href="#table-8">Table 8</a>.</p>
-
- <figure>
- <figcaption><span id="table-8">Table 8</span> &mdash; Completion Record Fields</figcaption>
- <table class="real-table">
- <tr>
- <th>Field</th>
- <th>Value</th>
- <th>Meaning</th>
- </tr>
- <tr>
- <td>[[type]]</td>
- <td>One of <b>normal</b>, <b>break</b>, <b>continue</b>, <b>return</b>, or <b>throw</b></td>
- <td>The type of completion that occurred.</td>
- </tr>
- <tr>
- <td>[[value]]</td>
- <td>any <a href="#sec-ecmascript-language-types">ECMAScript language value</a> or <b>empty</b></td>
- <td>The value that was produced.</td>
- </tr>
- <tr>
- <td>[[target]]</td>
- <td>any ECMAScript string or <b>empty</b></td>
- <td>The target label for directed control transfers.</td>
- </tr>
- </table>
- </figure>
-
- <p>The term &ldquo;abrupt completion&rdquo; refers to any completion with a <span style="font-family: Times New
- Roman">[[type]]</span> value other than <b>normal</b>.</p>
- </div>
-
- <section id="sec-normalcompletion">
- <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>
- NormalCompletion</h1>
-
- <p>The abstract operation NormalCompletion with a single <i>argument</i>, such as:</p>
-
- <ol class="proc">
- <li>Return NormalCompletion(<i>argument</i>).</li>
- </ol>
-
- <p>Is a shorthand that is defined as follows:</p>
-
- <ol class="proc">
- <li>Return <a href="#sec-completion-record-specification-type">Completion</a>{[[type]]: <span style="font-family:
- sans-serif">normal</span>, [[value]]: <i>argument</i>, [[target]]:<span style="font-family:
- sans-serif">empty</span>}.</li>
- </ol>
- </section>
-
- <section id="sec-implicit-completion-values">
- <h1><span class="secnum" id="sec-6.2.2.2"><a href="#sec-implicit-completion-values"
- title="link to this section">6.2.2.2</a></span> Implicit Completion Values</h1>
-
- <p>The algorithms of this specification often implicitly return <a
- href="#sec-completion-record-specification-type">Completion</a> Records whose [[type]] is <b>normal</b>. Unless it is
- otherwise obvious from the context, an algorithm statement that returns a value that is not a <a
- href="#sec-completion-record-specification-type">Completion Record</a>, such as:</p>
-
- <ol class="proc">
- <li>Return <code>"Infinity"</code>.</li>
- </ol>
-
- <p>means the same thing as:</p>
-
- <ol class="proc">
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<code>"Infinity"</code>).</li>
- </ol>
-
- <p>However, if the value expression of a &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement
- is a <a href="#sec-completion-record-specification-type">Completion Record</a> construction literal, the resulting <a
- href="#sec-completion-record-specification-type">Completion Record</a> is returned. If the value expression is a call to
- an abstract operation, the &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement simply returns
- the <a href="#sec-completion-record-specification-type">Completion Record</a> produced by the abstract operation.</p>
-
- <p>The abstract operation <span style="font-family: Times New Roman"><a
- href="#sec-completion-record-specification-type">Completion</a>(<i>completionRecord</i>)</span> is used to emphasize that
- a previously computed <a href="#sec-completion-record-specification-type">Completion Record</a> is being returned. The <a
- href="#sec-completion-record-specification-type">Completion</a> abstract operation takes a single argument,
- <var>completionRecord</var>, and performs the following steps: such as</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>completionRecord</i> is a <a
- href="#sec-completion-record-specification-type">Completion Record</a>.</li>
- <li>Return <i>completionRecord</i> as the <a href="#sec-completion-record-specification-type">Completion Record</a> of
- this abstract operation.</li>
- </ol>
-
- <p>A &ldquo;<span style="font-family: Times New Roman">return</span>&rdquo; statement without a value in an algorithm step
- means the same thing as:</p>
-
- <ol class="proc">
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- </ol>
-
- <p>Any reference to a <a href="#sec-completion-record-specification-type">Completion Record</a> value that is in a context
- that does not explicitly require a complete <a href="#sec-completion-record-specification-type">Completion Record</a>
- value is equivalent to an explicit reference to the [[value]] field of the <a
- href="#sec-completion-record-specification-type">Completion Record</a> value unless the <a
- href="#sec-completion-record-specification-type">Completion Record</a> is an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</p>
- </section>
-
- <section id="sec-throw-an-exception">
- <h1><span class="secnum" id="sec-6.2.2.3"><a href="#sec-throw-an-exception"
- title="link to this section">6.2.2.3</a></span> Throw an Exception</h1>
-
- <p>Algorithms steps that say to throw an exception, such as</p>
-
- <ol class="proc">
- <li>Throw a <b>TypeError</b> exception.</li>
- </ol>
-
- <p>mean the same things as:</p>
-
- <ol class="proc">
- <li>Return <a href="#sec-completion-record-specification-type">Completion</a>{[[type]]: <span style="font-family:
- sans-serif">throw</span>, [[value]]: a newly created <b>TypeError</b> object, [[target]]:<span style="font-family:
- sans-serif">empty</span>}.</li>
- </ol>
- </section>
-
- <section id="sec-returnifabrupt">
- <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>
- ReturnIfAbrupt</h1>
-
- <p>Algorithms steps that say</p>
-
- <ol class="proc">
- <li>ReturnIfAbrupt(<i>argument</i>).</li>
- </ol>
-
- <p>mean the same thing as:</p>
-
- <ol class="proc">
- <li>If <i>argument</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, return
- <i>argument</i>.</li>
- <li>Else if <i>argument</i> is a <a href="#sec-completion-record-specification-type">Completion Record</a>, let
- <i>argument</i> be <i>argument</i>.[[value]].</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-reference-specification-type">
- <div class="front">
- <h1><span class="secnum" id="sec-6.2.3"><a href="#sec-reference-specification-type"
- title="link to this section">6.2.3</a></span> The Reference Specification Type</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The Reference type is used to explain the behaviour of such operators as
- <code>delete</code>, <code>typeof</code>, the assignment operators, the <code>super</code> keyword and other language
- features. For example, the left-hand operand of an assignment is expected to produce a reference.</p>
- </div>
-
- <p>A <b>Reference</b> is a resolved name or property binding. A Reference consists of three components, the
- <var>base</var> value, the <var>referenced name</var> and the Boolean valued <var>strict reference</var> flag. The
- <var>base</var> value is either <b>undefined</b>, an Object, a Boolean, a String, a Symbol, a Number, or an <a
- href="#sec-environment-records">Environment Record</a> (<a href="#sec-environment-records">8.1.1</a>). A <var>base</var>
- value of <b>undefined</b> indicates that the Reference could not be resolved to a binding. The <var>referenced name</var>
- is a String or Symbol value.</p>
-
- <p>A Super Reference is a Reference that is used to represents a name binding that was expressed using the super keyword.
- A Super Reference has an additional <var>thisValue</var> component and its <var>base</var> value will never be an <a
- href="#sec-environment-records">Environment Record</a>.</p>
-
- <p>The following abstract operations are used in this specification to access the components of references:</p>
-
- <ul>
- <li>
- <p>GetBase(V). Returns the <i>base</i> value component of the reference V.</p>
- </li>
-
- <li>
- <p>GetReferencedName(V). Returns the <i>referenced name</i> component of the reference V.</p>
- </li>
-
- <li>
- <p>IsStrictReference(V). Returns the <i>strict reference</i> flag component of the reference V.</p>
- </li>
-
- <li>
- <p>HasPrimitiveBase(V). Returns <b>true</b> if <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>base</i>)
- is Boolean, String, Symbol, or Number.</p>
- </li>
-
- <li>
- <p>IsPropertyReference(V). Returns <b>true</b> if either the <i>base</i> value is an object or HasPrimitiveBase(V) is
- <b>true</b>; otherwise returns <b>false</b>.</p>
- </li>
-
- <li>
- <p>IsUnresolvableReference(V). Returns <b>true</b> if the <i>base</i> value is <b>undefined</b> and <b>false</b>
- otherwise.</p>
- </li>
-
- <li>
- <p>IsSuperReference(V). Returns <b>true</b> if this reference has a <i>thisValue</i> component.</p>
- </li>
- </ul>
-
- <p>The following abstract operations are used in this specification to operate on references:</p>
- </div>
-
- <section id="sec-getvalue">
- <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
- (V)</h1>
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is not <a
- href="#sec-reference-specification-type">Reference</a>, return <i>V</i>.</li>
- <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
- <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>), throw a <b>ReferenceError</b>
- exception.</li>
- <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>), then
- <ol class="block">
- <li>If <a href="#sec-reference-specification-type">HasPrimitiveBase</a>(<i>V</i>) is <b>true</b>, then
- <ol class="block">
- <li><a href="#sec-algorithm-conventions">Assert</a>: In this case, <i>base</i> will never be <b>null</b> or
- <b>undefined</b>.</li>
- <li>Let <i>base</i> be <a href="#sec-toobject">ToObject</a>(<i>base</i>).</li>
- </ol>
- </li>
- <li>Return <i>base.</i>[[Get]](<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <a
- href="#sec-getthisvalue">GetThisValue</a>(<i>V</i>)).</li>
- </ol>
- </li>
- <li>Else <i>base</i> must be an <a href="#sec-environment-records">Environment Record</a>,
- <ol class="block">
- <li>Return <i>base.</i>GetBindingValue(<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>),
- <a href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>)) (<a
- href="#sec-environment-records">see 8.1.1</a>).</li>
- </ol>
- </li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The object that may be created in step 5.a.ii is not accessible outside of the above
- abstract operation and the ordinary object [[Get]] internal method. An implementation might choose to avoid the actual
- creation of the object.</p>
- </div>
- </section>
-
- <section id="sec-putvalue">
- <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
- (V, W)</h1>
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>W</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is not <a
- href="#sec-reference-specification-type">Reference</a>, throw a <b>ReferenceError</b> exception.</li>
- <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
- <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>), then
- <ol class="block">
- <li>If <a href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>) is <b>true</b>, then
- <ol class="block">
- <li>Throw <b>ReferenceError</b> exception.</li>
- </ol>
- </li>
- <li>Let <i>globalObj</i> be <a href="#sec-getglobalobject">GetGlobalObject</a>().</li>
- <li>Return <a href="#sec-set-o-p-v-throw">Set</a>(<i>globalObj</i>,<a
- href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <b>false</b>).</li>
- </ol>
- </li>
- <li>Else if <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>), then
- <ol class="block">
- <li>If <a href="#sec-reference-specification-type">HasPrimitiveBase</a>(<i>V</i>) is <b>true</b>, then
- <ol class="block">
- <li><a href="#sec-algorithm-conventions">Assert</a>: In this case, <i>base</i> will never be <b>null</b> or
- <b>undefined</b>.</li>
- <li>Set <i>base</i> to <a href="#sec-toobject">ToObject</a>(<i>base</i>).</li>
- </ol>
- </li>
- <li>Let <i>succeeded</i> be <i>base.</i>[[Set]](<a
- href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <a
- href="#sec-getthisvalue">GetThisValue</a>(<i>V</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>succeeded</i>).</li>
- <li>If <i>succeeded</i> is <b>false</b> and <a
- href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>) is <b>true</b>, throw a
- <b>TypeError</b> exception.</li>
- <li>Return.</li>
- </ol>
- </li>
- <li>Else <i>base</i> must be an <a href="#sec-environment-records">Environment Record</a>.
- <ol class="block">
- <li>Return <i>base.</i>SetMutableBinding(<a
- href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>), <i>W</i>, <a
- href="#sec-reference-specification-type">IsStrictReference</a>(<i>V</i>)) (<a
- href="#sec-environment-records">see 8.1.1</a>).</li>
- </ol>
- </li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The object that may be created in step 6.a.ii is not accessible outside of the above
- algorithm and the ordinary object [[Set]] internal method. An implementation might choose to avoid the actual creation
- of that object.</p>
- </div>
- </section>
-
- <section id="sec-getthisvalue">
- <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>
- GetThisValue (V)</h1>
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-reference-specification-type">IsPropertyReference</a>(<i>V</i>) is <b>true</b>.</li>
- <li>If <a href="#sec-reference-specification-type">IsSuperReference</a>(<i>V</i>), then
- <ol class="block">
- <li>Return the value of the <i>thisValue</i> component of the reference <i>V</i>.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
- </ol>
- </section>
-
- <section id="sec-initializereferencedbinding">
- <h1><span class="secnum" id="sec-6.2.3.4"><a href="#sec-initializereferencedbinding"
- title="link to this section">6.2.3.4</a></span> InitializeReferencedBinding (V, W)</h1>
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>V</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>W</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>)
- is <a href="#sec-reference-specification-type">Reference</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>V</i>) is <b>false</b>.</li>
- <li>Let <i>base</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>V</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>base</i> is an <a href="#sec-environment-records">Environment
- Record</a>.</li>
- <li>Return <i>base.</i>InitializeBinding(<a href="#sec-reference-specification-type">GetReferencedName</a>(<i>V</i>),
- <i>W</i>).</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-property-descriptor-specification-type">
- <div class="front">
- <h1><span class="secnum" id="sec-6.2.4"><a href="#sec-property-descriptor-specification-type"
- title="link to this section">6.2.4</a></span> The Property Descriptor Specification Type</h1>
-
- <p>The Property Descriptor type is used to explain the manipulation and reification of Object property attributes. Values
- of the Property Descriptor type are Records. Each field&rsquo;s name is an attribute name and its value is a corresponding
- attribute value as specified in <a href="#sec-property-attributes">6.1.7.1</a>. In addition, any field may be present or
- absent. The schema name used within this specification to tag literal descriptions of Property Descriptor records is
- &ldquo;PropertyDescriptor&rdquo;.</p>
-
- <p>Property Descriptor values may be further classified as data Property Descriptors and accessor Property Descriptors
- based upon the existence or use of certain fields. A data Property Descriptor is one that includes any fields named either
- [[Value]] or [[Writable]]. An accessor Property Descriptor is one that includes any fields named either [[Get]] or
- [[Set]]. Any Property Descriptor may have fields named [[Enumerable]] and [[Configurable]]. A Property Descriptor value
- may not be both a data Property Descriptor and an accessor Property Descriptor; however, it may be neither. A generic
- Property Descriptor is a Property Descriptor value that is neither a data Property Descriptor nor an accessor Property
- Descriptor. A fully populated Property Descriptor is one that is either an accessor Property Descriptor or a data Property
- Descriptor and that has all of the fields that correspond to the property attributes defined in either <a
- href="#table-2">Table 2</a> or <a href="#table-3">Table 3</a>.</p>
-
- <p>The following abstract operations are used in this specification to operate upon Property Descriptor values:</p>
- </div>
-
- <section id="sec-isaccessordescriptor">
- <h1><span class="secnum" id="sec-6.2.4.1"><a href="#sec-isaccessordescriptor"
- title="link to this section">6.2.4.1</a></span> IsAccessorDescriptor ( Desc )</h1>
-
- <p>When the abstract operation IsAccessorDescriptor is called with <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
- <li>If both <i>Desc</i>.[[Get]] and <i>Desc</i>.[[Set]] are absent, return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-isdatadescriptor">
- <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>
- IsDataDescriptor ( Desc )</h1>
-
- <p>When the abstract operation IsDataDescriptor is called with <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
- <li>If both <i>Desc</i>.[[Value]] and <i>Desc</i>.[[Writable]] are absent, return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-isgenericdescriptor">
- <h1><span class="secnum" id="sec-6.2.4.3"><a href="#sec-isgenericdescriptor"
- title="link to this section">6.2.4.3</a></span> IsGenericDescriptor ( Desc )</h1>
-
- <p>When the abstract operation IsGenericDescriptor is called with <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>If <i>Desc</i> is <b>undefined</b>, return <b>false</b>.</li>
- <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) and <a
- href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) are both <b>false</b>, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-frompropertydescriptor">
- <h1><span class="secnum" id="sec-6.2.4.4"><a href="#sec-frompropertydescriptor"
- title="link to this section">6.2.4.4</a></span> FromPropertyDescriptor ( Desc )</h1>
-
- <p>When the abstract operation FromPropertyDescriptor is called with <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span>, the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>If <i>Desc</i> is <b>undefined</b>, return <b>undefined</b>.</li>
- <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
- sans-serif">%ObjectPrototype%</span>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>obj</i> is an extensible ordinary object with no own
- properties.</li>
- <li>If <i>Desc</i> has a [[Value]] field, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
- <code>"value"</code>, <i>Desc</i>.[[Value]]).</li>
- </ol>
- </li>
- <li>If <i>Desc</i> has a [[Writable]] field, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
- <code>"writable"</code>, <i>Desc</i>.[[Writable]]).</li>
- </ol>
- </li>
- <li>If <i>Desc</i> has a [[Get]] field, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
- <code>"get",</code> <i>Desc</i>.[[Get]]).</li>
- </ol>
- </li>
- <li>If <i>Desc</i> has a [[Set]] field, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
- <code>"set"</code>, <i>Desc</i>.[[Set]])</li>
- </ol>
- </li>
- <li>If <i>Desc</i> has an [[Enumerable]] field, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>,
- <code>"enumerable"</code>, <i>Desc</i>.[[Enumerable]]).</li>
- </ol>
- </li>
- <li>If <i>Desc</i> has a [[Configurable]] field, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i> ,
- <code>"configurable"</code>, <i>Desc</i>.[[Configurable]]).</li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: all of the above <a
- href="#sec-createdataproperty">CreateDataProperty</a> operations return <b>true</b>.</li>
- <li>Return <i>obj</i>.</li>
- </ol>
- </section>
-
- <section id="sec-topropertydescriptor">
- <h1><span class="secnum" id="sec-6.2.4.5"><a href="#sec-topropertydescriptor"
- title="link to this section">6.2.4.5</a></span> ToPropertyDescriptor ( Obj )</h1>
-
- <p>When the abstract operation ToPropertyDescriptor is called with object <span class="nt">Obj</span>, the following steps
- are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>Obj</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Obj</i>) is not Object throw a <b>TypeError</b>
- exception.</li>
- <li>Let <i>desc</i> be a new <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> that
- initially has no fields.</li>
- <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"enumerable"</code>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>enum</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
- <code>"enumerable"</code>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>enum</i>).</li>
- <li>Set the [[Enumerable]] field of <i>desc</i> to <i>enum</i>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"configurable"</code>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>conf</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
- <code>"configurable"</code>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>conf</i>).</li>
- <li>Set the [[Configurable]] field of <i>desc</i> to <i>conf</i>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"value"</code>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>value</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"value"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
- <li>Set the [[Value]] field of <i>desc</i> to <i>value</i>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"writable"</code>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>writable</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>Obj</i>,
- <code>"writable"</code>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>writable</i>).</li>
- <li>Set the [[Writable]] field of <i>desc</i> to <i>writable</i>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"get"</code>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>getter</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"get"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>getter</i>).</li>
- <li>If <a href="#sec-iscallable">IsCallable</a>(<i>getter</i>) is <b>false</b> and <i>getter</i> is not
- <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
- <li>Set the [[Get]] field of <i>desc</i> to <i>getter</i>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-hasproperty">HasProperty</a>(<i>Obj</i>, <code>"set"</code>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>setter</i> be <a href="#sec-get-o-p">Get</a>(<i>Obj</i>, <code>"set"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>setter</i>).</li>
- <li>If <a href="#sec-iscallable">IsCallable</a>(<i>setter</i>) is <b>false</b> and <i>setter</i> is not
- <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
- <li>Set the [[Set]] field of <i>desc</i> to <i>setter</i>.</li>
- </ol>
- </li>
- <li>If either <i>desc</i>.[[Get]] or <i>desc</i>.[[Set]] are present, then
- <ol class="block">
- <li>If either <i>desc</i>.[[Value]] or <i>desc</i>.[[Writable]] are present, throw a <b>TypeError</b>
- exception.</li>
- </ol>
- </li>
- <li>Return <i>desc</i>.</li>
- </ol>
- </section>
-
- <section id="sec-completepropertydescriptor">
- <h1><span class="secnum" id="sec-6.2.4.6"><a href="#sec-completepropertydescriptor"
- title="link to this section">6.2.4.6</a></span> CompletePropertyDescriptor ( Desc )</h1>
-
- <p>When the abstract operation CompletePropertyDescriptor is called with <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
- steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>Desc</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>Desc</i> is a <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a></li>
- <li>Let <i>like</i> be Record{[[Value]]: <b>undefined</b>, [[Writable]]: <b>false</b>, [[Get]]: <b>undefined</b>,
- [[Set]]: <b>undefined</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b>}.</li>
- <li>If either <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) or <a
- href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
- <ol class="block">
- <li>If <i>Desc</i> does not have a [[Value]] field, set <i>Desc</i>.[[Value]] to <i>like</i>.[[Value]].</li>
- <li>If <i>Desc</i> does not have a [[Writable]] field, set <i>Desc</i>.[[Writable]] to
- <i>like</i>.[[Writable]].</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>If <i>Desc</i> does not have a [[Get]] field, set <i>Desc</i>.[[Get]] to <i>like</i>.[[Get]].</li>
- <li>If <i>Desc</i> does not have a [[Set]] field, set <i>Desc</i>.[[Set]] to <i>like</i>.[[Set]].</li>
- </ol>
- </li>
- <li>If <i>Desc</i> does not have an [[Enumerable]] field, set <i>Desc</i>.[[Enumerable]] to
- <i>like</i>.[[Enumerable]].</li>
- <li>If <i>Desc</i> does not have a [[Configurable]] field, set <i>Desc</i>.[[Configurable]] to
- <i>like</i>.[[Configurable]].</li>
- <li>Return <i>Desc</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-lexical-environment-and-environment-record-specification-types">
- <h1><span class="secnum" id="sec-6.2.5"><a href="#sec-lexical-environment-and-environment-record-specification-types"
- title="link to this section">6.2.5</a></span> The Lexical Environment and Environment Record Specification Types</h1>
-
- <p>The <a href="#sec-lexical-environments">Lexical Environment</a> and <a href="#sec-environment-records">Environment
- Record</a> types are used to explain the behaviour of name resolution in nested functions and blocks. These types and the
- operations upon them are defined in <a href="#sec-lexical-environments">8.1</a>.</p>
- </section>
-
- <section id="sec-data-blocks">
- <div class="front">
- <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
- Blocks</h1>
-
- <p>The Data Block specification type is used to describe a distinct and mutable sequence of byte-sized (8 bit) numeric
- values. A Data Block value is created with a fixed number of bytes that each have the initial value 0.</p>
-
- <p>For notational convenience within this specification, an array-like syntax can be used to express to the individual
- bytes of a Data Block value. This notation presents a Data Block value as a 0-origined integer indexed sequence of bytes.
- 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
- 3<sup>rd</sup> byte.</p>
-
- <p>The following abstract operations are used in this specification to operate upon Data Block values:</p>
- </div>
-
- <section id="sec-createbytedatablock">
- <h1><span class="secnum" id="sec-6.2.6.1"><a href="#sec-createbytedatablock"
- title="link to this section">6.2.6.1</a></span> CreateByteDataBlock(size)</h1>
-
- <p>When the abstract operation CreateByteDataBlock is called with integer argument <var>size</var>, the following steps
- are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>size</i>&ge;0.</li>
- <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
- impossible to create such a <a href="#sec-data-blocks">Data Block</a>, throw a <b>RangeError</b> exception.</li>
- <li>Set all of the bytes of <i>db</i> to 0.</li>
- <li>Return <i>db</i>.</li>
- </ol>
- </section>
-
- <section id="sec-copydatablockbytes">
- <h1><span class="secnum" id="sec-6.2.6.2"><a href="#sec-copydatablockbytes"
- title="link to this section">6.2.6.2</a></span> CopyDataBlockBytes(toBlock, toIndex, fromBlock, fromIndex, count)</h1>
-
- <p>When the abstract operation CopyDataBlockBytes is called the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromBlock</i> and <i>toBlock</i> are distinct <a
- href="#sec-data-blocks">Data Block</a> values.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromIndex</i>, <i>toIndex</i>, and <i>count</i> are positive
- integer values.</li>
- <li>Let <i>fromSize</i> be the number of bytes in <i>fromBlock</i>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>fromIndex</i>+<i>count</i> &le; <i>fromSize</i>.</li>
- <li>Let <i>toSize</i> be the number of bytes in <i>toBlock</i>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>toIndex</i>+<i>count</i> &le; <i>toSize</i>.</li>
- <li>Repeat, while <i>count</i>&gt;0
- <ol class="block">
- <li>Set <i>toBlock</i>[<i>toIndex</i>] to the value of <i>fromBlock</i>[<i>fromIndex</i>].</li>
- <li>Increment <i>toIndex</i> and <i>fromIndex</i> each by 1.</li>
- <li>Decrement <i>count</i> by 1.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>)</li>
- </ol>
- </section>
- </section>
- </section>
-</section>
-
-<section id="sec-abstract-operations">
- <div class="front">
- <h1><span class="secnum" id="sec-7"><a href="#sec-abstract-operations" title="link to this section">7</a></span> Abstract
- Operations</h1>
-
- <p>These operations are not a part of the ECMAScript language; they are defined here to solely to aid the specification of the
- semantics of the ECMAScript language. Other, more specialized abstract operations are defined throughout this
- specification.</p>
- </div>
-
- <section id="sec-type-conversion">
- <div class="front">
- <h1><span class="secnum" id="sec-7.1"><a href="#sec-type-conversion" title="link to this section">7.1</a></span> Type
- Conversion</h1>
-
- <p>The ECMAScript language implicitly performs automatic type conversion as needed. To clarify the semantics of certain
- constructs it is useful to define a set of conversion abstract operations. The conversion abstract operations are
- polymorphic; they can accept a value of any <a href="#sec-ecmascript-language-types">ECMAScript language type</a> or of a <a
- href="#sec-completion-record-specification-type">Completion Record</a> value. But no other specification types are used with
- these operations.</p>
- </div>
-
- <section id="sec-toprimitive">
- <h1><span class="secnum" id="sec-7.1.1"><a href="#sec-toprimitive" title="link to this section">7.1.1</a></span> ToPrimitive
- ( input [, PreferredType] )</h1>
-
- <p>The abstract operation ToPrimitive takes an <var>input</var> argument and an optional argument <span
- class="nt">PreferredType</span>. The abstract operation ToPrimitive converts its <var>input</var> argument to a non-Object
- type. If an object is capable of converting to more than one primitive type, it may use the optional hint <span
- class="nt">PreferredType</span> to favour that type. Conversion occurs according to <a href="#table-9">Table 9</a>:</p>
-
- <figure>
- <figcaption><span id="table-9">Table 9</span> &mdash; ToPrimitive Conversions</figcaption>
- <table class="real-table">
- <tr>
- <th>Input Type</th>
- <th>Result</th>
- </tr>
- <tr>
- <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
- <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>
- </tr>
- <tr>
- <td>Undefined</td>
- <td>Return <var>input</var>.</td>
- </tr>
- <tr>
- <td>Null</td>
- <td>Return <var>input</var>.</td>
- </tr>
- <tr>
- <td>Boolean</td>
- <td>Return <var>input</var>.</td>
- </tr>
- <tr>
- <td>Number</td>
- <td>Return <var>input</var>.</td>
- </tr>
- <tr>
- <td>String</td>
- <td>Return <var>input</var>.</td>
- </tr>
- <tr>
- <td>Symbol</td>
- <td>Return <var>input</var>.</td>
- </tr>
- <tr>
- <td>Object</td>
- <td>Perform the steps following this table.</td>
- </tr>
- </table>
- </figure>
-
- <p>When <span style="font-family: Times New Roman"><a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>input</i>)</span> is Object, the following steps are taken:</p>
-
- <ol class="proc">
- <li>If <i>PreferredType</i> was not passed, let <i>hint</i> be <code>"default"</code>.</li>
- <li>Else if <i>PreferredType</i> is hint String, let <i>hint</i> be <code>"string"</code>.</li>
- <li>Else <i>PreferredType</i> is hint Number, let <i>hint</i> be <code>"number"</code>.</li>
- <li>Let <i>exoticToPrim</i> be <a href="#sec-getmethod">GetMethod</a>(<i>input</i>, @@toPrimitive).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exoticToPrim</i>).</li>
- <li>If <i>exoticToPrim</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>exoticToPrim</i>, <i>input,</i>
- &laquo;<i>hint</i>&raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, return
- <i>result</i>.</li>
- <li>Throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- <li>If <i>hint</i> is <code>"default"</code>, let <i>hint</i> be <code>"number"</code>.</li>
- <li>Return OrdinaryToPrimitive(<i>input,hint</i>).</li>
- </ol>
-
- <p>When the abstract operation OrdinaryToPrimitive is called with arguments <var>O</var> and <var>hint</var>, the following
- steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>hint</i>)
- is String and its value is either <code>"string"</code> or <code>"number"</code>.</li>
- <li>If <i>hint</i> is <code>"string"</code>, then
- <ol class="block">
- <li>Let <i>methodNames</i> be &laquo;<code>"toString"</code>, <code>"valueOf"</code>&raquo;.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>methodNames</i> be &laquo;<code>"valueOf"</code>, <code>"toString"</code>&raquo;.</li>
- </ol>
- </li>
- <li>For each <i>name</i> in <i>methodNames</i> in <a href="#sec-list-and-record-specification-type">List</a> order, do
- <ol class="block">
- <li>Let <i>method</i> be <a href="#sec-get-o-p">Get</a>(<i>O</i>, <i>name</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>method</i>).</li>
- <li>If <a href="#sec-iscallable">IsCallable</a>(<i>method</i>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>method</i>, <i>O</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, return
- <i>result</i>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Throw a <b>TypeError</b> exception.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> When ToPrimitive is called with no hint, then it generally behaves as if the hint were
- Number. However, objects may over-ride this behaviour by defining a @@toPrimitive method. Of the objects defined in this
- specification only Date objects (<a href="#sec-date.prototype-@@toprimitive">see 20.3.4.45</a>) and Symbol objects (<a
- href="#sec-symbol.prototype-@@toprimitive">see 19.4.3.4</a>) over-ride the default ToPrimitive behaviour. Date objects
- treat no hint as if the hint were String.</p>
- </div>
- </section>
-
- <section id="sec-toboolean">
- <h1><span class="secnum" id="sec-7.1.2"><a href="#sec-toboolean" title="link to this section">7.1.2</a></span> ToBoolean (
- argument )</h1>
-
- <p>The abstract operation ToBoolean converts <var>argument</var> to a value of type Boolean according to <a
- href="#table-10">Table 10</a>:</p>
-
- <figure>
- <figcaption><span id="table-10">Table 10</span> &mdash; ToBoolean Conversions</figcaption>
- <table class="real-table">
- <tr>
- <th>Argument Type</th>
- <th>Result</th>
- </tr>
- <tr>
- <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
- <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>
- </tr>
- <tr>
- <td>Undefined</td>
- <td>Return <b>false</b>.</td>
- </tr>
- <tr>
- <td>Null</td>
- <td>Return <b>false</b>.</td>
- </tr>
- <tr>
- <td>Boolean</td>
- <td>Return <var>argument</var>.</td>
- </tr>
- <tr>
- <td>Number</td>
- <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>
- </tr>
- <tr>
- <td>String</td>
- <td>Return <b>false</b> if <var>argument</var> is the empty String (its length is zero); otherwise return <b>true</b>.</td>
- </tr>
- <tr>
- <td>Symbol</td>
- <td>Return <b>true</b>.</td>
- </tr>
- <tr>
- <td>Object</td>
- <td>Return <b>true</b>.</td>
- </tr>
- </table>
- </figure>
- </section>
-
- <section id="sec-tonumber">
- <div class="front">
- <h1><span class="secnum" id="sec-7.1.3"><a href="#sec-tonumber" title="link to this section">7.1.3</a></span> ToNumber (
- argument )</h1>
-
- <p>The abstract operation ToNumber converts <var>argument</var> to a value of type Number according to <a
- href="#table-11">Table 11</a>:</p>
-
- <figure>
- <figcaption><span id="table-11">Table 11</span> &mdash; ToNumber Conversions</figcaption>
- <table class="real-table">
- <tr>
- <th>Argument Type</th>
- <th>Result</th>
- </tr>
- <tr>
- <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
- <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>
- </tr>
- <tr>
- <td>Undefined</td>
- <td>Return <b>NaN</b>.</td>
- </tr>
- <tr>
- <td>Null</td>
- <td>Return <b>+0</b>.</td>
- </tr>
- <tr>
- <td>Boolean</td>
- <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>
- </tr>
- <tr>
- <td>Number</td>
- <td>Return <var>argument</var> (no conversion).</td>
- </tr>
- <tr>
- <td>String</td>
- <td>See grammar and conversion algorithm below.</td>
- </tr>
- <tr>
- <td>Symbol</td>
- <td>Throw a <b>TypeError</b> exception.</td>
- </tr>
- <tr>
- <td>Object</td>
-
- <td>
- <p>Apply the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>primValue</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint Number).</li>
- <li>Return ToNumber(<i>primValue</i>).</li>
- </ol>
- </td>
- </tr>
- </table>
- </figure>
- </div>
-
- <section id="sec-tonumber-applied-to-the-string-type">
- <div class="front">
- <h1><span class="secnum" id="sec-7.1.3.1"><a href="#sec-tonumber-applied-to-the-string-type"
- title="link to this section">7.1.3.1</a></span> ToNumber Applied to the String Type</h1>
-
- <p><a href="#sec-tonumber">ToNumber</a> applied to Strings applies the following grammar to the input String interpreted
- as a sequence of UTF-16 encoded code points (<a href="#sec-ecmascript-language-types-string-type">6.1.4</a>). If the
- grammar cannot interpret the String as an expansion of <span class="nt">StringNumericLiteral</span>, then the result of
- <a href="#sec-tonumber">ToNumber</a> is <b>NaN</b>.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The terminal symbols of this grammar are all composed of Unicode BMP code points so
- the result will be <b>NaN</b> if the string contains the UTF-16 encoding of any supplementary code points or any
- unpaired surrogate code points</p>
- </div>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StrWhiteSpace</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">StrWhiteSpaceChar</span> <span class="nt">StrWhiteSpace</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StrWhiteSpaceChar</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">WhiteSpace</span></div>
- <div class="rhs"><span class="nt">LineTerminator</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">StrDecimalLiteral</span></div>
- <div class="rhs"><span class="nt">BinaryIntegerLiteral</span></div>
- <div class="rhs"><span class="nt">OctalIntegerLiteral</span></div>
- <div class="rhs"><span class="nt">HexIntegerLiteral</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">StrUnsignedDecimalLiteral</span></div>
- <div class="rhs"><code class="t">+</code> <span class="nt">StrUnsignedDecimalLiteral</span></div>
- <div class="rhs"><code class="t">-</code> <span class="nt">StrUnsignedDecimalLiteral</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">Infinity</span></div>
- <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>
- <div class="rhs"><code class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
- <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">DecimalDigit</span></div>
- <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">:::</span> <span class="grhsmod">one of</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ExponentPart</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ExponentIndicator</span> <span class="geq">:::</span> <span class="grhsmod">one of</span></div>
- <div class="rhs"><code class="t">e</code> <code class="t">E</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SignedInteger</span> <span class="geq">:::</span></div>
- <div class="rhs"><span class="nt">DecimalDigits</span></div>
- <div class="rhs"><code class="t">+</code> <span class="nt">DecimalDigits</span></div>
- <div class="rhs"><code class="t">-</code> <span class="nt">DecimalDigits</span></div>
- </div>
-
- <p>All grammar symbols not explicitly defined above have the definitions used in the Lexical Grammar for numeric
- literals (<a href="#sec-literals-numeric-literals">11.8.3</a>)</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Some differences should be noted between the syntax of a <i>StringNumericLiteral</i>
- and a <i>NumericLiteral</i> (<a href="#sec-literals-numeric-literals">see 11.8.3</a>):</p>
-
- <ul>
- <li>
- <p>A <i>StringNumericLiteral</i> may include leading and/or trailing white space and/or line terminators.</p>
- </li>
-
- <li>
- <p>A <i>StringNumericLiteral</i> that is decimal may have any number of leading <code>0</code> digits.</p>
- </li>
-
- <li>
- <p>A <i>StringNumericLiteral</i> that is decimal may include a <code>+</code> or <code>-</code> to indicate its
- sign.</p>
- </li>
-
- <li>
- <p>A <i>StringNumericLiteral</i> that is empty or contains only white space is converted to <b>+0</b>.</p>
- </li>
-
- <li>
- <p><code>Infinity</code> <code>and &ndash;Infinity</code> are recognized as a <i>StringNumericLiteral</i> but not
- as a <i>NumericLiteral</i>.</p>
- </li>
- </ul>
- </div>
- </div>
-
- <section id="sec-runtime-semantics-mv-s">
- <h1><span class="secnum" id="sec-7.1.3.1.1"><a href="#sec-runtime-semantics-mv-s"
- title="link to this section">7.1.3.1.1</a></span> Runtime Semantics: MV&rsquo;s</h1>
-
- <p>The conversion of a String to a Number value is similar overall to the determination of the Number value for a
- numeric literal (<a href="#sec-literals-numeric-literals">see 11.8.3</a>), but some of the details are different, so the
- process for converting a String numeric literal to a value of Number type is given here. This value is determined in two
- steps: first, a mathematical value (MV) is derived from the String numeric literal; second, this mathematical value is
- rounded as described below. The MV on any grammar symbol, not provided below, is the MV for that symbol defined in <a
- href="#sec-static-semantics-mv-s">11.8.3.1</a>.</p>
-
- <ul>
- <li>
- <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <span
- class="grhsannot">[empty]</span></span> is 0.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <span
- class="nt">StrWhiteSpace</span></span> is 0.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StringNumericLiteral</span> <span class="geq">:::</span> <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></span> is the MV of <span
- class="nt">StrNumericLiteral</span>, no matter whether white space is present or not.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
- class="nt">StrDecimalLiteral</span></span> is the MV of <span class="nt">StrDecimalLiteral</span>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
- class="nt">BinaryIntegerLiteral</span></span> is the MV of <span class="nt">BinaryIntegerLiteral</span>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
- class="nt">OctalIntegerLiteral</span></span> is the MV of <span class="nt">OctalIntegerLiteral</span>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrNumericLiteral</span> <span class="geq">:::</span> <span
- class="nt">HexIntegerLiteral</span></span> is the MV of <span class="nt">HexIntegerLiteral</span>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <span
- class="nt">StrUnsignedDecimalLiteral</span></span> is the MV of <span
- class="nt">StrUnsignedDecimalLiteral</span>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <code
- class="t">+</code> <span class="nt">StrUnsignedDecimalLiteral</span></span> is the MV of <span
- class="nt">StrUnsignedDecimalLiteral</span>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrDecimalLiteral</span> <span class="geq">:::</span> <code
- class="t">-</code> <span class="nt">StrUnsignedDecimalLiteral</span></span> is the negative of the MV of <span
- class="nt">StrUnsignedDecimalLiteral</span>. (Note that if the MV of <span
- class="nt">StrUnsignedDecimalLiteral</span> is 0, the negative of this MV is also 0. The rounding rule described
- below handles the conversion of this signless mathematical zero to a floating-point <b>+0</b> or <b>&minus;0</b> as
- appropriate.)</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
- class="nt">Infinity</span></span> is <span style="font-family: Times New Roman">10<sup>10000</sup></span> (a value
- so large that it will round to <b>+&infin;</b>).</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
- class="nt">DecimalDigits</span> <code class="t">.</code></span> is the MV of <span
- class="nt">DecimalDigits</span>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
- class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of
- the first <span class="nt">DecimalDigits</span> plus (the MV of the second <span class="nt">DecimalDigits</span>
- times <span style="font-family: Times New Roman">10<sup>&minus;<i>n</i></sup></span>), where <var>n</var> is the
- number of code points in the second <span class="nt">DecimalDigits</span>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
- class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">ExponentPart</span></span> is the MV of
- <i>DecimalDigits</i> times 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
- class="nt">DecimalDigits</span> <code class="t">.</code> <span class="nt">DecimalDigits</span> <span
- class="nt">ExponentPart</span></span> is (the MV of the first <i>DecimalDigits</i> plus (the MV of the second
- <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
- of code points in the second <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <code
- class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i> times
- 10<sup>&minus;<i>n</i></sup>, where <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <code
- class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of
- <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
- <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
- class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">StrUnsignedDecimalLiteral</span> <span class="geq">:::</span> <span
- class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of <i>DecimalDigits</i> times
- 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
- </li>
- </ul>
-
- <p>Once the exact MV for a String numeric literal has been determined, it is then rounded to a value of the Number type.
- If the MV is 0, then the rounded value is +0 unless the first non white space code point in the String numeric literal
- is &lsquo;<code>-</code>&rsquo;, in which case the rounded value is &minus;0. Otherwise, the rounded value must be the
- Number value for the MV (in the sense defined in <a href="#sec-ecmascript-language-types-number-type">6.1.6</a>), unless
- the literal includes a <span class="nt">StrUnsignedDecimalLiteral</span> and the literal has more than 20 significant
- digits, in which case the Number value may be either the Number value for the MV of a literal produced by replacing each
- significant digit after the 20th with a 0 digit or the Number value for the MV of a literal produced by replacing each
- significant digit after the 20th with a 0 digit and then incrementing the literal at the 20th digit position. A digit is
- significant if it is not part of an <span class="nt">ExponentPart</span> and</p>
-
- <ul>
- <li>it is not <code>0</code>; or</li>
- <li>there is a nonzero digit to its left and there is a nonzero digit, not in the <span
- class="nt">ExponentPart</span>, to its right.</li>
- </ul>
- </section>
- </section>
- </section>
-
- <section id="sec-tointeger">
- <h1><span class="secnum" id="sec-7.1.4"><a href="#sec-tointeger" title="link to this section">7.1.4</a></span> ToInteger (
- argument )</h1>
-
- <p>The abstract operation ToInteger converts <var>argument</var> to an integral numeric value. This abstract operation
- functions as follows:</p>
-
- <ol class="proc">
- <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
- <li>If <i>number</i> is <b>NaN</b>, return <b>+0</b>.</li>
- <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>
- <li>Return the number value that is the same sign as <i>number</i> and whose magnitude is <a
- href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
- </ol>
- </section>
-
- <section id="sec-toint32">
- <h1><span class="secnum" id="sec-7.1.5"><a href="#sec-toint32" title="link to this section">7.1.5</a></span> ToInt32 (
- argument )</h1>
-
- <p>The abstract operation ToInt32 converts <var>argument</var> to one of <span style="font-family: Times New
- Roman">2<sup>32</sup></span> integer values in the range <span style="font-family: Times New
- Roman">&minus;2<sup>31</sup></span> through <span style="font-family: Times New Roman">2<sup>31</sup>&minus;1</span>,
- inclusive. This abstract operation functions as follows:</p>
-
- <ol class="proc">
- <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
- <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
- <b>+0</b>.</li>
- <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
- href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
- <li>Let <i>int32bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>32</sup>.</li>
- <li>If <i>int32bit</i> &ge; 2<sup>31</sup>, return <i>int32bit</i> &minus; 2<sup>32</sup>, otherwise return
- <i>int32bit</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Given the above definition of ToInt32:</p>
-
- <ul>
- <li>
- <p>The ToInt32 abstract operation is idempotent: if applied to a result that it produced, the second application
- leaves that value unchanged.</p>
- </li>
-
- <li>
- <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>.
- (It is to preserve this latter property that +<b>&infin;</b> and &minus;<b>&infin;</b> are mapped to <b>+0</b>.)</p>
- </li>
-
- <li>
- <p>ToInt32 maps <b>&minus;0</b> to <b>+0</b>.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-touint32">
- <h1><span class="secnum" id="sec-7.1.6"><a href="#sec-touint32" title="link to this section">7.1.6</a></span> ToUint32 (
- argument )</h1>
-
- <p>The abstract operation ToUint32 converts <var>argument</var> to one of <span style="font-family: Times New
- Roman">2<sup>32</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
- style="font-family: Times New Roman">2<sup>32</sup>&minus;1</span>, inclusive. This abstract operation functions as
- follows:</p>
-
- <ol class="proc">
- <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
- <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
- <b>+0</b>.</li>
- <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
- href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
- <li>Let <i>int32bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>32</sup>.</li>
- <li>Return <i>int32bit</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Given the above definition of ToUint32:</p>
-
- <ul>
- <li>
- <p>Step 6 is the only difference between ToUint32 and <a href="#sec-toint32">ToInt32</a>.</p>
- </li>
-
- <li>
- <p>The ToUint32 abstract operation is idempotent: if applied to a result that it produced, the second application
- leaves that value unchanged.</p>
- </li>
-
- <li>
- <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>.
- (It is to preserve this latter property that <b>+&infin;</b> and <b>&minus;&infin;</b> are mapped to <b>+0</b>.)</p>
- </li>
-
- <li>
- <p>ToUint32 maps <b>&minus;0</b> to <b>+0</b>.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-toint16">
- <h1><span class="secnum" id="sec-7.1.7"><a href="#sec-toint16" title="link to this section">7.1.7</a></span> ToInt16 (
- argument )</h1>
-
- <p>The abstract operation ToInt16 converts <var>argument</var> to one of <span style="font-family: Times New
- Roman">2<sup>16</sup></span> integer values in the range <span style="font-family: Times New Roman">&minus;32768</span>
- through <span style="font-family: Times New Roman">32767</span>, inclusive. This abstract operation functions as
- follows:</p>
-
- <ol class="proc">
- <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
- <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
- <b>+0</b>.</li>
- <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
- href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
- <li>Let <i>int16bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>16</sup>.</li>
- <li>If <i>int16bit</i> &ge; 2<sup>15</sup>, return <i>int16bit</i> &minus; 2<sup>16</sup>, otherwise return
- <i>int16bit</i>.</li>
- </ol>
- </section>
-
- <section id="sec-touint16">
- <h1><span class="secnum" id="sec-7.1.8"><a href="#sec-touint16" title="link to this section">7.1.8</a></span> ToUint16 (
- argument )</h1>
-
- <p>The abstract operation ToUint16 converts <var>argument</var> to one of <span style="font-family: Times New
- Roman">2<sup>16</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
- style="font-family: Times New Roman">2<sup>16</sup>&minus;1</span>, inclusive. This abstract operation functions as
- follows:</p>
-
- <ol class="proc">
- <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
- <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
- <b>+0</b>.</li>
- <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
- href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
- <li>Let <i>int16bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>16</sup>.</li>
- <li>Return <i>int16bit</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Given the above definition of ToUint16:</p>
-
- <ul>
- <li>The substitution of 2<sup>16</sup> for 2<sup>32</sup> in step 5 is the only difference between <a
- href="#sec-touint32">ToUint32</a> and ToUint16.</li>
- <li>ToUint16 maps <b>&minus;0</b> to <span style="font-family: sans-serif"><b>+0</b></span>.</li>
- </ul>
- </div>
- </section>
-
- <section id="sec-toint8">
- <h1><span class="secnum" id="sec-7.1.9"><a href="#sec-toint8" title="link to this section">7.1.9</a></span> ToInt8 (
- argument )</h1>
-
- <p>The abstract operation ToInt8 converts <var>argument</var> to one of <span style="font-family: Times New
- Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">&minus;128</span> through
- <span style="font-family: Times New Roman">127</span>, inclusive. This abstract operation functions as follows:</p>
-
- <ol class="proc">
- <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
- <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
- <b>+0</b>.</li>
- <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
- href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
- <li>Let <i>int8bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>8</sup>.</li>
- <li>If <i>int8bit</i> &ge; 2<sup>7</sup>, return <i>int8bit</i> &minus; 2<sup>8</sup>, otherwise return
- <i>int8bit</i>.</li>
- </ol>
- </section>
-
- <section id="sec-touint8">
- <h1><span class="secnum" id="sec-7.1.10"><a href="#sec-touint8" title="link to this section">7.1.10</a></span> ToUint8 (
- argument )</h1>
-
- <p>The abstract operation ToUint8 converts <var>argument</var> to one of <span style="font-family: Times New
- Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
- style="font-family: Times New Roman">255</span>, inclusive. This abstract operation functions as follows:</p>
-
- <ol class="proc">
- <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
- <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
- <b>+0</b>.</li>
- <li>Let <i>int</i> be the mathematical value that is the same sign as <i>number</i> and whose magnitude is <a
- href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>number</i>)).</li>
- <li>Let <i>int8bit</i> be <i>int</i> <a href="#sec-algorithm-conventions">modulo</a> 2<sup>8</sup>.</li>
- <li>Return <i>int8bit</i>.</li>
- </ol>
- </section>
-
- <section id="sec-touint8clamp">
- <h1><span class="secnum" id="sec-7.1.11"><a href="#sec-touint8clamp" title="link to this section">7.1.11</a></span>
- ToUint8Clamp ( argument )</h1>
-
- <p>The abstract operation ToUint8Clamp converts <var>argument</var> to one of <span style="font-family: Times New
- Roman">2<sup>8</sup></span> integer values in the range <span style="font-family: Times New Roman">0</span> through <span
- style="font-family: Times New Roman">255</span>, inclusive. This abstract operation functions as follows:</p>
-
- <ol class="proc">
- <li>Let <i>number</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>number</i>).</li>
- <li>If <i>number</i> is <b>NaN</b>, return <b>+0</b>.</li>
- <li>If <i>number</i> &le; 0, return <b>+0</b>.</li>
- <li>If <i>number</i> &ge; 255, return 255.</li>
- <li>Let <i>f</i> be <a href="#sec-algorithm-conventions">floor</a>(<i>number</i>).</li>
- <li>If <i>f</i> <i>+</i> 0.5 &lt; <i>number</i>, return <i>f</i> + 1.</li>
- <li>If <i>number</i> &lt; <i>f +</i> 0.5, return <i>f</i>.</li>
- <li>If <i>f</i> is odd, return <i>f</i> + 1.</li>
- <li>Return <i>f</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Note that unlike the other ECMAScript integer conversion abstract operation, ToUint8Clamp
- rounds rather than truncates non-integer values and does not convert +<b>&infin;</b> to 0. ToUint8Clamp does &ldquo;round
- half to even&rdquo; tie-breaking. This differs from <code><a href="#sec-math.round">Math.round</a></code> which does
- &ldquo;round half up&rdquo; tie-breaking.</p>
- </div>
- </section>
-
- <section id="sec-tostring">
- <div class="front">
- <h1><span class="secnum" id="sec-7.1.12"><a href="#sec-tostring" title="link to this section">7.1.12</a></span> ToString (
- argument )</h1>
-
- <p>The abstract operation ToString converts <var>argument</var> to a value of type String according to <a
- href="#table-12">Table 12</a>:</p>
-
- <figure>
- <figcaption><span id="table-12">Table 12</span> &mdash; ToString Conversions</figcaption>
- <table class="real-table">
- <tr>
- <th>Argument Type</th>
- <th>Result</th>
- </tr>
- <tr>
- <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
- <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>
- </tr>
- <tr>
- <td>Undefined</td>
- <td>Return <code>"undefined"</code>.</td>
- </tr>
- <tr>
- <td>Null</td>
- <td>Return <code>"null"</code>.</td>
- </tr>
- <tr>
- <td>Boolean</td>
-
- <td>
- <p>If <var>argument</var> is <b>true</b>, return <code>"true"</code>.</p>
-
- <p>If <var>argument</var> is <b>false</b>, return <b><code>"false"</code>.</b></p>
- </td>
- </tr>
- <tr>
- <td>Number</td>
- <td>See <a href="#sec-tostring-applied-to-the-number-type">7.1.12.1</a>.</td>
- </tr>
- <tr>
- <td>String</td>
- <td>Return <var>argument</var>.</td>
- </tr>
- <tr>
- <td>Symbol</td>
- <td>Throw a <b>TypeError</b> exception.</td>
- </tr>
- <tr>
- <td>Object</td>
-
- <td>
- <p>Apply the following steps:</p>
-
- <p>1. Let <i>primValue</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint String).</p>
-
- <p>2. Return ToString(<i>primValue</i>).</p>
- </td>
- </tr>
- </table>
- </figure>
- </div>
-
- <section id="sec-tostring-applied-to-the-number-type">
- <h1><span class="secnum" id="sec-7.1.12.1"><a href="#sec-tostring-applied-to-the-number-type"
- title="link to this section">7.1.12.1</a></span> ToString Applied to the Number Type</h1>
-
- <p>The abstract operation <a href="#sec-tostring">ToString</a> converts a Number <var>m</var> to String format as
- follows:</p>
-
- <ol class="proc">
- <li>If <i>m</i> is <b>NaN</b>, return the String <code>"NaN"</code>.</li>
- <li>If <i>m</i> is <b>+0</b> or <b>&minus;0</b>, return the String <code>"0"</code>.</li>
- <li>If <i>m</i> is less than zero, return the String concatenation of the String <code>"-"</code> and <a
- href="#sec-tostring">ToString</a>(&minus;<i>m</i>).</li>
- <li>If <i>m</i> is +&infin;, return the String <code>"Infinity"</code>.</li>
- <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>
- &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
- <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
- representation of <i>s</i>, that <i>s</i> is not divisible by 10, and that the least significant digit of <i>s</i>
- is not necessarily uniquely determined by these criteria.</li>
- <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
- decimal representation of <i>s</i> (in order, with no leading zeroes), followed by <i>n&minus;k</i> occurrences of
- the code unit 0x0030 (DIGIT ZERO).</li>
- <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
- of the decimal representation of <i>s</i>, followed by the code unit 0x002E (FULL STOP), followed by the code units
- of the remaining <i>k&minus;n</i> digits of the decimal representation of <i>s</i>.</li>
- <li>If &minus;6 &lt; <i>n</i> &le; 0, return the String consisting of the code unit 0x0030 (DIGIT ZERO), followed by the
- code unit 0x002E (FULL STOP), followed by &minus;<i>n</i> occurrences of the code unit 0x0030 (DIGIT ZERO), followed
- by the code units of the <i>k</i> digits of the decimal representation of <i>s</i>.</li>
- <li>Otherwise, if <i>k</i> = 1, return the String consisting of the code unit of the single digit of <i>s</i>, followed
- by code unit 0x0065 (LATIN SMALL LETTER E), followed by the code unit 0x002B (PLUS SIGN) or the code unit 0x002D
- (HYPHEN-MINUS) according to whether <i>n</i>&minus;1 is positive or negative, followed by the code units of the
- decimal representation of the integer <a href="#sec-algorithm-conventions">abs</a>(<i>n</i>&minus;1) (with no
- leading zeroes).</li>
- <li>Return the String consisting of the code units of the most significant digit of the decimal representation of
- <i>s</i>, followed by code unit 0x002E (FULL STOP), followed by the code units of the remaining <i>k</i>&minus;1
- digits of the decimal representation of <i>s</i>, followed by code unit 0x0065 (LATIN SMALL LETTER E), followed by
- code unit 0x002B (PLUS SIGN) or the code unit 0x002D (HYPHEN-MINUS) according to whether <i>n</i>&minus;1 is
- positive or negative, followed by the code units of the decimal representation of the integer <a
- href="#sec-algorithm-conventions">abs</a>(<i>n</i>&minus;1) (with no leading zeroes).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE 1</span> The following observations may be useful as guidelines for implementations, but are
- not part of the normative requirements of this Standard:</p>
-
- <ul>
- <li>
- <p>If x is any Number value other than <b>&minus;0</b>, then <a href="#sec-tonumber">ToNumber</a>(<a
- href="#sec-tostring">ToString</a>(x)) is exactly the same Number value as x.</p>
- </li>
-
- <li>
- <p>The least significant digit of s is not always uniquely determined by the requirements listed in step 5.</p>
- </li>
- </ul>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 2</span> For implementations that provide more accurate conversions than required by the rules
- above, it is recommended that the following alternative version of step 5 be used as a guideline:</p>
-
- <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>
- &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
- <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
- <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
- 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
- decimal representation of <i>s</i> and that <i>s</i> is not divisible by 10.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 3</span> Implementers of ECMAScript may find useful the paper and code written by David M. Gay
- for binary-to-decimal conversion of floating-point numbers:</p>
-
- <p>Gay, David M. Correctly Rounded Binary-Decimal and Decimal-Binary Conversions. Numerical Analysis, Manuscript 90-10.
- AT&amp;T Bell Laboratories (Murray Hill, New Jersey). November 30, 1990. Available as<br><span style="font-family:
- sans-serif"><a
- 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>.
- Associated code available as<br><span style="font-family: sans-serif"><a
- href="http://netlib.sandia.gov/fp/dtoa.c">http://netlib.sandia.gov/fp/dtoa.c</a></span>&nbsp;and&nbsp;as<br><span
- style="font-family: sans-serif"><a
- 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
- various <code>netlib</code> mirror sites.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-toobject">
- <h1><span class="secnum" id="sec-7.1.13"><a href="#sec-toobject" title="link to this section">7.1.13</a></span> ToObject (
- argument )</h1>
-
- <p>The abstract operation ToObject converts <var>argument</var> to a value of type Object according to <a
- href="#table-13">Table 13</a>:</p>
-
- <figure>
- <figcaption><span id="table-13">Table 13</span> &mdash; ToObject Conversions</figcaption>
- <table class="real-table">
- <tr>
- <th>Argument Type</th>
- <th>Result</th>
- </tr>
- <tr>
- <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
- <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>
- </tr>
- <tr>
- <td>Undefined</td>
- <td>Throw a <b>TypeError</b> exception.</td>
- </tr>
- <tr>
- <td>Null</td>
- <td>Throw a <b>TypeError</b> exception.</td>
- </tr>
- <tr>
- <td>Boolean</td>
- <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>
- </tr>
- <tr>
- <td>Number</td>
- <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>
- </tr>
- <tr>
- <td>String</td>
- <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>
- </tr>
- <tr>
- <td>Symbol</td>
- <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>
- </tr>
- <tr>
- <td>Object</td>
- <td>Return <i>argument</i>.</td>
- </tr>
- </table>
- </figure>
- </section>
-
- <section id="sec-topropertykey">
- <h1><span class="secnum" id="sec-7.1.14"><a href="#sec-topropertykey" title="link to this section">7.1.14</a></span>
- ToPropertyKey ( argument )</h1>
-
- <p>The abstract operation ToPropertyKey converts <var>argument</var> to a value that can be used as a <a
- href="#sec-object-type">property key</a> by performing the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>key</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>argument</i>, hint String).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>key</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>key</i>) is Symbol, then
- <ol class="block">
- <li>Return <i>key</i>.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-tostring">ToString</a>(<i>key</i>).</li>
- </ol>
- </section>
-
- <section id="sec-tolength">
- <h1><span class="secnum" id="sec-7.1.15"><a href="#sec-tolength" title="link to this section">7.1.15</a></span> ToLength (
- argument )</h1>
-
- <p>The abstract operation ToLength converts <var>argument</var> to an integer suitable for use as the length of an
- array-like object. It performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
- <li>Let <i>len</i> be <a href="#sec-tointeger">ToInteger</a>(<i>argument</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
- <li>If <i>len</i> &le; +0, return +0.</li>
- <li>If <i>len</i> is <b>+&infin;</b>, return 2<sup>53</sup>-1.</li>
- <li>Return min(<i>len</i>, 2<sup>53</sup>-1).</li>
- </ol>
- </section>
-
- <section id="sec-canonicalnumericindexstring">
- <h1><span class="secnum" id="sec-7.1.16"><a href="#sec-canonicalnumericindexstring"
- title="link to this section">7.1.16</a></span> CanonicalNumericIndexString ( argument )</h1>
-
- <p>The abstract operation CanonicalNumericIndexString returns <var>argument</var> converted to a numeric value if it is a
- String representation of a Number that would be produced by <a href="#sec-tostring">ToString</a>, or the string
- <code>"-0"</code>. Otherwise, it returns <span class="value">undefined.</span> This abstract operation functions as
- follows:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is String.</li>
- <li>If <i>argument</i> is <code>"-0"</code>, return &minus;0.</li>
- <li>Let <i>n</i> be <a href="#sec-tonumber">ToNumber</a>(<i>argument</i>).</li>
- <li>If <a href="#sec-samevalue">SameValue</a>(<a href="#sec-tostring">ToString</a>(<i>n</i>), <i>argument</i>) is
- <b>false</b>, return <b>undefined</b>.</li>
- <li>Return <i>n</i>.</li>
- </ol>
-
- <p>A <i>canonical numeric string</i> is any String value for which the CanonicalNumericIndexString abstract operation does
- not return <span class="value">undefined</span>.</p>
- </section>
- </section>
-
- <section id="sec-testing-and-comparison-operations">
- <div class="front">
- <h1><span class="secnum" id="sec-7.2"><a href="#sec-testing-and-comparison-operations"
- title="link to this section">7.2</a></span> Testing and Comparison Operations</h1>
- </div>
-
- <section id="sec-requireobjectcoercible">
- <h1><span class="secnum" id="sec-7.2.1"><a href="#sec-requireobjectcoercible" title="link to this section">7.2.1</a></span>
- RequireObjectCoercible ( argument )</h1>
-
- <p>The abstract operation RequireObjectCoercible throws an error if <var>argument</var> is a value that cannot be converted
- to an Object using <a href="#sec-toobject">ToObject</a>. It is defined by <a href="#table-14">Table 14</a>:</p>
-
- <figure>
- <figcaption><span id="table-14">Table 14</span>&nbsp;&mdash; RequireObjectCoercible Results</figcaption>
- <table class="real-table">
- <tr>
- <th>Argument Type</th>
- <th>Result</th>
- </tr>
- <tr>
- <td><a href="#sec-completion-record-specification-type">Completion Record</a></td>
- <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>
- </tr>
- <tr>
- <td>Undefined</td>
- <td>Throw a <b>TypeError</b> exception.</td>
- </tr>
- <tr>
- <td>Null</td>
- <td>Throw a <b>TypeError</b> exception.</td>
- </tr>
- <tr>
- <td>Boolean</td>
- <td>Return <var>argument</var>.</td>
- </tr>
- <tr>
- <td>Number</td>
- <td>Return <var>argument</var>.</td>
- </tr>
- <tr>
- <td>String</td>
- <td>Return <var>argument</var>.</td>
- </tr>
- <tr>
- <td>Symbol</td>
- <td>Return <var>argument</var>.</td>
- </tr>
- <tr>
- <td>Object</td>
- <td>Return <var>argument</var>.</td>
- </tr>
- </table>
- </figure>
- </section>
-
- <section id="sec-isarray">
- <h1><span class="secnum" id="sec-7.2.2"><a href="#sec-isarray" title="link to this section">7.2.2</a></span> IsArray (
- argument )</h1>
-
- <p>The abstract operation IsArray takes one argument <var>argument</var>, and performs the following steps:</p>
-
- <ol class="proc">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
- <li>If <i>argument</i> is an <a href="#sec-array-exotic-objects">Array exotic object</a>, return <b>true</b>.</li>
- <li>If <i>argument</i> is a Proxy exotic object, then
- <ol class="block">
- <li>If the value of the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
- of <i>argument</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>argument</i>.</li>
- <li>Return IsArray(<i>target</i>).</li>
- </ol>
- </li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-iscallable">
- <h1><span class="secnum" id="sec-7.2.3"><a href="#sec-iscallable" title="link to this section">7.2.3</a></span> IsCallable (
- argument )</h1>
-
- <p>The abstract operation IsCallable determines if <var>argument</var>, which must be an <a
- href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
- href="#sec-completion-record-specification-type">Completion Record</a>, is a callable function with a [[Call]] internal
- method.</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
- <li>If <i>argument</i> has a [[Call]] internal method, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-isconstructor">
- <h1><span class="secnum" id="sec-7.2.4"><a href="#sec-isconstructor" title="link to this section">7.2.4</a></span>
- IsConstructor ( argument )</h1>
-
- <p>The abstract operation IsConstructor determines if <var>argument</var>, which must be an <a
- href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
- href="#sec-completion-record-specification-type">Completion Record</a>, is a function object with a [[Construct]] internal
- method.</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
- <li>If <i>argument</i> has a [[Construct]] internal method, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-isextensible-o">
- <h1><span class="secnum" id="sec-7.2.5"><a href="#sec-isextensible-o" title="link to this section">7.2.5</a></span>
- IsExtensible (O)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">IsExtensible</span> is used to determine whether
- additional properties can be added to the object that is <var>O</var>. A Boolean value is returned. This abstract operation
- performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li>Return <i>O</i>.[[IsExtensible]]().</li>
- </ol>
- </section>
-
- <section id="sec-isinteger">
- <h1><span class="secnum" id="sec-7.2.6"><a href="#sec-isinteger" title="link to this section">7.2.6</a></span> IsInteger (
- argument )</h1>
-
- <p>The abstract operation IsInteger determines if <var>argument</var> is a finite integer numeric value.</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Number, return <b>false</b>.</li>
- <li>If <i>argument</i> is <b>NaN</b>, <b>+&infin;</b>, or <b>&minus;&infin;</b>, return <b>false</b>.</li>
- <li>If <a href="#sec-algorithm-conventions">floor</a>(<a href="#sec-algorithm-conventions">abs</a>(<i>argument</i>)) &ne;
- <a href="#sec-algorithm-conventions">abs</a>(<i>argument</i>), return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-ispropertykey">
- <h1><span class="secnum" id="sec-7.2.7"><a href="#sec-ispropertykey" title="link to this section">7.2.7</a></span>
- IsPropertyKey ( argument )</h1>
-
- <p>The abstract operation IsPropertyKey determines if <var>argument</var>, which must be an <a
- href="#sec-ecmascript-language-types">ECMAScript language value</a> or a <a
- href="#sec-completion-record-specification-type">Completion Record</a>, is a value that may be used as a <a
- href="#sec-object-type">property key</a>.</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argument</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is String, return <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is Symbol, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-isregexp">
- <h1><span class="secnum" id="sec-7.2.8"><a href="#sec-isregexp" title="link to this section">7.2.8</a></span> IsRegExp (
- argument )</h1>
-
- <p>The abstract operation IsRegExp with argument <var>argument</var> performs the following steps:</p>
-
- <ol class="proc">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>argument</i>) is not Object, return <b>false</b>.</li>
- <li>Let <i>isRegExp</i> be <a href="#sec-get-o-p">Get</a>(<i>argument</i>, @@match).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>isRegExp</i>).</li>
- <li>If <i>isRegExp</i> is not <b>undefined</b>, return <a href="#sec-toboolean">ToBoolean</a>(<i>isRegExp</i>).</li>
- <li>If <i>argument</i> has a [[RegExpMatcher]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a>, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-samevalue">
- <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,
- y)</h1>
-
- <p>The internal comparison abstract operation SameValue(<var>x</var>, <var>y</var>), where <var>x</var> and <var>y</var> are
- <a href="#sec-ecmascript-language-types">ECMAScript language values</a>, produces <b>true</b> or <b>false</b>. Such a
- comparison is performed as follows:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
- <ol class="block">
- <li>If <i>x</i> is NaN and <i>y</i> is NaN, return <b>true</b>.</li>
- <li>If <i>x</i> is +0 and <i>y</i> is -0, return <b>false</b>.</li>
- <li>If <i>x</i> is -0 and <i>y</i> is +0, return <b>false</b>.</li>
- <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
- <ol class="block">
- <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
- corresponding indices) return <b>true</b>; otherwise, return <b>false</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
- <ol class="block">
- <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
- <b>false</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Symbol, then
- <ol class="block">
- <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>
- </ol>
- </li>
- <li>Return <b>true</b> if <i>x</i> and <i>y</i> are the same Object value. Otherwise, return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-samevaluezero">
- <h1><span class="secnum" id="sec-7.2.10"><a href="#sec-samevaluezero" title="link to this section">7.2.10</a></span>
- SameValueZero(x, y)</h1>
-
- <p>The internal comparison abstract operation SameValueZero(<var>x</var>, <var>y</var>), where <var>x</var> and <var>y</var>
- are <a href="#sec-ecmascript-language-types">ECMAScript language values</a>, produces <b>true</b> or <b>false</b>. Such a
- comparison is performed as follows:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
- <ol class="block">
- <li>If <i>x</i> is NaN and <i>y</i> is NaN, return <b>true</b>.</li>
- <li>If <i>x</i> is +0 and <i>y</i> is -0, return <b>true</b>.</li>
- <li>If <i>x</i> is -0 and <i>y</i> is +0, return <b>true</b>.</li>
- <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
- <ol class="block">
- <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
- corresponding indices) return <b>true</b>; otherwise, return <b>false</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
- <ol class="block">
- <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
- <b>false</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Symbol, then
- <ol class="block">
- <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>
- </ol>
- </li>
- <li>Return <b>true</b> if <i>x</i> and <i>y</i> are the same Object value. Otherwise, return <b>false</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> SameValueZero differs from SameValue only in its treatment of +0 and -0.</p>
- </div>
- </section>
-
- <section id="sec-abstract-relational-comparison">
- <h1><span class="secnum" id="sec-7.2.11"><a href="#sec-abstract-relational-comparison"
- title="link to this section">7.2.11</a></span> Abstract Relational Comparison</h1>
-
- <p>The comparison <var>x</var> &lt; <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b>,
- <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
- <var>y</var> the algorithm takes a Boolean flag named <span class="nt">LeftFirst</span> as a parameter. The flag is used to
- control the order in which operations with potentially visible side-effects are performed upon <var>x</var> and
- <var>y</var>. It is necessary because ECMAScript specifies left to right evaluation of expressions. The default value of
- <span class="nt">LeftFirst</span> is <b>true</b> and indicates that the <var>x</var> parameter corresponds to an expression
- that occurs to the left of the <var>y</var> parameter&rsquo;s corresponding expression. If <span class="nt">LeftFirst</span>
- is <b>false</b>, the reverse is the case and operations must be performed upon <var>y</var> before <var>x</var>. Such a
- comparison is performed as follows:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
- <li>If the <i>LeftFirst</i> flag is <b>true</b>, then
- <ol class="block">
- <li>Let <i>px</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>, hint Number).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>px</i>).</li>
- <li>Let <i>py</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>, hint Number).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>py</i>).</li>
- </ol>
- </li>
- <li>Else the order of evaluation needs to be reversed to preserve left to right evaluation
- <ol class="block">
- <li>Let <i>py</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>, hint Number).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>py</i>).</li>
- <li>Let <i>px</i> be <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>, hint Number).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>px</i>).</li>
- </ol>
- </li>
- <li>If both <i>px</i> and <i>py</i> are Strings, then
- <ol class="block">
- <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
- <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
- String is a prefix of itself, because <i>r</i> may be the empty String.)</li>
- <li>If <i>px</i> is a prefix of <i>py</i>, return <b>true</b>.</li>
- <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
- different from the code unit at index <i>k</i> within <i>py</i>. (There must be such a <i>k</i>, for neither
- String is a prefix of the other.)</li>
- <li>Let <i>m</i> be the integer that is the code unit value at index <i>k</i> within <i>px</i>.</li>
- <li>Let <i>n</i> be the integer that is the code unit value at index <i>k</i> within <i>py</i>.</li>
- <li>If <i>m</i> &lt; <i>n</i>, return <b>true</b>. Otherwise, return <b>false</b>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <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
- values evaluation order is not important.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nx</i>).</li>
- <li>Let <i>ny</i> be <a href="#sec-tonumber">ToNumber</a>(<i>py</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ny</i>).</li>
- <li>If <i>nx</i> is <b>NaN</b>, return <b>undefined</b>.</li>
- <li>If <i>ny</i> is <b>NaN</b>, return <b>undefined</b>.</li>
- <li>If <i>nx</i> and <i>ny</i> are the same Number value, return <b>false</b>.</li>
- <li>If <i>nx</i> is <b>+0</b> and <i>ny</i> is <b>&minus;0</b>, return <b>false</b>.</li>
- <li>If <i>nx</i> is <b>&minus;0</b> and <i>ny</i> is <b>+0</b>, return <b>false</b>.</li>
- <li>If <i>nx</i> is <b>+&infin;</b>, return <b>false</b>.</li>
- <li>If <i>ny</i> is <b>+&infin;</b>, return <b>true</b>.</li>
- <li>If <i>ny</i> is <b>&minus;&infin;</b>, return <b>false</b>.</li>
- <li>If <i>nx</i> is <b>&minus;&infin;</b>, return <b>true</b>.</li>
- <li>If the mathematical value of <i>nx</i> is less than the mathematical value of <i>ny</i> &mdash;note that these
- mathematical values are both finite and not both zero&mdash;return <b>true</b>. Otherwise, return
- <b>false</b>.</li>
- </ol>
- </li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE 1</span> Step 5 differs from step 11 in the algorithm for the addition operator <code>+</code>
- (<a href="#sec-addition-operator-plus">12.7.3</a>) in using &ldquo;and&rdquo; instead of &ldquo;or&rdquo;.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 2</span> The comparison of Strings uses a simple lexicographic ordering on sequences of code unit
- values. There is no attempt to use the more complex, semantically oriented definitions of character or string equality and
- collating order defined in the Unicode specification. Therefore String values that are canonically equal according to the
- Unicode standard could test as unequal. In effect this algorithm assumes that both Strings are already in normalized form.
- Also, note that for strings containing supplementary characters, lexicographic ordering on sequences of UTF-16 code unit
- values differs from that on sequences of code point values.</p>
- </div>
- </section>
-
- <section id="sec-abstract-equality-comparison">
- <h1><span class="secnum" id="sec-7.2.12"><a href="#sec-abstract-equality-comparison"
- title="link to this section">7.2.12</a></span> Abstract Equality Comparison</h1>
-
- <p>The comparison <var>x</var> == <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b> or
- <b>false</b>. Such a comparison is performed as follows:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>x</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>y</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is the same as <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), then
- <ol class="block">
- <li>Return the result of performing Strict Equality Comparison <i>x</i> === <i>y</i>.</li>
- </ol>
- </li>
- <li>If <i>x</i> is <b>null</b> and <i>y</i> is <b>undefined</b>, return <b>true</b>.</li>
- <li>If <i>x</i> is <b>undefined</b> and <i>y</i> is <b>null</b>, return <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number and <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is String,<br>return the result of the comparison
- <i>x</i> == <a href="#sec-tonumber">ToNumber</a>(<i>y</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String and <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Number,<br>return the result of the comparison <a
- href="#sec-tonumber">ToNumber</a>(<i>x</i>) == <i>y</i>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, return the result of the comparison
- <a href="#sec-tonumber">ToNumber</a>(<i>x</i>) == <i>y</i>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Boolean, return the result of the comparison
- <i>x</i> == <a href="#sec-tonumber">ToNumber</a>(<i>y</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is either String, Number, or Symbol and <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is Object, then<br>return the result of the comparison
- <i>x</i> == <a href="#sec-toprimitive">ToPrimitive</a>(<i>y</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Object and <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>) is either String, Number, or Symbol, then<br>return
- the result of the comparison <a href="#sec-toprimitive">ToPrimitive</a>(<i>x</i>) == <i>y</i>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-strict-equality-comparison">
- <h1><span class="secnum" id="sec-7.2.13"><a href="#sec-strict-equality-comparison"
- title="link to this section">7.2.13</a></span> Strict Equality Comparison</h1>
-
- <p>The comparison <var>x</var> === <var>y</var>, where <var>x</var> and <var>y</var> are values, produces <b>true</b> or
- <b>false</b>. Such a comparison is performed as follows:</p>
-
- <ol class="proc">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is different from <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>y</i>), return <b>false</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Undefined, return <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Null, return <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Number, then
- <ol class="block">
- <li>If <i>x</i> is <b>NaN</b>, return <b>false</b>.</li>
- <li>If <i>y</i> is <b>NaN</b>, return <b>false</b>.</li>
- <li>If <i>x</i> is the same Number value as <i>y</i>, return <b>true</b>.</li>
- <li>If <i>x</i> is <b>+0</b> and <i>y</i> is <b>&minus;0</b>, return <b>true</b>.</li>
- <li>If <i>x</i> is <b>&minus;0</b> and <i>y</i> is <b>+0</b>, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is String, then
- <ol class="block">
- <li>If <i>x</i> and <i>y</i> are exactly the same sequence of code units (same length and same code units at
- corresponding indices), return <b>true</b>.</li>
- <li>Else, return <b>false</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>x</i>) is Boolean, then
- <ol class="block">
- <li>If <i>x</i> and <i>y</i> are both <b>true</b> or both <b>false</b>, return <b>true</b>.</li>
- <li>Else, return <b>false</b>.</li>
- </ol>
- </li>
- <li>If <i>x</i> and <i>y</i> are the same Symbol value, return <b>true</b>.</li>
- <li>If <i>x</i> and <i>y</i> are the same Object value, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> This algorithm differs from <a href="#sec-samevalue">the SameValue Algorithm</a> (<a
- href="#sec-samevalue">7.2.9</a>) in its treatment of signed zeroes and NaNs.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-operations-on-objects">
- <div class="front">
- <h1><span class="secnum" id="sec-7.3"><a href="#sec-operations-on-objects" title="link to this section">7.3</a></span>
- Operations on Objects</h1>
- </div>
-
- <section id="sec-get-o-p">
- <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>
-
- <p>The abstract operation <span style="font-family: Times New Roman">Get</span> is used to retrieve the value of a specific
- property of an object. The 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 <a href="#sec-object-type">property key</a>. This abstract operation performs the following
- steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Return <i>O</i>.[[Get]](<i>P</i>, <i>O</i>).</li>
- </ol>
- </section>
-
- <section id="sec-getv">
- <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>
-
- <p>The abstract operation GetV is used to retrieve the value of a specific property of an <a
- href="#sec-ecmascript-language-types">ECMAScript language value</a>. If the value is not an object, the property lookup is
- performed using a wrapper object appropriate for the type of the value. The operation is called with arguments <var>V</var>
- 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
- abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>O</i> be <a href="#sec-toobject">ToObject</a>(<i>V</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>O</i>).</li>
- <li>Return <i>O</i>.[[Get]](<i>P</i>, <i>V</i>).</li>
- </ol>
- </section>
-
- <section id="sec-set-o-p-v-throw">
- <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,
- P, V, Throw)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">Set</span> is used to set the value of a specific
- property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, <var>V</var>, and <span
- class="nt">Throw</span> where <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>,
- <var>V</var> is the new value for the property and <span class="nt">Throw</span> is a Boolean flag. This abstract operation
- performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Throw</i>) is Boolean.</li>
- <li>Let <i>success</i> be <i>O</i>.[[Set]](<i>P</i>, <i>V</i>, <i>O</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
- <li>If <i>success</i> is <b>false</b> and <i>Throw</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>success</i>.</li>
- </ol>
- </section>
-
- <section id="sec-createdataproperty">
- <h1><span class="secnum" id="sec-7.3.4"><a href="#sec-createdataproperty" title="link to this section">7.3.4</a></span>
- CreateDataProperty (O, P, V)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">CreateDataProperty</span> is used to create a new own
- property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where
- <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
- for the property. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>newDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
- <b>true</b>, [[Configurable]]: <b>true</b>}.</li>
- <li>Return <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>newDesc</i>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
- used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist.
- If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return
- <b>false</b>.</p>
- </div>
- </section>
-
- <section id="sec-createmethodproperty">
- <h1><span class="secnum" id="sec-7.3.5"><a href="#sec-createmethodproperty" title="link to this section">7.3.5</a></span>
- CreateMethodProperty (O, P, V)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">CreateMethodProperty</span> is used to create a new own
- property of an object. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where
- <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
- for the property. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>newDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
- <b>false</b>, [[Configurable]]: <b>true</b>}.</li>
- <li>Return <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>newDesc</i>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
- used for built-in methods and methods defined using class declaration syntax. Normally, the property will not already
- exist. If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return
- <b>false</b>.</p>
- </div>
- </section>
-
- <section id="sec-createdatapropertyorthrow">
- <h1><span class="secnum" id="sec-7.3.6"><a href="#sec-createdatapropertyorthrow"
- title="link to this section">7.3.6</a></span> CreateDataPropertyOrThrow (O, P, V)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">CreateDataPropertyOrThrow</span> is used to create a
- new own property of an object. It throws a <span class="value">TypeError</span> exception if the requested property update
- cannot be performed. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>V</var> where <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 for the
- property. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>success</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>O</i>, <i>P</i>, <i>V</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
- <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>success</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> This abstract operation creates a property whose attributes are set to the same defaults
- used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist.
- If it does exist and is not configurable or if <i>O</i> is not extensible, [[DefineOwnProperty]] will return <b>false</b>
- <span style="font-family: sans-serif">causing this operation to throw a</span> <b>TypeError</b> <span style="font-family:
- sans-serif">exception</span>.</p>
- </div>
- </section>
-
- <section id="sec-definepropertyorthrow">
- <h1><span class="secnum" id="sec-7.3.7"><a href="#sec-definepropertyorthrow" title="link to this section">7.3.7</a></span>
- DefinePropertyOrThrow (O, P, desc)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">DefinePropertyOrThrow</span> is used to call the
- [[DefineOwnProperty]] internal method of an object in a manner that will throw a <b>TypeError</b> exception if the requested
- property update cannot be performed. The operation is called with arguments <var>O</var>, <var>P</var>, and <var>desc</var>
- 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
- the <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> for the property. This abstract operation
- performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>success</i> be <i>O</i>.[[DefineOwnProperty]](<i>P</i>, <i>desc</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
- <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>success</i>.</li>
- </ol>
- </section>
-
- <section id="sec-deletepropertyorthrow">
- <h1><span class="secnum" id="sec-7.3.8"><a href="#sec-deletepropertyorthrow" title="link to this section">7.3.8</a></span>
- DeletePropertyOrThrow (O, P)</h1>
-
- <p>The abstract operation DeletePropertyOrThrow is used to remove a specific own property of an object. It throws an
- exception if the property is not configurable. The 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 <a href="#sec-object-type">property key</a>. This abstract operation
- performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>success</i> be <i>O</i>.[[Delete]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>success</i>).</li>
- <li>If <i>success</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>success</i>.</li>
- </ol>
- </section>
-
- <section id="sec-getmethod">
- <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,
- P)</h1>
-
- <p>The abstract operation GetMethod is used to get the value of a specific property of an object when the value of the
- property is expected to be a function. The operation is called with arguments <var>O</var> and <var>P</var> where
- <var>O</var> is the object, <var>P</var> is the <a href="#sec-object-type">property key</a>. This abstract operation
- performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>func</i> be <a href="#sec-getv">GetV</a>(<i>O</i>, <i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
- <li>If <i>func</i> is either <b>undefined</b> or <b>null</b>, return <b>undefined</b>.</li>
- <li>If <a href="#sec-iscallable">IsCallable</a>(<i>func</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>func</i>.</li>
- </ol>
- </section>
-
- <section id="sec-hasproperty">
- <h1><span class="secnum" id="sec-7.3.10"><a href="#sec-hasproperty" title="link to this section">7.3.10</a></span>
- HasProperty (O, P)</h1>
-
- <p>The abstract operation HasProperty is used to determine whether an object has a property with the specified <a
- href="#sec-object-type">property key</a>. The property may be either an own or inherited. A Boolean value is returned. The
- 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
- <a href="#sec-object-type">property key</a>. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Return <i>O</i>.[[HasProperty]](<i>P</i>).</li>
- </ol>
- </section>
-
- <section id="sec-hasownproperty">
- <h1><span class="secnum" id="sec-7.3.11"><a href="#sec-hasownproperty" title="link to this section">7.3.11</a></span>
- HasOwnProperty (O, P)</h1>
-
- <p>The abstract operation HasOwnProperty is used to determine whether an object has an own property with the specified <a
- href="#sec-object-type">property key</a>. A Boolean value is returned. The 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 <a href="#sec-object-type">property key</a>. This
- abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
- <li>If <i>desc</i> is <b>undefined</b>, return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-call">
- <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,
- [argumentsList])</h1>
-
- <p>The abstract operation Call is used to call the [[Call]] internal method of a function object. The operation is called
- with arguments <var>F</var>, <var>V</var> , and optionally <var>argumentsList</var> where <var>F</var> is the function
- object, <var>V</var> is an <a href="#sec-ecmascript-language-types">ECMAScript language value</a> that is the <b>this</b>
- value of the [[Call]], and <var>argumentsList</var> is the value passed to the corresponding argument of the internal
- method. If <var>argumentsList</var> is not present, an empty <a href="#sec-list-and-record-specification-type">List</a> is
- used as its value. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>F</i>).</li>
- <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
- href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>If <a href="#sec-iscallable">IsCallable</a>(<i>F</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>F</i>.[[Call]](<i>V</i>, <i>argumentsList</i>).</li>
- </ol>
- </section>
-
- <section id="sec-invoke">
- <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,
- [argumentsList])</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">Invoke</span> is used to call a method property of an
- object. The operation is called with arguments <var>O</var>, <var>P</var> , and optionally <var>argumentsList</var> where
- <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
- href="#sec-object-type">property key</a>, and <var>argumentsList</var> is the list of arguments values passed to the method.
- If <var>argumentsList</var> is not present, an empty <a href="#sec-list-and-record-specification-type">List</a> is used as
- its value. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>P</i> is a valid <a href="#sec-object-type">property key</a>.</li>
- <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
- href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Let <i>func</i> be <a href="#sec-getv">GetV</a>(<i>O</i>, <i>P</i>).</li>
- <li>Return <a href="#sec-call">Call</a>(<i>func</i>, <i>O</i>, <i>argumentsList</i>).</li>
- </ol>
- </section>
-
- <section id="sec-construct">
- <h1><span class="secnum" id="sec-7.3.14"><a href="#sec-construct" title="link to this section">7.3.14</a></span> Construct
- (F, [argumentsList], [newTarget])</h1>
-
- <p>The abstract operation Construct is used to call the [[Construct]] internal method of a function object. The operation is
- called with arguments <var>F</var>, and optionally <span style="font-family: Times New Roman"><i>argumentsList</i>, and
- <i>newTarget</i></span> where <var>F</var> is the function object. <var>argumentsList</var> and <var>newTarget</var> are the
- values to be passed as the corresponding arguments of the internal method. If <var>argumentsList</var> is not present, an
- empty <a href="#sec-list-and-record-specification-type">List</a> is used as its value. If <var>newTarget</var> is not
- present, <var>F</var> is used as its value. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li>If <i>newTarget</i> was not passed, let <i>newTarget</i> be <i>F</i>.</li>
- <li>If <i>argumentsList</i> was not passed, let <i>argumentsList</i> be a new empty <a
- href="#sec-list-and-record-specification-type">List</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>F</i>) is
- <b>true</b>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>newTarget</i>) is
- <b>true</b>.</li>
- <li>Return <i>F</i>.[[Construct]](<i>argumentsList</i>, <i>newTarget</i>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> If <i>newTarget</i> is not passed, this operation is equivalent to: <code>new
- F(...argumentsList)</code></p>
- </div>
- </section>
-
- <section id="sec-setintegritylevel">
- <h1><span class="secnum" id="sec-7.3.15"><a href="#sec-setintegritylevel" title="link to this section">7.3.15</a></span>
- SetIntegrityLevel (O, level)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">SetIntegrityLevel</span> is used to fix the set of own
- properties of an object. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>level</i> is either <code>"sealed"</code> or
- <code>"frozen"</code>.</li>
- <li>Let <i>status</i> be <i>O</i>.[[PreventExtensions]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>If <i>status</i> is <b>false</b>, return <b>false</b>.</li>
- <li>Let <i>keys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>keys</i>).</li>
- <li>If <i>level</i> is <code>"sealed"</code>, then
- <ol class="block">
- <li>Repeat for each element <i>k</i> of <i>keys</i>,
- <ol class="block">
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>O</i>, <i>k</i>,
- PropertyDescriptor{ [[Configurable]]: <b>false</b>}).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Else <i>level</i> is <code>"frozen"</code>,
- <ol class="block">
- <li>Repeat for each element <i>k</i> of <i>keys</i>,
- <ol class="block">
- <li>Let <i>currentDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>k</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>currentDesc</i>).</li>
- <li>If <i>currentDesc</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>currentDesc</i>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>desc</i> be the PropertyDescriptor{[[Configurable]]: <b>false</b>}.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>desc</i> be the PropertyDescriptor { [[Configurable]]: <b>false</b>, [[Writable]]: <b>false</b>
- }.</li>
- </ol>
- </li>
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>O</i>, <i>k</i>,
- <i>desc</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-testintegritylevel">
- <h1><span class="secnum" id="sec-7.3.16"><a href="#sec-testintegritylevel" title="link to this section">7.3.16</a></span>
- TestIntegrityLevel (O, level)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">TestIntegrityLevel</span> is used to determine if the
- set of own properties of an object are fixed. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>level</i> is either <code>"sealed"</code> or
- <code>"frozen"</code>.</li>
- <li>Let <i>status</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>O</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>If <i>status</i> is <b>true</b>, return <b>false</b></li>
- <li>NOTE If the object is extensible, none of its properties are examined.</li>
- <li>Let <i>keys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>keys</i>).</li>
- <li>Repeat for each element <i>k</i> of <i>keys</i>,
- <ol class="block">
- <li>Let <i>currentDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>k</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>currentDesc</i>).</li>
- <li>If <i>currentDesc</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>If <i>currentDesc</i>.[[Configurable]] is <b>true</b>, return <b>false</b>.</li>
- <li>If <i>level</i> is <code>"frozen"</code> and <a
- href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>currentDesc</i>) is <b>true</b>, then
- <ol class="block">
- <li>If <i>currentDesc</i>.[[Writable]] is <b>true</b>, return <b>false</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-createarrayfromlist">
- <h1><span class="secnum" id="sec-7.3.17"><a href="#sec-createarrayfromlist" title="link to this section">7.3.17</a></span>
- CreateArrayFromList (elements)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">CreateArrayFromList</span> is used to create an Array
- object whose elements are provided by a <a href="#sec-list-and-record-specification-type">List</a>. This abstract operation
- performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>elements</i> is a <a
- href="#sec-list-and-record-specification-type">List</a> whose elements are all <a
- href="#sec-ecmascript-language-types">ECMAScript language values</a>.</li>
- <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0) (<a href="#sec-arraycreate">see 9.4.2.2</a>).</li>
- <li>Let <i>n</i> be 0.</li>
- <li>For each element <i>e</i> of <i>elements</i>
- <ol class="block">
- <li>Let <i>status</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
- href="#sec-tostring">ToString</a>(<i>n</i>), <i>e</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is <b>true</b>.</li>
- <li>Increment <i>n</i> by 1.</li>
- </ol>
- </li>
- <li>Return <i>array</i>.</li>
- </ol>
- </section>
-
- <section id="sec-createlistfromarraylike">
- <h1><span class="secnum" id="sec-7.3.18"><a href="#sec-createlistfromarraylike"
- title="link to this section">7.3.18</a></span> CreateListFromArrayLike (obj [, elementTypes] )</h1>
-
- <p>The abstract operation CreateListFromArrayLike is used to create a List value whose elements are provided by the indexed
- properties of an array-like object, <var>obj</var>. The optional argument <var>elementTypes</var> is a <a
- href="#sec-list-and-record-specification-type">List</a> containing the names of ECMAScript Language Types that are allowed
- for element values of the <a href="#sec-list-and-record-specification-type">List</a> that is created. This abstract
- operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>obj</i>).</li>
- <li>If <i>elementTypes</i> was not passed, let <i>elementTypes</i> be (Undefined, Null, Boolean, String, Symbol, Number,
- Object).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>obj</i>) is not Object, throw a <b>TypeError</b>
- exception.</li>
- <li>Let <i>len</i> be <a href="#sec-tolength">ToLength</a>(<a href="#sec-get-o-p">Get</a>(<i>obj</i>,
- <code>"length"</code>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
- <li>Let <i>list</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Let <i>index</i> be 0.</li>
- <li>Repeat while <i>index</i> &lt; <i>len</i>
- <ol class="block">
- <li>Let <i>indexName</i> be <a href="#sec-tostring">ToString</a>(<i>index</i>).</li>
- <li>Let <i>next</i> be <a href="#sec-get-o-p">Get</a>(<i>obj</i>, <i>indexName</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>next</i>) is not an element of <i>elementTypes</i>,
- throw a <b>TypeError</b> exception.</li>
- <li>Append <i>next</i> as the last element of <i>list</i>.</li>
- <li>Set <i>index</i> to <i>index</i> + 1.</li>
- </ol>
- </li>
- <li>Return <i>list</i>.</li>
- </ol>
- </section>
-
- <section id="sec-ordinaryhasinstance">
- <h1><span class="secnum" id="sec-7.3.19"><a href="#sec-ordinaryhasinstance" title="link to this section">7.3.19</a></span>
- OrdinaryHasInstance (C, O)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">OrdinaryHasInstance</span> implements the default
- algorithm for determining if an object <var>O</var> inherits from the instance object inheritance path provided by
- constructor <var>C</var>. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li>If <a href="#sec-iscallable">IsCallable</a>(<i>C</i>) is <b>false</b>, return <b>false</b>.</li>
- <li>If <i>C</i> has a <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, then
- <ol class="block">
- <li>Let <i>BC</i> be the value of <i>C&rsquo;s</i> <a
- href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Return <a href="#sec-instanceofoperator">InstanceofOperator</a>(<i>O</i>,<i>BC</i>) (<a
- href="#sec-instanceofoperator">see 12.9.4</a>).</li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is not Object, return <b>false</b>.</li>
- <li>Let <i>P</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, <code>"prototype"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>P</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is not Object, throw a <b>TypeError</b>
- exception.</li>
- <li>Repeat
- <ol class="block">
- <li>Let <i>O</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>O</i>).</li>
- <li>If <i>O</i> is <code>null</code>, return <b>false</b>.</li>
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>P</i>, <i>O</i>) is <b>true</b>, return <b>true</b>.</li>
- </ol>
- </li>
- </ol>
- </section>
-
- <section id="sec-speciesconstructor">
- <h1><span class="secnum" id="sec-7.3.20"><a href="#sec-speciesconstructor" title="link to this section">7.3.20</a></span>
- SpeciesConstructor ( O, defaultConstructor )</h1>
-
- <p>The abstract operation SpeciesConstructor is used to retrieve the constructor that should be used to create new objects
- that are derived from the argument object <var>O</var>. The <var>defaultConstructor</var> argument is the constructor to use
- if a constructor @@species property cannot be found starting from <var>O</var>. This abstract operation performs the
- following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>) is
- Object.</li>
- <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>O</i>, <code>"constructor"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
- <li>If <i>C</i> is <b>undefined</b>, return <i>defaultConstructor</i>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>C</i>) is not Object, throw a <b>TypeError</b>
- exception.</li>
- <li>Let <i>S</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, @@species).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>S</i>).</li>
- <li>If <i>S</i> is either <b>undefined</b> or <b>null</b>, return <i>defaultConstructor</i>.</li>
- <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>S</i>) is <b>true</b>, return <i>S.</i></li>
- <li>Throw a <b>TypeError</b> exception.</li>
- </ol>
- </section>
-
- <section id="sec-enumerableownnames">
- <h1><span class="secnum" id="sec-7.3.21"><a href="#sec-enumerableownnames" title="link to this section">7.3.21</a></span>
- EnumerableOwnNames (O)</h1>
-
- <p>When the abstract operation EnumerableOwnNames is called with Object <var>O</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>O</i>)
- is Object.</li>
- <li>Let <i>ownKeys</i> be <i>O</i>.[[OwnPropertyKeys]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ownKeys</i>).</li>
- <li>Let <i>names</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Repeat, for each element <i>key</i> of <i>ownKeys</i> in <a href="#sec-list-and-record-specification-type">List</a>
- order
- <ol class="block">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>key</i>) is String, then
- <ol class="block">
- <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>key</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
- <li>If <i>desc</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>If <i>desc.</i>[[Enumerable]] is <b>true</b>, append <i>key</i> to <i>names</i>.</li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Order the elements of <i>names</i> so they are in the same relative order as would be produced by the Iterator that
- would be returned if the [[Enumerate]] internal method was invoked on <i>O</i>.</li>
- <li>Return <i>names</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The order of elements is returned list is the same as the enumeration order that used by a
- for-in statement.</p>
- </div>
- </section>
-
- <section id="sec-getfunctionrealm">
- <h1><span class="secnum" id="sec-7.3.22"><a href="#sec-getfunctionrealm" title="link to this section">7.3.22</a></span>
- GetFunctionRealm ( obj )</h1>
-
- <p>The abstract operation GetFunctionRealm with argument <var>obj</var> performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>obj</i> is a callable object.</li>
- <li>If <i>obj</i> has a [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, then
- <ol class="block">
- <li>Return <i>obj</i>&rsquo;s [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a>.</li>
- </ol>
- </li>
- <li>If <i>obj</i> is a <a href="#sec-bound-function-exotic-objects">Bound Function</a> exotic object, then
- <ol class="block">
- <li>Let <i>target</i> be <i>obj</i>&rsquo;s <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a>
- <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Return GetFunctionRealm(<i>target</i>).</li>
- </ol>
- </li>
- <li>If <i>obj</i> is a Proxy exotic object, then
- <ol class="block">
- <li>If the value of the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
- of <i>obj</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li>Let <i>proxyTarget</i> be the value of <i>obj</i>&rsquo;s [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Return GetFunctionRealm(<i>proxyTarget</i>).</li>
- </ol>
- </li>
- <li>Return <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
- href="#sec-code-realms">Realm</a>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Step 5 will only be reached if <i>target</i> is a non-standard exotic function object that
- does not have a [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-operations-on-iterator-objects">
- <div class="front">
- <h1><span class="secnum" id="sec-7.4"><a href="#sec-operations-on-iterator-objects"
- title="link to this section">7.4</a></span> Operations on Iterator Objects</h1>
-
- <p>See Common Iteration Interfaces (<a href="#sec-iteration">25.1</a>).</p>
- </div>
-
- <section id="sec-getiterator">
- <h1><span class="secnum" id="sec-7.4.1"><a href="#sec-getiterator" title="link to this section">7.4.1</a></span> GetIterator
- ( obj, method )</h1>
-
- <p>The abstract operation GetIterator with argument <span style="font-family: Times New Roman"><i>obj</i> and</span>
- optional argument <var>method</var> performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>obj</i>).</li>
- <li>If <i>method</i> was not passed, then
- <ol class="block">
- <li>Let <i>method</i> be <a href="#sec-getmethod">GetMethod</a>(<i>obj</i>, @@iterator).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>method</i>).</li>
- </ol>
- </li>
- <li>Let <i>iterator</i> be <a href="#sec-call">Call</a>(<i>method</i>,<i>obj</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>)<i>.</i></li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterator</i>) is not Object, throw a <b>TypeError</b>
- exception.</li>
- <li>Return <i>iterator</i>.</li>
- </ol>
- </section>
-
- <section id="sec-iteratornext">
- <h1><span class="secnum" id="sec-7.4.2"><a href="#sec-iteratornext" title="link to this section">7.4.2</a></span>
- IteratorNext ( iterator, value )</h1>
-
- <p>The abstract operation IteratorNext with argument <var>iterator</var> and optional argument <var>value</var> performs the
- following steps:</p>
-
- <ol class="proc">
- <li>If <i>value</i> was not passed, then
- <ol class="block">
- <li>Let <i>result</i> be <a href="#sec-invoke">Invoke</a>(<i>iterator</i>, <code>"next"</code>, &laquo;&zwj;
- &raquo;).</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>result</i> be <a href="#sec-invoke">Invoke</a>(<i>iterator</i>, <code>"next"</code>,
- &laquo;&zwj;<i>value</i>&raquo;).</li>
- </ol>
- </li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is not Object, throw a <b>TypeError</b>
- exception.</li>
- <li>Return <i>result</i>.</li>
- </ol>
- </section>
-
- <section id="sec-iteratorcomplete">
- <h1><span class="secnum" id="sec-7.4.3"><a href="#sec-iteratorcomplete" title="link to this section">7.4.3</a></span>
- IteratorComplete ( iterResult )</h1>
-
- <p>The abstract operation IteratorComplete with argument <var>iterResult</var> performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterResult</i>) is Object.</li>
- <li>Return <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-get-o-p">Get</a>(<i>iterResult</i>,
- <code>"done"</code>)).</li>
- </ol>
- </section>
-
- <section id="sec-iteratorvalue">
- <h1><span class="secnum" id="sec-7.4.4"><a href="#sec-iteratorvalue" title="link to this section">7.4.4</a></span>
- IteratorValue ( iterResult )</h1>
-
- <p>The abstract operation IteratorValue with argument <var>iterResult</var> performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterResult</i>) is Object.</li>
- <li>Return <a href="#sec-get-o-p">Get</a>(<i>iterResult</i>, <code>"value"</code>).</li>
- </ol>
- </section>
-
- <section id="sec-iteratorstep">
- <h1><span class="secnum" id="sec-7.4.5"><a href="#sec-iteratorstep" title="link to this section">7.4.5</a></span>
- IteratorStep ( iterator )</h1>
-
- <p>The abstract operation IteratorStep with argument <var>iterator</var> requests the next value from <var>iterator</var>
- and returns either <span class="value">false</span> indicating that the iterator has reached its end or the IteratorResult
- object if a next value is available. IteratorStep performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>result</i> be <a href="#sec-iteratornext">IteratorNext</a>(<i>iterator</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
- <li>Let <i>done</i> be <a href="#sec-iteratorcomplete">IteratorComplete</a>(<i>result</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>done</i>).</li>
- <li>If <i>done</i> is <b>true</b>, return <b>false</b>.</li>
- <li>Return <i>result</i>.</li>
- </ol>
- </section>
-
- <section id="sec-iteratorclose">
- <h1><span class="secnum" id="sec-7.4.6"><a href="#sec-iteratorclose" title="link to this section">7.4.6</a></span>
- IteratorClose( iterator, completion )</h1>
-
- <p>The abstract operation IteratorClose with arguments <var>iterator</var> and <var>completion</var> is used to notify an
- iterator that it should perform any actions it would normally perform when it has reached its completed state:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>iterator</i>) is Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>completion</i> is a <a
- href="#sec-completion-record-specification-type">Completion Record</a>.</li>
- <li>Let <i>return</i> be <a href="#sec-getmethod">GetMethod</a>(<i>iterator</i>, <code>"return"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>return</i>).</li>
- <li>If <i>return</i> is <b>undefined</b>, return <a
- href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
- <li>Let <i>innerResult</i> be <a href="#sec-call">Call</a>(<i>return</i>, <i>iterator</i>, &laquo;&zwj; &raquo;).</li>
- <li>If <i>completion</i>.[[type]] is <span style="font-family: sans-serif">throw</span>, return <a
- href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
- <li>If <i>innerResult</i>.[[type]] is <span style="font-family: sans-serif">throw</span>, return <a
- href="#sec-completion-record-specification-type">Completion</a>(<i>innerResult</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>innerResult</i>.[[value]]) is not Object<i>,</i> throw
- a <b>TypeError</b> exception.</li>
- <li>Return <a href="#sec-completion-record-specification-type">Completion</a>(<i>completion</i>).</li>
- </ol>
- </section>
-
- <section id="sec-createiterresultobject">
- <h1><span class="secnum" id="sec-7.4.7"><a href="#sec-createiterresultobject" title="link to this section">7.4.7</a></span>
- CreateIterResultObject ( value, done )</h1>
-
- <p>The abstract operation CreateIterResultObject with arguments <var>value</var> and <var>done</var> creates an object that
- supports the IteratorResult interface by performing the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>done</i>)
- is Boolean.</li>
- <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
- sans-serif">%ObjectPrototype%</span>).</li>
- <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <code>"value"</code>, <i>value</i>).</li>
- <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <code>"done"</code>, <i>done</i>).</li>
- <li>Return <i>obj</i>.</li>
- </ol>
- </section>
-
- <section id="sec-createlistiterator">
- <div class="front">
- <h1><span class="secnum" id="sec-7.4.8"><a href="#sec-createlistiterator" title="link to this section">7.4.8</a></span>
- CreateListIterator ( list )</h1>
-
- <p>The abstract operation CreateListIterator with argument <var>list</var> creates an Iterator (<a
- href="#sec-iterator-interface">25.1.1.2</a>) object whose next method returns the successive elements of <var>list</var>.
- It performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>iterator</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%IteratorPrototype%, &laquo;[[IteratorNext]],
- [[IteratedList]], [[ListIteratorNextIndex]]&raquo;).</li>
- <li>Set <i>iterator&rsquo;s</i> [[IteratedList]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a> to <i>list</i>.</li>
- <li>Set <i>iterator&rsquo;s</i> [[ListIteratorNextIndex]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to 0.</li>
- <li>Let <i>next</i> be a new built-in function object as defined in ListIterator <code>next</code> (<a
- href="#sec-listiterator-next">7.4.8.1</a>).</li>
- <li>Set <i>iterator&rsquo;s</i> [[IteratorNext]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a> to <i>next</i>.</li>
- <li>Perform <a href="#sec-createmethodproperty">CreateMethodProperty</a>(<i>iterator</i>, <code>"next"</code>,
- <i>next</i>).</li>
- <li>Return <i>iterator</i>.</li>
- </ol>
- </div>
-
- <section id="sec-listiterator-next">
- <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>
- ListIterator next( )</h1>
-
- <p>The ListIterator <code>next</code> method is a standard built-in function object (<a
- href="#sec-ecmascript-standard-built-in-objects">clause 17</a>) that performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>O</i> be the <b>this</b> value.</li>
- <li>Let <i>f</i> be the active function object.</li>
- <li>If <i>O</i> does not have a [[IteratorNext]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a>, throw a <b>TypeError</b> exception.</li>
- <li>Let <i>next</i> be the value of the [[IteratorNext]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>f</i>, <i>next</i>) is <b>false</b>, throw a <b>TypeError</b>
- exception.</li>
- <li>If <i>O</i> does not have a [[IteratedList]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a>, throw a <b>TypeError</b> exception.</li>
- <li>Let <i>list</i> be the value of the [[IteratedList]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>index</i> be the value of the [[ListIteratorNextIndex]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>len</i> be the number of elements of <i>list</i>.</li>
- <li>If <i>index</i> &ge; <i>len</i>, then
- <ol class="block">
- <li>Return <a href="#sec-createiterresultobject">CreateIterResultObject</a>(<b>undefined</b>, <b>true</b>).</li>
- </ol>
- </li>
- <li>Set the value of the [[ListIteratorNextIndex]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a> of <i>O</i> to <i>index</i>+1.</li>
- <li>Return <a href="#sec-createiterresultobject">CreateIterResultObject</a>(<i>list</i>[<i>index</i>],
- <b>false</b>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A ListIterator <code>next</code> method will throw an exception if applied to any object
- other than the one with which it was originally associated.</p>
- </div>
- </section>
- </section>
- </section>
-</section>
-
-<section id="sec-executable-code-and-execution-contexts">
- <div class="front">
- <h1><span class="secnum" id="sec-8"><a href="#sec-executable-code-and-execution-contexts"
- title="link to this section">8</a></span> Executable Code and Execution Contexts</h1>
- </div>
-
- <section id="sec-lexical-environments">
- <div class="front">
- <h1><span class="secnum" id="sec-8.1"><a href="#sec-lexical-environments" title="link to this section">8.1</a></span>
- Lexical Environments</h1>
-
- <p>A <i>Lexical Environment</i> is a specification type used to define the association of <span
- class="nt">Identifiers</span> to specific variables and functions based upon the lexical nesting structure of ECMAScript
- code. A Lexical Environment consists of an <a href="#sec-environment-records">Environment Record</a> and a possibly null
- reference to an <i>outer</i> Lexical Environment. Usually a Lexical Environment is associated with some specific syntactic
- structure of ECMAScript code such as a <span class="nt">FunctionDeclaration</span>, a <span
- class="nt">BlockStatement</span>, or a <span class="nt">Catch</span> clause of a <span class="nt">TryStatement</span> and a
- new Lexical Environment is created each time such code is evaluated.</p>
-
- <p>An <a href="#sec-environment-records">Environment Record</a> records the identifier bindings that are created within the
- scope of its associated Lexical Environment. It is referred to as the Lexical Environment&rsquo;s EnvironmentRecord</p>
-
- <p>The outer environment reference is used to model the logical nesting of Lexical Environment values. The outer reference
- of a (inner) Lexical Environment is a reference to the Lexical Environment that logically surrounds the inner Lexical
- Environment. An outer Lexical Environment may, of course, have its own outer Lexical Environment. A Lexical Environment may
- serve as the outer environment for multiple inner Lexical Environments. For example, if a <span
- class="nt">FunctionDeclaration</span> contains two nested <span class="nt">FunctionDeclarations</span> then the Lexical
- Environments of each of the nested functions will have as their outer Lexical Environment the Lexical Environment of the
- current evaluation of the surrounding function.</p>
-
- <p>A <i>global environment</i> is a Lexical Environment which does not have an outer environment. The global
- environment&rsquo;s outer environment reference is <b>null</b>. A global environment&rsquo;s <a
- href="#sec-environment-records">Environment Record</a> may be prepopulated with identifier bindings and includes an
- associated <i>global object</i> whose properties provide some of <a href="#sec-global-environment-records">the global
- environment</a>&rsquo;s identifier bindings. This global object is the value of a global environment&rsquo;s
- <code>this</code> binding. As ECMAScript code is executed, additional properties may be added to the global object and the
- initial properties may be modified.</p>
-
- <p>A <i>module environment</i> is a Lexical Environment that contains the bindings for the top level declarations of a <span
- class="nt">Module</span>. It also contains the bindings that are explicitly imported by the <span class="nt">Module</span>.
- The outer environment of a module environment is a global environment.</p>
-
- <p>A <i>function environment</i> is a Lexical Environment that corresponds to the invocation of an <a
- href="#sec-ecmascript-function-objects">ECMAScript function object</a>. A function environment may establish a new
- <code>this</code> binding. A function environment also captures the state necessary to support <code>super</code> method
- invocations.</p>
-
- <p>Lexical Environments and <a href="#sec-environment-records">Environment Record</a> values are purely specification
- mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an
- ECMAScript program to directly access or manipulate such values.</p>
- </div>
-
- <section id="sec-environment-records">
- <div class="front">
- <h1><span class="secnum" id="sec-8.1.1"><a href="#sec-environment-records" title="link to this section">8.1.1</a></span>
- Environment Records</h1>
-
- <p>There are two primary kinds of Environment Record values used in this specification: <i>declarative Environment
- Records</i> and <i>object Environment Records</i>. Declarative Environment Records are used to define the effect of
- ECMAScript language syntactic elements such as <span class="nt">FunctionDeclarations</span>, <span
- class="nt">VariableDeclarations</span>, and <span class="nt">Catch</span> clauses that directly associate identifier
- bindings with <a href="#sec-ecmascript-language-types">ECMAScript language values</a>. Object Environment Records are used
- to define the effect of ECMAScript elements such as <span class="nt">WithStatement</span> that associate identifier
- bindings with the properties of some object. <a href="#sec-global-environment-records">Global Environment Records</a> and
- function Environment Records are specializations that are used for specifically for <span class="nt">Script</span> global
- declarations and for top-level declarations within functions.</p>
-
- <p>For specification purposes Environment Record values are values of the Record specification type and can be thought of
- as existing in a simple object-oriented hierarchy where Environment Record is an abstract class with three concrete
- subclasses, declarative Environment Record, object Environment Record, and global Environment Record. <a
- href="#sec-function-environment-records">Function Environment Records</a> and module Environment Records are subclasses of
- declarative Environment Record. The abstract class includes the abstract specification methods defined in <a
- href="#table-15">Table 15</a>. These abstract methods have distinct concrete algorithms for each of the concrete
- subclasses.</p>
-
- <figure>
- <figcaption><span id="table-15">Table 15</span> &mdash; Abstract Methods of Environment Records</figcaption>
- <table class="real-table">
- <tr>
- <th>Method</th>
- <th>Purpose</th>
- </tr>
- <tr>
- <td>HasBinding(N)</td>
- <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>
- </tr>
- <tr>
- <td>CreateMutableBinding(N, D)</td>
- <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>
- </tr>
- <tr>
- <td>CreateImmutableBinding(N, S)</td>
- <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>
- </tr>
- <tr>
- <td>InitializeBinding(N,V)</td>
- <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>
- </tr>
- <tr>
- <td>SetMutableBinding(N,V, S)</td>
- <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>
- </tr>
- <tr>
- <td>GetBindingValue(N,S)</td>
- <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>
- </tr>
- <tr>
- <td>DeleteBinding(N)</td>
- <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>
- </tr>
- <tr>
- <td>HasThisBinding()</td>
- <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>
- </tr>
- <tr>
- <td>HasSuperBinding()</td>
- <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>
- </tr>
- <tr>
- <td>WithBaseObject ()</td>
- <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>
- </tr>
- </table>
- </figure>
- </div>
-
- <section id="sec-declarative-environment-records">
- <div class="front">
- <h1><span class="secnum" id="sec-8.1.1.1"><a href="#sec-declarative-environment-records"
- title="link to this section">8.1.1.1</a></span> Declarative Environment Records</h1>
-
- <p>Each declarative <a href="#sec-environment-records">Environment Record</a> is associated with an ECMAScript program
- scope containing variable, constant, let, class, module, import, and/or function declarations. A declarative <a
- href="#sec-environment-records">Environment Record</a> binds the set of identifiers defined by the declarations
- contained within its scope.</p>
-
- <p>The behaviour of the concrete specification methods for declarative environment records is defined by the following
- algorithms.</p>
- </div>
-
- <section id="sec-declarative-environment-records-hasbinding-n">
- <h1><span class="secnum" id="sec-8.1.1.1.1"><a href="#sec-declarative-environment-records-hasbinding-n"
- title="link to this section">8.1.1.1.1</a></span> HasBinding(N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for declarative Environment
- Records simply determines if the argument identifier is one of the identifiers bound by the record:</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
- method was invoked.</li>
- <li>If <i>envRec</i> has a binding for the name that is the value of <i>N</i>, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-declarative-environment-records-createmutablebinding-n-d">
- <h1><span class="secnum" id="sec-8.1.1.1.2"><a href="#sec-declarative-environment-records-createmutablebinding-n-d"
- title="link to this section">8.1.1.1.2</a></span> CreateMutableBinding (N, D)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for declarative
- Environment Records creates a new mutable binding for the name <var>N</var> that is uninitialized. A binding must not
- already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
- <var>D</var> is provided and has the value <b>true</b> the new binding is marked as being subject to deletion.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
- method was invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
- <li>Create a mutable binding in <i>envRec</i> for <i>N</i> and record that it is uninitialized. If <i>D</i> is
- <b>true</b> record that the newly created binding may be deleted by a subsequent DeleteBinding call.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
- </section>
-
- <section id="sec-declarative-environment-records-createimmutablebinding-n-s">
- <h1><span class="secnum" id="sec-8.1.1.1.3"><a href="#sec-declarative-environment-records-createimmutablebinding-n-s"
- title="link to this section">8.1.1.1.3</a></span> CreateImmutableBinding (N, S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding for declarative
- Environment Records creates a new immutable binding for the name <var>N</var> that is uninitialized. A binding must not
- already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
- <var>S</var> is provided and has the value <b>true</b> the new binding is marked as a strict binding.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
- method was invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
- <li>Create an immutable binding in <i>envRec</i> for <i>N</i> and record that it is uninitialized. If <i>S</i> is
- <b>true</b> record that the newly created binding is a strict binding.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
- </section>
-
- <section id="sec-declarative-environment-records-initializebinding-n-v">
- <h1><span class="secnum" id="sec-8.1.1.1.4"><a href="#sec-declarative-environment-records-initializebinding-n-v"
- title="link to this section">8.1.1.1.4</a></span> InitializeBinding (N,V)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for declarative
- Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
- the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
- exist.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
- method was invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> must have an uninitialized binding for
- <i>N</i>.</li>
- <li>Set the bound value for <i>N</i> in <i>envRec</i> to <i>V</i>.</li>
- <li>Record that the binding for <i>N</i> in <i>envRec</i> has been initialized.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
- </section>
-
- <section id="sec-declarative-environment-records-setmutablebinding-n-v-s">
- <h1><span class="secnum" id="sec-8.1.1.1.5"><a href="#sec-declarative-environment-records-setmutablebinding-n-v-s"
- title="link to this section">8.1.1.1.5</a></span> SetMutableBinding (N,V,S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for declarative
- Environment Records attempts to change the bound value of the current binding of the identifier whose name is the value
- of the argument <var>N</var> to the value of argument <var>V</var>. A binding for <var>N</var> normally already exist,
- but in rare cases it may not. If the binding is an immutable binding, a <b>TypeError</b> is thrown if <span
- style="font-family: Times New Roman">S</span> is <span class="value">true</span>.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
- method was invoked.</li>
- <li>If <i>envRec</i> does not have a binding for <i>N</i>, then
- <ol class="block">
- <li>If <i>S</i> is <b>true</b> throw a <b>ReferenceError</b> exception.</li>
- <li>Perform <i>envRec</i>.CreateMutableBinding(<i>N</i>, <b>true</b>).</li>
- <li>Perform <i>envRec</i>.InitializeBinding(<i>N</i>, <i>V</i>).</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
- </li>
- <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>
- <li>If the binding for <i>N</i> in <i>envRec</i> has not yet been initialized throw a <b>ReferenceError</b>
- exception.</li>
- <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>
- <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
- <b>TypeError</b> exception.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> An example of ECMAScript code that results in a missing binding at step 2 is:</p>
-
- <pre>function f(){eval("var x; x = (delete x, 0);")}</pre>
- </div>
- </section>
-
- <section id="sec-declarative-environment-records-getbindingvalue-n-s">
- <h1><span class="secnum" id="sec-8.1.1.1.6"><a href="#sec-declarative-environment-records-getbindingvalue-n-s"
- title="link to this section">8.1.1.1.6</a></span> GetBindingValue(N,S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for declarative
- Environment Records simply returns the value of its bound identifier whose name is the value of the argument
- <var>N</var>. 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></p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
- method was invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for <i>N</i>.</li>
- <li>If the binding for <i>N</i> in <i>envRec</i> is an uninitialized binding, throw a <b>ReferenceError</b>
- exception.</li>
- <li>Return the value currently bound to <i>N</i> in <i>envRec</i>.</li>
- </ol>
- </section>
-
- <section id="sec-declarative-environment-records-deletebinding-n">
- <h1><span class="secnum" id="sec-8.1.1.1.7"><a href="#sec-declarative-environment-records-deletebinding-n"
- title="link to this section">8.1.1.1.7</a></span> DeleteBinding (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for declarative
- Environment Records can only delete bindings that have been explicitly designated as being subject to deletion.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the declarative <a href="#sec-environment-records">Environment Record</a> for which the
- method was invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for the name that is the value of
- <i>N</i>.</li>
- <li>If the binding for <i>N</i> in <i>envRec</i> cannot be deleted, return <b>false</b>.</li>
- <li>Remove the binding for <i>N</i> from <i>envRec</i>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-declarative-environment-records-hasthisbinding">
- <h1><span class="secnum" id="sec-8.1.1.1.8"><a href="#sec-declarative-environment-records-hasthisbinding"
- title="link to this section">8.1.1.1.8</a></span> HasThisBinding ()</h1>
-
- <p>Regular declarative Environment Records do not provide a <code>this</code> binding.</p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-declarative-environment-records-hassuperbinding">
- <h1><span class="secnum" id="sec-8.1.1.1.9"><a href="#sec-declarative-environment-records-hassuperbinding"
- title="link to this section">8.1.1.1.9</a></span> HasSuperBinding ()</h1>
-
- <p>Regular declarative Environment Records do not provide a <code>super</code> binding.</p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-declarative-environment-records-withbaseobject">
- <h1><span class="secnum" id="sec-8.1.1.1.10"><a href="#sec-declarative-environment-records-withbaseobject"
- title="link to this section">8.1.1.1.10</a></span> WithBaseObject()</h1>
-
- <p>Declarative Environment Records always return <b>undefined</b> as their WithBaseObject.</p>
-
- <ol class="proc">
- <li>Return <b>undefined</b>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-object-environment-records">
- <div class="front">
- <h1><span class="secnum" id="sec-8.1.1.2"><a href="#sec-object-environment-records"
- title="link to this section">8.1.1.2</a></span> Object Environment Records</h1>
-
- <p>Each object <a href="#sec-environment-records">Environment Record</a> is associated with an object called its
- <i>binding object</i>. An object <a href="#sec-environment-records">Environment Record</a> binds the set of string
- identifier names that directly correspond to the property names of its binding object. Property keys that are not
- strings in the form of an <span class="nt">IdentifierName</span> are not included in the set of bound identifiers. Both
- own and inherited properties are included in the set regardless of the setting of their [[Enumerable]] attribute.
- Because properties can be dynamically added and deleted from objects, the set of identifiers bound by an object <a
- href="#sec-environment-records">Environment Record</a> may potentially change as a side-effect of any operation that
- adds or deletes properties. Any bindings that are created as a result of such a side-effect are considered to be a
- mutable binding even if the Writable attribute of the corresponding property has the value <b>false</b>. Immutable
- bindings do not exist for object Environment Records.</p>
-
- <p>Object Environment Records created for <code>with</code> statements (<a href="#sec-with-statement">13.10</a>) can
- provide their binding object as an implicit <b>this</b> value for use in function calls. The capability is controlled by
- a <var>withEnvironment</var> Boolean value that is associated with each object <a
- href="#sec-environment-records">Environment Record</a>. By default, the value of <var>withEnvironment</var> is
- <b>false</b> for any object <a href="#sec-environment-records">Environment Record</a>.</p>
-
- <p>The behaviour of the concrete specification methods for object environment records is defined by the following
- algorithms.</p>
- </div>
-
- <section id="sec-object-environment-records-hasbinding-n">
- <h1><span class="secnum" id="sec-8.1.1.2.1"><a href="#sec-object-environment-records-hasbinding-n"
- title="link to this section">8.1.1.2.1</a></span> HasBinding(N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for object Environment
- Records determines if its associated binding object has a property whose name is the value of the argument
- <var>N</var>:</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
- <li>Let <i>foundBinding</i> be <a href="#sec-hasproperty">HasProperty</a>(<i>bindings</i>, <i>N</i>)</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>foundBinding</i>).</li>
- <li>If <i>foundBinding</i> is <b>false</b>, return <b>false</b>.</li>
- <li>If the <i>withEnvironment</i> flag of <i>envRec</i> is <b>false</b>, return <b>true</b>.</li>
- <li>Let <i>unscopables</i> be <a href="#sec-get-o-p">Get</a>(<i>bindings</i>, @@unscopables).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>unscopables</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>unscopables</i>) is Object, then
- <ol class="block">
- <li>Let <i>blocked</i> be <a href="#sec-toboolean">ToBoolean</a>(<a
- href="#sec-get-o-p">Get</a>(<i>unscopables</i>, <i>N</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>blocked</i>).</li>
- <li>If <i>blocked</i> is <b>true</b>, return <b>false</b>.</li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-object-environment-records-createmutablebinding-n-d">
- <h1><span class="secnum" id="sec-8.1.1.2.2"><a href="#sec-object-environment-records-createmutablebinding-n-d"
- title="link to this section">8.1.1.2.2</a></span> CreateMutableBinding (N, D)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for object
- Environment Records creates in an Environment Record&rsquo;s associated binding object a property whose name is the
- String value and initializes it to the value <b>undefined</b>. If Boolean argument <var>D</var> is provided and has the
- value <b>true</b> the new property&rsquo;s [[Configurable]] attribute is set to <b>true</b>, otherwise it is set to
- <b>false</b>.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
- <li>If <i>D</i> is <b>true</b> then let <i>configValue</i> be <b>true</b> otherwise let <i>configValue</i> be
- <b>false</b>.</li>
- <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>bindings</i>, <i>N</i>,
- PropertyDescriptor{[[Value]]:<b>undefined</b>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>true</b> ,
- [[Configurable]]: <i>configValue</i>}).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Normally <i>envRec</i> will not have a binding for <i>N</i> but if it does, the
- semantics of <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a> may result in an existing binding being
- replaced or shadowed or cause an <a href="#sec-completion-record-specification-type">abrupt completion</a> to be
- returned.</p>
- </div>
- </section>
-
- <section id="sec-object-environment-records-createimmutablebinding-n-s">
- <h1><span class="secnum" id="sec-8.1.1.2.3"><a href="#sec-object-environment-records-createimmutablebinding-n-s"
- title="link to this section">8.1.1.2.3</a></span> CreateImmutableBinding (N, S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding is never used
- within this specification in association with Object Environment Records.</p>
- </section>
-
- <section id="sec-object-environment-records-initializebinding-n-v">
- <h1><span class="secnum" id="sec-8.1.1.2.4"><a href="#sec-object-environment-records-initializebinding-n-v"
- title="link to this section">8.1.1.2.4</a></span> InitializeBinding (N,V)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for object
- Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
- the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
- exist.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> must have an uninitialized binding for
- <i>N</i>.</li>
- <li>Record that the binding for <i>N</i> in <i>envRec</i> has been initialized.</li>
- <li>Return <i>envRec</i>.SetMutableBinding(<i>N</i>, <i>V</i>, <b>false</b>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> In this specification, all uses of CreateMutableBinding for object Environment Records
- are immediately followed by a call to InitializeBinding for the same name. Hence, implementations do not need to
- explicitly track the initialization state of individual object Environment Record bindings.</p>
- </div>
- </section>
-
- <section id="sec-object-environment-records-setmutablebinding-n-v-s">
- <h1><span class="secnum" id="sec-8.1.1.2.5"><a href="#sec-object-environment-records-setmutablebinding-n-v-s"
- title="link to this section">8.1.1.2.5</a></span> SetMutableBinding (N,V,S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for object
- Environment Records attempts to set the value of the Environment Record&rsquo;s associated binding object&rsquo;s
- property whose name is the value of the argument <var>N</var> to the value of argument <var>V</var>. A property named
- <var>N</var> normally already exists but if it does not or is not currently writable, error handling is determined by
- the value of the Boolean argument <var>S</var>.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
- <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>
- </ol>
- </section>
-
- <section id="sec-object-environment-records-getbindingvalue-n-s">
- <h1><span class="secnum" id="sec-8.1.1.2.6"><a href="#sec-object-environment-records-getbindingvalue-n-s"
- title="link to this section">8.1.1.2.6</a></span> GetBindingValue(N,S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for object Environment
- Records returns the value of its associated binding object&rsquo;s property whose name is the String value of the
- argument identifier <var>N</var>. The property should already exist but if it does not the result depends upon the value
- of the <var>S</var> argument:</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
- <li>Let <i>value</i> be <a href="#sec-hasproperty">HasProperty</a>(<i>bindings</i>, <i>N</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
- <li>If <i>value</i> is <b>false</b>, then
- <ol class="block">
- <li>If <i>S</i> is <b>false</b>, return the value <b>undefined</b>, otherwise throw a <b>ReferenceError</b>
- exception.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-get-o-p">Get</a>(<i>bindings</i>, <i>N</i>).</li>
- </ol>
- </section>
-
- <section id="sec-object-environment-records-deletebinding-n">
- <h1><span class="secnum" id="sec-8.1.1.2.7"><a href="#sec-object-environment-records-deletebinding-n"
- title="link to this section">8.1.1.2.7</a></span> DeleteBinding (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for object Environment
- Records can only delete bindings that correspond to properties of the environment object whose [[Configurable]]
- attribute have the value <b>true</b>.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>bindings</i> be the binding object for <i>envRec</i>.</li>
- <li>Return <i>bindings</i>.[[Delete]](<i>N</i>).</li>
- </ol>
- </section>
-
- <section id="sec-object-environment-records-hasthisbinding">
- <h1><span class="secnum" id="sec-8.1.1.2.8"><a href="#sec-object-environment-records-hasthisbinding"
- title="link to this section">8.1.1.2.8</a></span> HasThisBinding ()</h1>
-
- <p>Regular object environment records do not provide a <code>this</code> binding.</p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-object-environment-records-hassuperbinding">
- <h1><span class="secnum" id="sec-8.1.1.2.9"><a href="#sec-object-environment-records-hassuperbinding"
- title="link to this section">8.1.1.2.9</a></span> HasSuperBinding ()</h1>
-
- <p>Regular object environment records do not provide a <code>super</code> binding.</p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-object-environment-records-withbaseobject">
- <h1><span class="secnum" id="sec-8.1.1.2.10"><a href="#sec-object-environment-records-withbaseobject"
- title="link to this section">8.1.1.2.10</a></span> WithBaseObject()</h1>
-
- <p>Object environment records return <b>undefined</b> as their WithBaseObject unless their <var>withEnvironment</var>
- flag is <b>true</b>.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the object <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>If the <i>withEnvironment</i> flag of <i>envRec</i> is <b>true</b>, return the binding object for
- <i>envRec</i>.</li>
- <li>Otherwise, return <b>undefined</b>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-function-environment-records">
- <div class="front">
- <h1><span class="secnum" id="sec-8.1.1.3"><a href="#sec-function-environment-records"
- title="link to this section">8.1.1.3</a></span> Function Environment Records</h1>
-
- <p>A function <a href="#sec-environment-records">Environment Record</a> is a declarative <a
- href="#sec-environment-records">Environment Record</a> that is used to represent the top-level scope of a function and,
- if the function is not an <span class="nt">ArrowFunction</span>, provides a <code>this</code> binding. If a function is
- not an <span class="nt">ArrowFunction</span> function and references <code>super</code>, its function <a
- href="#sec-environment-records">Environment Record</a> also contains the state that is used to perform
- <code>super</code> method invocations from within the function.</p>
-
- <p>Function Environment Records have the additional state fields listed in <a href="#table-16">Table 16</a>.</p>
-
- <figure>
- <figcaption><span id="table-16">Table 16</span> &mdash; Additional Fields of Function Environment Records</figcaption>
- <table class="real-table">
- <tr>
- <th>Field Name</th>
- <th>Value</th>
- <th>Meaning</th>
- </tr>
- <tr>
- <td>[[thisValue]]</td>
- <td>Any</td>
- <td>This is the <span class="value">this</span> value used for this invocation of the function.</td>
- </tr>
- <tr>
- <td>[[thisBindingStatus]]</td>
- <td><code>"lexical"</code> | <code>"initialized"</code> | <code>"uninitialized"</code></td>
- <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>
- </tr>
- <tr>
- <td>[[FunctionObject]]</td>
- <td>Object</td>
- <td>The function Object whose invocation caused this <a href="#sec-environment-records">Environment Record</a> to be created.</td>
- </tr>
- <tr>
- <td>[[HomeObject]]</td>
- <td>Object | <b>undefined</b></td>
- <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>
- </tr>
- <tr>
- <td>[[NewTarget]]</td>
- <td>Object | <b>undefined</b></td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>Function Environment Records support all of the declarative Environment Record methods listed in <a
- href="#table-15">Table 15</a> and share the same specifications for all of those methods except for HasThisBinding and
- HasSuperBinding. In addition, function Environment Records support the methods listed in <a href="#table-17">Table
- 17</a>:</p>
-
- <figure>
- <figcaption><span id="table-17">Table 17</span> &mdash; Additional Methods of Function Environment Records</figcaption>
- <table class="real-table">
- <tr>
- <th>Method</th>
- <th>Purpose</th>
- </tr>
- <tr>
- <td><a href="#sec-bindthisvalue">BindThisValue</a>(V)</td>
- <td>Set the [[thisValue]] and record that it has been initialized.</td>
- </tr>
- <tr>
- <td>GetThisBinding()</td>
- <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>
- </tr>
- <tr>
- <td><a href="#sec-getsuperbase">GetSuperBase</a>()</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>The behaviour of the additional concrete specification methods for function Environment Records is defined by the
- following algorithms:</p>
- </div>
-
- <section id="sec-bindthisvalue">
- <h1><span class="secnum" id="sec-8.1.1.3.1"><a href="#sec-bindthisvalue"
- title="link to this section">8.1.1.3.1</a></span> BindThisValue(V)</h1>
- <ol class="proc">
- <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
- was invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i>.[[thisBindingStatus]] is not
- <code>"lexical"</code>.</li>
- <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"initialized"</code>, throw a <b>ReferenceError</b>
- exception.</li>
- <li>Set <i>envRec</i>.[[thisValue]] to <i>V</i>.</li>
- <li>Set <i>envRec</i>.[[thisBindingStatus]] to <code>"initialized"</code>.</li>
- <li>Return <i>V</i>.</li>
- </ol>
- </section>
-
- <section id="sec-function-environment-records-hasthisbinding">
- <h1><span class="secnum" id="sec-8.1.1.3.2"><a href="#sec-function-environment-records-hasthisbinding"
- title="link to this section">8.1.1.3.2</a></span> HasThisBinding ()</h1>
- <ol class="proc">
- <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
- was invoked.</li>
- <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"lexical"</code>, return <b>false</b>; otherwise, return
- <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-function-environment-records-hassuperbinding">
- <h1><span class="secnum" id="sec-8.1.1.3.3"><a href="#sec-function-environment-records-hassuperbinding"
- title="link to this section">8.1.1.3.3</a></span> HasSuperBinding ()</h1>
- <ol class="proc">
- <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
- was invoked.</li>
- <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"lexical"</code>, return <b>false</b>.</li>
- <li>If <i>envRec</i>.[[HomeObject]] has the value <b>undefined</b>, return <b>false</b>, otherwise, return
- <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-function-environment-records-getthisbinding">
- <h1><span class="secnum" id="sec-8.1.1.3.4"><a href="#sec-function-environment-records-getthisbinding"
- title="link to this section">8.1.1.3.4</a></span> GetThisBinding ()</h1>
- <ol class="proc">
- <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
- was invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i>.[[thisBindingStatus]] is not
- <code>"lexical"</code>.</li>
- <li>If <i>envRec</i>.[[thisBindingStatus]] is <code>"uninitialized"</code>, throw a <b>ReferenceError</b>
- exception.</li>
- <li>Return <i>envRec</i>.[[thisValue]].</li>
- </ol>
- </section>
-
- <section id="sec-getsuperbase">
- <h1><span class="secnum" id="sec-8.1.1.3.5"><a href="#sec-getsuperbase"
- title="link to this section">8.1.1.3.5</a></span> GetSuperBase ()</h1>
- <ol class="proc">
- <li>Let <i>envRec</i> be the function <a href="#sec-environment-records">Environment Record</a> for which the method
- was invoked.</li>
- <li>Let <i>home</i> be the value of <i>envRec</i>.[[HomeObject]].</li>
- <li>If <i>home</i> has the value <b>undefined</b>, return <b>undefined</b>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>home</i>) is Object.</li>
- <li>Return <i>home.</i>[[GetPrototypeOf]]().</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-global-environment-records">
- <div class="front">
- <h1><span class="secnum" id="sec-8.1.1.4"><a href="#sec-global-environment-records"
- title="link to this section">8.1.1.4</a></span> Global Environment Records</h1>
-
- <p>A global <a href="#sec-environment-records">Environment Record</a> is used to represent the outer most scope that is
- shared by all of the ECMAScript <span class="nt">Script</span> elements that are processed in a common <a
- href="#sec-code-realms">Realm</a> (<a href="#sec-code-realms">8.2</a>). A global <a
- href="#sec-environment-records">Environment Record</a> provides the bindings for built-in globals (<a
- href="#sec-global-object">clause 18</a>), properties of the global object, and for all top-level declarations (<a
- href="#sec-block-static-semantics-toplevellexicallyscopeddeclarations">13.1.8</a>, <a
- href="#sec-block-static-semantics-toplevelvarscopeddeclarations">13.1.10</a>) that occur within a <span
- class="nt">Script</span>.</p>
-
- <p>A global <a href="#sec-environment-records">Environment Record</a> is logically a single record but it is specified
- as a composite encapsulating an object <a href="#sec-environment-records">Environment Record</a> and a declarative <a
- href="#sec-environment-records">Environment Record</a>. The object <a href="#sec-environment-records">Environment
- Record</a> has as its base object the global object of the associated <a href="#sec-code-realms">Realm</a>. This global
- object is the value returned by the global <a href="#sec-environment-records">Environment Record</a>&rsquo;s
- GetThisBinding concrete method. The object <a href="#sec-environment-records">Environment Record</a> component of a
- global <a href="#sec-environment-records">Environment Record</a> contains the bindings for all built-in globals (<a
- href="#sec-global-object">clause 18</a>) and all bindings introduced by a <span style="font-family: Times New
- Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, or <span class="nt">VariableStatement</span>
- contained in global code. The bindings for all other ECMAScript declarations in global code are contained in the
- declarative <a href="#sec-environment-records">Environment Record</a> component of the global <a
- href="#sec-environment-records">Environment Record</a>.</p>
-
- <p>Properties may be created directly on a global object. Hence, the object <a
- href="#sec-environment-records">Environment Record</a> component of a global <a
- href="#sec-environment-records">Environment Record</a> may contain both bindings created explicitly by <span
- style="font-family: Times New Roman"><i>FunctionDeclaration</i>, <i>GeneratorDeclaration</i></span>, or <span
- class="nt">VariableDeclaration</span> declarations and binding created implicitly as properties of the global object. In
- order to identify which bindings were explicitly created using declarations, a global <a
- href="#sec-environment-records">Environment Record</a> maintains a list of the names bound using its
- CreateGlobalVarBindings and CreateGlobalFunctionBindings concrete methods.</p>
-
- <p>Global Environment Records have the additional fields listed in <a href="#table-18">Table 18</a> and the additional
- methods listed in <a href="#table-19">Table 19</a>.</p>
-
- <figure>
- <figcaption><span id="table-18">Table 18</span> &mdash; Additional Fields of Global Environment Records</figcaption>
- <table class="real-table">
- <tr>
- <th>Field Name</th>
- <th>Value</th>
- <th>Meaning</th>
- </tr>
- <tr>
- <td>[[ObjectRecord]]</td>
- <td><a href="#sec-object-environment-records">Object Environment Record</a></td>
- <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>
- </tr>
- <tr>
- <td>[[DeclarativeRecord]]</td>
- <td><a href="#sec-declarative-environment-records">Declarative Environment Record</a></td>
- <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>
- </tr>
- <tr>
- <td>[[VarNames]]</td>
- <td><a href="#sec-list-and-record-specification-type">List</a> of String</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <figure>
- <figcaption><span id="table-19">Table 19</span> &mdash; Additional Methods of Global Environment Records</figcaption>
- <table class="real-table">
- <tr>
- <th>Method</th>
- <th>Purpose</th>
- </tr>
- <tr>
- <td>GetThisBinding()</td>
- <td>Return the value of this <a href="#sec-environment-records">Environment Record</a>&rsquo;s <code>this</code> binding.</td>
- </tr>
- <tr>
- <td><a href="#sec-hasvardeclaration">HasVarDeclaration</a> (N)</td>
- <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>
- </tr>
- <tr>
- <td><a href="#sec-haslexicaldeclaration">HasLexicalDeclaration</a> (N)</td>
- <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>
- </tr>
- <tr>
- <td><a href="#sec-hasrestrictedglobalproperty">HasRestrictedGlobalProperty</a> (N)</td>
- <td>Determines if the argument is the name of a global object property that may not be shadowed by a global lexically binding.</td>
- </tr>
- <tr>
- <td><a href="#sec-candeclareglobalvar">CanDeclareGlobalVar</a> (N)</td>
- <td>Determines if a corresponding <a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a> call would succeed if called for the same argument <var>N</var>.</td>
- </tr>
- <tr>
- <td><a href="#sec-candeclareglobalfunction">CanDeclareGlobalFunction</a> (N)</td>
- <td>Determines if a corresponding <a href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a> call would succeed if called for the same argument <var>N</var>.</td>
- </tr>
- <tr>
- <td><a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a>(N, D)</td>
- <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>
- </tr>
- <tr>
- <td><a href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a>(N, V, D)</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>The behaviour of the concrete specification methods for global Environment Records is defined by the following
- algorithms.</p>
- </div>
-
- <section id="sec-global-environment-records-hasbinding-n">
- <h1><span class="secnum" id="sec-8.1.1.4.1"><a href="#sec-global-environment-records-hasbinding-n"
- title="link to this section">8.1.1.4.1</a></span> HasBinding(N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasBinding for global Environment
- Records simply determines if the argument identifier is one of the identifiers bound by the record:</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
- <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, return <b>true</b>.</li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Return <i>ObjRec.</i>HasBinding(<i>N</i>).</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-createmutablebinding-n-d">
- <h1><span class="secnum" id="sec-8.1.1.4.2"><a href="#sec-global-environment-records-createmutablebinding-n-d"
- title="link to this section">8.1.1.4.2</a></span> CreateMutableBinding (N, D)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateMutableBinding for global
- Environment Records creates a new mutable binding for the name <var>N</var> that is uninitialized. The binding is
- created in the associated DeclarativeRecord. A binding for <var>N</var> must not already exist in the DeclarativeRecord.
- If Boolean argument <var>D</var> is provided and has the value <b>true</b> the new binding is marked as being subject to
- deletion.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
- <li>If <i>DclRec</i>.HasBinding(<i>N</i>) is <b>true</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>DclRec</i>.CreateMutableBinding(<i>N</i>, <i>D</i>).</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-createimmutablebinding-n-s">
- <h1><span class="secnum" id="sec-8.1.1.4.3"><a href="#sec-global-environment-records-createimmutablebinding-n-s"
- title="link to this section">8.1.1.4.3</a></span> CreateImmutableBinding (N, S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImmutableBinding for global
- Environment Records creates a new immutable binding for the name <var>N</var> that is uninitialized. A binding must not
- already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. If Boolean argument
- <var>S</var> is provided and has the value <b>true</b> the new binding is marked as a strict binding.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
- <li>If <i>DclRec</i>.HasBinding(<i>N</i>) is <b>true</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>DclRec</i>.CreateImmutableBinding(<i>N</i>, <i>S</i>).</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-initializebinding-n-v">
- <h1><span class="secnum" id="sec-8.1.1.4.4"><a href="#sec-global-environment-records-initializebinding-n-v"
- title="link to this section">8.1.1.4.4</a></span> InitializeBinding (N,V)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method InitializeBinding for global
- Environment Records is used to set the bound value of the current binding of the identifier whose name is the value of
- the argument <var>N</var> to the value of argument <var>V</var>. An uninitialized binding for <var>N</var> must already
- exist.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
- <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
- <ol class="block">
- <li>Return <i>DclRec</i>.InitializeBinding(<i>N</i>, <i>V</i>).</li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: If the binding exists it must be in the object <a
- href="#sec-environment-records">Environment Record</a>.</li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Return <i>ObjRec.</i>InitializeBinding(<i>N</i>, <i>V</i>).</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-setmutablebinding-n-v-s">
- <h1><span class="secnum" id="sec-8.1.1.4.5"><a href="#sec-global-environment-records-setmutablebinding-n-v-s"
- title="link to this section">8.1.1.4.5</a></span> SetMutableBinding (N,V,S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method SetMutableBinding for global
- Environment Records attempts to change the bound value of the current binding of the identifier whose name is the value
- of the argument <var>N</var> to the value of argument <var>V</var>. If the binding is an immutable binding, a
- <b>TypeError</b> is thrown if <span style="font-family: Times New Roman">S</span> is <span class="value">true</span>. A
- property named <var>N</var> normally already exists but if it does not or is not currently writable, error handling is
- determined by the value of the Boolean argument <var>S</var>.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
- <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
- <ol class="block">
- <li>Return <i>DclRec.</i>SetMutableBinding(<i>N</i>, <i>V</i>, <i>S</i>).</li>
- </ol>
- </li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Return <i>ObjRec</i>.SetMutableBinding(<i>N</i>, <i>V</i>, <i>S</i>).</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-getbindingvalue-n-s">
- <h1><span class="secnum" id="sec-8.1.1.4.6"><a href="#sec-global-environment-records-getbindingvalue-n-s"
- title="link to this section">8.1.1.4.6</a></span> GetBindingValue(N,S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for global Environment
- Records returns the value of its bound identifier whose name is the value of the argument <var>N</var>. If the binding
- is an uninitialized binding throw a <b>ReferenceError</b> exception. A property named <var>N</var> normally already
- exists but if it does not or is not currently writable, error handling is determined by the value of the Boolean
- argument <var>S</var>.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
- <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
- <ol class="block">
- <li>Return <i>DclRec.</i>GetBindingValue(<i>N</i>, <i>S</i>).</li>
- </ol>
- </li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Return <i>ObjRec</i>.GetBindingValue(<i>N</i>, <i>S</i>).</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-deletebinding-n">
- <h1><span class="secnum" id="sec-8.1.1.4.7"><a href="#sec-global-environment-records-deletebinding-n"
- title="link to this section">8.1.1.4.7</a></span> DeleteBinding (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for global Environment
- Records can only delete bindings that have been explicitly designated as being subject to deletion.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
- <li>If <i>DclRec.</i>HasBinding(<i>N</i>) is <b>true</b>, then
- <ol class="block">
- <li>Return <i>DclRec.</i>DeleteBinding(<i>N</i>).</li>
- </ol>
- </li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
- <li>Let <i>existingProp</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject</i>, <i>N</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
- <li>If <i>existingProp</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>status</i> be <i>ObjRec.</i>DeleteBinding(<i>N</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>If <i>status</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>varNames</i> be <i>envRec</i>.[[VarNames]].</li>
- <li>If <i>N</i> is an element of <i>varNames</i>, remove that element from the <i>varNames</i>.</li>
- </ol>
- </li>
- <li>Return <i>status</i>.</li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-hasthisbinding">
- <h1><span class="secnum" id="sec-8.1.1.4.8"><a href="#sec-global-environment-records-hasthisbinding"
- title="link to this section">8.1.1.4.8</a></span> HasThisBinding ()</h1>
-
- <p><a href="#sec-global-environment-records">Global Environment Records</a> always provide a <code>this</code> binding
- whose value is the associated global object.</p>
-
- <ol class="proc">
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-hassuperbinding">
- <h1><span class="secnum" id="sec-8.1.1.4.9"><a href="#sec-global-environment-records-hassuperbinding"
- title="link to this section">8.1.1.4.9</a></span> HasSuperBinding ()</h1>
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-withbaseobject">
- <h1><span class="secnum" id="sec-8.1.1.4.10"><a href="#sec-global-environment-records-withbaseobject"
- title="link to this section">8.1.1.4.10</a></span> WithBaseObject()</h1>
-
- <p><a href="#sec-global-environment-records">Global Environment Records</a> always return <b>undefined</b> as their
- WithBaseObject.</p>
-
- <ol class="proc">
- <li>Return <b>undefined</b>.</li>
- </ol>
- </section>
-
- <section id="sec-global-environment-records-getthisbinding">
- <h1><span class="secnum" id="sec-8.1.1.4.11"><a href="#sec-global-environment-records-getthisbinding"
- title="link to this section">8.1.1.4.11</a></span> GetThisBinding ()</h1>
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Let <i>bindings</i> be the binding object for <i>ObjRec</i>.</li>
- <li>Return <i>bindings</i>.</li>
- </ol>
- </section>
-
- <section id="sec-hasvardeclaration">
- <h1><span class="secnum" id="sec-8.1.1.4.12"><a href="#sec-hasvardeclaration"
- title="link to this section">8.1.1.4.12</a></span> HasVarDeclaration (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasVarDeclaration for global
- Environment Records determines if the argument identifier has a binding in this record that was created using a <span
- class="nt">VariableStatement</span> or a <span class="prod"><span class="nt">FunctionDeclaration</span> <span
- class="geq">:</span></span></p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
- <li>If <i>varDeclaredNames</i> contains the value of <i>N</i>, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-haslexicaldeclaration">
- <h1><span class="secnum" id="sec-8.1.1.4.13"><a href="#sec-haslexicaldeclaration"
- title="link to this section">8.1.1.4.13</a></span> HasLexicalDeclaration (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasLexicalDeclaration for global
- Environment Records determines if the argument identifier has a binding in this record that was created using a lexical
- declaration such as a <span class="nt">LexicalDeclaration</span> or a <span class="prod"><span
- class="nt">ClassDeclaration</span> <span class="geq">:</span></span></p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>DclRec</i> be <i>envRec</i>.[[DeclarativeRecord]].</li>
- <li>Return <i>DclRec.</i>HasBinding(<i>N</i>).</li>
- </ol>
- </section>
-
- <section id="sec-hasrestrictedglobalproperty">
- <h1><span class="secnum" id="sec-8.1.1.4.14"><a href="#sec-hasrestrictedglobalproperty"
- title="link to this section">8.1.1.4.14</a></span> HasRestrictedGlobalProperty (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method HasRestrictedGlobalProperty for global
- Environment Records determines if the argument identifier is the name of a property of the global object that must not
- be shadowed by a global lexically binding:</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
- <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
- <li>If <i>existingProp</i> is <b>undefined</b>, return <b>false</b>.</li>
- <li>If <i>existingProp</i>.[[Configurable]] is <b>true</b>, return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Properties may exist upon a global object that were directly created rather than being
- declared using a var or function declaration. A global lexical binding may not be created that has the same name as a
- non-configurable property of the global object. The global property <code>undefined</code> is an example of such a
- property.</p>
- </div>
- </section>
-
- <section id="sec-candeclareglobalvar">
- <h1><span class="secnum" id="sec-8.1.1.4.15"><a href="#sec-candeclareglobalvar"
- title="link to this section">8.1.1.4.15</a></span> CanDeclareGlobalVar (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CanDeclareGlobalVar for global
- Environment Records determines if a corresponding <a href="#sec-createglobalvarbinding">CreateGlobalVarBinding</a> call
- would succeed if called for the same argument <var>N</var>. Redundant var declarations and var declarations for
- pre-existing global object properties are allowed.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
- <li>Let <i>hasProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject, N</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasProperty</i>).</li>
- <li>If <i>hasProperty</i> is <b>true</b>, return <b>true</b>.</li>
- <li>Return <a href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
- </ol>
- </section>
-
- <section id="sec-candeclareglobalfunction">
- <h1><span class="secnum" id="sec-8.1.1.4.16"><a href="#sec-candeclareglobalfunction"
- title="link to this section">8.1.1.4.16</a></span> CanDeclareGlobalFunction (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CanDeclareGlobalFunction for global
- Environment Records determines if a corresponding <a
- href="#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a> call would succeed if called for the same
- argument <var>N</var>.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
- <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
- <li>If <i>existingProp</i> is <b>undefined</b>, return <a
- href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
- <li>If <i>existingProp</i>.[[Configurable]] is <b>true</b>, return <b>true</b>.</li>
- <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>existingProp</i>) is <b>true</b> and
- <i>existingProp</i> has attribute values {[[Writable]]: <b>true</b>, [[Enumerable]]: <b>true</b>}, return
- <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-createglobalvarbinding">
- <h1><span class="secnum" id="sec-8.1.1.4.17"><a href="#sec-createglobalvarbinding"
- title="link to this section">8.1.1.4.17</a></span> CreateGlobalVarBinding (N, D)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateGlobalVarBinding for global
- Environment Records creates and initializes a mutable binding in the associated object Environment Record and records
- the bound name in the associated [[VarNames]] <a href="#sec-list-and-record-specification-type">List</a>. If a binding
- already exists, it is reused and assumed to be initialized.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
- <li>Let <i>hasProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>globalObject, N</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasProperty</i>).</li>
- <li>Let <i>extensible</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>globalObject</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensible</i>).</li>
- <li>If <i>hasProperty</i> is <b>false</b> and <i>extensible</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>status</i> be <i>ObjRec.</i>CreateMutableBinding(<i>N</i>, <i>D</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Let <i>status</i> be <i>ObjRec.</i>InitializeBinding(<i>N</i>, <b>undefined</b>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- </ol>
- </li>
- <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
- <li>If <i>varDeclaredNames</i> does not contain the value of <i>N</i>, then
- <ol class="block">
- <li>Append <i>N</i> to <i>varDeclaredNames</i>.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
- </section>
-
- <section id="sec-createglobalfunctionbinding">
- <h1><span class="secnum" id="sec-8.1.1.4.18"><a href="#sec-createglobalfunctionbinding"
- title="link to this section">8.1.1.4.18</a></span> CreateGlobalFunctionBinding (N, V, D)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateGlobalFunctionBinding for global
- Environment Records creates and initializes a mutable binding in the associated object Environment Record and records
- the bound name in the associated [[VarNames]] <a href="#sec-list-and-record-specification-type">List</a>. If a binding
- already exists, it is replaced.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the global <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li>Let <i>ObjRec</i> be <i>envRec</i>.[[ObjectRecord]].</li>
- <li>Let <i>globalObject</i> be the binding object for <i>ObjRec</i>.</li>
- <li>Let <i>existingProp</i> be <i>globalObject</i>.[[GetOwnProperty]](<i>N</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingProp</i>).</li>
- <li>If <i>existingProp</i> is <b>undefined</b> or <i>existingProp</i>.[[Configurable]] is <b>true</b>, then
- <ol class="block">
- <li>Let <i>desc</i> be the PropertyDescriptor{[[Value]]:<i>V</i>, [[Writable]]: <b>true</b>, [[Enumerable]]:
- <b>true</b> , [[Configurable]]: <i>D</i>}.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>desc</i> be the PropertyDescriptor{[[Value]]:<i>V</i> }.</li>
- </ol>
- </li>
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>globalObject</i>, <i>N</i>,
- <i>desc</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <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>,
- <b>false</b>).</li>
- <li>Record that the binding for <i>N</i> in <i>ObjRec</i> has been initialized.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Let <i>varDeclaredNames</i> be <i>envRec</i>.[[VarNames]].</li>
- <li>If <i>varDeclaredNames</i> does not contain the value of <i>N</i>, then
- <ol class="block">
- <li>Append <i>N</i> to <i>varDeclaredNames</i>.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Global function declarations are always represented as own properties of the global
- object. If possible, an existing own property is reconfigured to have a standard set of attribute values. Steps 10-12
- are equivalent to what calling the InitializeBinding concrete method would do and if <i>globalObject</i> is a Proxy
- will produce the same sequence of Proxy trap calls.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-module-environment-records">
- <div class="front">
- <h1><span class="secnum" id="sec-8.1.1.5"><a href="#sec-module-environment-records"
- title="link to this section">8.1.1.5</a></span> Module Environment Records</h1>
-
- <p>A module <a href="#sec-environment-records">Environment Record</a> is a declarative <a
- href="#sec-environment-records">Environment Record</a> that is used to represent the outer scope of an ECMAScript <span
- class="nt">Module</span>. In additional to normal mutable and immutable bindings, module Environment Records also
- provide immutable import bindings which are bindings that provide indirect access to a target binding that exists in
- another Environment Record.</p>
-
- <p>Module Environment Records support all of the declarative Environment Record methods listed in <a
- href="#table-15">Table 15</a> and share the same specifications for all of those methods except for GetBindingValue,
- DeleteBinding, HasThisBinding and GetThisBinding. In addition, module Environment Records support the methods listed in
- <a href="#table-20">Table 20</a>:</p>
-
- <figure>
- <figcaption><span id="table-20">Table 20</span> &mdash; Additional Methods of Module Environment Records</figcaption>
- <table class="real-table">
- <tr>
- <th>Method</th>
- <th>Purpose</th>
- </tr>
- <tr>
- <td><a href="#sec-createimportbinding">CreateImportBinding</a>(N, M, N2 )</td>
- <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>
- </tr>
- <tr>
- <td>GetThisBinding()</td>
- <td>Return the value of this <a href="#sec-environment-records">Environment Record</a>&rsquo;s <code>this</code> binding.</td>
- </tr>
- </table>
- </figure>
-
- <p>The behaviour of the additional concrete specification methods for module Environment Records are defined by the
- following algorithms:</p>
- </div>
-
- <section id="sec-module-environment-records-getbindingvalue-n-s">
- <h1><span class="secnum" id="sec-8.1.1.5.1"><a href="#sec-module-environment-records-getbindingvalue-n-s"
- title="link to this section">8.1.1.5.1</a></span> GetBindingValue(N,S)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method GetBindingValue for module Environment
- Records returns the value of its bound identifier whose name is the value of the argument <var>N</var>. However, if the
- binding is an indirect binding the value of the target binding is returned. If the binding exists but is uninitialized a
- <span class="value">ReferenceError</span> is thrown, regardless of the value of <i><span style="font-family: Times New
- Roman">S</span>.</i></p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a binding for <i>N</i>.</li>
- <li>If the binding for <i>N</i> is an indirect binding, then
- <ol class="block">
- <li>Let <i>M</i> and <i>N2</i> be the indirection values provided when this binding for <i>N</i> was created.</li>
- <li>If <i>M</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
- <li>Let <i>targetEnv</i> be <i>M</i>.[[Environment]].</li>
- <li>If <i>targetEnv</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
- <li>Let <i>targetER</i> be <i>targetEnv</i>&rsquo;s EnvironmentRecord.</li>
- <li>Return <i>targetER</i>.GetBindingValue(<i>N2</i>, <i>S</i>).</li>
- </ol>
- </li>
- <li>If the binding for <i>N</i> in <i>envRec</i> is an uninitialized binding, throw a <b>ReferenceError</b>
- exception.</li>
- <li>Return the value currently bound to <i>N</i> in <i>envRec</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Because a <i>Module</i> is always <a href="#sec-strict-mode-code">strict mode
- code</a>, calls to GetBindingValue should always pass <b>true</b> <span style="font-family: sans-serif">as</span>
- <span style="font-family: sans-serif">the value of</span> <i>S</i>.</p>
- </div>
- </section>
-
- <section id="sec-module-environment-records-deletebinding-n">
- <h1><span class="secnum" id="sec-8.1.1.5.2"><a href="#sec-module-environment-records-deletebinding-n"
- title="link to this section">8.1.1.5.2</a></span> DeleteBinding (N)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method DeleteBinding for module Environment
- Records refuses to delete bindings.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <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>
- <li>Return <b>false</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Because the bindings of a module <a href="#sec-environment-records">Environment
- Record</a> are not deletable.</p>
- </div>
- </section>
-
- <section id="sec-module-environment-records-hasthisbinding">
- <h1><span class="secnum" id="sec-8.1.1.5.3"><a href="#sec-module-environment-records-hasthisbinding"
- title="link to this section">8.1.1.5.3</a></span> HasThisBinding ()</h1>
-
- <p>Module Environment Records provide a <code>this</code> binding.</p>
-
- <ol class="proc">
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-environment-records-getthisbinding">
- <h1><span class="secnum" id="sec-8.1.1.5.4"><a href="#sec-module-environment-records-getthisbinding"
- title="link to this section">8.1.1.5.4</a></span> GetThisBinding ()</h1>
- <ol class="proc">
- <li>Return <b>undefined</b>.</li>
- </ol>
- </section>
-
- <section id="sec-createimportbinding">
- <h1><span class="secnum" id="sec-8.1.1.5.5"><a href="#sec-createimportbinding"
- title="link to this section">8.1.1.5.5</a></span> CreateImportBinding (N, M, N2)</h1>
-
- <p>The concrete <a href="#sec-environment-records">Environment Record</a> method CreateImportBinding for module
- Environment Records creates a new initialized immutable indirect binding for the name <var>N</var>. A binding must not
- already exist in this <a href="#sec-environment-records">Environment Record</a> for <var>N</var>. <var>M</var> is a
- Module Record (<a href="#sec-abstract-module-records">see 15.2.1.14</a>), and <var>N2</var> is the name of a binding
- that exists in M&rsquo;s module <a href="#sec-environment-records">Environment Record</a>. Accesses to the value of the
- new binding will indirectly access the bound value of value of the target binding.</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be the module <a href="#sec-environment-records">Environment Record</a> for which the method was
- invoked.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> does not already have a binding for <i>N</i>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>M</i> is a Module Record.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: When <i>M</i>.[[Environment]] is instantiated it will have a
- direct binding for <i>N2</i>.</li>
- <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
- target binding and record that the binding is initialized.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
- </section>
- </section>
- </section>
-
- <section id="sec-lexical-environment-operations">
- <div class="front">
- <h1><span class="secnum" id="sec-8.1.2"><a href="#sec-lexical-environment-operations"
- title="link to this section">8.1.2</a></span> Lexical Environment Operations</h1>
-
- <p>The following abstract operations are used in this specification to operate upon lexical environments:</p>
- </div>
-
- <section id="sec-getidentifierreference">
- <h1><span class="secnum" id="sec-8.1.2.1"><a href="#sec-getidentifierreference"
- title="link to this section">8.1.2.1</a></span> GetIdentifierReference (lex, name, strict)</h1>
-
- <p>The abstract operation GetIdentifierReference is called with a <a href="#sec-lexical-environments">Lexical
- Environment</a> <var>lex</var>, a String <var>name</var>, and a Boolean flag <var>strict.</var> The value of
- <var>lex</var> may be <b>null</b>. When called, the following steps are performed:</p>
-
- <ol class="proc">
- <li>If <i>lex</i> is the value <b>null</b>, then
- <ol class="block">
- <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is
- <b>undefined</b>, whose referenced name is <i>name</i>, and whose strict reference flag is <i>strict</i>.</li>
- </ol>
- </li>
- <li>Let <i>envRec</i> be <i>lex</i>&rsquo;s EnvironmentRecord.</li>
- <li>Let <i>exists</i> be <i>envRec</i>.HasBinding(<i>name</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exists</i>).</li>
- <li>If <i>exists</i> is <b>true</b>, then
- <ol class="block">
- <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is
- <i>envRec</i>, whose referenced name is <i>name</i>, and whose strict reference flag is <i>strict.</i></li>
- </ol>
- </li>
- <li>Else
- <ol class="block">
- <li>Let <i>outer</i> be the value of <i>lex&rsquo;s</i> <a href="#sec-lexical-environments">outer environment
- reference</a>.</li>
- <li>Return GetIdentifierReference(<i>outer</i>, <i>name</i>, <i>strict</i>).</li>
- </ol>
- </li>
- </ol>
- </section>
-
- <section id="sec-newdeclarativeenvironment">
- <h1><span class="secnum" id="sec-8.1.2.2"><a href="#sec-newdeclarativeenvironment"
- title="link to this section">8.1.2.2</a></span> NewDeclarativeEnvironment (E)</h1>
-
- <p>When the abstract operation NewDeclarativeEnvironment is called with a <a href="#sec-lexical-environments">Lexical
- Environment</a> as argument <var>E</var> the following steps are performed:</p>
-
- <ol class="proc">
- <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
- <li>Let <i>envRec</i> be a new declarative <a href="#sec-environment-records">Environment Record</a> containing no
- bindings.</li>
- <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
- <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
- <li>Return <i>env</i>.</li>
- </ol>
- </section>
-
- <section id="sec-newobjectenvironment">
- <h1><span class="secnum" id="sec-8.1.2.3"><a href="#sec-newobjectenvironment"
- title="link to this section">8.1.2.3</a></span> NewObjectEnvironment (O, E)</h1>
-
- <p>When the abstract operation NewObjectEnvironment is called with an Object <var>O</var> and a <a
- href="#sec-lexical-environments">Lexical Environment</a> <var>E</var> as arguments, the following steps are performed:</p>
-
- <ol class="proc">
- <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
- <li>Let <i>envRec</i> be a new object <a href="#sec-environment-records">Environment Record</a> containing <i>O</i> as
- the binding object.</li>
- <li>Set <i>env&rsquo;s</i> EnvironmentRecord to <i>envRec</i>.</li>
- <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
- <li>Return <i>env</i>.</li>
- </ol>
- </section>
-
- <section id="sec-newfunctionenvironment">
- <h1><span class="secnum" id="sec-8.1.2.4"><a href="#sec-newfunctionenvironment"
- title="link to this section">8.1.2.4</a></span> NewFunctionEnvironment ( F, newTarget )</h1>
-
- <p>When the abstract operation NewFunctionEnvironment is called with arguments <var>F</var> and <var>newTarget</var> the
- following steps are performed:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an ECMAScript function.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Undefined or Object.</li>
- <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
- <li>Let <i>envRec</i> be a new function <a href="#sec-environment-records">Environment Record</a> containing no
- bindings.</li>
- <li>Set <i>envRec</i>.[[FunctionObject]] to <i>F</i>.</li>
- <li>If <i>F&rsquo;s</i> [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is
- <span style="font-family: sans-serif">lexical</span>, set <i>envRec</i>.[[thisBindingStatus]] to
- <code>"lexical"</code>.</li>
- <li>Else, Set <i>envRec</i>.[[thisBindingStatus]] to <code>"uninitialized"</code>.</li>
- <li>Let <i>home</i> be the value of <i>F&rsquo;s</i> [[HomeObject]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Set <i>envRec</i>.[[HomeObject]] to <i>home</i>.</li>
- <li>Set <i>envRec</i>.[[NewTarget]] to <i>newTarget</i>.</li>
- <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
- <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to the value of
- <i>F&rsquo;s</i> [[Environment]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Return <i>env</i>.</li>
- </ol>
- </section>
-
- <section id="sec-newglobalenvironment">
- <h1><span class="secnum" id="sec-8.1.2.5"><a href="#sec-newglobalenvironment"
- title="link to this section">8.1.2.5</a></span> NewGlobalEnvironment ( G )</h1>
-
- <p>When the abstract operation NewGlobalEnvironment is called with an ECMAScript Object <var>G</var> as its argument, the
- following steps are performed:</p>
-
- <ol class="proc">
- <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
- <li>Let <i>objRec</i> be a new object <a href="#sec-environment-records">Environment Record</a> containing <i>G</i> as
- the binding object.</li>
- <li>Let <i>dclRec</i> be a new declarative <a href="#sec-environment-records">Environment Record</a> containing no
- bindings.</li>
- <li>Let <i>globalRec</i> be a new global <a href="#sec-environment-records">Environment Record</a>.</li>
- <li>Set <i>globalRec</i>.[[ObjectRecord]] to <i>objRec</i>.</li>
- <li>Set <i>globalRec</i>.[[DeclarativeRecord]] to <i>dclRec</i>.</li>
- <li>Set <i>globalRec</i>.[[VarNames]] to a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Set <i>env&rsquo;s</i> EnvironmentRecord to <i>globalRec</i>.</li>
- <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to
- <b>null</b></li>
- <li>Return <i>env</i>.</li>
- </ol>
- </section>
-
- <section id="sec-newmoduleenvironment">
- <h1><span class="secnum" id="sec-8.1.2.6"><a href="#sec-newmoduleenvironment"
- title="link to this section">8.1.2.6</a></span> NewModuleEnvironment (E)</h1>
-
- <p>When the abstract operation NewModuleEnvironment is called with a <a href="#sec-lexical-environments">Lexical
- Environment</a> argument <var>E</var> the following steps are performed:</p>
-
- <ol class="proc">
- <li>Let <i>env</i> be a new <a href="#sec-lexical-environments">Lexical Environment</a>.</li>
- <li>Let <i>envRec</i> be a new module <a href="#sec-environment-records">Environment Record</a> containing no
- bindings.</li>
- <li>Set <i>env&rsquo;s</i> EnvironmentRecord to be <i>envRec</i>.</li>
- <li>Set the <a href="#sec-lexical-environments">outer lexical environment reference</a> of <i>env</i> to <i>E</i>.</li>
- <li>Return <i>env</i>.</li>
- </ol>
- </section>
- </section>
- </section>
-
- <section id="sec-code-realms">
- <div class="front">
- <h1><span class="secnum" id="sec-8.2"><a href="#sec-code-realms" title="link to this section">8.2</a></span> Code
- Realms</h1>
-
- <p>Before it is evaluated, all ECMAScript code must be associated with a <i>Realm</i>. Conceptually, a realm consists of a
- set of intrinsic objects, an ECMAScript global environment, all of the ECMAScript code that is loaded within the scope of
- that global environment, and other associated state and resources.</p>
-
- <p>A Realm is specified as a Record with the fields specified in <a href="#table-21">Table 21</a>:</p>
-
- <figure>
- <figcaption><span id="table-21">Table 21</span> &mdash; Realm Record Fields</figcaption>
- <table class="real-table">
- <tr>
- <th>Field Name</th>
- <th>Value</th>
- <th>Meaning</th>
- </tr>
- <tr>
- <td>[[intrinsics]]</td>
- <td>Record whose field names are intrinsic keys and whose values are objects</td>
- <td>These are the intrinsic values used by code associated with this Realm</td>
- </tr>
- <tr>
- <td>[[globalThis]]</td>
- <td>Object</td>
- <td>The global object for this Realm</td>
- </tr>
- <tr>
- <td>[[globalEnv]]</td>
- <td><a href="#sec-lexical-environments">Lexical Environment</a></td>
- <td>The global environment for this Realm</td>
- </tr>
- <tr>
- <td>[[templateMap]]</td>
- <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>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>An implementation may define other, implementation specific fields.</p>
- </div>
-
- <section id="sec-createrealm">
- <h1><span class="secnum" id="sec-8.2.1"><a href="#sec-createrealm" title="link to this section">8.2.1</a></span> CreateRealm
- ( )</h1>
-
- <p>The abstract operation CreateRealm with no arguments performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>realmRec</i> be a new Record.</li>
- <li>Perform <a href="#sec-createintrinsics">CreateIntrinsics</a>(<i>realmRec</i>).</li>
- <li>Set <i>realmRec</i>.[[globalThis]] to <b>undefined</b>.</li>
- <li>Set <i>realmRec</i>.[[globalEnv]] to <b>undefined</b>.</li>
- <li>Set <i>realmRec</i>.[[templateMap]] to a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Return <i>realmRec</i>.</li>
- </ol>
- </section>
-
- <section id="sec-createintrinsics">
- <h1><span class="secnum" id="sec-8.2.2"><a href="#sec-createintrinsics" title="link to this section">8.2.2</a></span>
- CreateIntrinsics ( realmRec )</h1>
-
- <p>When the abstract operation CreateIntrinsics with argument <var>realmRec</var> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>intrinsics</i> be a new Record.</li>
- <li>Set <i>realmRec</i>.[[intrinsics]] to <i>intrinsics</i>.</li>
- <li>Let <i>objProto</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<b>null</b>).</li>
- <li>Set <i>intrinsics</i>.[[%ObjectPrototype%]] to <i>objProto</i>.</li>
- <li>Let <i>throwerSteps</i> be the algorithm steps specified in <a href="#sec-%throwtypeerror%">9.2.7.1</a> for the <a
- href="#sec-%throwtypeerror%">%ThrowTypeError%</a> function.</li>
- <li>Let <i>thrower</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
- <i>throwerSteps</i>, <b>null</b>).</li>
- <li>Set <i>intrinsics</i>.[[<span style="font-family: sans-serif"><a
- href="#sec-%throwtypeerror%">%ThrowTypeError%</a></span>]] to <i>thrower</i>.</li>
- <li>Let <i>noSteps</i> be an empty sequence of algorithm steps.</li>
- <li>Let <i>funcProto</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
- <i>noSteps</i>, <i>objProto</i>).</li>
- <li>Set <i>intrinsics</i>.[[%FunctionPrototype%]] to <i>funcProto</i>.</li>
- <li><a href="#sec-call">Call</a> <i>thrower</i>.[[SetPrototypeOf]](<i>funcProto</i>).</li>
- <li>Perform <a href="#sec-addrestrictedfunctionproperties">AddRestrictedFunctionProperties</a>(<i>funcProto</i>,
- <i>realmRec</i>).</li>
- <li>Set fields of <i>intrinsics</i> with the values listed in <a href="#table-7">Table 7</a> that have not already been
- handled above. The field names are the names listed in column one of the table. The value of each field is a new
- object value fully and recursively populated with property values as defined by the specification of each object in
- clauses 18-26. All object property values are newly created object values. All values that are built-in function
- objects are created by performing <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realmRec</i>,
- &lt;steps&gt;, &lt;prototype&gt;, &lt;slots&gt;) where &lt;steps&gt; is the definition of that function provided by
- this specification, &lt;prototype&gt; is the specified value of the function&rsquo;s [[Prototype]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> and &lt;slots&gt; is a list of the names, if
- any, of the functions specified internal slots. The creation of the intrinsics and their properties must be ordered to
- avoid any dependencies upon objects that have not yet been created.</li>
- <li>Return <i>intrinsics</i>.</li>
- </ol>
- </section>
-
- <section id="sec-setrealmglobalobject">
- <h1><span class="secnum" id="sec-8.2.3"><a href="#sec-setrealmglobalobject" title="link to this section">8.2.3</a></span>
- SetRealmGlobalObject ( realmRec, globalObj )</h1>
-
- <p>The abstract operation SetRealmGlobalObject with arguments <var>realmRec</var> and <var>globalObj</var> performs the
- following steps:</p>
-
- <ol class="proc">
- <li>If <i>globalObj</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>intrinsics</i> be <i>realmRec</i>.[[intrinsics]].</li>
- <li>Let <i>globalObj</i> be <a
- href="#sec-objectcreate">ObjectCreate</a>(<i>intrinsics</i>.[[%ObjectPrototype%]]).</li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>globalObj</i>) is Object.</li>
- <li>Set <i>realmRec</i>.[[globalThis]] to <i>globalObj</i>.</li>
- <li>Let <i>newGlobalEnv</i> be <a href="#sec-newglobalenvironment">NewGlobalEnvironment</a>(<i>globalObj</i>).</li>
- <li>Set <i>realmRec</i>.[[globalEnv]] to <i>newGlobalEnv</i>.</li>
- <li>Return <i>realmRec</i>.</li>
- </ol>
- </section>
-
- <section id="sec-setdefaultglobalbindings">
- <h1><span class="secnum" id="sec-8.2.4"><a href="#sec-setdefaultglobalbindings"
- title="link to this section">8.2.4</a></span> SetDefaultGlobalBindings ( realmRec )</h1>
-
- <p>The abstract operation SetDefaultGlobalBindings with argument <var>realmRec</var> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>global</i> be <i>realmRec</i>.[[globalThis]].</li>
- <li>For each property of the Global Object specified in <a href="#sec-global-object">clause 18</a>, do
- <ol class="block">
- <li>Let <i>name</i> be the string value of the property name.</li>
- <li>Let <i>desc</i> be the fully populated data property descriptor for the property containing the specified
- attributes for the property. For properties listed in <a
- href="#sec-function-properties-of-the-global-object">18.2</a>, <a
- href="#sec-constructor-properties-of-the-global-object">18.3</a>, or <a
- href="#sec-other-properties-of-the-global-object">18.4</a> the value of the [[Value]] attribute is the
- corresponding intrinsic object from <i>realmRec</i>.</li>
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>global</i>, <i>name</i>,
- <i>desc</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- </ol>
- </li>
- <li>Return <i>global</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-execution-contexts">
- <div class="front">
- <h1><span class="secnum" id="sec-8.3"><a href="#sec-execution-contexts" title="link to this section">8.3</a></span>
- Execution Contexts</h1>
-
- <p>An <i>execution context</i> is a specification device that is used to track the runtime evaluation of code by an
- ECMAScript implementation. At any point in time, there is at most one execution context that is actually executing code.
- This is known as the <i>running</i> execution context. A stack is used to track execution contexts. The running execution
- context is always the top element of this stack. A new execution context is created whenever control is transferred from the
- executable code associated with the currently running execution context to executable code that is not associated with that
- execution context. The newly created execution context is pushed onto the stack and becomes the running execution
- context.</p>
-
- <p>An execution context contains whatever implementation specific state is necessary to track the execution progress of its
- associated code. Each execution context has at least the state components listed in <a href="#table-22">Table 22</a>.</p>
-
- <figure>
- <figcaption><span id="table-22">Table 22</span> &mdash;State Components for All Execution Contexts</figcaption>
- <table class="real-table">
- <tr>
- <th>Component</th>
- <th>Purpose</th>
- </tr>
- <tr>
- <td>code evaluation state</td>
- <td>Any state needed to perform, suspend, and resume evaluation of the code associated with this execution context.</td>
- </tr>
- <tr>
- <td>Function</td>
- <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>
- </tr>
- <tr>
- <td><a href="#sec-code-realms">Realm</a></td>
- <td>The <a href="#sec-code-realms">Realm</a> from which associated code accesses ECMAScript resources.</td>
- </tr>
- </table>
- </figure>
-
- <p>Evaluation of code by the running execution context may be suspended at various points defined within this specification.
- Once the running execution context has been suspended a different execution context may become the running execution context
- and commence evaluating its code. At some later time a suspended execution context may again become the running execution
- context and continue evaluating its code at the point where it had previously been suspended. Transition of the running
- execution context status among execution contexts usually occurs in stack-like last-in/first-out manner. However, some
- ECMAScript features require non-LIFO transitions of the running execution context.</p>
-
- <p>The value of the <a href="#sec-code-realms">Realm</a> component of the running execution context is also called the
- <i>current <a href="#sec-code-realms">Realm</a></i>. The value of the Function component of the running execution context is
- also called the <i>active function object.</i></p>
-
- <p>Execution contexts for ECMAScript code have the additional state components listed in <a href="#table-23">Table
- 23</a>.</p>
-
- <figure>
- <figcaption><span id="table-23">Table 23</span> &mdash; Additional State Components for ECMAScript Code Execution Contexts</figcaption>
- <table class="real-table">
- <tr>
- <th>Component</th>
- <th>Purpose</th>
- </tr>
- <tr>
- <td>LexicalEnvironment</td>
- <td>Identifies the <a href="#sec-lexical-environments">Lexical Environment</a> used to resolve identifier references made by code within this execution context.</td>
- </tr>
- <tr>
- <td>VariableEnvironment</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>The LexicalEnvironment and VariableEnvironment components of an execution context are always Lexical Environments. When
- an execution context is created its LexicalEnvironment and VariableEnvironment components initially have the same value.</p>
-
- <p>Execution contexts representing the evaluation of generator objects have the additional state components listed in <a
- href="#table-24">Table 24</a>.</p>
-
- <figure>
- <figcaption><span id="table-24">Table 24</span> &mdash; Additional State Components for Generator Execution Contexts</figcaption>
- <table class="real-table">
- <tr>
- <th>Component</th>
- <th>Purpose</th>
- </tr>
- <tr>
- <td>Generator</td>
- <td>The GeneratorObject that this execution context is evaluating.</td>
- </tr>
- </table>
- </figure>
-
- <p>In most situations only the running execution context (the top of the execution context stack) is directly manipulated by
- algorithms within this specification. Hence when the terms &ldquo;LexicalEnvironment&rdquo;, and
- &ldquo;VariableEnvironment&rdquo; are used without qualification they are in reference to those components of the running
- execution context.</p>
-
- <p>An execution context is purely a specification mechanism and need not correspond to any particular artefact of an
- ECMAScript implementation. It is impossible for ECMAScript code to directly access or observe an execution context.</p>
- </div>
-
- <section id="sec-resolvebinding">
- <h1><span class="secnum" id="sec-8.3.1"><a href="#sec-resolvebinding" title="link to this section">8.3.1</a></span>
- ResolveBinding ( name, [env] )</h1>
-
- <p>The ResolveBinding abstract operation is used to determine the binding of <var>name</var> passed as a string value. The
- optional argument <var>env</var> can be used to explicitly provide the <a href="#sec-lexical-environments">Lexical
- Environment</a> that is to be searched for the binding. During execution of ECMAScript code, ResolveBinding is performed
- using the following algorithm:</p>
-
- <ol class="proc">
- <li>If <i>env</i> was not passed or if <i>env</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>env</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
- href="#sec-execution-contexts">LexicalEnvironment</a>.</li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>env</i> is a <a href="#sec-lexical-environments">Lexical
- Environment</a>.</li>
- <li>If the code matching the syntactic production that is being evaluated is contained in <a
- href="#sec-strict-mode-code">strict mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be
- <b>false</b>.</li>
- <li>Return <a href="#sec-getidentifierreference">GetIdentifierReference</a>(<i>env</i>, <i>name</i>, <i>strict</i> ).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The result of ResolveBinding is always a <a
- href="#sec-reference-specification-type">Reference</a> value with its referenced name component equal to the <i>name</i>
- argument.</p>
- </div>
- </section>
-
- <section id="sec-getthisenvironment">
- <h1><span class="secnum" id="sec-8.3.2"><a href="#sec-getthisenvironment" title="link to this section">8.3.2</a></span>
- GetThisEnvironment ( )</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">GetThisEnvironment</span> finds the <a
- href="#sec-environment-records">Environment Record</a> that currently supplies the binding of the keyword <code>this</code>.
- <span style="font-family: Times New Roman">GetThisEnvironment</span> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>lex</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
- href="#sec-execution-contexts">LexicalEnvironment</a>.</li>
- <li>Repeat
- <ol class="block">
- <li>Let <i>envRec</i> be <i>lex</i>&rsquo;s EnvironmentRecord.</li>
- <li>Let <i>exists</i> be <i>envRec</i>.HasThisBinding().</li>
- <li>If <i>exists</i> is <b>true</b>, return <i>envRec</i>.</li>
- <li>Let <i>outer</i> be the value of <i>lex&rsquo;s</i> <a href="#sec-lexical-environments">outer environment
- reference</a>.</li>
- <li>Let <i>lex</i> be <i>outer</i>.</li>
- </ol>
- </li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The loop in step 2 will always terminate because the list of environments always ends with
- <a href="#sec-global-environment-records">the global environment</a> which has a <code>this</code> binding.</p>
- </div>
- </section>
-
- <section id="sec-resolvethisbinding">
- <h1><span class="secnum" id="sec-8.3.3"><a href="#sec-resolvethisbinding" title="link to this section">8.3.3</a></span>
- ResolveThisBinding ( )</h1>
-
- <p>The abstract operation ResolveThisBinding determines the binding of the keyword <code>this</code> using the <a
- href="#sec-execution-contexts">LexicalEnvironment</a> of <a href="#sec-execution-contexts">the running execution
- context</a>. ResolveThisBinding performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
- <li>Return <i>envRec</i>.GetThisBinding().</li>
- </ol>
- </section>
-
- <section id="sec-getnewtarget">
- <h1><span class="secnum" id="sec-8.3.4"><a href="#sec-getnewtarget" title="link to this section">8.3.4</a></span>
- GetNewTarget ( )</h1>
-
- <p>The abstract operation GetNewTarget determines the NewTarget value using the <a
- href="#sec-execution-contexts">LexicalEnvironment</a> of <a href="#sec-execution-contexts">the running execution
- context</a>. GetNewTarget performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> has a [[NewTarget]] field.</li>
- <li>Return <i>envRec</i>.[[NewTarget]].</li>
- </ol>
- </section>
-
- <section id="sec-getglobalobject">
- <h1><span class="secnum" id="sec-8.3.5"><a href="#sec-getglobalobject" title="link to this section">8.3.5</a></span>
- GetGlobalObject ( )</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">GetGlobalObject</span> returns the global object used
- by <a href="#sec-execution-contexts">the currently running execution context</a>. <span style="font-family: Times New
- Roman">GetGlobalObject</span> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>ctx</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>currentRealm</i> be <i>ctx&rsquo;s</i> <a href="#sec-code-realms">Realm</a>.</li>
- <li>Return <i>currentRealm</i>.[[globalThis]].</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-jobs-and-job-queues">
- <div class="front">
- <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
- and Job Queues</h1>
-
- <p>A Job is an abstract operation that initiates an ECMAScript computation when no other ECMAScript computation is currently
- in progress. A Job abstract operation may be defined to accept an arbitrary set of job parameters.</p>
-
- <p>Execution of a Job can be initiated only when there is no running <a href="#sec-execution-contexts">execution context</a>
- and <a href="#sec-execution-contexts">the execution context stack</a> is empty. A PendingJob is a request for the future
- execution of a Job. A PendingJob is an internal Record whose fields are specified in <a href="#table-25">Table 25</a>. Once
- execution of a Job is initiated, the Job always executes to completion. No other Job may be initiated until the currently
- running Job completes. However, the currently running Job or external events may cause the enqueuing of additional
- PendingJobs that may be initiated sometime after completion of the currently running Job.</p>
-
- <figure>
- <figcaption><span id="table-25">Table 25</span> &mdash; PendingJob Record Fields</figcaption>
- <table class="real-table">
- <tr>
- <th>Field Name</th>
- <th>Value</th>
- <th>Meaning</th>
- </tr>
- <tr>
- <td>[[Job]]</td>
- <td>The name of a Job abstract operation</td>
- <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>
- </tr>
- <tr>
- <td>[[Arguments]]</td>
- <td>A <a href="#sec-list-and-record-specification-type">List</a></td>
- <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>
- </tr>
- <tr>
- <td>[[Realm]]</td>
- <td>A <a href="#sec-code-realms">Realm</a> Record</td>
- <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>
- </tr>
- <tr>
- <td>[[HostDefined]]</td>
- <td>Any, default value is <span class="value">undefined</span>.</td>
- <td>Field reserved for use by host environments that need to associate additional information with a pending Job.</td>
- </tr>
- </table>
- </figure>
-
- <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
- defined by an ECMAScript implementation. Every ECMAScript implementation has at least the Job Queues defined in <a
- href="#table-26">Table 26</a>.</p>
-
- <figure>
- <figcaption><span id="table-26">Table 26</span> &mdash; Required Job Queues</figcaption>
- <table class="real-table">
- <tr>
- <th>Name</th>
- <th>Purpose</th>
- </tr>
- <tr>
- <td>ScriptJobs</td>
- <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>
- </tr>
- <tr>
- <td>PromiseJobs</td>
- <td>Jobs that are responses to the settlement of a Promise (<a href="#sec-promise-objects">see 25.4</a>).</td>
- </tr>
- </table>
- </figure>
-
- <p>A request for the future execution of a Job is made by enqueueing, on a Job Queue, a PendingJob record that includes a
- Job abstract operation name and any necessary argument values. When there is no running <a
- href="#sec-execution-contexts">execution context</a> and <a href="#sec-execution-contexts">the execution context stack</a>
- is empty, the ECMAScript implementation removes the first PendingJob from a Job Queue and uses the information contained in
- it to create an <a href="#sec-execution-contexts">execution context</a> and starts execution of the associated Job abstract
- operation.</p>
-
- <p>The PendingJob records from a single Job Queue are always initiated in FIFO order. This specification does not define the
- order in which multiple Job Queues are serviced. An ECMAScript implementation may interweave the FIFO evaluation of the
- PendingJob records of a Job Queue with the evaluation of the PendingJob records of one or more other Job Queues. An
- implementation must define what occurs when there are no running <a href="#sec-execution-contexts">execution context</a> and
- all Job Queues are empty.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Typically an ECMAScript implementation will have its Job Queues pre-initialized with at
- least one PendingJob and one of those Jobs will be the first to be executed. An implementation might choose to free all
- resources and terminate if the current Job completes and all Job Queues are empty. Alternatively, it might choose to wait
- for a some implementation specific agent or mechanism to enqueue new PendingJob requests.</p>
- </div>
-
- <p>The following abstract operations are used to create and manage Jobs and Job Queues:</p>
- </div>
-
- <section id="sec-enqueuejob">
- <h1><span class="secnum" id="sec-8.4.1"><a href="#sec-enqueuejob" title="link to this section">8.4.1</a></span> EnqueueJob (
- queueName, job, arguments)</h1>
-
- <p>The EnqueueJob abstract operation requires three arguments: <var>queueName</var>, <var>job</var>, and
- <var>arguments</var>. It performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>queueName</i>) is String and its value is the name of a Job
- Queue recognized by this implementation.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>job</i> is the name of a Job.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>arguments</i> is a <a
- href="#sec-list-and-record-specification-type">List</a> that has the same number of elements as the number of
- parameters required by <i>job</i>.</li>
- <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>callerRealm</i> be <i>callerContext&rsquo;s</i> <a href="#sec-code-realms">Realm</a>.</li>
- <li>Let <i>pending</i> be PendingJob{ [[Job]]: <i>job</i>, [[Arguments]]: <i>arguments</i>, [[Realm]]: <i>callerRealm</i>,
- [[HostDefined]]: <b>undefined</b> }.</li>
- <li>Perform any implementation or host environment defined processing of <i>pending</i>. This may include modifying the
- [[HostDefined]] field or any other field of <i>pending</i>.</li>
- <li>Add <i>pending</i> at the back of the Job Queue named by <i>queueName</i>.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>).</li>
- </ol>
- </section>
-
- <section id="sec-nextjob-result">
- <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
- result</h1>
-
- <p>An algorithm step such as:</p>
-
- <ol class="proc">
- <li>NextJob <i>result</i>.</li>
- </ol>
-
- <p>is used in Job abstract operations in place of:</p>
-
- <ol class="proc">
- <li>Return <i>result</i>.</li>
- </ol>
-
- <p>Job abstract operations must not contain a Return step or a <a href="#sec-returnifabrupt">ReturnIfAbrupt</a> step. The
- NextJob <var>result</var> operation is equivalent to the following steps:</p>
-
- <ol class="proc">
- <li>If <i>result</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, perform
- implementation defined unhandled exception processing.</li>
- <li><a href="#sec-execution-contexts">Suspend</a> <a href="#sec-execution-contexts">the running execution context</a> and
- remove it from <a href="#sec-execution-contexts">the execution context stack</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: The <a href="#sec-execution-contexts">execution context stack</a> is
- now empty.</li>
- <li>Let <i>nextQueue</i> be a non-empty Job Queue chosen in an implementation defined manner. If all Job Queues are empty,
- the result is implementation defined.</li>
- <li>Let <i>nextPending</i> be the PendingJob record at the front of <i>nextQueue</i>. Remove that record from
- <i>nextQueue</i>.</li>
- <li>Let <i>newContext</i> be a new <a href="#sec-execution-contexts">execution context</a>.</li>
- <li>Set <i>newContext</i>&rsquo;s <a href="#sec-code-realms">Realm</a> to <i>nextPending</i>.[[Realm]].</li>
- <li>Push <i>newContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>newContext</i> is
- now <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Perform any implementation or host environment defined job initialization using <i>nextPending</i>.</li>
- <li>Perform the abstract operation named by <i>nextPending</i>.[[Job]] using the elements of
- <i>nextPending</i>.[[Arguments]] as its arguments.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-ecmascript-initialization">
- <div class="front">
- <h1><span class="secnum" id="sec-8.5"><a href="#sec-ecmascript-initialization" title="link to this section">8.5</a></span>
- ECMAScript Initialization()</h1>
-
- <p>An ECMAScript implementation performs the following steps prior to the execution of any Jobs or the evaluation of any
- ECMAScript code:</p>
-
- <ol class="proc">
- <li>Let <i>realm</i> be <a href="#sec-createrealm">CreateRealm</a>().</li>
- <li>Let <i>newContext</i> be a new <a href="#sec-execution-contexts">execution context</a>.</li>
- <li>Set the Function of <i>newContext</i> to <b>null</b>.</li>
- <li>Set the <a href="#sec-code-realms">Realm</a> of <i>newContext</i> to <i>realm</i>.</li>
- <li>Push <i>newContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>newContext</i> is
- now <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>status</i> be <a href="#sec-initializehostdefinedrealm">InitializeHostDefinedRealm</a>(<i>realm</i>).</li>
- <li>If <i>status</i> is an <a href="#sec-completion-record-specification-type">abrupt completion</a>, then
- <ol class="block">
- <li><a href="#sec-algorithm-conventions">Assert</a>: The first realm could not be created.</li>
- <li>Terminate ECMAScript execution.</li>
- </ol>
- </li>
- <li>In an implementation dependent manner, obtain the ECMAScript source texts (see <a
- href="#sec-ecmascript-language-source-code">clause 10</a>) for zero or more ECMAScript scripts and/or ECMAScript
- modules. For each such <i>sourceText</i> do,
- <ol class="block">
- <li>If <i>sourceText</i> is the source code of a script, then
- <ol class="block">
- <li>Perform <a href="#sec-enqueuejob">EnqueueJob</a>(<code>"ScriptJobs"</code>, <a
- href="#sec-scriptevaluationjob">ScriptEvaluationJob</a>, &laquo; <i>sourceText</i> &raquo;).</li>
- </ol>
- </li>
- <li>Else <i>sourceText</i> is the source code of a module,
- <ol class="block">
- <li>Perform <a href="#sec-enqueuejob">EnqueueJob</a>(<code>"ScriptJobs"</code>, <a
- href="#sec-toplevelmoduleevaluationjob">TopLevelModuleEvaluationJob</a>, &laquo; <i>sourceText</i>
- &raquo;).</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>NextJob <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- </ol>
- </div>
-
- <section id="sec-initializehostdefinedrealm">
- <h1><span class="secnum" id="sec-8.5.1"><a href="#sec-initializehostdefinedrealm"
- title="link to this section">8.5.1</a></span> InitializeHostDefinedRealm ( realm )</h1>
-
- <p>The abstract operation InitializeHostDefinedRealm with parameter <var>realm</var> performs the following steps:</p>
-
- <ol class="proc">
- <li>If this implementation requires use of an exotic object to serve as <i>realm</i>&rsquo;s global object, let
- <i>global</i> be such an object created in an implementation defined manner. Otherwise, let <i>global</i> be
- <b>undefined</b> indicating that an ordinary object should be created as the global object.</li>
- <li>Perform <a href="#sec-setrealmglobalobject">SetRealmGlobalObject</a>(<i>realm</i>, <i>global</i>).</li>
- <li>Let <i>globalObj</i> be <a href="#sec-setdefaultglobalbindings">SetDefaultGlobalBindings</a>(<i>realm</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>globalObj</i>).</li>
- <li>Create any implementation defined global object properties on <i>globalObj</i>.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- </ol>
- </section>
- </section>
-</section>
-
-<section id="sec-ordinary-and-exotic-objects-behaviours">
- <div class="front">
- <h1><span class="secnum" id="sec-9"><a href="#sec-ordinary-and-exotic-objects-behaviours"
- title="link to this section">9</a></span> Ordinary and Exotic Objects Behaviours</h1>
- </div>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots">
- <div class="front">
- <h1><span class="secnum" id="sec-9.1"><a href="#sec-ordinary-object-internal-methods-and-internal-slots"
- title="link to this section">9.1</a></span> Ordinary Object Internal Methods and Internal Slots</h1>
-
- <p>All ordinary objects have an <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called
- [[Prototype]]. The value of this <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is either
- <b>null</b> or an object and is used for implementing inheritance. Data properties of the [[Prototype]] object are inherited
- (are visible as properties of the child object) for the purposes of get access, but not for set access. Accessor properties
- are inherited for both get access and set access.</p>
-
- <p>Every ordinary object has a Boolean-valued [[Extensible]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> that controls whether or not properties may be
- added to the object. If the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a> is <b>false</b> then additional properties may not be added to the object. In addition, if [[Extensible]] is
- <b>false</b> the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
- the object may not be modified. Once the value of an object&rsquo;s [[Extensible]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> has been set to <b>false</b> it may not be
- subsequently changed to <b>true</b>.</p>
-
- <p>In the following algorithm descriptions, assume <var>O</var> is an ordinary object, <var>P</var> is a <a
- href="#sec-object-type">property key value</a>, <var>V</var> is any <a href="#sec-ecmascript-language-types">ECMAScript
- language value</a>, and <span class="nt">Desc</span> is a <a href="#sec-property-descriptor-specification-type">Property
- Descriptor</a> record.</p>
- </div>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof">
- <h1><span class="secnum" id="sec-9.1.1"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof"
- title="link to this section">9.1.1</a></span> [[GetPrototypeOf]] ( )</h1>
-
- <p>When the [[GetPrototypeOf]] internal method of <var>O</var> is called the following steps are taken:</p>
-
- <ol class="proc">
- <li>Return the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
- <i>O</i>.</li>
- </ol>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-setprototypeof-v">
- <h1><span class="secnum" id="sec-9.1.2"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-setprototypeof-v"
- title="link to this section">9.1.2</a></span> [[SetPrototypeOf]] (V)</h1>
-
- <p>When the [[SetPrototypeOf]] internal method of <var>O</var> is called with argument <var>V</var> the following steps are
- taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
- <li>Let <i>extensible</i> be the value of the [[Extensible]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>current</i> be the value of the [[Prototype]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>current</i>), return <b>true.</b></li>
- <li>If <i>extensible</i> is <b>false</b>, return <b>false</b>.</li>
- <li>Let <i>p</i> be <i>V</i>.</li>
- <li>Let <i>done</i> be <b>false</b>.</li>
- <li>Repeat while <i>done</i> is <b>false</b>,
- <ol class="block">
- <li>If <i>p</i> is <b>null</b>, let <i>done</i> be <b>true</b>.</li>
- <li>Else, if <a href="#sec-samevalue">SameValue</a>(<i>p</i>, <i>O</i>) is <b>true</b>, return <b>false</b>.</li>
- <li>Else,
- <ol class="block">
- <li>If the [[GetPrototypeOf]] internal method of <i>p</i> is not the ordinary object internal method defined in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-getprototypeof">9.1.1</a>, let <i>done</i> be
- <b>true</b>.</li>
- <li>Else, let <i>p</i> be the value of <i>p</i>&rsquo;s [[Prototype]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Set the value of the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
- <i>O</i> to <i>V</i>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The loop in step 8 guarantees that there will be no circularities in any prototype chain
- that only includes objects that use the ordinary object definitions for [[GetPrototypeOf]] and [[SetPrototypeOf]].</p>
- </div>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-isextensible">
- <h1><span class="secnum" id="sec-9.1.3"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-isextensible"
- title="link to this section">9.1.3</a></span> [[IsExtensible]] ( )</h1>
-
- <p>When the [[IsExtensible]] internal method of <var>O</var> is called the following steps are taken:</p>
-
- <ol class="proc">
- <li>Return the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
- <i>O</i>.</li>
- </ol>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-preventextensions">
- <h1><span class="secnum" id="sec-9.1.4"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-preventextensions"
- title="link to this section">9.1.4</a></span> [[PreventExtensions]] ( )</h1>
-
- <p>When the [[PreventExtensions]] internal method of <var>O</var> is called the following steps are taken:</p>
-
- <ol class="proc">
- <li>Set the value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
- <i>O</i> to <b>false</b>.</li>
- <li>Return <b>true.</b></li>
- </ol>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-getownproperty-p">
- <div class="front">
- <h1><span class="secnum" id="sec-9.1.5"><a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-getownproperty-p"
- title="link to this section">9.1.5</a></span> [[GetOwnProperty]] (P)</h1>
-
- <p>When the [[GetOwnProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
- <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>Return <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
- </ol>
- </div>
-
- <section id="sec-ordinarygetownproperty">
- <h1><span class="secnum" id="sec-9.1.5.1"><a href="#sec-ordinarygetownproperty"
- title="link to this section">9.1.5.1</a></span> OrdinaryGetOwnProperty (O, P)</h1>
-
- <p>When the abstract operation OrdinaryGetOwnProperty is called with Object <var>O</var> and with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>If <i>O</i> does not have an own property with key <i>P</i>, return <b>undefined</b>.</li>
- <li>Let <i>D</i> be a newly created <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> with
- no fields.</li>
- <li>Let <i>X</i> be <i>O</i>&rsquo;s own property whose key is <i>P</i>.</li>
- <li>If <i>X</i> is a data property, then
- <ol class="block">
- <li>Set <i>D</i>.[[Value]] to the value of <i>X</i>&rsquo;s [[Value]] attribute.</li>
- <li>Set <i>D</i>.[[Writable]] to the value of <i>X</i>&rsquo;s [[Writable]] attribute</li>
- </ol>
- </li>
- <li>Else <i>X</i> is an accessor property, so
- <ol class="block">
- <li>Set <i>D</i>.[[Get]] to the value of <i>X</i>&rsquo;s [[Get]] attribute.</li>
- <li>Set <i>D</i>.[[Set]] to the value of <i>X</i>&rsquo;s [[Set]] attribute.</li>
- </ol>
- </li>
- <li>Set <i>D</i>.[[Enumerable]] to the value of <i>X</i>&rsquo;s [[Enumerable]] attribute.</li>
- <li>Set <i>D</i>.[[Configurable]] to the value of <i>X</i>&rsquo;s [[Configurable]] attribute.</li>
- <li>Return <i>D</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc">
- <div class="front">
- <h1><span class="secnum" id="sec-9.1.6"><a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc"
- title="link to this section">9.1.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
-
- <p>When the [[DefineOwnProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property
- key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span
- class="nt">Desc</span>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>O</i>, <i>P</i>, <i>Desc</i>).</li>
- </ol>
- </div>
-
- <section id="sec-ordinarydefineownproperty">
- <h1><span class="secnum" id="sec-9.1.6.1"><a href="#sec-ordinarydefineownproperty"
- title="link to this section">9.1.6.1</a></span> OrdinaryDefineOwnProperty (O, P, Desc)</h1>
-
- <p>When the abstract operation <span style="font-family: Times New Roman">OrdinaryDefineOwnProperty</span> is called with
- Object <var>O</var>, <a href="#sec-object-type">property key</a> <span style="font-family: Times New
- Roman"><i>P</i>,</span> and <a href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span
- class="nt">Desc</span> the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>current</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>current</i>).</li>
- <li>Let <i>extensible</i> be the value of the [[Extensible]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Return <a href="#sec-validateandapplypropertydescriptor">ValidateAndApplyPropertyDescriptor</a>(<i>O</i>, <i>P</i>,
- <i>extensible</i>, <i>Desc</i>, <i>current</i>).</li>
- </ol>
- </section>
-
- <section id="sec-iscompatiblepropertydescriptor">
- <h1><span class="secnum" id="sec-9.1.6.2"><a href="#sec-iscompatiblepropertydescriptor"
- title="link to this section">9.1.6.2</a></span> IsCompatiblePropertyDescriptor (Extensible, Desc, Current)</h1>
-
- <p>When the abstract operation <span style="font-family: Times New Roman">IsCompatiblePropertyDescriptor</span> is called
- with Boolean value <span class="nt">Extensible</span>, and Property Descriptors <span class="nt">Desc</span>, and <span
- class="nt">Current</span> the following steps are taken:</p>
-
- <ol class="proc">
- <li>Return <a href="#sec-validateandapplypropertydescriptor">ValidateAndApplyPropertyDescriptor</a>(<b>undefined</b>,
- <b>undefined</b>, <i>Extensible</i>, <i>Desc</i>, <i>Current</i>).</li>
- </ol>
- </section>
-
- <section id="sec-validateandapplypropertydescriptor">
- <h1><span class="secnum" id="sec-9.1.6.3"><a href="#sec-validateandapplypropertydescriptor"
- title="link to this section">9.1.6.3</a></span> ValidateAndApplyPropertyDescriptor (O, P, extensible, Desc,
- current)</h1>
-
- <p>When the abstract operation <span style="font-family: Times New Roman">ValidateAndApplyPropertyDescriptor</span> is
- called with Object <var>O</var>, <a href="#sec-object-type">property key</a> <span style="font-family: Times New
- Roman"><i>P</i>,</span> Boolean value <var>extensible</var>, and Property Descriptors <span class="nt">Desc</span>, and
- <var>current</var> the following steps are taken:</p>
-
- <p>This algorithm contains steps that test various fields of the <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> for specific
- values. The fields that are tested in this manner need not actually exist in <span class="nt">Desc</span>. If a field is
- absent then its value is considered to be <b>false</b>.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> If <b>undefined</b> is passed as the <i>O</i> argument only validation is performed and
- no object updates are performed.</p>
- </div>
-
- <ol class="proc">
- <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
- href="#sec-object-type">property key</a>.</li>
- <li>If <i>current</i> is <b>undefined</b>, then
- <ol class="block">
- <li>If <i>extensible</i> is <b>false</b>, return <b>false</b>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>extensible</i> is <b>true</b>.</li>
- <li>If <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) or <a
- href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
- <ol class="block">
- <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
- [[Value]], [[Writable]], [[Enumerable]] and [[Configurable]] attribute values are described by <i>Desc</i>.
- If the value of an attribute field of <i>Desc</i> is absent, the attribute of the newly created property is
- set to its default value.</li>
- </ol>
- </li>
- <li>Else <i>Desc</i> must be an accessor <a href="#sec-property-descriptor-specification-type">Property
- Descriptor</a>,
- <ol class="block">
- <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
- [[Get]], [[Set]], [[Enumerable]] and [[Configurable]] attribute values are described by <i>Desc</i>. If the
- value of an attribute field of <i>Desc</i> is absent, the attribute of the newly created property is set to
- its default value.</li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
- </li>
- <li>Return <b>true</b>, if every field in <i>Desc</i> is absent.</li>
- <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
- <i>Desc</i> is the same value as the corresponding field in <i>current</i> when compared using <a
- href="#sec-samevalue">the SameValue algorithm</a>.</li>
- <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
- <ol class="block">
- <li>Return <b>false</b>, if the [[Configurable]] field of <i>Desc</i> is <b>true</b>.</li>
- <li>Return <b>false</b>, if the [[Enumerable]] field of <i>Desc</i> is present and the [[Enumerable]] fields of
- <i>current</i> and <i>Desc</i> are the Boolean negation of each other.</li>
- </ol>
- </li>
- <li>If <a href="#sec-isgenericdescriptor">IsGenericDescriptor</a>(<i>Desc</i>) is <b>true</b>, no further validation is
- required.</li>
- <li>Else if <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) and <a
- href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) have different results, then
- <ol class="block">
- <li>Return <b>false</b>, if the [[Configurable]] field of <i>current</i> is <b>false</b>.</li>
- <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) is <b>true</b>, then
- <ol class="block">
- <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
- property to an accessor property. Preserve the existing values of the converted property&rsquo;s
- [[Configurable]] and [[Enumerable]] attributes and set the rest of the property&rsquo;s attributes to their
- default values.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <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
- property to a data property. Preserve the existing values of the converted property&rsquo;s [[Configurable]]
- and [[Enumerable]] attributes and set the rest of the property&rsquo;s attributes to their default
- values.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Else if <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>current</i>) and <a
- href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>Desc</i>) are both <b>true</b>, then
- <ol class="block">
- <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
- <ol class="block">
- <li>Return <b>false</b>, if the [[Writable]] field of <i>current</i> is <b>false</b> and the [[Writable]] field
- of <i>Desc</i> is <b>true</b>.</li>
- <li>If the [[Writable]] field of <i>current</i> is <b>false</b>, then
- <ol class="block">
- <li>Return <b>false</b>, if the [[Value]] field of <i>Desc</i> is present and <a
- href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Value]], <i>current</i>.[[Value]]) is
- <b>false</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Else the [[Configurable]] field of <i>current</i> is <b>true</b>, so any change is acceptable.</li>
- </ol>
- </li>
- <li>Else <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>current</i>) and <a
- href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) are both <b>true</b>,
- <ol class="block">
- <li>If the [[Configurable]] field of <i>current</i> is <b>false</b>, then
- <ol class="block">
- <li>Return <b>false</b>, if the [[Set]] field of <i>Desc</i> is present and <a
- href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Set]], <i>current</i>.[[Set]]) is <b>false</b>.</li>
- <li>Return <b>false</b>, if the [[Get]] field of <i>Desc</i> is present and <a
- href="#sec-samevalue">SameValue</a>(<i>Desc</i>.[[Get]], <i>current</i>.[[Get]]) is <b>false</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>If <i>O</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>For each field of <i>Desc</i> that is present, set the corresponding attribute of the property named <i>P</i> of
- object <i>O</i> to the value of the field.</li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Step 8.b allows any field of Desc to be different from the corresponding field of
- current if current&rsquo;s [[Configurable]] field is <b>true</b>. This even permits changing the [[Value]] of a property
- whose [[Writable]] attribute is <b>false</b>. This is allowed because a <b>true</b> [[Configurable]] attribute would
- permit an equivalent sequence of calls where [[Writable]] is first set to <b>true</b>, a new [[Value]] is set, and then
- [[Writable]] is set to <b>false</b>.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p">
- <div class="front">
- <h1><span class="secnum" id="sec-9.1.7"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p"
- title="link to this section">9.1.7</a></span> [[HasProperty]](P)</h1>
-
- <p>When the [[HasProperty]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
- <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
- </ol>
- </div>
-
- <section id="sec-ordinaryhasproperty">
- <h1><span class="secnum" id="sec-9.1.7.1"><a href="#sec-ordinaryhasproperty"
- title="link to this section">9.1.7.1</a></span> OrdinaryHasProperty (O, P)</h1>
-
- <p>When the abstract operation OrdinaryHasProperty is called with Object <var>O</var> and with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>hasOwn</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
- <li>If <i>hasOwn</i> is not <b>undefined</b>, return <b>true</b>.</li>
- <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
- <li>If <i>parent</i> is not <b>null</b>, then
- <ol class="block">
- <li>Return <i>parent</i>.[[HasProperty]](<i>P</i>).</li>
- </ol>
- </li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">
- <h1><span class="secnum" id="sec-9.1.8"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver"
- title="link to this section">9.1.8</a></span> [[Get]] (P, Receiver)</h1>
-
- <p>When the [[Get]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>
- and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span> the following
- steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
- <li>If <i>desc</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
- <li>If <i>parent</i> is <b>null</b>, return <b>undefined.</b></li>
- <li>Return <i>parent</i>.[[Get]](<i>P</i>, <i>Receiver</i>).</li>
- </ol>
- </li>
- <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>desc</i>) is <b>true</b>, return
- <i>desc</i>.[[Value]].</li>
- <li>Otherwise, <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>desc</i>) must be <b>true</b> so, let
- <i>getter</i> be <i>desc</i>.[[Get]].</li>
- <li>If <i>getter</i> is <b>undefined</b>, return <b>undefined</b>.</li>
- <li>Return <a href="#sec-call">Call</a>(<i>getter,</i> <i>Receiver</i>).</li>
- </ol>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver">
- <h1><span class="secnum" id="sec-9.1.9"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver"
- title="link to this section">9.1.9</a></span> [[Set]] ( P, V, Receiver)</h1>
-
- <p>When the [[Set]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>,
- value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
- class="nt">Receiver</span>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>ownDesc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ownDesc</i>).</li>
- <li>If <i>ownDesc</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>parent</i> be <i>O</i>.[[GetPrototypeOf]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>parent</i>).</li>
- <li>If <i>parent</i> is not <b>null</b>, then
- <ol class="block">
- <li>Return <i>parent</i>.[[Set]](<i>P</i>, <i>V</i>, <i>Receiver</i>).</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>ownDesc</i> be the PropertyDescriptor{[[Value]]: <b>undefined</b>, [[Writable]]: <b>true</b>,
- [[Enumerable]]: <b>true</b>, [[Configurable]]: <b>true</b>}.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>ownDesc</i>) is <b>true</b>, then
- <ol class="block">
- <li>If <i>ownDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>Receiver</i>) is not Object, return
- <b>false</b>.</li>
- <li>Let <i>existingDescriptor</i> be <i>Receiver</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>existingDescriptor</i>).</li>
- <li>If <i>existingDescriptor</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>valueDesc</i> be the PropertyDescriptor{[[Value]]: <i>V</i>}.</li>
- <li>Return <i>Receiver</i>.[[DefineOwnProperty]](<i>P</i>, <i>valueDesc</i>).</li>
- </ol>
- </li>
- <li>Else <i>Receiver</i> does not currently have a property <i>P</i>,
- <ol class="block">
- <li>Return <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>Receiver</i>, <i>P</i>, <i>V</i>).</li>
- </ol>
- </li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>ownDesc</i>) is <b>true</b>.</li>
- <li>Let <i>setter</i> be <i>ownDesc</i>.[[Set]].</li>
- <li>If <i>setter</i> is <b>undefined</b>, return <b>false</b>.</li>
- <li>Let <i>setterResult</i> be <a href="#sec-call">Call</a>(<i>setter</i>, <i>Receiver</i>, &laquo;<i>V</i>&raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>setterResult</i>).</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-delete-p">
- <h1><span class="secnum" id="sec-9.1.10"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-delete-p"
- title="link to this section">9.1.10</a></span> [[Delete]] (P)</h1>
-
- <p>When the [[Delete]] internal method of <var>O</var> is called with <a href="#sec-object-type">property key</a>
- <var>P</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>desc</i> be <i>O</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
- <li>If <i>desc</i> is <b>undefined</b>, return <b>true</b>.</li>
- <li>If <i>desc</i>.[[Configurable]] is <b>true</b>, then
- <ol class="block">
- <li>Remove the own property with name <i>P</i> from <i>O</i>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-enumerate">
- <h1><span class="secnum" id="sec-9.1.11"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-enumerate"
- title="link to this section">9.1.11</a></span> [[Enumerate]] ()</h1>
-
- <p>When the [[Enumerate]] internal method of <var>O</var> is called the following steps are taken:</p>
-
- <ol class="proc">
- <li>Return an Iterator object (<a href="#sec-iterator-interface">25.1.1.2</a>) whose <code>next</code> method iterates
- over all the String-valued keys of enumerable properties of <i>O</i>. The Iterator object must inherit from
- %IteratorPrototype% (<a href="#sec-%iteratorprototype%-object">25.1.2</a>). The mechanics and order of enumerating the
- properties is not specified but must conform to the rules specified below.</li>
- </ol>
-
- <p>The iterator&rsquo;s <code>next</code> method processes object properties to determine whether the <a
- href="#sec-object-type">property key</a> should be returned as an iterator value. Returned property keys do not include keys
- that are Symbols. Properties of the target object may be deleted during enumeration. A property that is deleted before it is
- processed by the iterator&rsquo;s <code>next</code> method is ignored. If new properties are added to the target object
- during enumeration, the newly added properties are not guaranteed to be processed in the active enumeration. A property name
- will be returned by the iterator&rsquo;s <code>next</code> method at most once in any enumeration.</p>
-
- <p>Enumerating the properties of the target object includes enumerating properties of its prototype, and the prototype of
- the prototype, and so on, recursively; but a property of a prototype is not processed if it has the same name as a property
- that has already been processed by the iterator&rsquo;s <code>next</code> method. The values of [[Enumerable]] attributes
- are not considered when determining if a property of a prototype object has already been processed. The enumerable property
- names of prototype objects must be obtained as if by invoking the prototype object&rsquo;s [[Enumerate]] internal method.
- [[Enumerate]] must obtain the own property keys of the target object as if by calling its [[OwnPropertyKeys]] internal
- method. Property attributes of the target object must be obtained as if by calling its [[GetOwnProperty]] internal
- method.</p>
-
- <p class="Note">NOTE The following is an informative definition of an ECMAScript generator function that conforms to these
- rules:</p>
-
- <pre>function* enumerate(obj) {</pre>
- <pre>let visited=new Set;</pre>
- <pre>for (let key of <a href="#sec-reflect.ownkeys">Reflect.ownKeys</a>(obj)) {</pre>
- <pre>if (typeof key === "string") {</pre>
- <pre>let desc = <a href="#sec-reflect.getownpropertydescriptor">Reflect.getOwnPropertyDescriptor</a>(obj,key);</pre>
- <pre>if (desc) {</pre>
- <pre>visited.add(key);</pre>
- <pre>if (desc.enumerable) yield key;</pre>
- <pre>}</pre>
- <pre>}</pre>
- <pre>}</pre>
- <pre>let proto = <a href="#sec-reflect.getprototypeof">Reflect.getPrototypeOf</a>(obj)</pre>
- <pre>if (proto === null) return;</pre>
- <pre>for (let protoName of <a href="#sec-reflect.enumerate">Reflect.enumerate</a>(proto)) {</pre>
- <pre>if (!visited.has(protoName)) yield protoName;</pre>
- <pre>}</pre>
- <pre>}</pre>
- </section>
-
- <section id="sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys">
- <h1><span class="secnum" id="sec-9.1.12"><a href="#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys"
- title="link to this section">9.1.12</a></span> [[OwnPropertyKeys]] ( )</h1>
-
- <p>When the [[OwnPropertyKeys]] internal method of <var>O</var> is called the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <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
- numeric index order
- <ol class="block">
- <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <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
- index, in property creation order
- <ol class="block">
- <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <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
- order
- <ol class="block">
- <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <li>Return <i>keys</i>.</li>
- </ol>
- </section>
-
- <section id="sec-objectcreate">
- <h1><span class="secnum" id="sec-9.1.13"><a href="#sec-objectcreate" title="link to this section">9.1.13</a></span>
- ObjectCreate(proto, internalSlotsList)</h1>
-
- <p>The abstract operation ObjectCreate with argument <var>proto</var> (an object or null) is used to specify the runtime
- creation of new ordinary objects. The optional argument <var>internalSlotsList</var> is a <a
- href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
- part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
- used. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li>If <i>internalSlotsList</i> was not provided, let <i>internalSlotsList</i> be an empty <a
- href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Let <i>obj</i> be a newly created object with an <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a> for each name in <i>internalSlotsList</i>.</li>
- <li>Set <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
- <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
- <i>proto</i>.</li>
- <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
- <b>true</b>.</li>
- <li>Return <i>obj</i>.</li>
- </ol>
- </section>
-
- <section id="sec-ordinarycreatefromconstructor">
- <h1><span class="secnum" id="sec-9.1.14"><a href="#sec-ordinarycreatefromconstructor"
- title="link to this section">9.1.14</a></span> OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto,
- internalSlotsList )</h1>
-
- <p>The abstract operation OrdinaryCreateFromConstructor creates an ordinary object whose [[Prototype]] value is retrieved
- from a constructor&rsquo;s <code>prototype</code> property, if it exists. Otherwise the intrinsic named by
- <var>intrinsicDefaultProto</var> is used for [[Prototype]]. The optional <var>internalSlotsList</var> is a <a
- href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
- part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
- used. This abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>intrinsicDefaultProto</i> is a string value that is this
- specification&rsquo;s name of an intrinsic object. The corresponding object must be an intrinsic that is intended to
- be used as the [[Prototype]] value of an object.</li>
- <li>Let <i>proto</i> be <a href="#sec-getprototypefromconstructor">GetPrototypeFromConstructor</a>(<i>constructor</i>,
- <i>intrinsicDefaultProto</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
- <li>Return <a href="#sec-objectcreate">ObjectCreate</a>(<i>proto</i>, <i>internalSlotsList</i>).</li>
- </ol>
- </section>
-
- <section id="sec-getprototypefromconstructor">
- <h1><span class="secnum" id="sec-9.1.15"><a href="#sec-getprototypefromconstructor"
- title="link to this section">9.1.15</a></span> GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )</h1>
-
- <p>The abstract operation GetPrototypeFromConstructor determines the [[Prototype]] value that should be used to create an
- object corresponding to a specific constructor. The value is retrieved from the constructor&rsquo;s <code>prototype</code>
- property, if it exists. Otherwise the intrinsic named by <var>intrinsicDefaultProto</var> is used for [[Prototype]]. This
- abstract operation performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>intrinsicDefaultProto</i> is a string value that is this
- specification&rsquo;s name of an intrinsic object. The corresponding object must be an intrinsic that is intended to
- be used as the [[Prototype]] value of an object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-isconstructor">IsConstructor</a> (<i>constructor</i>)
- is <b>true</b>.</li>
- <li>Let <i>proto</i> be <a href="#sec-get-o-p">Get</a>(<i>constructor</i>, <code>"prototype"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>proto</i>) is not Object, then
- <ol class="block">
- <li>Let <i>realm</i> be <a href="#sec-getfunctionrealm">GetFunctionRealm</a>(<i>constructor</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>realm</i>).</li>
- <li>Let <i>proto</i> be <i>realm&rsquo;s</i> intrinsic object named <i>intrinsicDefaultProto</i>.</li>
- </ol>
- </li>
- <li>Return <i>proto</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> If <i>constructor</i> does not supply a [[Prototype]] value, the default value that is
- used is obtained from the <a href="#sec-code-realms">Code Realm</a> of the <i>constructor</i> function rather than from <a
- href="#sec-execution-contexts">the running execution context</a>.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-ecmascript-function-objects">
- <div class="front">
- <h1><span class="secnum" id="sec-9.2"><a href="#sec-ecmascript-function-objects" title="link to this section">9.2</a></span>
- ECMAScript Function Objects</h1>
-
- <p>ECMAScript function objects encapsulate parameterized ECMAScript code closed over a <a
- href="#sec-lexical-environments">lexical environment</a> and support the dynamic evaluation of that code. An ECMAScript
- function object is an ordinary object and has the same internal slots and the same internal methods as other ordinary
- objects. The code of an ECMAScript function object may be either <a href="#sec-strict-mode-code">strict mode code</a> (<a
- href="#sec-strict-mode-code">10.2.1</a>) or non-<a href="#sec-strict-mode-code">strict mode code</a>. An ECMAScript function
- object whose code is <a href="#sec-strict-mode-code">strict mode code</a> is called a <i>strict function</i>. One whose code
- is not <a href="#sec-strict-mode-code">strict mode code</a> is called a <i>non-strict function</i>.</p>
-
- <p>ECMAScript function objects have the additional internal slots listed in <a href="#table-27">Table 27</a>.</p>
-
- <figure>
- <figcaption><span id="table-27">Table 27</span> &mdash; Internal Slots of ECMAScript Function Objects</figcaption>
- <table class="real-table">
- <tr>
- <th>Internal Slot</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>[[Environment]]</td>
- <td><a href="#sec-lexical-environments">Lexical Environment</a></td>
- <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>
- </tr>
- <tr>
- <td>[[FormalParameters]]</td>
- <td>Parse Node</td>
- <td>The root parse node of the source text that defines the function&rsquo;s formal parameter list.</td>
- </tr>
- <tr>
- <td>[[FunctionKind]]</td>
- <td>String</td>
- <td>Either <code>"normal"</code>, <code>"classConstructor"</code> or <code>"generator"</code>.</td>
- </tr>
- <tr>
- <td>[[ECMAScriptCode]]</td>
- <td>Parse Node</td>
- <td>The root parse node of the source text that defines the function&rsquo;s body.</td>
- </tr>
- <tr>
- <td>[[ConstructorKind]]</td>
- <td>String</td>
- <td>Either <code>"base"</code> or <code>"derived"</code>.</td>
- </tr>
- <tr>
- <td>[[Realm]]</td>
- <td><a href="#sec-code-realms">Realm</a> Record</td>
- <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>
- </tr>
- <tr>
- <td>[[ThisMode]]</td>
- <td>(lexical, strict, global)</td>
- <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>
- </tr>
- <tr>
- <td>[[Strict]]</td>
- <td>Boolean</td>
- <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>
- </tr>
- <tr>
- <td>[[HomeObject]]</td>
- <td>Object</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>All ECMAScript function objects have the [[Call]] internal method defined here. ECMAScript functions that are also
- constructors in addition have the [[Construct]] internal method. ECMAScript function objects whose code is not <a
- href="#sec-strict-mode-code">strict mode code</a> have the [[GetOwnProperty]] internal method defined here.</p>
- </div>
-
- <section id="sec-ecmascript-function-objects-call-thisargument-argumentslist">
- <div class="front">
- <h1><span class="secnum" id="sec-9.2.1"><a href="#sec-ecmascript-function-objects-call-thisargument-argumentslist"
- title="link to this section">9.2.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
-
- <p>The [[Call]] internal method for an <a href="#sec-ecmascript-function-objects">ECMAScript function object</a>
- <var>F</var> is called with parameters <var>thisArgument</var> and <var>argumentsList</var>, a <a
- href="#sec-list-and-record-specification-type">List</a> of <a href="#sec-ecmascript-language-types">ECMAScript language
- values</a>. The following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a
- href="#sec-ecmascript-function-objects">ECMAScript function object</a>.</li>
- <li>If <i>F</i>&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is
- <code>"classConstructor"</code>, throw a <b>TypeError</b> exception.</li>
- <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>calleeContext</i> be <a href="#sec-prepareforordinarycall">PrepareForOrdinaryCall</a>(<i>F</i>,
- <b>undefined</b>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>calleeContext</i> is now <a href="#sec-execution-contexts">the
- running execution context</a>.</li>
- <li>Perform <a href="#sec-ordinarycallbindthis">OrdinaryCallBindThis</a>(<i>F</i>, <i>calleeContext</i>,
- <i>thisArgument</i>).</li>
- <li>Let <i>result</i> be <a href="#sec-ordinarycallevaluatebody">OrdinaryCallEvaluateBody</a>(<i>F</i>,
- <i>argumentsList</i>).</li>
- <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
- <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>If <i>result</i>.[[type]] is <span style="font-family: sans-serif">return</span>, return <a
- href="#sec-normalcompletion">NormalCompletion</a>(<i>result</i>.[[value]]).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> When <i>calleeContext</i> is removed from <a href="#sec-execution-contexts">the
- execution context stack</a> in step 8 it must not be destroyed if it is <a href="#sec-execution-contexts">suspended</a>
- and retained for later resumption by an accessible generator object<i>.</i></p>
- </div>
- </div>
-
- <section id="sec-prepareforordinarycall">
- <h1><span class="secnum" id="sec-9.2.1.1"><a href="#sec-prepareforordinarycall"
- title="link to this section">9.2.1.1</a></span> PrepareForOrdinaryCall( F, newTarget )</h1>
-
- <p>When the abstract operation PrepareForOrdinaryCall is called with function object <var>F</var> <span
- style="font-family: Times New Roman">and <a href="#sec-ecmascript-language-types">ECMAScript language value</a>
- <i>newTarget</i></span>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Undefined or Object.</li>
- <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>calleeContext</i> be a new <a href="#sec-execution-contexts">ECMAScript code execution context</a>.</li>
- <li>Set the Function of <i>calleeContext</i> to <i>F</i>.</li>
- <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Set the <a href="#sec-code-realms">Realm</a> of <i>calleeContext</i> to <i>calleeRealm</i>.</li>
- <li>Let <i>localEnv</i> be <a href="#sec-newfunctionenvironment">NewFunctionEnvironment</a>(<i>F</i>,
- <i>newTarget</i>).</li>
- <li>Set the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i> to <i>localEnv</i>.</li>
- <li>Set the <a href="#sec-execution-contexts">VariableEnvironment</a> of <i>calleeContext</i> to <i>localEnv</i>.</li>
- <li>If <i>callerContext</i> is not already <a href="#sec-execution-contexts">suspended</a>, <a
- href="#sec-execution-contexts">Suspend</a> <i>callerContext</i>.</li>
- <li>Push <i>calleeContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>;
- <i>calleeContext</i> is now <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li><span style="font-family: sans-serif">NOTE Any exception objects produced after this point are associated
- with</span> <i>calleeRealm</i>.</li>
- <li>Return <i>calleeContext</i>.</li>
- </ol>
- </section>
-
- <section id="sec-ordinarycallbindthis">
- <h1><span class="secnum" id="sec-9.2.1.2"><a href="#sec-ordinarycallbindthis"
- title="link to this section">9.2.1.2</a></span> OrdinaryCallBindThis ( F, calleeContext, thisArgument )</h1>
-
- <p>When the abstract operation OrdinaryCallBindThis is called with function object <var>F</var>, <a
- href="#sec-execution-contexts">execution context</a> <var>calleeContext</var>, and ECMAScript value
- <var>thisArgument</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>thisMode</i> be the value of <i>F</i>&rsquo;s [[ThisMode]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <i>thisMode</i> is <span style="font-family: sans-serif">lexical</span>, return <a
- href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>localEnv</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i>.</li>
- <li>If <i>thisMode</i> is <span style="font-family: sans-serif">strict</span>, let <i>thisValue</i> be
- <i>thisArgument</i>.</li>
- <li>Else
- <ol class="block">
- <li>if <i>thisArgument</i> is <b>null</b> or <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>thisValue</i> be <i>calleeRealm</i>.[[globalThis]].</li>
- </ol>
- </li>
- <li>Else
- <ol class="block">
- <li>Let <i>thisValue</i> be <a href="#sec-toobject">ToObject</a>(<i>thisArgument</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>thisValue</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li><span style="font-family: sans-serif">NOTE <a href="#sec-toobject">ToObject</a> produces</span> <span
- style="font-family: sans-serif">wrapper objects using</span> <i>calleeRealm</i>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Let <i>envRec</i> be <i>localEnv</i>&rsquo;s EnvironmentRecord.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: The next step never returns an <a
- href="#sec-completion-record-specification-type">abrupt completion</a> because <i>envRec</i>.[[thisBindingStatus]]
- is <code>"uninitialized"</code>.</li>
- <li>Return <i>envRec</i>.<a href="#sec-bindthisvalue">BindThisValue</a>(<i>thisValue</i>).</li>
- </ol>
- </section>
-
- <section id="sec-ordinarycallevaluatebody">
- <h1><span class="secnum" id="sec-9.2.1.3"><a href="#sec-ordinarycallevaluatebody"
- title="link to this section">9.2.1.3</a></span> OrdinaryCallEvaluateBody ( F, argumentsList )</h1>
-
- <p>When the abstract operation OrdinaryCallEvaluateBody is called with function object <var>F</var> and <a
- href="#sec-list-and-record-specification-type">List</a> <var>argumentsList</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>status</i> be <a href="#sec-functiondeclarationinstantiation">FunctionDeclarationInstantiation</a>(<i>F</i>,
- <i>argumentsList</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>)</li>
- <li>Return the result of EvaluateBody of the parsed code that is the value of <i>F</i>'s [[ECMAScriptCode]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> passing <i>F</i> as the argument.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-ecmascript-function-objects-construct-argumentslist-newtarget">
- <h1><span class="secnum" id="sec-9.2.2"><a href="#sec-ecmascript-function-objects-construct-argumentslist-newtarget"
- title="link to this section">9.2.2</a></span> [[Construct]] ( argumentsList, newTarget)</h1>
-
- <p>The [[Construct]] internal method for an <a href="#sec-ecmascript-function-objects">ECMAScript Function object</a>
- <var>F</var> is called with parameters <var>argumentsList</var> and <span style="font-family: Times New
- Roman"><i>newTarget</i>. <i>argumentsList</i></span> is a possibly empty <a
- href="#sec-list-and-record-specification-type">List</a> of <a href="#sec-ecmascript-language-types">ECMAScript language
- values</a>. The following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
- function object</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newTarget</i>) is Object.</li>
- <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>kind</i> be <i>F</i>&rsquo;s [[ConstructorKind]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <i>kind</i> is <code>"base"</code>, then
- <ol class="block">
- <li>Let <i>thisArgument</i> be <a
- href="#sec-ordinarycreatefromconstructor">OrdinaryCreateFromConstructor</a>(<i>newTarget</i>,
- <code>"%ObjectPrototype%"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>thisArgument</i>).</li>
- </ol>
- </li>
- <li>Let <i>calleeContext</i> be <a href="#sec-prepareforordinarycall">PrepareForOrdinaryCall</a>(<i>F</i>,
- <i>newTarget</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>calleeContext</i> is now <a href="#sec-execution-contexts">the
- running execution context</a>.</li>
- <li>If <i>kind</i> is <code>"base"</code>, perform <a href="#sec-ordinarycallbindthis">OrdinaryCallBindThis</a>(<i>F</i>,
- <i>calleeContext</i>, <i>thisArgument</i>).</li>
- <li>Let <i>constructorEnv</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of
- <i>calleeContext</i>.</li>
- <li>Let <i>envRec</i> be <i>constructorEnv</i>&rsquo;s EnvironmentRecord.</li>
- <li>Let <i>result</i> be <a href="#sec-ordinarycallevaluatebody">OrdinaryCallEvaluateBody</a>(<i>F</i>,
- <i>argumentsList</i>).</li>
- <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
- <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>If <i>result</i>.[[type]] is <span style="font-family: sans-serif">return</span>, then
- <ol class="block">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>.[[value]]) is Object, return <a
- href="#sec-normalcompletion">NormalCompletion</a>(<i>result</i>.[[value]]).</li>
- <li>If <i>kind</i> is <code>"base"</code>, return <a
- href="#sec-normalcompletion">NormalCompletion</a>(<i>thisArgument</i>).</li>
- <li>If <i>result</i>.[[value]] is not <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- <li>Else, <a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
- <li>Return <i>envRec</i>.GetThisBinding().</li>
- </ol>
- </section>
-
- <section id="sec-functionallocate">
- <h1><span class="secnum" id="sec-9.2.3"><a href="#sec-functionallocate" title="link to this section">9.2.3</a></span>
- FunctionAllocate (functionPrototype, strict [,functionKind] )</h1>
-
- <p>The abstract operation FunctionAllocate requires the two arguments <span style="font-family: Times New
- Roman"><i>functionPrototype</i> and <i>strict</i>.</span> It also accepts one optional argument, <var>functionKind</var>.
- FunctionAllocate performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>functionPrototype</i>) is Object.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>functionKind</i> is present, its value is either
- <code>"normal"</code>, <code>"non-constructor"</code> or <code>"generator"</code>.</li>
- <li>If <i>functionKind</i> is not present, let <i>functionKind</i> be <code>"normal"</code>.</li>
- <li>If <i>functionKind</i> is <code>"non-constructor"</code>, then
- <ol class="block">
- <li>Let <i>functionKind</i> be <code>"normal"</code>.</li>
- <li>Let <i>needsConstruct</i> be <b>false</b>.</li>
- </ol>
- </li>
- <li>Else let <i>needsConstruct</i> be <b>true</b>.</li>
- <li>Let <i>F</i> be a newly created <a href="#sec-ecmascript-function-objects">ECMAScript function object</a> with the
- internal slots listed in <a href="#table-27">Table 27</a>. All of those internal slots are initialized to
- <b>undefined</b>.</li>
- <li>Set <i>F</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
- <li>Set <i>F</i>&rsquo;s [[Call]] internal method to the definition specified in <a
- href="#sec-ecmascript-function-objects-call-thisargument-argumentslist">9.2.1</a>.</li>
- <li>If <i>needsConstruct</i> is <b>true</b>, then
- <ol class="block">
- <li>Set <i>F</i>&rsquo;s [[Construct]] internal method to the definition specified in <a
- href="#sec-ecmascript-function-objects-construct-argumentslist-newtarget">9.2.2</a>.</li>
- <li>If <i>functionKind</i> is <code>"generator"</code>, set the [[ConstructorKind]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
- <code>"derived"</code>.</li>
- <li>Else, set the [[ConstructorKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
- <i>F</i> to <code>"base"</code>.</li>
- <li>NOTE Generator functions are tagged as <code>"derived"</code> constructors to prevent [[Construct]] from
- preallocating a generator instance. Generator instance objects are allocated when EvaluateBody is applied to the
- <span class="nt">GeneratorBody</span> of a generator function.</li>
- </ol>
- </li>
- <li>Set the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
- <i>strict</i>.</li>
- <li>Set the [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
- <i>functionKind</i>.</li>
- <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
- <i>functionPrototype</i>.</li>
- <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
- <b>true</b>.</li>
- <li>Set the [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <a
- href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a href="#sec-code-realms">Realm</a>.</li>
- <li>Return <i>F</i>.</li>
- </ol>
- </section>
-
- <section id="sec-functioninitialize">
- <h1><span class="secnum" id="sec-9.2.4"><a href="#sec-functioninitialize" title="link to this section">9.2.4</a></span>
- FunctionInitialize (F, kind, ParameterList, Body, Scope)</h1>
-
- <p>The abstract operation FunctionInitialize requires the arguments: a function object <var>F</var>, <var>kind</var> which
- is one of (Normal, Method, Arrow), a parameter list production specified by <span class="nt">ParameterList</span>, a body
- production specified by <span class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a>
- specified by <span style="font-family: Times New Roman"><i>Scope</i>.</span> FunctionInitialize performs the following
- steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
- <code>length</code> own property.</li>
- <li>Let <i>len</i> be the ExpectedArgumentCount of <i>ParameterList</i>.</li>
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"length"</code>,
- PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
- <b>true</b>}).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Let <i>Strict</i> be the value of the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a> of <i>F</i>.</li>
- <li>Set the [[Environment]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to the
- value of <i>Scope</i>.</li>
- <li>Set the [[FormalParameters]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i>
- to <i>ParameterList</i> .</li>
- <li>Set the [[ECMAScriptCode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
- <i>Body</i>.</li>
- <li>If <i>kind</i> is <span style="font-family: sans-serif">Arrow</span>, set the [[ThisMode]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <span style="font-family:
- sans-serif">lexical</span>.</li>
- <li>Else if <i>Strict</i> is <b>true</b>, set the [[ThisMode]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to <span style="font-family:
- sans-serif">strict</span>.</li>
- <li>Else set the [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
- <span style="font-family: sans-serif">global</span>.</li>
- <li>Return <i>F</i>.</li>
- </ol>
- </section>
-
- <section id="sec-functioncreate">
- <h1><span class="secnum" id="sec-9.2.5"><a href="#sec-functioncreate" title="link to this section">9.2.5</a></span>
- FunctionCreate (kind, ParameterList, Body, Scope, Strict, prototype)</h1>
-
- <p>The abstract operation FunctionCreate requires the arguments: <var>kind</var> which is one of (Normal, Method, Arrow), a
- parameter list production specified by <span class="nt">ParameterList</span>, a body production specified by <span
- class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a> specified by <span
- class="nt">Scope</span>, a Boolean flag <span class="nt">Strict</span>, and optionally, an object <span style="font-family:
- Times New Roman"><i>prototype</i>.</span> FunctionCreate performs the following steps:</p>
-
- <ol class="proc">
- <li>If the <i>prototype</i> argument was not passed, then
- <ol class="block">
- <li>Let <i>prototype</i> be the intrinsic object %FunctionPrototype%.</li>
- </ol>
- </li>
- <li>If <i>kind</i> is not <span style="font-family: sans-serif">Normal</span>, let <i>allocKind</i> be
- <code>"non-constructor"</code>.</li>
- <li>Else let <i>allocKind</i> be <code>"normal"</code>.</li>
- <li>Let <i>F</i> be <a href="#sec-functionallocate">FunctionAllocate</a>(<i>prototype</i>, <i>Strict</i>,
- <i>allocKind</i>).</li>
- <li>Return <a href="#sec-functioninitialize">FunctionInitialize</a>(<i>F</i>, <i>kind</i>, <i>ParameterList</i>,
- <i>Body</i>, <i>Scope</i>).</li>
- </ol>
- </section>
-
- <section id="sec-generatorfunctioncreate">
- <h1><span class="secnum" id="sec-9.2.6"><a href="#sec-generatorfunctioncreate" title="link to this section">9.2.6</a></span>
- GeneratorFunctionCreate (kind, ParameterList, Body, Scope, Strict)</h1>
-
- <p>The abstract operation GeneratorFunctionCreate requires the arguments: <var>kind</var> which is one of (Normal, Method),
- a parameter list production specified by <span class="nt">ParameterList</span>, a body production specified by <span
- class="nt">Body</span>, a <a href="#sec-lexical-environments">Lexical Environment</a> specified by <span
- class="nt">Scope</span>, and a Boolean flag <span class="nt">Strict</span>. GeneratorFunctionCreate performs the following
- steps:</p>
-
- <ol class="proc">
- <li>Let <i>functionPrototype</i> be the intrinsic object %Generator%.</li>
- <li>Let <i>F</i> be <a href="#sec-functionallocate">FunctionAllocate</a>(<i>functionPrototype</i>, <i>Strict</i>,
- <code>"generator"</code>).</li>
- <li>Return <a href="#sec-functioninitialize">FunctionInitialize</a>(<i>F</i>, <i>kind</i>, <i>ParameterList</i>,
- <i>Body</i>, <i>Scope</i>).</li>
- </ol>
- </section>
-
- <section id="sec-addrestrictedfunctionproperties">
- <div class="front">
- <h1><span class="secnum" id="sec-9.2.7"><a href="#sec-addrestrictedfunctionproperties"
- title="link to this section">9.2.7</a></span> AddRestrictedFunctionProperties ( F, realm )</h1>
-
- <p>The abstract operation AddRestrictedFunctionProperties is called with a function object <var>F</var> and <a
- href="#sec-code-realms">Realm</a> Record <var>realm</var> as its argument. It performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>realm</i>.[[intrinsics]].[[<span style="font-family:
- sans-serif">%ThrowTypeError%]] exists and has been initialized.</span></li>
- <li>Let <i>thrower</i> be <i>realm</i>.[[intrinsics]].[[<span style="font-family:
- sans-serif">%ThrowTypeError%]].</span></li>
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"caller"</code>,
- PropertyDescriptor {[[Get]]: <i>thrower</i>, [[Set]]: <i>thrower</i>, [[Enumerable]]: <b>false</b>,
- [[Configurable]]: <b>true</b>}).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i> , <code>"arguments"</code>,
- PropertyDescriptor {[[Get]]: <i>thrower</i>, [[Set]]: <i>thrower</i>, [[Enumerable]]: <b>false</b>,
- [[Configurable]]: <b>true</b>}).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: The above returned value is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- </ol>
- </div>
-
- <section id="sec-%throwtypeerror%">
- <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>
- %ThrowTypeError% ( )</h1>
-
- <p>The %ThrowTypeError% intrinsic is an anonymous built-in function object that is defined once for each <a
- href="#sec-code-realms">Realm</a>. When %ThrowTypeError% is called it performs the following steps:</p>
-
- <ol class="proc">
- <li>Throw a <b>TypeError</b> exception.</li>
- </ol>
-
- <p>The value of the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of a
- %ThrowTypeError% function is <span class="value">false</span>.</p>
-
- <p>The <code>length</code> property of a %ThrowTypeError% function has the attributes {&nbsp;[[Writable]]: <b>false</b>,
- [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b> }.</p>
- </section>
- </section>
-
- <section id="sec-makeconstructor">
- <h1><span class="secnum" id="sec-9.2.8"><a href="#sec-makeconstructor" title="link to this section">9.2.8</a></span>
- MakeConstructor (F, writablePrototype, prototype)</h1>
-
- <p>The abstract operation MakeConstructor requires a Function argument <var>F</var> and optionally, a Boolean
- <var>writablePrototype</var> and an object <var>prototype</var>. If <var>prototype</var> is provided it is assumed to
- already contain, if needed, a <code>"constructor"</code> property whose value is <var>F</var>. This operation converts
- <var>F</var> into a constructor by performing the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
- function object</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> has a [[Construct]] internal method.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
- <code>prototype</code> own property.</li>
- <li>Let <i>installNeeded</i> be <b>false</b>.</li>
- <li>If the <i>prototype</i> argument was not provided, then
- <ol class="block">
- <li>Let <i>installNeeded</i> be <b>true</b>.</li>
- <li>Let <i>prototype</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
- sans-serif">%ObjectPrototype%</span>).</li>
- </ol>
- </li>
- <li>If the <i>writablePrototype</i> argument was not provided, then
- <ol class="block">
- <li>Let <i>writablePrototype</i> be <b>true</b>.</li>
- </ol>
- </li>
- <li>If <i>installNeeded</i>, then
- <ol class="block">
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>prototype</i>,
- <code>"constructor"</code>, PropertyDescriptor{[[Value]]: <i>F</i>, [[Writable]]: <i>writablePrototype</i>,
- [[Enumerable]]: <b>false</b>, [[Configurable]]: <i>writablePrototype</i> }).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- </ol>
- </li>
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>,
- <code>"prototype"</code>, PropertyDescriptor{[[Value]]: <i>prototype</i>, [[Writable]]: <i>writablePrototype</i>,
- [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>false</b>}).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- </ol>
- </section>
-
- <section id="sec-makeclassconstructor">
- <h1><span class="secnum" id="sec-9.2.9"><a href="#sec-makeclassconstructor" title="link to this section">9.2.9</a></span>
- MakeClassConstructor ( F)</h1>
-
- <p>The abstract operation MakeClassConstructor with argument <var>F</var> performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
- function object</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i>&rsquo;s [[FunctionKind]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is <code>"normal"</code>.</li>
- <li>Set <i>F</i>&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
- <code>"classConstructor"</code>.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- </ol>
- </section>
-
- <section id="sec-makemethod">
- <h1><span class="secnum" id="sec-9.2.10"><a href="#sec-makemethod" title="link to this section">9.2.10</a></span> MakeMethod
- ( F, homeObject)</h1>
-
- <p>The abstract operation MakeMethod with arguments <var>F</var> and <var>homeObject</var> configures <var>F</var> as a
- method by performing the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an <a href="#sec-ecmascript-function-objects">ECMAScript
- function object</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>homeObject</i> ) is Object.</li>
- <li>Set the [[HomeObject]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>F</i> to
- <i>homeObject</i>.</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- </ol>
- </section>
-
- <section id="sec-setfunctionname">
- <h1><span class="secnum" id="sec-9.2.11"><a href="#sec-setfunctionname" title="link to this section">9.2.11</a></span>
- SetFunctionName (F, name, prefix)</h1>
-
- <p>The abstract operation SetFunctionName requires a Function argument <var>F</var>, a String or Symbol argument
- <var>name</var> and optionally a String argument <var>prefix</var>. This operation adds a <code>name</code> property to
- <var>F</var> by performing the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>F</i> is an extensible object that does not have a
- <code>name</code> own property.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>)
- is either Symbol or String.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>prefix</i> was passed then <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>prefix</i>) is String.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>) is Symbol, then
- <ol class="block">
- <li>Let <i>description</i> be <i>name</i>&rsquo;s [[Description]] value.</li>
- <li>If <i>description</i> is <b>undefined</b>, let <i>name</i> be the empty String.</li>
- <li>Else, let <i>name</i> be the concatenation of <code>"["</code>, <i>description</i>, and <code>"]"</code>.</li>
- </ol>
- </li>
- <li>If <i>prefix</i> was passed, then
- <ol class="block">
- <li>Let <i>name</i> be the concatenation of <i>prefix</i>, code unit 0x0020 (SPACE), and <i>name</i>.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>F</i>, <code>"name"</code>,
- PropertyDescriptor{[[Value]]: <i>name</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
- <b>true</b>}).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: the result is never an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- </ol>
- </section>
-
- <section id="sec-functiondeclarationinstantiation">
- <h1><span class="secnum" id="sec-9.2.12"><a href="#sec-functiondeclarationinstantiation"
- title="link to this section">9.2.12</a></span> FunctionDeclarationInstantiation(func, argumentsList)</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> When an <a href="#sec-execution-contexts">execution context</a> is established for
- evaluating an ECMAScript function a new function <a href="#sec-environment-records">Environment Record</a> is created and
- bindings for each formal parameter are instantiated in that <a href="#sec-environment-records">Environment Record</a>.
- Each declaration in the function body is also instantiated. If the function&rsquo;s formal parameters do not include any
- default value initializers then the body declarations are instantiated in the same <a
- href="#sec-environment-records">Environment Record</a> as the parameters. If default value parameter initializers exist, a
- second <a href="#sec-environment-records">Environment Record</a> is created for the body declarations. Formal parameters
- and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during
- evaluation of the function body.</p>
- </div>
-
- <p>FunctionDeclarationInstantiation is performed as follows using arguments <var>func</var> and <var>argumentsList</var>.
- <var>func</var> is the function object for which the <a href="#sec-execution-contexts">execution context</a> is being
- established.</p>
-
- <ol class="proc">
- <li>Let <i>calleeContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>env</i> be the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i>.</li>
- <li>Let <i>envRec</i> be <i>env</i>&rsquo;s <a href="#sec-environment-records">Environment Record</a>.</li>
- <li>Let <i>code</i> be the value of the [[ECMAScriptCode]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i>.</li>
- <li>Let <i>strict</i> be the value of the [[Strict]] <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a> of <i>func</i>.</li>
- <li>Let <i>formals</i> be the value of the [[FormalParameters]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i>.</li>
- <li>Let <i>parameterNames</i> be the BoundNames of <i>formals</i>.</li>
- <li>If <i>parameterNames</i> has any duplicate entries, let <i>hasDuplicates</i> be <b>true</b>. Otherwise, let
- <i>hasDuplicates</i> be <b>false</b>.</li>
- <li>Let <i>simpleParameterList</i> be IsSimpleParameterList of <i>formals</i>.</li>
- <li>Let <i>hasParameterExpressions</i> be ContainsExpression of <i>formals.</i></li>
- <li>Let <i>varNames</i> be the VarDeclaredNames of <i>code</i>.</li>
- <li>Let <i>varDeclarations</i> be the VarScopedDeclarations of <i>code</i>.</li>
- <li>Let <i>lexicalNames</i> be the LexicallyDeclaredNames of <i>code</i>.</li>
- <li>Let <i>functionNames</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Let <i>functionsToInitialize</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>For each <i>d</i> in <i>varDeclarations</i>, in reverse list order do
- <ol class="block">
- <li>If <i>d</i> is neither a <i>VariableDeclaration</i> or a <i>ForBinding</i>, then
- <ol class="block">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>d</i> is either a <i>FunctionDeclaration</i> or a
- <i>GeneratorDeclaration</i>.</li>
- <li>Let <i>fn</i> be the sole element of the BoundNames of <i>d.</i></li>
- <li>If <i>fn</i> is not an element of <i>functionNames</i>, then
- <ol class="block">
- <li>Insert <i>fn</i> as the first element of <i>functionNames</i>.</li>
- <li>NOTE If there are multiple <span style="font-family: Times New Roman"><i>FunctionDeclarations</i> or
- <i>GeneratorDeclarations</i></span> for the same name, the last declaration is used.</li>
- <li>Insert <i>d</i> as the first element of <i>functionsToInitialize</i>.</li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Let <i>argumentsObjectNeeded</i> be <b>true</b>.</li>
- <li>If the value of the [[ThisMode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of
- <i>func</i> is <span style="font-family: sans-serif">lexical</span>, then
- <ol class="block">
- <li>NOTE Arrow functions never have an arguments objects.</li>
- <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
- </ol>
- </li>
- <li>Else if <code>"arguments"</code> is an element of <i>parameterNames</i>, then
- <ol class="block">
- <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
- </ol>
- </li>
- <li>Else if <i>hasParameterExpressions</i> is <b>false</b>, then
- <ol class="block">
- <li>If <code>"arguments"</code> is an element of <i>functionNames</i> or if <code>"arguments"</code> is an element of
- <i>lexicalNames</i>, then
- <ol class="block">
- <li>Let <i>argumentsObjectNeeded</i> be <b>false</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>For each String <i>paramName</i> in <i>parameterNames</i>, do
- <ol class="block">
- <li>Let <i>alreadyDeclared</i> be <i>envRec</i>.HasBinding(<i>paramName</i>).</li>
- <li>NOTE Early errors ensure that duplicate parameter names can only occur in non-strict functions that do not have
- parameter default values or rest parameters.</li>
- <li>If <i>alreadyDeclared</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<i>paramName</i>).</li>
- <li>If <i>hasDuplicates</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>status</i> be <i>envRec</i>.InitializeBinding(<i>paramName</i>, <b>undefined</b>).</li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
- href="#sec-completion-record-specification-type">abrupt completion</a> for either of the above
- operations.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>If <i>argumentsObjectNeeded</i> is <b>true</b>, then
- <ol class="block">
- <li>If <i>strict</i> is <b>true</b> or if <i>simpleParameterList</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>ao</i> be <a
- href="#sec-createunmappedargumentsobject">CreateUnmappedArgumentsObject</a>(<i>argumentsList</i>)<i>.</i></li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>NOTE mapped argument object is only provided for non-strict functions that don&rsquo;t have a rest parameter,
- any parameter default value initializers, or any destructured parameters .</li>
- <li>Let <i>ao</i> be <a href="#sec-createmappedargumentsobject">CreateMappedArgumentsObject</a>(<i>func</i>,
- <i>formals</i>, <i>argumentsList</i>, <i>env</i>).</li>
- </ol>
- </li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ao</i>).</li>
- <li>If <i>strict</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>status</i> be <i>envRec</i>.CreateImmutableBinding(<code>"arguments"</code>).</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<code>"arguments"</code>).</li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li><a href="#sec-call">Call</a> <i>envRec</i>.InitializeBinding(<code>"arguments"</code>, <i>ao</i>).</li>
- <li>Append <code>"arguments"</code> to <i>parameterNames</i>.</li>
- </ol>
- </li>
- <li>Let <i>iteratorRecord</i> be Record {[[iterator]]: <a
- href="#sec-createlistiterator">CreateListIterator</a>(<i>argumentsList</i>), [[done]]: <b>false</b>}.</li>
- <li>If <i>hasDuplicates</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>formalStatus</i> be IteratorBindingInitialization for <i>formals</i> with <i>iteratorRecord</i> and
- <b>undefined</b> as arguments.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>formalStatus</i> be IteratorBindingInitialization for <i>formals</i> with <i>iteratorRecord</i> and
- <i>envRec</i> as arguments.</li>
- </ol>
- </li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>formalStatus</i>).</li>
- <li>If <i>hasParameterExpressions</i> is <b>false</b>, then
- <ol class="block">
- <li>NOTE Only a single <a href="#sec-lexical-environments">lexical environment</a> is needed for the parameters and
- top-level vars.</li>
- <li>Let <i>instantiatedVarNames</i> be a copy of the <a href="#sec-list-and-record-specification-type">List</a>
- <i>parameterNames</i>.</li>
- <li>For each <i>n</i> in <i>varNames</i>, do
- <ol class="block">
- <li>If <i>n</i> is not an element of <i>instantiatedVarNames</i>, then
- <ol class="block">
- <li>Append <i>n</i> to <i>instantiatedVarNames</i>.</li>
- <li>Let <i>status</i> be <i>envRec</i>.CreateMutableBinding(<i>n</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li><a href="#sec-call">Call</a> <i>envRec</i>.InitializeBinding(<i>n</i>, <b>undefined</b>).</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Let <i>varEnv</i> be <i>env</i>.</li>
- <li>Let <i>varEnvRec</i> be <i>envRec</i>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>NOTE A separate <a href="#sec-environment-records">Environment Record</a> is needed to ensure that closures
- created by expressions in the formal parameter list do not have visibility of declarations in the function
- body.</li>
- <li>Let <i>varEnv</i> be <a href="#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a>(<i>env</i>).</li>
- <li>Let <i>varEnvRec</i> be <i>varEnv</i>&rsquo;s EnvironmentRecord.</li>
- <li>Set the <a href="#sec-execution-contexts">VariableEnvironment</a> of <i>calleeContext</i> to <i>varEnv</i>.</li>
- <li>Let <i>instantiatedVarNames</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>For each <i>n</i> in <i>varNames</i>, do
- <ol class="block">
- <li>If <i>n</i> is not an element of <i>instantiatedVarNames</i>, then
- <ol class="block">
- <li>Append <i>n</i> to <i>instantiatedVarNames</i>.</li>
- <li>Let <i>status</i> be <i>varEnvRec</i>.CreateMutableBinding(<i>n</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>n</i> is not an element of <i>parameterNames</i> or if <i>n</i> is an element of
- <i>functionNames</i>, let <i>initialValue</i> be <b>undefined</b>.</li>
- <li>else,
- <ol class="block">
- <li>Let <i>initialValue</i> be <i>envRec.</i>GetBindingValue(<i>n</i>, <b>false</b>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initialValue</i>).</li>
- </ol>
- </li>
- <li><a href="#sec-call">Call</a> <i>varEnvRec</i>.InitializeBinding(<i>n</i>, <i>initialValue</i>).</li>
- <li>NOTE vars whose names are the same as a formal parameter, initially have the same value as the
- corresponding initialized parameter.</li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- <li>NOTE: Annex <a href="#sec-block-level-function-declarations-web-legacy-compatibility-semantics">B.3.3</a> adds
- additional steps at this point.</li>
- <li>If <i>strict</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>lexEnv</i> be <a href="#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a>(<i>varEnv</i>).</li>
- <li>NOTE: Non-strict functions use a separate lexical <a href="#sec-environment-records">Environment Record</a> for
- top-level lexical declarations so that a direct <code>eval</code> (<a
- href="#sec-function-calls-runtime-semantics-evaluation">see 12.3.4.1</a>) can determine whether any var scoped
- declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This
- is not needed for strict functions because a strict direct <code>eval</code> always places all declarations into a
- new <a href="#sec-environment-records">Environment Record</a>.</li>
- </ol>
- </li>
- <li>Else, let <i>lexEnv</i> be <i>varEnv</i>.</li>
- <li>Let <i>lexEnvRec</i> be <i>lexEnv</i>&rsquo;s EnvironmentRecord.</li>
- <li>Set the <a href="#sec-execution-contexts">LexicalEnvironment</a> of <i>calleeContext</i> to <i>lexEnv</i>.</li>
- <li>Let <i>lexDeclarations</i> be the LexicallyScopedDeclarations of <i>code</i>.</li>
- <li>For each element <i>d</i> in <i>lexDeclarations</i> do
- <ol class="block">
- <li>NOTE A lexically declared name cannot be the same as a function/generator declaration, formal parameter, or a var
- name. Lexically declared names are only instantiated here but not initialized.</li>
- <li>For each element <i>dn</i> of the BoundNames of <i>d</i> do
- <ol class="block">
- <li>If IsConstantDeclaration of <i>d</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>status</i> be <i>lexEnvRec</i>.CreateImmutableBinding(<i>dn</i>, <b>true</b>).</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>status</i> be <i>lexEnvRec</i>.CreateMutableBinding(<i>dn</i>, <b>false</b>).</li>
- </ol>
- </li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- </ol>
- </li>
- <li>For each parsed grammar phrase <i>f</i> in <i>functionsToInitialize</i>, do
- <ol class="block">
- <li>Let <i>fn</i> be the sole element of the BoundNames of <i>f.</i></li>
- <li>Let <i>fo</i> be the result of performing InstantiateFunctionObject for <i>f</i> with argument <i>lexEnv</i>.</li>
- <li>Let <i>status</i> be <i>varEnvRec</i>.SetMutableBinding(<i>fn</i>, <i>fo</i>, <b>false</b>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is never an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<span style="font-family: sans-serif">empty</span>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE 1</span> <a
- href="#sec-block-level-function-declarations-web-legacy-compatibility-semantics">B.3.3</a> provides an extension to the
- above algorithm that is necessary for backwards compatibility with web browser implementations of ECMAScript that predate
- the sixth edition of ECMA-262.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 2</span> Parameter <i>Initializers</i> may contain direct eval expressions (<a
- href="#sec-function-calls-runtime-semantics-evaluation">12.3.4.1</a>). Any top level declarations of such evals are only
- visible to the eval code (<a href="#sec-types-of-source-code">10.2</a>). The creation of the environment for such
- declarations is described in <a
- href="#sec-function-definitions-runtime-semantics-iteratorbindinginitialization">14.1.18</a>.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-built-in-function-objects">
- <div class="front">
- <h1><span class="secnum" id="sec-9.3"><a href="#sec-built-in-function-objects" title="link to this section">9.3</a></span>
- Built-in Function Objects</h1>
-
- <p>The built-in function objects defined in this specification may be implemented as either ECMAScript function objects (<a
- href="#sec-ecmascript-function-objects">9.2</a>) whose behaviour is provided using ECMAScript code or as implementation
- provided exotic function objects whose behaviour is provided in some other manner. In either case, the effect of calling
- such functions must conform to their specifications. An implementation may also provide additional built-in function objects
- that are not defined in this specification.</p>
-
- <p>If a built-in function object is implemented as an exotic object it must have the ordinary object behaviour specified in
- <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>. All such exotic function objects also have
- [[Prototype]], [[Extensible]], and [[Realm]] internal slots.</p>
-
- <p>Unless otherwise specified every built-in function object has the %FunctionPrototype% object (<a
- href="#sec-properties-of-the-function-prototype-object">19.2.3</a>) as the initial value of its [[Prototype]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</p>
-
- <p>The behaviour specified for each built-in function via algorithm steps or other means is the specification of the
- function body behaviour for both [[Call]] and [[Construct]] invocations of the function. However, [[Construct]] invocation
- is not supported by all built-in functions. For each built-in function, when invoked with [[Call]], the [[Call]]
- <var>thisArgument</var> provides the <span class="value">this</span> value, the [[Call]] <var>argumentsList</var> provides
- the named parameters, and the NewTarget value is <span class="value">undefined</span>. When invoked with [[Construct]], the
- <span class="value">this</span> value is uninitialized, the [[Construct]] <var>argumentsList</var> provides the named
- parameters, and the [[Construct]] <var>newTarget</var> parameter provides the NewTarget value. If the built-in function is
- implemented as an <a href="#sec-ecmascript-function-objects">ECMAScript function object</a> then this specified behaviour
- must be implemented by the ECMAScript code that is the body of the function. Built-in functions that are ECMAScript function
- objects must be strict mode functions. If a built-in constructor has any [[Call]] behaviour other than throwing a <span
- class="value">TypeError</span> exception, an ECMAScript implementation of the function must be done in a manner that does
- not cause the function&rsquo;s [[FunctionKind]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
- to have the value <code>"classConstructor"</code>.</p>
-
- <p>Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method
- unless otherwise specified in the description of a particular function. When a built-in constructor is called as part of a
- <code>new</code> expression the <var>argumentsList</var> parameter of the invoked [[Construct]] internal method provides the
- values for the built-in constructor&rsquo;s named parameters.</p>
-
- <p>Built-in functions that are not constructors do not have a <code>prototype</code> property unless otherwise specified in
- the description of a particular function.</p>
-
- <p>If a built-in function object is not implemented as an ECMAScript function it must provide [[Call]] and [[Construct]]
- internal methods that conform to the following definitions:</p>
- </div>
-
- <section id="sec-built-in-function-objects-call-thisargument-argumentslist">
- <h1><span class="secnum" id="sec-9.3.1"><a href="#sec-built-in-function-objects-call-thisargument-argumentslist"
- title="link to this section">9.3.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
-
- <p>The [[Call]] internal method for a built-in function object <var>F</var> is called with parameters
- <var>thisArgument</var> and <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
- href="#sec-ecmascript-language-types">ECMAScript language values</a>. The following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>callerContext</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>If <i>callerContext</i> is not already <a href="#sec-execution-contexts">suspended</a>, <a
- href="#sec-execution-contexts">Suspend</a> <i>callerContext</i>.</li>
- <li>Let <i>calleeContext</i> be a new <a href="#sec-execution-contexts">ECMAScript code execution context</a>.</li>
- <li>Set the Function of <i>calleeContext</i> to <i>F</i>.</li>
- <li>Let <i>calleeRealm</i> be the value of <i>F&rsquo;s</i> [[Realm]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Set the <a href="#sec-code-realms">Realm</a> of <i>calleeContext</i> to <i>calleeRealm</i>.</li>
- <li>Perform any necessary implementation defined initialization of <i>calleeContext</i>.</li>
- <li>Push <i>calleeContext</i> onto <a href="#sec-execution-contexts">the execution context stack</a>; <i>calleeContext</i>
- is now <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>result</i> be the <a href="#sec-completion-record-specification-type">Completion Record</a> that is the result
- of evaluating <i>F</i> in an implementation defined manner that conforms to the specification of <i>F</i>.
- <i>thisArgument</i> is the <b>this</b> value, <i>argumentsList</i> provides the named parameters, and the NewTarget
- value is <b>undefined</b>.</li>
- <li>Remove <i>calleeContext</i> from <a href="#sec-execution-contexts">the execution context stack</a> and restore
- <i>callerContext</i> as <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Return <i>result</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE 1</span> When <i>calleeContext</i> is removed from <a href="#sec-execution-contexts">the
- execution context stack</a> it must not be destroyed if it has been <a href="#sec-execution-contexts">suspended</a> and
- retained by an accessible generator object for later resumption<i>.</i></p>
- </div>
- </section>
-
- <section id="sec-built-in-function-objects-construct-argumentslist-newtarget">
- <h1><span class="secnum" id="sec-9.3.2"><a href="#sec-built-in-function-objects-construct-argumentslist-newtarget"
- title="link to this section">9.3.2</a></span> [[Construct]] (argumentsList, newTarget)</h1>
-
- <p>The [[Construct]] internal method for built-in function object <var>F</var> is called with parameters
- <var>argumentsList</var> and <var>newTarget</var>. The steps performed are the same as [[Call]] (<a
- href="#sec-built-in-function-objects-call-thisargument-argumentslist">see 9.3.1</a>) except that step 9 is replaced by:</p>
-
- <ol class="proc">
- <li>Let <i>result</i> be the <a href="#sec-completion-record-specification-type">Completion Record</a> that is the result
- of evaluating <i>F</i> in an implementation defined manner that conforms to the specification of <i>F</i>. The
- <b>this</b> value is uninitialized, <i>argumentsList</i> provides the named parameters, and <i>newTarget</i> provides
- the NewTarget value.</li>
- </ol>
- </section>
-
- <section id="sec-createbuiltinfunction">
- <h1><span class="secnum" id="sec-9.3.3"><a href="#sec-createbuiltinfunction" title="link to this section">9.3.3</a></span>
- CreateBuiltinFunction(realm, steps, prototype, internalSlotsList)</h1>
-
- <p>The abstract operation CreateBuiltinFunction takes arguments <span style="font-family: Times New Roman"><i>realm</i>,
- <i>prototype</i>,</span> and <var>steps</var>. The optional argument <var>internalSlotsList</var> is a <a
- href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
- part of the object. If the list is not provided, an empty <a href="#sec-list-and-record-specification-type">List</a> is
- used. CreateBuiltinFunction returns a built-in function object created by the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>realm</i> is a <a href="#sec-code-realms">Realm</a> Record.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>steps</i> is either a set of algorithm steps or other definition
- of a functions behaviour provided in this specification.</li>
- <li>Let <i>func</i> be a new built-in function object that when called performs the action described by <i>steps</i>. The
- new function object has internal slots whose names are the elements of <i>internalSlotsList</i>. The initial value of
- each of those internal slots is <b>undefined<i>.</i></b></li>
- <li>Set the [[Realm]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i> to
- <i>realm</i>.</li>
- <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>func</i> to
- <i>prototype</i>.</li>
- <li>Return <i>func</i>.</li>
- </ol>
-
- <p>Each built-in function defined in this specification is created as if by calling the CreateBuiltinFunction abstract
- operation, unless otherwise specified.</p>
- </section>
- </section>
-
- <section id="sec-built-in-exotic-object-internal-methods-and-slots">
- <div class="front">
- <h1><span class="secnum" id="sec-9.4"><a href="#sec-built-in-exotic-object-internal-methods-and-slots"
- title="link to this section">9.4</a></span> Built-in Exotic Object Internal Methods and Slots</h1>
-
- <p>This specification defines several kinds of built-in exotic objects. These objects generally behave similar to ordinary
- objects except for a few specific situations. The following exotic objects use the ordinary object internal methods except
- where it is explicitly specified otherwise below:</p>
- </div>
-
- <section id="sec-bound-function-exotic-objects">
- <div class="front">
- <h1><span class="secnum" id="sec-9.4.1"><a href="#sec-bound-function-exotic-objects"
- title="link to this section">9.4.1</a></span> Bound Function Exotic Objects</h1>
-
- <p>A <i>bound function</i> is an exotic object that wraps another function object. A bound function is callable (it has a
- [[Call]] internal method and may have a [[Construct]] internal method). Calling a bound function generally results in a
- call of its wrapped function.</p>
-
- <p>Bound function objects do not have the internal slots of ECMAScript function objects defined in <a
- href="#table-27">Table 27</a>. Instead they have the internal slots defined in <a href="#table-28">Table 28</a>.</p>
-
- <figure>
- <figcaption><span id="table-28">Table 28</span> &mdash; Internal Slots of Exotic Bound Function Objects</figcaption>
- <table class="real-table">
- <tr>
- <th>Internal Slot</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>[[BoundTargetFunction]]</td>
- <td>Callable Object</td>
- <td>The wrapped function object.</td>
- </tr>
- <tr>
- <td>[[BoundThis]]</td>
- <td>Any</td>
- <td>The value that is always passed as the <b>this</b> value when calling the wrapped function.</td>
- </tr>
- <tr>
- <td>[[BoundArguments]]</td>
- <td><a href="#sec-list-and-record-specification-type">List</a> of Any</td>
- <td>A list of values whose elements are used as the first arguments to any call to the wrapped function.</td>
- </tr>
- </table>
- </figure>
-
- <p>Unlike ECMAScript function objects, bound function objects do not use an alternative definition of the
- [[GetOwnProperty]] internal methods. Bound function objects provide all of the essential internal methods as specified in
- <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>. However, they use the following definitions
- for the essential internal methods of function objects.</p>
- </div>
-
- <section id="sec-bound-function-exotic-objects-call-thisargument-argumentslist">
- <h1><span class="secnum" id="sec-9.4.1.1"><a href="#sec-bound-function-exotic-objects-call-thisargument-argumentslist"
- title="link to this section">9.4.1.1</a></span> [[Call]] ( thisArgument, argumentsList)</h1>
-
- <p>When the [[Call]] internal method of an exotic <a href="#sec-bound-function-exotic-objects">bound function</a> object,
- <var>F</var>, which was created using the bind function is called with parameters <var>thisArgument</var> and
- <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
- href="#sec-ecmascript-language-types">ECMAScript language values</a>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>target</i> be the value of <i>F&rsquo;s</i> <a
- href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>boundThis</i> be the value of <i>F&rsquo;s</i> <a href="#sec-bound-function-exotic-objects">[[BoundThis]]</a>
- <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>boundArgs</i> be the value of <i>F&rsquo;s</i> <a
- href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <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
- the same values as the list <i>argumentsList</i> in the same order.</li>
- <li>Return <a href="#sec-call">Call</a>(<i>target</i>, <i>boundThis</i>, <i>args</i>).</li>
- </ol>
- </section>
-
- <section id="sec-bound-function-exotic-objects-construct-argumentslist-newtarget">
- <h1><span class="secnum" id="sec-9.4.1.2"><a href="#sec-bound-function-exotic-objects-construct-argumentslist-newtarget"
- title="link to this section">9.4.1.2</a></span> [[Construct]] (argumentsList, newTarget)</h1>
-
- <p>When the [[Construct]] internal method of an exotic <a href="#sec-bound-function-exotic-objects">bound function</a>
- object, <var>F</var> that was created using the bind function is called with a list of arguments <span style="font-family:
- Times New Roman"><i>argumentsList</i> and <i>newTarget</i></span>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>target</i> be the value of <i>F&rsquo;s</i> <a
- href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>target</i> has a [[Construct]] internal method.</li>
- <li>Let <i>boundArgs</i> be the value of <i>F&rsquo;s</i> <a
- href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <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
- the same values as the list <i>argumentsList</i> in the same order.</li>
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>F</i>, <i>newTarget</i>) is <b>true</b>, let <i>newTarget</i> be
- <i>target</i>.</li>
- <li>Return <a href="#sec-construct">Construct</a>(<i>target</i>, <i>args</i>, <i>newTarget</i>).</li>
- </ol>
- </section>
-
- <section id="sec-boundfunctioncreate">
- <h1><span class="secnum" id="sec-9.4.1.3"><a href="#sec-boundfunctioncreate"
- title="link to this section">9.4.1.3</a></span> BoundFunctionCreate (targetFunction, boundThis, boundArgs)</h1>
-
- <p>The abstract operation BoundFunctionCreate with arguments <var>targetFunction</var>, <var>boundThis</var> and
- <var>boundArgs</var> is used to specify the creation of new <a href="#sec-bound-function-exotic-objects">Bound
- Function</a> exotic objects. It performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>targetFunction</i>) is Object.</li>
- <li>Let <i>proto</i> be <i>targetFunction</i>.[[GetPrototypeOf]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>proto</i>).</li>
- <li>Let <i>obj</i> be a newly created object.</li>
- <li>Set <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
- <li>Set the [[Call]] internal method of <i>obj</i> as described in <a
- href="#sec-bound-function-exotic-objects-call-thisargument-argumentslist">9.4.1.1</a>.</li>
- <li>If <i>targetFunction</i> has a [[Construct]] internal method, then
- <ol class="block">
- <li>Set the [[Construct]] internal method of <i>obj</i> as described in <a
- href="#sec-bound-function-exotic-objects-construct-argumentslist-newtarget">9.4.1.2</a>.</li>
- </ol>
- </li>
- <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
- <i>proto</i>.</li>
- <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
- <b>true</b>.</li>
- <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundTargetFunction]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
- <i>targetFunction</i>.</li>
- <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundThis]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to the value of
- <i>boundThis</i>.</li>
- <li>Set the <a href="#sec-bound-function-exotic-objects">[[BoundArguments]]</a> <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to <i>boundArgs</i>.</li>
- <li>Return <i>obj</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-array-exotic-objects">
- <div class="front">
- <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>
- Array Exotic Objects</h1>
-
- <p>An <i>Array object</i> is an exotic object that gives special treatment to array index property keys (<a
- 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>.
- Every Array object has a <code>length</code> property whose value is always a nonnegative integer less than <span
- style="font-family: Times New Roman">2<sup>32</sup></span>. The value of the <code>length</code> property is numerically
- greater than the name of every own property whose name is an array index; whenever an own property of an Array object is
- created or changed, other properties are adjusted as necessary to maintain this invariant. Specifically, whenever an own
- property is added whose name is an array index, the value of the <code>length</code> property is changed, if necessary, to
- be one more than the numeric value of that array index; and whenever the value of the <code>length</code> property is
- changed, every own property whose name is an array index whose value is not smaller than the new length is deleted. This
- constraint applies only to own properties of an Array object and is unaffected by <code>length</code> or array index
- properties that may be inherited from its prototypes.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A String property name <i>P</i> is an <i>array index</i> if and only if <a
- href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>P</i>)) is equal to <i>P</i> and <a
- href="#sec-touint32">ToUint32</a>(<i>P</i>) is not equal to 2<sup>32</sup>&minus;1.</p>
- </div>
-
- <p>Array exotic objects always have a non-configurable property named <code>"length"</code>.</p>
-
- <p>Array exotic objects provide an alternative definition for the [[DefineOwnProperty]] internal method. Except for that
- internal method, Array exotic objects provide all of the other essential internal methods as specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
- </div>
-
- <section id="sec-array-exotic-objects-defineownproperty-p-desc">
- <h1><span class="secnum" id="sec-9.4.2.1"><a href="#sec-array-exotic-objects-defineownproperty-p-desc"
- title="link to this section">9.4.2.1</a></span> [[DefineOwnProperty]] ( P, Desc)</h1>
-
- <p>When the [[DefineOwnProperty]] internal method of an <a href="#sec-array-exotic-objects">Array exotic object</a>
- <var>A</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>, and <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
- steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>If <i>P</i> is <code>"length"</code>, then
- <ol class="block">
- <li>Return <a href="#sec-arraysetlength">ArraySetLength</a>(<i>A</i>, <i>Desc</i>).</li>
- </ol>
- </li>
- <li>Else if <i>P</i> is an array index, then
- <ol class="block">
- <li>Let <i>oldLenDesc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>A</i>,
- <code>"length"</code>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>oldLenDesc</i> will never be <b>undefined</b> or an accessor
- descriptor because Array objects are created with a length data property that cannot be deleted or
- reconfigured.</li>
- <li>Let <i>oldLen</i> be <i>oldLenDesc</i>.[[Value]].</li>
- <li>Let <i>index</i> be <a href="#sec-touint32">ToUint32</a>(<i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>index</i> will never be an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>index</i> &ge; <i>oldLen</i> and <i>oldLenDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
- <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
- <i>P</i>, <i>Desc</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>succeeded</i> is <b>false</b>, return <b>false</b>.</li>
- <li>If <i>index</i> &ge; <i>oldLen</i>
- <ol class="block">
- <li>Set <i>oldLenDesc</i>.[[Value]] to <i>index</i> + 1.</li>
- <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
- <code>"length"</code>, <i>oldLenDesc</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is <b>true</b>.</li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <i>P</i>, <i>Desc</i>).</li>
- </ol>
- </section>
-
- <section id="sec-arraycreate">
- <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>
- ArrayCreate(length, proto)</h1>
-
- <p>The abstract operation ArrayCreate with argument <var>length</var> (a positive integer) and optional argument
- <var>proto</var> is used to specify the creation of new Array exotic objects. It performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>length</i> is an integer Number &ge; 0.</li>
- <li>If <i>length</i> is &minus;0, let <i>length</i> be +0.</li>
- <li>If <i>length</i>&gt;2<sup>32</sup>-1, throw a <b>RangeError</b> exception.</li>
- <li>If the <i>proto</i> argument was not passed, let <i>proto</i> be the intrinsic object <span style="font-family:
- sans-serif">%ArrayPrototype%</span>.</li>
- <li>Let <i>A</i> be a newly created <a href="#sec-array-exotic-objects">Array exotic object</a>.</li>
- <li>Set <i>A</i>&rsquo;s essential internal methods except for [[DefineOwnProperty]] to the default ordinary object
- definitions specified in <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
- <li>Set the [[DefineOwnProperty]] internal method of <i>A</i> as specified in <a
- href="#sec-array-exotic-objects-defineownproperty-p-desc">9.4.2.1</a>.</li>
- <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
- <i>proto</i>.</li>
- <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
- <b>true</b>.</li>
- <li>Perform <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
- PropertyDescriptor{[[Value]]: <i>length</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
- [[Configurable]]: <b>false</b>}).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: the preceding step never produces an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Return <i>A</i>.</li>
- </ol>
- </section>
-
- <section id="sec-arrayspeciescreate">
- <h1><span class="secnum" id="sec-9.4.2.3"><a href="#sec-arrayspeciescreate"
- title="link to this section">9.4.2.3</a></span> ArraySpeciesCreate(originalArray, length)</h1>
-
- <p>The abstract operation ArraySpeciesCreate with arguments <var>originalArray</var> and <var>length</var> is used to
- specify the creation of a new Array object using a constructor function that is derived from <var>originalArray</var>. It
- performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>length</i> is an integer Number &ge; 0.</li>
- <li>If <i>length</i> is &minus;0, let <i>length</i> be +0.</li>
- <li>Let <i>C</i> be <b>undefined</b>.</li>
- <li>Let <i>isArray</i> be <a href="#sec-isarray">IsArray</a>(<i>originalArray</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>isArray</i>).</li>
- <li>If <i>isArray</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>originalArray</i>, <code>"constructor"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
- <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>C</i>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>thisRealm</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
- href="#sec-code-realms">Realm</a>.</li>
- <li>Let <i>realmC</i> be <a href="#sec-getfunctionrealm">GetFunctionRealm</a>(<i>C</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>realmC</i>).</li>
- <li>If <i>thisRealm</i> and <i>realmC</i> are not the same <a href="#sec-code-realms">Realm</a> Record, then
- <ol class="block">
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>C</i>, <i>realmC</i>.[[intrinsics]].[[%Array%]]) is
- <b>true</b>, let <i>C</i> be <b>undefined</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>C</i>) is Object, then
- <ol class="block">
- <li>Let <i>C</i> be <a href="#sec-get-o-p">Get</a>(<i>C</i>, @@species).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>C</i>).</li>
- <li>If <i>C</i> is <b>null</b>, let <i>C</i> be <b>undefined</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>If <i>C</i> is <b>undefined</b>, return <a href="#sec-arraycreate">ArrayCreate</a>(<i>length</i>).</li>
- <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>C</i>) is <b>false</b>, throw a <b>TypeError</b>
- exception<i>.</i></li>
- <li>Return <a href="#sec-construct">Construct</a>(<i>C</i>, &laquo;<i>length</i>&raquo;).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> If <i>originalArray</i> was created using the standard built-in Array constructor for a
- <a href="#sec-code-realms">Realm</a> that is not the <a href="#sec-code-realms">Realm</a> of <a
- href="#sec-execution-contexts">the running execution context</a>, then a new Array is created using the <a
- href="#sec-code-realms">Realm</a> of <a href="#sec-execution-contexts">the running execution context</a>. This maintains
- compatibility with Web browsers that have historically had that behaviour for the Array.prototype methods that now are
- defined using ArraySpeciesCreate.</p>
- </div>
- </section>
-
- <section id="sec-arraysetlength">
- <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>
- ArraySetLength(A, Desc)</h1>
-
- <p>When the abstract operation ArraySetLength is called with an <a href="#sec-array-exotic-objects">Array exotic
- object</a> <span style="font-family: Times New Roman"><i>A</i>,</span> and <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> <span class="nt">Desc</span> the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>If the [[Value]] field of <i>Desc</i> is absent, then
- <ol class="block">
- <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
- <i>Desc</i>).</li>
- </ol>
- </li>
- <li>Let <i>newLenDesc</i> be a copy of <i>Desc</i>.</li>
- <li>Let <i>newLen</i> be <a href="#sec-touint32">ToUint32</a>(<i>Desc</i>.[[Value]]).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newLen</i>).</li>
- <li>Let <i>numberLen</i> be <a href="#sec-tonumber">ToNumber</a>(<i>Desc</i>.[[Value]]).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newLen</i>).</li>
- <li>If <i>newLen</i> &ne; <i>numberLen</i>, throw a <b>RangeError</b> exception.</li>
- <li>Set <i>newLenDesc</i>.[[Value]] to <i>newLen</i>.</li>
- <li>Let <i>oldLenDesc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>A</i>,
- <code>"length"</code>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>oldLenDesc</i> will never be <b>undefined</b> or an accessor
- descriptor because Array objects are created with a length data property that cannot be deleted or
- reconfigured.</li>
- <li>Let <i>oldLen</i> be <i>oldLenDesc</i>.[[Value]].</li>
- <li>If <i>newLen</i> &ge;<i>oldLen</i>, then
- <ol class="block">
- <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
- <i>newLenDesc</i>).</li>
- </ol>
- </li>
- <li>If <i>oldLenDesc</i>.[[Writable]] is <b>false</b>, return <b>false</b>.</li>
- <li>If <i>newLenDesc</i>.[[Writable]] is absent or has the value <b>true</b>, let <i>newWritable</i> be
- <b>true</b>.</li>
- <li>Else,
- <ol class="block">
- <li>Need to defer setting the [[Writable]] attribute to <b>false</b> in case any elements cannot be deleted.</li>
- <li>Let <i>newWritable</i> be <b>false</b>.</li>
- <li>Set <i>newLenDesc</i>.[[Writable]] to <b>true</b>.</li>
- </ol>
- </li>
- <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
- <code>"length"</code>, <i>newLenDesc</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>succeeded</i> is <b>false</b>, return <b>false</b>.</li>
- <li>While <i>newLen</i> &lt; <i>oldLen</i> repeat,
- <ol class="block">
- <li>Set <i>oldLen</i> to <i>oldLen</i> &ndash; 1.</li>
- <li>Let <i>deleteSucceeded</i> be <i>A</i>.[[Delete]](<a href="#sec-tostring">ToString</a>(<i>oldLen</i>)).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>deleteSucceeded</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>deleteSucceeded</i> is <b>false</b>, then
- <ol class="block">
- <li>Set <i>newLenDesc</i>.[[Value]] to <i>oldLen</i> <i>+</i> 1.</li>
- <li>If <i>newWritable</i> is <b>false</b>, set <i>newLenDesc</i>.[[Writable]] to <b>false</b>.</li>
- <li>Let <i>succeeded</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>,
- <code>"length"</code>, <i>newLenDesc</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>succeeded</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>If <i>newWritable</i> is <b>false</b>, then
- <ol class="block">
- <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>A</i>, <code>"length"</code>,
- PropertyDescriptor{[[Writable]]: <b>false</b>}). This call will always return <b>true</b>.</li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> In steps 3 and 4, if <i>Desc</i>.[[Value]] is an object then its <code>valueOf</code>
- method is called twice. This is legacy behaviour that was specified with this effect starting with the 2<sup>nd</sup>
- Edition of this specification.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-string-exotic-objects">
- <div class="front">
- <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>
- String Exotic Objects</h1>
-
- <p>A <i>String object</i> is an exotic object that encapsulates a String value and exposes virtual integer indexed data
- properties corresponding to the individual code unit elements of the string value. Exotic String objects always have a
- data property named <code>"length"</code> whose value is the number of code unit elements in the encapsulated String
- value. Both the code unit data properties and the <code>"length"</code> property are non-writable and
- non-configurable.</p>
-
- <p>Exotic String objects have the same internal slots as ordinary objects. They also have a [[StringData]] internal
- slot.</p>
-
- <p>Exotic String objects provide alternative definitions for the following internal methods. All of the other exotic
- String object essential internal methods that are not defined below are as specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
- </div>
-
- <section id="sec-string-exotic-objects-getownproperty-p">
- <div class="front">
- <h1><span class="secnum" id="sec-9.4.3.1"><a href="#sec-string-exotic-objects-getownproperty-p"
- title="link to this section">9.4.3.1</a></span> [[GetOwnProperty]] ( P )</h1>
-
- <p>When the [[GetOwnProperty]] internal method of an exotic String object <var>S</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>desc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>S</i>, <i>P</i>).</li>
- <li>If <i>desc</i> is not <b>undefined</b> return <i>desc</i>.</li>
- <li>Return <a href="#sec-stringgetindexproperty">StringGetIndexProperty</a>(<i>S</i>, <i>P</i>).</li>
- </ol>
- </div>
-
- <section id="sec-stringgetindexproperty">
- <h1><span class="secnum" id="sec-9.4.3.1.1"><a href="#sec-stringgetindexproperty"
- title="link to this section">9.4.3.1.1</a></span> StringGetIndexProperty (S, P)</h1>
-
- <p>When the abstract operation StringGetIndexProperty is called with an exotic String object <var>S</var> and with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is not String, return <b>undefined</b>.</li>
- <li>Let <i>index</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a> (<i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>index</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>index</i> is <b>undefined</b>, return <b>undefined</b>.</li>
- <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>undefined</b>.</li>
- <li>If <i>index</i> = &minus;0, return <b>undefined</b>.</li>
- <li>Let <i>str</i> be the String value of the [[StringData]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i>.</li>
- <li>Let <i>len</i> be the number of elements in <i>str</i>.</li>
- <li>If <i>index</i> &lt; 0 or <i>len</i> &le; <i>index</i>, return <b>undefined</b>.</li>
- <li>Let <i>resultStr</i> be a String value of length 1, containing one code unit from <i>str</i>, specifically the
- code unit at index <i>index</i>.</li>
- <li>Return a PropertyDescriptor{ [[Value]]: <i>resultStr</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>,
- [[Configurable]]: <b>false</b> }.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-string-exotic-objects-hasproperty-p">
- <h1><span class="secnum" id="sec-9.4.3.2"><a href="#sec-string-exotic-objects-hasproperty-p"
- title="link to this section">9.4.3.2</a></span> [[HasProperty]](P)</h1>
-
- <p>When the [[HasProperty]] internal method of an exotic String object <var>S</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>elementDesc</i> be <a href="#sec-stringgetindexproperty">StringGetIndexProperty</a>(<i>S</i>, <i>P</i>).</li>
- <li>If <i>elementDesc</i> is not <b>undefined</b>, return <b>true</b>.</li>
- <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>S</i>, <i>P</i>)..</li>
- </ol>
- </section>
-
- <section id="sec-string-exotic-objects-ownpropertykeys">
- <h1><span class="secnum" id="sec-9.4.3.3"><a href="#sec-string-exotic-objects-ownpropertykeys"
- title="link to this section">9.4.3.3</a></span> [[OwnPropertyKeys]] ( )</h1>
-
- <p>When the [[OwnPropertyKeys]] internal method of a <a href="#sec-string-exotic-objects">String exotic object</a>
- <var>O</var> is called the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Let <i>str</i> be the String value of the [[StringData]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>len</i> be the number of elements in <i>str</i>.</li>
- <li>For each integer <i>i</i> starting with 0 such that <i>i</i> &lt; <i>len</i>, in ascending order,
- <ol class="block">
- <li>Add <a href="#sec-tostring">ToString</a>(<i>i</i>) as the last element of <i>keys</i></li>
- </ol>
- </li>
- <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
- and <a href="#sec-tointeger">ToInteger</a>(<i>P</i>) &ge; <i>len</i>, in ascending numeric index order,
- <ol class="block">
- <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and <i>P</i> is not an integer index, in
- property creation order,
- <ol class="block">
- <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, in property creation order,
- <ol class="block">
- <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <li>Return <i>keys</i>.</li>
- </ol>
- </section>
-
- <section id="sec-stringcreate">
- <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>
- StringCreate( value, prototype)</h1>
-
- <p>The abstract operation StringCreate with arguments <var>value</var> and <var>prototype</var> is used to specify the
- creation of new exotic String objects. It performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>prototype</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>value</i>) is String.</li>
- <li>Let <i>S</i> be a newly created <a href="#sec-string-exotic-objects">String exotic object</a>.</li>
- <li>Set the [[StringData]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
- <i>value</i>.</li>
- <li>Set <i>S</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
- <li>Set the [[GetOwnProperty]] internal method of <i>S</i> as specified in <a
- href="#sec-string-exotic-objects-getownproperty-p">9.4.3.1</a>.</li>
- <li>Set the [[HasProperty]] internal method of <i>S</i> as specified in <a
- href="#sec-string-exotic-objects-hasproperty-p">9.4.3.2</a>.</li>
- <li>Set the [[OwnPropertyKeys]] internal method of <i>S</i> as specified in <a
- href="#sec-string-exotic-objects-ownpropertykeys">9.4.3.3</a>.</li>
- <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
- <i>prototype</i>.</li>
- <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>S</i> to
- <b>true</b>.</li>
- <li>Let <i>length</i> be the number of code unit elements in <i>value.</i></li>
- <li>Let <i>status</i> be <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>S</i>, <code>"length"</code>,
- PropertyDescriptor{[[Value]]: <i>length</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>,
- [[Configurable]]: <b>false</b> }).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Return <i>S</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-arguments-exotic-objects">
- <div class="front">
- <h1><span class="secnum" id="sec-9.4.4"><a href="#sec-arguments-exotic-objects"
- title="link to this section">9.4.4</a></span> Arguments Exotic Objects</h1>
-
- <p>Most ECMAScript functions make an arguments objects available to their code. Depending upon the characteristics of the
- function definition, its argument object is either an ordinary object or an <i>arguments exotic object</i>. An arguments
- exotic object is an exotic object whose array index properties map to the formal parameters bindings of an invocation of
- its associated ECMAScript function.</p>
-
- <p>Arguments exotic objects have the same internal slots as ordinary objects. They also have a [[ParameterMap]] internal
- slot. Ordinary arguments objects also have a [[ParameterMap]] internal slot whose value is always undefined. For ordinary
- argument objects the [[ParameterMap]] internal slot is only used by <code><a
- href="#sec-object.prototype.tostring">Object.prototype.toString</a></code> (<a
- href="#sec-object.prototype.tostring">19.1.3.6</a>) to identify them as such.</p>
-
- <p>Arguments exotic objects provide alternative definitions for the following internal methods. All of the other exotic
- arguments object essential internal methods that are not defined below are as specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a></p>
-
- <div class="note">
- <p><span class="nh">NOTE 1</span> For non-strict functions the integer indexed data properties of an arguments object
- whose numeric name values are less than the number of formal parameters of the corresponding function object initially
- share their values with the corresponding argument bindings in the function&rsquo;s <a
- href="#sec-execution-contexts">execution context</a>. This means that changing the property changes the corresponding
- value of the argument binding and vice-versa. This correspondence is broken if such a property is deleted and then
- redefined or if the property is changed into an accessor property. For strict mode functions, the values of the
- arguments object&rsquo;s properties are simply a copy of the arguments passed to the function and there is no dynamic
- linkage between the property values and the formal parameter values.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 2</span> The ParameterMap object and its property values are used as a device for specifying
- the arguments object correspondence to argument bindings. The ParameterMap object and the objects that are the values of
- its properties are not directly observable from ECMAScript code. An ECMAScript implementation does not need to actually
- create or use such objects to implement the specified semantics.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 3</span> Arguments objects for strict mode functions define non-configurable accessor
- properties named <code>"caller"</code> and <code>"callee"</code> which throw a <b>TypeError</b> exception on access. The
- <code>"callee"</code> property has a more specific meaning for non-strict functions and a <code>"caller"</code> property
- has historically been provided as an implementation-defined extension by some ECMAScript implementations. The strict
- mode definition of these properties exists to ensure that neither of them is defined in any other manner by conforming
- ECMAScript implementations.</p>
- </div>
- </div>
-
- <section id="sec-arguments-exotic-objects-getownproperty-p">
- <h1><span class="secnum" id="sec-9.4.4.1"><a href="#sec-arguments-exotic-objects-getownproperty-p"
- title="link to this section">9.4.4.1</a></span> [[GetOwnProperty]] (P)</h1>
-
- <p>The [[GetOwnProperty]] internal method of an arguments exotic object when called with a <a
- href="#sec-object-type">property key</a> <var>P</var> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>args</i> be the arguments object.</li>
- <li>Let <i>desc</i> be <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>args</i>, <i>P</i>).</li>
- <li>If <i>desc</i> is <b>undefined</b>, return <i>desc</i>.</li>
- <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
- <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is never an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If the value of <i>isMapped</i> is <b>true</b>, then
- <ol class="block">
- <li>Set <i>desc</i>.[[Value]] to <a href="#sec-get-o-p">Get</a>(<i>map</i>, <i>P</i>).</li>
- </ol>
- </li>
- <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>desc</i>) is <b>true</b> and <i>P</i> is
- <code>"caller"</code> and <i>desc</i>.[[Value]] is a strict mode Function object, throw a <b>TypeError</b>
- exception.</li>
- <li>Return <i>desc</i>.</li>
- </ol>
-
- <p>If an implementation does not provide a built-in <code>caller</code> property for argument exotic objects then step 8
- of this algorithm is must be skipped.</p>
- </section>
-
- <section id="sec-arguments-exotic-objects-defineownproperty-p-desc">
- <h1><span class="secnum" id="sec-9.4.4.2"><a href="#sec-arguments-exotic-objects-defineownproperty-p-desc"
- title="link to this section">9.4.4.2</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
-
- <p>The [[DefineOwnProperty]] internal method of an arguments exotic object when called with a <a
- href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
- Descriptor</a> <span class="nt">Desc</span> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>args</i> be the arguments object.</li>
- <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
- <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
- <li>Let <i>allowed</i> be <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>args</i>, <i>P</i>,
- <i>Desc</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>allowed</i>).</li>
- <li>If <i>allowed</i> is <b>false</b>, return <b>false</b>.</li>
- <li>If the value of <i>isMapped</i> is <b>true</b>, then
- <ol class="block">
- <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) is <b>true</b>, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
- </ol>
- </li>
- <li>Else
- <ol class="block">
- <li>If <i>Desc</i>.[[Value]] is present, then
- <ol class="block">
- <li>Let <i>setStatus</i> be <a href="#sec-set-o-p-v-throw">Set</a>(<i>map</i>, <i>P</i>,
- <i>Desc</i>.[[Value]], <b>false</b>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>setStatus</i> is <b>true</b> because formal
- parameters mapped by argument objects are always writable.</li>
- </ol>
- </li>
- <li>If <i>Desc</i>.[[Writable]] is present and its value is <b>false</b>, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
- </ol>
- </li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-arguments-exotic-objects-get-p-receiver">
- <h1><span class="secnum" id="sec-9.4.4.3"><a href="#sec-arguments-exotic-objects-get-p-receiver"
- title="link to this section">9.4.4.3</a></span> [[Get]] (P, Receiver)</h1>
-
- <p>The [[Get]] internal method of an arguments exotic object when called with a <a href="#sec-object-type">property
- key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
- class="nt">Receiver</span> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>args</i> be the arguments object.</li>
- <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
- <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If the value of <i>isMapped</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>v</i> be the result of calling the default ordinary object [[Get]] internal method (<a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>args</i> passing
- <i>P</i> and <i>Receiver</i> as the arguments.</li>
- </ol>
- </li>
- <li>Else <i>map</i> contains a formal parameter mapping for <i>P</i>,
- <ol class="block">
- <li>Let <i>v</i> be <a href="#sec-get-o-p">Get</a>(<i>map</i>, <i>P</i>).</li>
- </ol>
- </li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>v</i>).</li>
- <li>Return <i>v</i>.</li>
- </ol>
- </section>
-
- <section id="sec-arguments-exotic-objects-set-p-v-receiver">
- <h1><span class="secnum" id="sec-9.4.4.4"><a href="#sec-arguments-exotic-objects-set-p-v-receiver"
- title="link to this section">9.4.4.4</a></span> [[Set]] ( P, V, Receiver)</h1>
-
- <p>The [[Set]] internal method of an arguments exotic object when called with <a href="#sec-object-type">property key</a>
- <var>P</var>, value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
- class="nt">Receiver</span> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>args</i> be the arguments object.</li>
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>args</i>, <i>Receiver</i>) is <b>false</b>, then
- <ol class="block">
- <li>Let <i>isMapped</i> be <b>false</b>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
- <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- </ol>
- </li>
- <li>If the value of <i>isMapped</i> is <b>false</b>, then
- <ol class="block">
- <li>Return the result of calling the default ordinary object [[Set]] internal method (<a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-set-p-v-receiver">9.1.9</a>) on <i>args</i>
- passing <i>P</i>, <i>V</i> and <i>Receiver</i> as the arguments.</li>
- </ol>
- </li>
- <li>Else <i>map</i> contains a formal parameter mapping for <i>P</i>,
- <ol class="block">
- <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>
- </ol>
- </li>
- </ol>
- </section>
-
- <section id="sec-arguments-exotic-objects-delete-p">
- <h1><span class="secnum" id="sec-9.4.4.5"><a href="#sec-arguments-exotic-objects-delete-p"
- title="link to this section">9.4.4.5</a></span> [[Delete]] (P)</h1>
-
- <p>The [[Delete]] internal method of an arguments exotic object when called with a <a href="#sec-object-type">property
- key</a> <var>P</var> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>map</i> be the value of the [[ParameterMap]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of the arguments object.</li>
- <li>Let <i>isMapped</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>map</i>, <i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>isMapped</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Let <i>result</i> be the result of calling the default [[Delete]] internal method for ordinary objects (<a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-delete-p">9.1.10</a>) on the arguments object passing
- <i>P</i> as the argument.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
- <li>If <i>result</i> is <b>true</b> and the value of <i>isMapped</i> is <b>true</b>, then
- <ol class="block">
- <li><a href="#sec-call">Call</a> <i>map</i>.[[Delete]](<i>P</i>).</li>
- </ol>
- </li>
- <li>Return <i>result</i>.</li>
- </ol>
- </section>
-
- <section id="sec-createunmappedargumentsobject">
- <h1><span class="secnum" id="sec-9.4.4.6"><a href="#sec-createunmappedargumentsobject"
- title="link to this section">9.4.4.6</a></span> CreateUnmappedArgumentsObject(argumentsList)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">CreateUnmappedArgumentsObject</span> called with an
- argument <var>argumentsList</var> performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>len</i> be the number of elements in <i>argumentsList</i>.</li>
- <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%ObjectPrototype%,
- &laquo;&zwj;[[ParameterMap]]&raquo;).</li>
- <li>Set <i>obj</i>&rsquo;s [[ParameterMap]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a>
- to <b>undefined</b>.</li>
- <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"length"</code>,
- PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
- <b>true</b>}).</li>
- <li>Let <i>index</i> be 0.</li>
- <li>Repeat while <i>index</i> &lt; <i>len</i>,
- <ol class="block">
- <li>Let <i>val</i> be <i>argumentsList</i>[<i>index</i>].</li>
- <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <a
- href="#sec-tostring">ToString</a>(<i>index</i>), <i>val</i>).</li>
- <li>Let <i>index</i> be <i>index</i> + 1</li>
- </ol>
- </li>
- <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, @@iterator, PropertyDescriptor
- {[[Value]]:%ArrayProto_values%, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
- <b>true</b>}).</li>
- <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"caller"</code>,
- PropertyDescriptor {[[Get]]: <a href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Set]]: <a
- href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
- <b>false</b>}).</li>
- <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"callee"</code>,
- PropertyDescriptor {[[Get]]: <a href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Set]]: <a
- href="#sec-%throwtypeerror%">%ThrowTypeError%</a>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
- <b>false</b>}).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: the above property definitions will not produce an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Return <i>obj</i></li>
- </ol>
- </section>
-
- <section id="sec-createmappedargumentsobject">
- <div class="front">
- <h1><span class="secnum" id="sec-9.4.4.7"><a href="#sec-createmappedargumentsobject"
- title="link to this section">9.4.4.7</a></span> CreateMappedArgumentsObject ( func, formals, argumentsList, env
- )</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">CreateMappedArgumentsObject</span> is called with
- object <var>func</var>, parsed grammar phrase <var>formals</var>, <a
- href="#sec-list-and-record-specification-type">List</a> <var>argumentsList</var>, and <a
- href="#sec-environment-records">Environment Record</a> <span style="font-family: Times New Roman"><i>env</i>.</span> The
- following steps are performed:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>formals</i> does not contain a rest parameter, any binding
- patterns, or any initializers. It may contain duplicate identifiers.</li>
- <li>Let <i>len</i> be the number of elements in <i>argumentsList</i>.</li>
- <li>Let <i>obj</i> be a newly created arguments exotic object with a [[ParameterMap]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Set the [[GetOwnProperty]] internal method of <i>obj</i> as specified in <a
- href="#sec-arguments-exotic-objects-getownproperty-p">9.4.4.1</a>.</li>
- <li>Set the [[DefineOwnProperty]] internal method of <i>obj</i> as specified in <a
- href="#sec-arguments-exotic-objects-defineownproperty-p-desc">9.4.4.2</a>.</li>
- <li>Set the [[Get]] internal method of <i>obj</i> as specified in <a
- href="#sec-arguments-exotic-objects-get-p-receiver">9.4.4.3</a>.</li>
- <li>Set the [[Set]] internal method of <i>obj</i> as specified in <a
- href="#sec-arguments-exotic-objects-set-p-v-receiver">9.4.4.4</a>.</li>
- <li>Set the [[Delete]] internal method of <i>obj</i> as specified in <a
- href="#sec-arguments-exotic-objects-delete-p">9.4.4.5</a>.</li>
- <li>Set the remainder of <i>obj</i>&rsquo;s essential internal methods to the default ordinary object definitions
- specified in <a href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
- <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i> to
- %ObjectPrototype%.</li>
- <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i>
- to <b>true</b>.</li>
- <li>Let <i>parameterNames</i> be the BoundNames of <i>formals</i>.</li>
- <li>Let <i>numberOfParameters</i> be the number of elements in <i>parameterNames</i></li>
- <li>Let <i>index</i> be 0.</li>
- <li>Repeat while <i>index</i> &lt; <i>len</i> ,
- <ol class="block">
- <li>Let <i>val</i> be <i>argumentsList</i>[<i>index</i>].</li>
- <li>Perform <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>obj</i>, <a
- href="#sec-tostring">ToString</a>(<i>index</i>), <i>val</i>).</li>
- <li>Let <i>index</i> be <i>index</i> + 1</li>
- </ol>
- </li>
- <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"length"</code>,
- PropertyDescriptor{[[Value]]: <i>len</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
- [[Configurable]]: <b>true</b>}).</li>
- <li>Let <i>map</i> be <a href="#sec-objectcreate">ObjectCreate</a>(<b>null</b>).</li>
- <li>Let <i>mappedNames</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Let <i>index</i> be <i>numberOfParameters</i> &minus; 1.</li>
- <li>Repeat while <i>index</i> &ge; 0 ,
- <ol class="block">
- <li>Let <i>name</i> be <i>parameterNames</i>[<i>index</i>].</li>
- <li>If <i>name</i> is not an element of <i>mappedNames</i>, then
- <ol class="block">
- <li>Add <i>name</i> as an element of the list <i>mappedNames</i>.</li>
- <li>If <i>index</i> &lt; <i>len</i>, then
- <ol class="block">
- <li>Let <i>g</i> be <a href="#sec-makearggetter">MakeArgGetter</a>(<i>name</i>, <i>env</i>).</li>
- <li>Let <i>p</i> be <a href="#sec-makeargsetter">MakeArgSetter</a>(<i>name</i>, <i>env</i>).</li>
- <li><a href="#sec-call">Call</a> <i>map</i>.[[DefineOwnProperty]](<a
- href="#sec-tostring">ToString</a>(<i>index</i>), PropertyDescriptor{[[Set]]: <i>p</i>, [[Get]]:
- <i>g,</i> [[Enumerable]]: <b>false</b>, [[Configurable]]: <b>true</b>}).</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Let <i>index</i> be <i>index</i> &minus; 1</li>
- </ol>
- </li>
- <li>Set the [[ParameterMap]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>obj</i>
- to <i>map</i>.</li>
- <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, @@iterator, PropertyDescriptor
- {[[Value]]:%ArrayProto_values%, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
- <b>true</b>}).</li>
- <li>Perform <a href="#sec-definepropertyorthrow">DefinePropertyOrThrow</a>(<i>obj</i>, <code>"callee"</code>,
- PropertyDescriptor {[[Value]]: <i>func</i>, [[Writable]]: <b>true</b>, [[Enumerable]]: <b>false</b>,
- [[Configurable]]: <b>true</b>}).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: the above property definitions will not produce an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>Return <i>obj</i></li>
- </ol>
- </div>
-
- <section id="sec-makearggetter">
- <h1><span class="secnum" id="sec-9.4.4.7.1"><a href="#sec-makearggetter"
- title="link to this section">9.4.4.7.1</a></span> MakeArgGetter ( name, env)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">MakeArgGetter</span> called with String
- <var>name</var> and <a href="#sec-environment-records">Environment Record</a> <var>env</var> creates a built-in function
- object that when executed returns the value bound for <var>name</var> in <var>env</var>. It performs the following
- steps:</p>
-
- <ol class="proc">
- <li>Let <i>realm</i> be <a href="#sec-execution-contexts">the current Realm</a>.</li>
- <li>Let <i>steps</i> be the steps of an ArgGetter function as specified below.</li>
- <li>Let <i>getter</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realm</i>, <i>steps</i>,
- %FunctionPrototype%, &laquo;&zwj;[[name]], [[env]]&raquo; ).</li>
- <li>Set <i>getter&rsquo;s</i> [[name]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
- <i>name</i>.</li>
- <li>Set <i>getter&rsquo;s</i> [[env]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
- <i>env</i>.</li>
- <li>Return <i>getter</i>.</li>
- </ol>
-
- <p>An ArgGetter function is an anonymous built-in function with [[name]] and [[env]] internal slots. When an ArgGetter
- function <var>f</var> that expects no arguments is called it performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>name</i> be the value of <i>f&rsquo;s</i> [[name]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>env</i> be the value of <i>f&rsquo;s</i> [[env]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a></li>
- <li>Return <i>env</i>.GetBindingValue(<i>name</i>, <b>false</b>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> ArgGetter functions are never directly accessible to ECMAScript code.</p>
- </div>
- </section>
-
- <section id="sec-makeargsetter">
- <h1><span class="secnum" id="sec-9.4.4.7.2"><a href="#sec-makeargsetter"
- title="link to this section">9.4.4.7.2</a></span> MakeArgSetter ( name, env)</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">MakeArgSetter</span> called with String
- <var>name</var> and <a href="#sec-environment-records">Environment Record</a> <var>env</var> creates a built-in function
- object that when executed sets the value bound for <var>name</var> in <var>env</var>. It performs the following
- steps:</p>
-
- <ol class="proc">
- <li>Let <i>realm</i> be <a href="#sec-execution-contexts">the current Realm</a>.</li>
- <li>Let <i>steps</i> be the steps of an ArgSetter function as specified below.</li>
- <li>Let <i>setter</i> be <a href="#sec-createbuiltinfunction">CreateBuiltinFunction</a>(<i>realm</i>, <i>steps</i>,
- %FunctionPrototype%, &laquo;&zwj;[[name]], [[env]]&raquo; ).</li>
- <li>Set <i>setter&rsquo;s</i> [[name]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
- <i>name</i>.</li>
- <li>Set <i>setter&rsquo;s</i> [[env]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
- <i>env</i>.</li>
- <li>Return <i>setter</i>.</li>
- </ol>
-
- <p>An ArgSetter function is an anonymous built-in function with [[name]] and [[env]] internal slots. When an ArgSetter
- function <var>f</var> is called with argument <var>value</var> it performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>name</i> be the value of <i>f&rsquo;s</i> [[name]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>env</i> be the value of <i>f&rsquo;s</i> [[env]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a></li>
- <li>Return <i>env</i>.SetMutableBinding(<i>name</i>, <i>value</i>, <b>false</b>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> ArgSetter functions are never directly accessible to ECMAScript code.</p>
- </div>
- </section>
- </section>
- </section>
-
- <section id="sec-integer-indexed-exotic-objects">
- <div class="front">
- <h1><span class="secnum" id="sec-9.4.5"><a href="#sec-integer-indexed-exotic-objects"
- title="link to this section">9.4.5</a></span> Integer Indexed Exotic Objects</h1>
-
- <p>An <i>Integer Indexed object</i> is an exotic object that performs special handling of integer index property keys.</p>
-
- <p>Integer Indexed exotic objects have the same internal slots as ordinary objects additionally [[ViewedArrayBuffer]],
- [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</p>
-
- <p>Integer Indexed Exotic objects provide alternative definitions for the following internal methods. All of the other
- Integer Indexed exotic object essential internal methods that are not defined below are as specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</p>
- </div>
-
- <section id="sec-integer-indexed-exotic-objects-getownproperty-p">
- <h1><span class="secnum" id="sec-9.4.5.1"><a href="#sec-integer-indexed-exotic-objects-getownproperty-p"
- title="link to this section">9.4.5.1</a></span> [[GetOwnProperty]] ( P )</h1>
-
- <p>When the [[GetOwnProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
- <ol class="block">
- <li>Let <i>numericIndex</i> be <a
- href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>(<i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>numericIndex</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>value</i> be <a href="#sec-integerindexedelementget">IntegerIndexedElementGet</a> (<i>O</i>,
- <i>numericIndex</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>value</i>).</li>
- <li>If <i>value</i> is <b>undefined</b>, return <b>undefined</b>.</li>
- <li>Return a PropertyDescriptor{ [[Value]]: <i>value</i>, [[Enumerable]]: <b>true</b>, [[Writable]]:
- <b>true</b>, [[Configurable]]: <b>false</b> }.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <a href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
- </ol>
- </section>
-
- <section id="sec-integer-indexed-exotic-objects-hasproperty-p">
- <h1><span class="secnum" id="sec-9.4.5.2"><a href="#sec-integer-indexed-exotic-objects-hasproperty-p"
- title="link to this section">9.4.5.2</a></span> [[HasProperty]](P)</h1>
-
- <p>When the [[HasProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
- <ol class="block">
- <li>Let <i>numericIndex</i> be <a
- href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>(<i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>numericIndex</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a
- <b>TypeError</b> exception.</li>
- <li>If <a href="#sec-isinteger">IsInteger</a>(<i>numericIndex</i>) is <b>false</b>, return <b>false</b></li>
- <li>If <i>numericIndex</i> = &minus;0, return <b>false</b>.</li>
- <li>If <i>numericIndex</i> &lt; 0, return <b>false</b>.</li>
- <li>If <i>numericIndex</i> &ge; the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>, return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <a href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
- </ol>
- </section>
-
- <section id="sec-integer-indexed-exotic-objects-defineownproperty-p-desc">
- <h1><span class="secnum" id="sec-9.4.5.3"><a href="#sec-integer-indexed-exotic-objects-defineownproperty-p-desc"
- title="link to this section">9.4.5.3</a></span> [[DefineOwnProperty]] ( P, Desc)</h1>
-
- <p>When the [[DefineOwnProperty]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var>, and <a href="#sec-property-descriptor-specification-type">Property
- Descriptor</a> <span class="nt">Desc</span> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has a [[ViewedArrayBuffer]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String, then
- <ol class="block">
- <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
- (<i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>numericIndex</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>If <a href="#sec-isinteger">IsInteger</a>(<i>numericIndex</i>) is <b>false</b>, return <b>false</b></li>
- <li>Let <i>intIndex</i> be <i>numericIndex</i>.</li>
- <li>If <i>intIndex</i> = &minus;0, return <b>false</b>.</li>
- <li>If <i>intIndex</i> &lt; 0, return <b>false</b>.</li>
- <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <i>intIndex</i> &ge; <i>length</i>, return <b>false</b>.</li>
- <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>Desc</i>) is <b>true</b>, return
- <b>false.</b></li>
- <li>If <i>Desc</i> has a [[Configurable]] field and if <i>Desc</i>.[[Configurable]] is <b>true</b>, return
- <b>false<i>.</i></b></li>
- <li>If <i>Desc</i> has an [[Enumerable]] field and if <i>Desc</i>.[[Enumerable]] is <b>false</b>, return
- <b>false<i>.</i></b></li>
- <li>If <i>Desc</i> has a [[Writable]] field and if <i>Desc</i>.[[Writable]] is <b>false</b>, return
- <b>false</b>.</li>
- <li>If <i>Desc</i> has a [[Value]] field, then
- <ol class="block">
- <li>Let <i>value</i> be <i>Desc</i>.[[Value]].</li>
- <li>Return <a href="#sec-integerindexedelementset">IntegerIndexedElementSet</a> (<i>O</i>, <i>intIndex</i>,
- <i>value</i>).</li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <a href="#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<i>O</i>, <i>P</i>, <i>Desc</i>).</li>
- </ol>
- </section>
-
- <section id="sec-integer-indexed-exotic-objects-get-p-receiver">
- <h1><span class="secnum" id="sec-9.4.5.4"><a href="#sec-integer-indexed-exotic-objects-get-p-receiver"
- title="link to this section">9.4.5.4</a></span> [[Get]] (P, Receiver)</h1>
-
- <p>When the [[Get]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language
- value</a> <span class="nt">Receiver</span> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and if <a
- href="#sec-samevalue">SameValue</a>(<i>O</i>, <i>Receiver</i>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
- (<i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>numericIndex</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>Return <a href="#sec-integerindexedelementget">IntegerIndexedElementGet</a> (<i>O</i>,
- <i>numericIndex</i>).</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return the result of calling the default ordinary object [[Get]] internal method (<a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
- <i>P</i> and <i>Receiver</i> as arguments.</li>
- </ol>
- </section>
-
- <section id="sec-integer-indexed-exotic-objects-set-p-v-receiver">
- <h1><span class="secnum" id="sec-9.4.5.5"><a href="#sec-integer-indexed-exotic-objects-set-p-v-receiver"
- title="link to this section">9.4.5.5</a></span> [[Set]] ( P, V, Receiver)</h1>
-
- <p>When the [[Set]] internal method of an Integer Indexed exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var>, value <var>V</var>, and <a
- href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span>, the following steps
- are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and if <a
- href="#sec-samevalue">SameValue</a>(<i>O</i>, <i>Receiver</i>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>numericIndex</i> be <a href="#sec-canonicalnumericindexstring">CanonicalNumericIndexString</a>
- (<i>P</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>numericIndex</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</li>
- <li>If <i>numericIndex</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>Return <a href="#sec-integerindexedelementset">IntegerIndexedElementSet</a> (<i>O</i>, <i>numericIndex</i>,
- <i>V</i>).</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return the result of calling the default ordinary object [[Set]] internal method (<a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
- <i>P</i>, <i>V</i>, and <i>Receiver</i> as arguments.</li>
- </ol>
- </section>
-
- <section id="sec-integer-indexed-exotic-objects-ownpropertykeys">
- <h1><span class="secnum" id="sec-9.4.5.6"><a href="#sec-integer-indexed-exotic-objects-ownpropertykeys"
- title="link to this section">9.4.5.6</a></span> [[OwnPropertyKeys]] ()</h1>
-
- <p>When the [[OwnPropertyKeys]] internal method of an Integer Indexed exotic object <var>O</var> is called the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>keys</i> be a new empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
- [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
- <li>Let <i>len</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>For each integer <i>i</i> starting with 0 such that <i>i</i> &lt; <i>len</i>, in ascending order,
- <ol class="block">
- <li>Add <a href="#sec-tostring">ToString</a>(<i>i</i>) as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is String and <i>P</i> is not an integer index, in
- property creation order
- <ol class="block">
- <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <li>For each own <a href="#sec-object-type">property key</a> <i>P</i> of <i>O</i> such that <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, in property creation order
- <ol class="block">
- <li>Add <i>P</i> as the last element of <i>keys</i>.</li>
- </ol>
- </li>
- <li>Return <i>keys</i>.</li>
- </ol>
- </section>
-
- <section id="sec-integerindexedobjectcreate">
- <h1><span class="secnum" id="sec-9.4.5.7"><a href="#sec-integerindexedobjectcreate"
- title="link to this section">9.4.5.7</a></span> IntegerIndexedObjectCreate <span style="font-family:
- sans-serif">(prototype, internalSlotsList)</span></h1>
-
- <p>The abstract operation IntegerIndexedObjectCreate with arguments <var>prototype</var> and <var>internalSlotsList</var>
- is used to specify the creation of new Integer Indexed exotic objects. The argument <var>internalSlotsList</var> is a <a
- href="#sec-list-and-record-specification-type">List</a> of the names of additional internal slots that must be defined as
- part of the object. IntegerIndexedObjectCreate performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>A</i> be a newly created object with an <a href="#sec-object-internal-methods-and-internal-slots">internal
- slot</a> for each name in <i>internalSlotsList</i>.</li>
- <li>Set <i>A</i>&rsquo;s essential internal methods to the default ordinary object definitions specified in <a
- href="#sec-ordinary-object-internal-methods-and-internal-slots">9.1</a>.</li>
- <li>Set the [[GetOwnProperty]] internal method of <i>A</i> as specified in <a
- href="#sec-integer-indexed-exotic-objects-getownproperty-p">9.4.5.1</a>.</li>
- <li>Set the [[HasProperty]] internal method of <i>A</i> as specified in <a
- href="#sec-integer-indexed-exotic-objects-hasproperty-p">9.4.5.2</a>.</li>
- <li>Set the [[DefineOwnProperty]] internal method of <i>A</i> as specified in <a
- href="#sec-integer-indexed-exotic-objects-defineownproperty-p-desc">9.4.5.3</a>.</li>
- <li>Set the [[Get]] internal method of <i>A</i> as specified in <a
- href="#sec-integer-indexed-exotic-objects-get-p-receiver">9.4.5.4</a>.</li>
- <li>Set the [[Set]] internal method of <i>A</i> as specified in <a
- href="#sec-integer-indexed-exotic-objects-set-p-v-receiver">9.4.5.5</a>.</li>
- <li>Set the [[OwnPropertyKeys]] internal method of <i>A</i> as specified in <a
- href="#sec-integer-indexed-exotic-objects-ownpropertykeys">9.4.5.6</a>.</li>
- <li>Set the [[Prototype]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
- <i>prototype</i>.</li>
- <li>Set the [[Extensible]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>A</i> to
- <b>true</b>.</li>
- <li>Return <i>A</i>.</li>
- </ol>
- </section>
-
- <section id="sec-integerindexedelementget">
- <h1><span class="secnum" id="sec-9.4.5.8"><a href="#sec-integerindexedelementget"
- title="link to this section">9.4.5.8</a></span> IntegerIndexedElementGet ( O, index )</h1>
-
- <p>The abstract operation IntegerIndexedElementGet with arguments <var>O</var> and <var>index</var> performs the following
- steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>index</i>) is Number.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
- [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
- <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a <b>TypeError</b>
- exception.</li>
- <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>undefined</b></li>
- <li>If <i>index</i> = &minus;0, return <b>undefined</b>.</li>
- <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <i>index</i> &lt; 0 or <i>index</i> &ge; <i>length</i>, return <b>undefined</b>.</li>
- <li>Let <i>offset</i> be the value of <i>O</i>&rsquo;s [[ByteOffset]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>arrayTypeName</i> be the string value of <i>O</i>&rsquo;s [[TypedArrayName]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>elementSize</i> be the Number value of the Element Size value specified in <a href="#table-49">Table 49</a>
- for <i>arrayTypeName</i>.</li>
- <li>Let <i>indexedPosition</i> = (<i>index</i> &times; <i>elementSize</i>) + <i>offset</i>.</li>
- <li>Let <i>elementType</i> be the string value of the Element Type value in <a href="#table-49">Table 49</a> for
- <i>arrayTypeName</i>.</li>
- <li>Return <a href="#sec-getvaluefrombuffer">GetValueFromBuffer</a>(<i>buffer</i>, <i>indexedPosition</i>,
- <i>elementType</i>).</li>
- </ol>
- </section>
-
- <section id="sec-integerindexedelementset">
- <h1><span class="secnum" id="sec-9.4.5.9"><a href="#sec-integerindexedelementset"
- title="link to this section">9.4.5.9</a></span> IntegerIndexedElementSet ( O, index, value )</h1>
-
- <p>The abstract operation IntegerIndexedElementSet with arguments <var>O</var>, <var>index</var>, and <var>value</var>
- performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>index</i>) is Number.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>O</i> is an Object that has [[ViewedArrayBuffer]],
- [[ArrayLength]], [[ByteOffset]], and [[TypedArrayName]] internal slots.</li>
- <li>Let <i>numValue</i> be <a href="#sec-tonumber">ToNumber</a>(<i>value</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>numValue</i>).</li>
- <li>Let <i>buffer</i> be the value of <i>O</i>&rsquo;s [[ViewedArrayBuffer]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <a href="#sec-isdetachedbuffer">IsDetachedBuffer</a>(<i>buffer</i>) is <b>true</b>, throw a <b>TypeError</b>
- exception.</li>
- <li>If <a href="#sec-isinteger">IsInteger</a>(<i>index</i>) is <b>false</b>, return <b>false</b></li>
- <li>If <i>index</i> = &minus;0, return <b>false</b>.</li>
- <li>Let <i>length</i> be the value of <i>O</i>&rsquo;s [[ArrayLength]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <i>index</i> &lt; 0 or <i>index</i> &ge; <i>length</i>, return <b>false</b>.</li>
- <li>Let <i>offset</i> be the value of <i>O</i>&rsquo;s [[ByteOffset]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>arrayTypeName</i> be the string value of <i>O</i>&rsquo;s [[TypedArrayName]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>elementSize</i> be the Number value of the Element Size value specified in <a href="#table-49">Table 49</a>
- for <i>arrayTypeName</i>.</li>
- <li>Let <i>indexedPosition</i> = (<i>index</i> &times; <i>elementSize</i>) + <i>offset</i>.</li>
- <li>Let <i>elementType</i> be the string value of the Element Type value in <a href="#table-49">Table 49</a> for
- <i>arrayTypeName</i>.</li>
- <li>Let <i>status</i> be <a href="#sec-setvalueinbuffer">SetValueInBuffer</a>(<i>buffer</i>, <i>indexedPosition</i>,
- <i>elementType</i>, <i>numValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-module-namespace-exotic-objects">
- <div class="front">
- <h1><span class="secnum" id="sec-9.4.6"><a href="#sec-module-namespace-exotic-objects"
- title="link to this section">9.4.6</a></span> Module Namespace Exotic Objects</h1>
-
- <p>A <i>module namespace object</i> is an exotic object that exposes the bindings exported from an ECMAScript <span
- class="nt">Module</span> <var>(See <a href="#sec-exports">15.2.3</a>)</var>. There is a one-to-one correspondence between
- the String-keyed own properties of a module namespace exotic object and the binding names exported by the <span
- class="nt">Module</span>. The exported bindings include any bindings that are indirectly exported using <code>export
- *</code> export items. Each String-valued own <a href="#sec-object-type">property key</a> is the StringValue of the
- corresponding exported binding name. These are the only String-keyed properties of a module namespace exotic object. Each
- such property has the attributes {[[Configurable]]: <span class="value">false</span>, [[Enumerable]]: <span
- class="value">true</span>}. Module namespace objects are not extensible.</p>
-
- <p>Module namespace objects have the internal slots defined in <a href="#table-29">Table 29</a>.</p>
-
- <figure>
- <figcaption><span id="table-29">Table 29</span> &mdash; Internal Slots of Module Namespace Exotic Objects</figcaption>
- <table class="real-table">
- <tr>
- <th>Internal Slot</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>[[Module]]</td>
- <td>Module Record</td>
- <td>The Module Record whose exports this namespace exposes.</td>
- </tr>
- <tr>
- <td>[[Exports]]</td>
- <td><a href="#sec-list-and-record-specification-type">List</a> of String</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <p>Module namespace exotic objects provide alternative definitions for all of the internal methods.</p>
- </div>
-
- <section id="sec-module-namespace-exotic-objects-getprototypeof">
- <h1><span class="secnum" id="sec-9.4.6.1"><a href="#sec-module-namespace-exotic-objects-getprototypeof"
- title="link to this section">9.4.6.1</a></span> [[GetPrototypeOf]] ( )</h1>
-
- <p>When the [[GetPrototypeOf]] internal method of a module namespace exotic object <var>O</var> is called the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>Return <b>null</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-setprototypeof-v">
- <h1><span class="secnum" id="sec-9.4.6.2"><a href="#sec-module-namespace-exotic-objects-setprototypeof-v"
- title="link to this section">9.4.6.2</a></span> [[SetPrototypeOf]] (V)</h1>
-
- <p>When the [[SetPrototypeOf]] internal method of a module namespace exotic object <var>O</var> is called with argument
- <var>V</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-isextensible">
- <h1><span class="secnum" id="sec-9.4.6.3"><a href="#sec-module-namespace-exotic-objects-isextensible"
- title="link to this section">9.4.6.3</a></span> [[IsExtensible]] ( )</h1>
-
- <p>When the [[IsExtensible]] internal method of a module namespace exotic object <var>O</var> is called the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-preventextensions">
- <h1><span class="secnum" id="sec-9.4.6.4"><a href="#sec-module-namespace-exotic-objects-preventextensions"
- title="link to this section">9.4.6.4</a></span> [[PreventExtensions]] ( )</h1>
-
- <p>When the [[PreventExtensions]] internal method of a module namespace exotic object <var>O</var> is called the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-getownproperty-p">
- <h1><span class="secnum" id="sec-9.4.6.5"><a href="#sec-module-namespace-exotic-objects-getownproperty-p"
- title="link to this section">9.4.6.5</a></span> [[GetOwnProperty]] (P)</h1>
-
- <p>When the [[GetOwnProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, return <a
- href="#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<i>O</i>, <i>P</i>).</li>
- <li>Throw a <b>TypeError</b> exception.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-defineownproperty-p-desc">
- <h1><span class="secnum" id="sec-9.4.6.6"><a href="#sec-module-namespace-exotic-objects-defineownproperty-p-desc"
- title="link to this section">9.4.6.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
-
- <p>When the [[DefineOwnProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
- Descriptor</a> <span class="nt">Desc</span>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-hasproperty-p">
- <h1><span class="secnum" id="sec-9.4.6.7"><a href="#sec-module-namespace-exotic-objects-hasproperty-p"
- title="link to this section">9.4.6.7</a></span> [[HasProperty]] (P)</h1>
-
- <p>When the [[HasProperty]] internal method of a module namespace exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, return <a
- href="#sec-ordinaryhasproperty">OrdinaryHasProperty</a>(<i>O</i>, <i>P</i>).</li>
- <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <i>P</i> is an element of <i>exports</i>, return <b>true</b>.</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-get-p-receiver">
- <h1><span class="secnum" id="sec-9.4.6.8"><a href="#sec-module-namespace-exotic-objects-get-p-receiver"
- title="link to this section">9.4.6.8</a></span> [[Get]] (P, Receiver)</h1>
-
- <p>When the [[Get]] internal method of a module namespace exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language
- value</a> <span class="nt">Receiver</span> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>P</i>) is Symbol, then
- <ol class="block">
- <li>Return the result of calling the default ordinary object [[Get]] internal method (<a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-get-p-receiver">9.1.8</a>) on <i>O</i> passing
- <i>P</i> and <i>Receiver</i> as arguments.</li>
- </ol>
- </li>
- <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <i>P</i> is not an element of <i>exports</i>, return <b>undefined</b>.</li>
- <li>Let <i>m</i> be the value of <i>O</i>&rsquo;s [[Module]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>binding</i> be <i>m</i>.<a href="#sec-resolveexport">ResolveExport</a>(<i>P</i>, &laquo;&raquo;,
- &laquo;&raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>binding</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>binding</i> is neither <b>null</b> nor
- <code>"ambiguous"</code>.</li>
- <li>Let <i>targetModule</i> be <i>binding</i>.[[module]],</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>targetModule</i> is not <b>undefined</b>.</li>
- <li>Let <i>targetEnv</i> be <i>targetModule</i>.[[Environment]].</li>
- <li>If <i>targetEnv</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
- <li>Let <i>targetEnvRec</i> be <i>targetEnv</i>&rsquo;s EnvironmentRecord.</li>
- <li>Return <i>targetEnvRec</i>.GetBindingValue(<i>binding.</i>[[bindingName]], <b>true</b>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> <a href="#sec-resolveexport">ResolveExport</a> is idempotent and side-effect free. An
- implementation might choose to pre-compute or cache the <a href="#sec-resolveexport">ResolveExport</a> results for the
- [[Exports]] of each module namespace exotic object.</p>
- </div>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-set-p-v-receiver">
- <h1><span class="secnum" id="sec-9.4.6.9"><a href="#sec-module-namespace-exotic-objects-set-p-v-receiver"
- title="link to this section">9.4.6.9</a></span> [[Set]] ( P, V, Receiver)</h1>
-
- <p>When the [[Set]] internal method of <span style="font-family: Times New Roman">a</span> module namespace exotic object
- <var>O</var> is called with <a href="#sec-object-type">property key</a> <var>P</var>, value <var>V</var>, and <a
- href="#sec-ecmascript-language-types">ECMAScript language value</a> <span class="nt">Receiver</span>, the following steps
- are taken:</p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-delete-p">
- <h1><span class="secnum" id="sec-9.4.6.10"><a href="#sec-module-namespace-exotic-objects-delete-p"
- title="link to this section">9.4.6.10</a></span> [[Delete]] (P)</h1>
-
- <p>When the [[Delete]] internal method of a module namespace exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>If <i>P</i> is an element of <i>exports</i>, return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-enumerate">
- <h1><span class="secnum" id="sec-9.4.6.11"><a href="#sec-module-namespace-exotic-objects-enumerate"
- title="link to this section">9.4.6.11</a></span> [[Enumerate]] ()</h1>
-
- <p>When the [[Enumerate]] internal method of a module namespace exotic object <var>O</var> is called the following steps
- are taken:</p>
-
- <ol class="proc">
- <li>Let <i>exports</i> be the value of <i>O</i>&rsquo;s [[Exports]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Return <a href="#sec-createlistiterator">CreateListIterator</a>(<i>exports</i>).</li>
- </ol>
- </section>
-
- <section id="sec-module-namespace-exotic-objects-ownpropertykeys">
- <h1><span class="secnum" id="sec-9.4.6.12"><a href="#sec-module-namespace-exotic-objects-ownpropertykeys"
- title="link to this section">9.4.6.12</a></span> [[OwnPropertyKeys]] ( )</h1>
-
- <p>When the [[OwnPropertyKeys]] internal method of a module namespace exotic object <var>O</var> is called the following
- steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>exports</i> be a copy of the value of <i>O</i>&rsquo;s [[Exports]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a>.</li>
- <li>Let <i>symbolKeys</i> be the result of calling the default ordinary object [[OwnPropertyKeys]] internal method (<a
- href="#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys">9.1.12</a>) on <i>O</i> passing no
- arguments.</li>
- <li>Append all the entries of <i>symbolKeys</i> to the end of <i>exports</i>.</li>
- <li>Return <i>exports</i>.</li>
- </ol>
- </section>
-
- <section id="sec-modulenamespacecreate">
- <h1><span class="secnum" id="sec-9.4.6.13"><a href="#sec-modulenamespacecreate"
- title="link to this section">9.4.6.13</a></span> ModuleNamespaceCreate (module, exports)</h1>
-
- <p>The abstract operation ModuleNamespaceCreate with arguments <var>module</var>, and <var>exports</var> is used to
- specify the creation of new module namespace exotic objects. It performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>module</i> is a Module Record (<a
- href="#sec-abstract-module-records">see 15.2.1.14</a>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>module</i>.[[Namespace]] is <b>undefined</b>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>exports</i> is a <a
- href="#sec-list-and-record-specification-type">List</a> of string values.</li>
- <li>Let <i>M</i> be a newly created object.</li>
- <li>Set <i>M</i>&rsquo;s essential internal methods to the definitions specified in <a
- href="#sec-module-namespace-exotic-objects">9.4.6</a>.</li>
- <li>Set <i>M</i>&rsquo;s [[Module]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
- <i>module</i>.</li>
- <li>Set <i>M</i>&rsquo;s [[Exports]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> to
- <i>exports</i>.</li>
- <li>Create own properties of <i>M</i> corresponding to the definitions in <a
- href="#sec-module-namespace-objects">26.3</a>.</li>
- <li>Set <i>module</i>.[[Namespace]] to <i>M</i>.</li>
- <li>Return <i>M</i>.</li>
- </ol>
- </section>
- </section>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots">
- <div class="front">
- <h1><span class="secnum" id="sec-9.5"><a href="#sec-proxy-object-internal-methods-and-internal-slots"
- title="link to this section">9.5</a></span> Proxy Object Internal Methods and Internal Slots</h1>
-
- <p>A proxy object is an exotic object whose essential internal methods are partially implemented using ECMAScript code.
- Every proxy objects has an <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called
- [[ProxyHandler]]. The value of [[ProxyHandler]] is an object, called the proxy&rsquo;s <i>handler object</i>, or <span
- class="value">null</span>. Methods (see <a href="#table-30">Table 30</a>) of a handler object may be used to augment the
- implementation for one or more of the proxy object&rsquo;s internal methods. Every proxy object also has an <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> called [[ProxyTarget]] whose value is either an
- object or the <b>null</b> value. This object is called the proxy&rsquo;s <i>target object</i>.</p>
-
- <figure>
- <figcaption><span id="table-30">Table 30</span> &mdash; Proxy Handler Methods</figcaption>
- <table class="real-table">
- <tr>
- <th>Internal Method</th>
- <th>Handler Method</th>
- </tr>
- <tr>
- <td>[[GetPrototypeOf]]</td>
- <td><code>getPrototypeOf</code></td>
- </tr>
- <tr>
- <td>[[SetPrototypeOf]]</td>
- <td><code>setPrototypeOf</code></td>
- </tr>
- <tr>
- <td>[[IsExtensible]]</td>
- <td><code>isExtensible</code></td>
- </tr>
- <tr>
- <td>[[PreventExtensions]]</td>
- <td><code>preventExtensions</code></td>
- </tr>
- <tr>
- <td>[[GetOwnProperty]]</td>
- <td><code>getOwnPropertyDescriptor</code></td>
- </tr>
- <tr>
- <td>[[HasProperty]]</td>
- <td><code>has</code></td>
- </tr>
- <tr>
- <td>[[Get]]</td>
- <td><code>get</code></td>
- </tr>
- <tr>
- <td>[[Set]]</td>
- <td><code>set</code></td>
- </tr>
- <tr>
- <td>[[Delete]]</td>
- <td><code>deleteProperty</code></td>
- </tr>
- <tr>
- <td>[[DefineOwnProperty]]</td>
- <td><code>defineProperty</code></td>
- </tr>
- <tr>
- <td>[[Enumerate]]</td>
- <td><code>enumerate</code></td>
- </tr>
- <tr>
- <td>[[OwnPropertyKeys]]</td>
- <td><code>ownKeys</code></td>
- </tr>
- <tr>
- <td>[[Call]]</td>
- <td><code>apply</code></td>
- </tr>
- <tr>
- <td>[[Construct]]</td>
- <td><code>construct</code></td>
- </tr>
- </table>
- </figure>
-
- <p>When a handler method is called to provide the implementation of a proxy object internal method, the handler method is
- passed the proxy&rsquo;s target object as a parameter. A proxy&rsquo;s handler object does not necessarily have a method
- corresponding to every essential internal method. Invoking an internal method on the proxy results in the invocation of the
- corresponding internal method on the proxy&rsquo;s target object if the handler object does not have a method corresponding
- to the internal trap.</p>
-
- <p>The [[ProxyHandler]] and [[ProxyTarget]] internal slots of a proxy object are always initialized when the object is
- created and typically may not be modified. Some proxy objects are created in a manner that permits them to be subsequently
- <i>revoked</i>. When a proxy is revoked, its [[ProxyHander]] and [[ProxyTarget]] internal slots are set to <b>null</b>
- causing subsequent invocations of internal methods on that proxy object to throw a <span class="value">TypeError</span>
- exception.</p>
-
- <p>Because proxy objects permit the implementation of internal methods to be provided by arbitrary ECMAScript code, it is
- possible to define a proxy object whose handler methods violates the invariants defined in <a
- href="#sec-invariants-of-the-essential-internal-methods">6.1.7.3</a>. Some of the internal method invariants defined in <a
- href="#sec-invariants-of-the-essential-internal-methods">6.1.7.3</a> are essential integrity invariants. These invariants
- are explicitly enforced by the proxy object internal methods specified in this section. An ECMAScript implementation must be
- robust in the presence of all possible invariant violations.</p>
-
- <p>In the following algorithm descriptions, assume <var>O</var> is an ECMAScript proxy object, <var>P</var> is a <a
- href="#sec-object-type">property key value</a>, <var>V</var> is any <a href="#sec-ecmascript-language-types">ECMAScript
- language value</a> and <span style="font-family: Times New Roman">Desc</span> is a <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> record.</p>
- </div>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-getprototypeof">
- <h1><span class="secnum" id="sec-9.5.1"><a href="#sec-proxy-object-internal-methods-and-internal-slots-getprototypeof"
- title="link to this section">9.5.1</a></span> [[GetPrototypeOf]] ( )</h1>
-
- <p>When the [[GetPrototypeOf]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
- taken:</p>
-
- <ol class="proc">
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"getPrototypeOf"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[GetPrototypeOf]]().</li>
- </ol>
- </li>
- <li>Let <i>handlerProto</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>,
- &laquo;<i>target</i>&raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>handlerProto</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handlerProto</i>) is neither Object nor Null, throw a
- <b>TypeError</b> exception.</li>
- <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
- <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>handlerProto</i>.</li>
- <li>Let <i>targetProto</i> be <i>target</i>.[[GetPrototypeOf]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetProto</i>).</li>
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>handlerProto</i>, <i>targetProto</i>) is <b>false</b>, throw a
- <b>TypeError</b> exception.</li>
- <li>Return <i>handlerProto</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[GetPrototypeOf]] for proxy objects enforces the following invariant:</p>
-
- <ul>
- <li>
- <p>The result of [[GetPrototypeOf]] must be either an Object or <b>null</b>.</p>
- </li>
-
- <li>
- <p>If the target object is not extensible, [[GetPrototypeOf]] applied to the proxy object must return the same value
- as [[GetPrototypeOf]] applied to the proxy object&rsquo;s target object.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v">
- <h1><span class="secnum" id="sec-9.5.2"><a href="#sec-proxy-object-internal-methods-and-internal-slots-setprototypeof-v"
- title="link to this section">9.5.2</a></span> [[SetPrototypeOf]] (V)</h1>
-
- <p>When the [[SetPrototypeOf]] internal method of a Proxy exotic object <var>O</var> is called with argument <var>V</var>
- the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: Either <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Object or <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>V</i>) is Null.</li>
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"setPrototypeOf"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[SetPrototypeOf]](<i>V</i>).</li>
- </ol>
- </li>
- <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
- <i>handler</i>, &laquo;<i>target</i>, <i>V</i>&raquo;)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
- <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
- <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>booleanTrapResult</i>.</li>
- <li>Let <i>targetProto</i> be <i>target</i>.[[GetPrototypeOf]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetProto</i>).</li>
- <li>If <i>booleanTrapResult</i> is <b>true</b> and <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>targetProto</i>) is
- <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>booleanTrapResult</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[SetPrototypeOf]] for proxy objects enforces the following invariant:</p>
-
- <ul>
- <li>
- <p>The result of [[SetPrototypeOf]] is a Boolean value.</p>
- </li>
-
- <li>
- <p>If the target object is not extensible, the argument value must be the same as the result of [[GetPrototypeOf]]
- applied to target object.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-isextensible">
- <h1><span class="secnum" id="sec-9.5.3"><a href="#sec-proxy-object-internal-methods-and-internal-slots-isextensible"
- title="link to this section">9.5.3</a></span> [[IsExtensible]] ( )</h1>
-
- <p>When the [[IsExtensible]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
- taken:</p>
-
- <ol class="proc">
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"isExtensible"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[IsExtensible]]().</li>
- </ol>
- </li>
- <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
- <i>handler</i>, &laquo;<i>target</i>&raquo;)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
- <li>Let <i>targetResult</i> be <i>target</i>.[[IsExtensible]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetResult</i>).</li>
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>booleanTrapResult</i>, <i>targetResult</i>) is <b>false</b>, throw a
- <b>TypeError</b> exception.</li>
- <li>Return <i>booleanTrapResult</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[IsExtensible]] for proxy objects enforces the following invariant:</p>
-
- <ul>
- <li>
- <p>The result of [[IsExtensible]] is a Boolean value.</p>
- </li>
-
- <li>
- <p>[[IsExtensible]] applied to the proxy object must return the same value as [[IsExtensible]] applied to the proxy
- object&rsquo;s target object with the same argument.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-preventextensions">
- <h1><span class="secnum" id="sec-9.5.4"><a href="#sec-proxy-object-internal-methods-and-internal-slots-preventextensions"
- title="link to this section">9.5.4</a></span> [[PreventExtensions]] ( )</h1>
-
- <p>When the [[PreventExtensions]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
- taken:</p>
-
- <ol class="proc">
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"preventExtensions"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[PreventExtensions]]().</li>
- </ol>
- </li>
- <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
- <i>handler</i>, &laquo;<i>target</i>&raquo;)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
- <li>If <i>booleanTrapResult</i> is <b>true</b>, then
- <ol class="block">
- <li>Let <i>targetIsExtensible</i> be <i>target</i>.[[IsExtensible]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetIsExtensible</i>).</li>
- <li>If <i>targetIsExtensible</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- <li>Return <i>booleanTrapResult</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[PreventExtensions]] for proxy objects enforces the following invariant:</p>
-
- <ul>
- <li>
- <p>The result of [[PreventExtensions]] is a Boolean value.</p>
- </li>
-
- <li>
- <p>[[PreventExtensions]] applied to the proxy object only returns <b>true</b> if [[IsExtensible]] applied to the proxy
- object&rsquo;s target object is <b>false</b>.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p">
- <h1><span class="secnum" id="sec-9.5.5"><a href="#sec-proxy-object-internal-methods-and-internal-slots-getownproperty-p"
- title="link to this section">9.5.5</a></span> [[GetOwnProperty]] (P)</h1>
-
- <p>When the [[GetOwnProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>,
- <code>"getOwnPropertyDescriptor"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
- </ol>
- </li>
- <li>Let <i>trapResultObj</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>,
- <i>P</i>&raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResultObj</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>trapResultObj</i>) is neither Object nor Undefined,
- throw a <b>TypeError</b> exception.</li>
- <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
- <li>If <i>trapResultObj</i> is <b>undefined</b>, then
- <ol class="block">
- <li>If <i>targetDesc</i> is <b>undefined</b>, return <b>undefined</b>.</li>
- <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
- <li>If <a href="#sec-toboolean">ToBoolean</a>(<i>extensibleTarget</i>) is <b>false</b>, throw a <b>TypeError</b>
- exception.</li>
- <li>Return <b>undefined</b>.</li>
- </ol>
- </li>
- <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
- <li>Let <i>resultDesc</i> be <a href="#sec-topropertydescriptor">ToPropertyDescriptor</a>(<i>trapResultObj</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>resultDesc</i>).</li>
- <li><a href="#sec-call">Call</a> <a
- href="#sec-completepropertydescriptor">CompletePropertyDescriptor</a>(<i>resultDesc</i>).</li>
- <li>Let <i>valid</i> be <a href="#sec-iscompatiblepropertydescriptor">IsCompatiblePropertyDescriptor</a>
- (<i>extensibleTarget</i>, <i>resultDesc</i>, <i>targetDesc</i>).</li>
- <li>If <i>valid</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>If <i>resultDesc</i>.[[Configurable]] is <b>false</b>, then
- <ol class="block">
- <li>If <i>targetDesc</i> is <b>undefined</b> or <i>targetDesc</i>.[[Configurable]] is <b>true</b><i>,</i> then
- <ol class="block">
- <li>Throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <i>resultDesc</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[GetOwnProperty]] for proxy objects enforces the following invariants:</p>
-
- <ul>
- <li>
- <p>The result of [[GetOwnProperty]] must be either an Object or <b>undefined</b>.</p>
- </li>
-
- <li>
- <p>A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target
- object.</p>
- </li>
-
- <li>
- <p>A property cannot be reported as non-existent, if it exists as an own property of the target object and the target
- object is not extensible.</p>
- </li>
-
- <li>
- <p>A property cannot be reported as existent, if it does not exists as an own property of the target object and the
- target object is not extensible.</p>
- </li>
-
- <li>
- <p>A property cannot be reported as non-configurable, if it does not exists as an own property of the target object or
- if it exists as a configurable own property of the target object.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc">
- <h1><span class="secnum" id="sec-9.5.6"><a
- href="#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc"
- title="link to this section">9.5.6</a></span> [[DefineOwnProperty]] (P, Desc)</h1>
-
- <p>When the [[DefineOwnProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var> and <a href="#sec-property-descriptor-specification-type">Property
- Descriptor</a> <span class="nt">Desc</span>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"defineProperty"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[DefineOwnProperty]](<i>P</i>, <i>Desc</i>).</li>
- </ol>
- </li>
- <li>Let <i>descObj</i> be <a href="#sec-frompropertydescriptor">FromPropertyDescriptor</a>(<i>Desc</i>).</li>
- <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
- <i>handler</i>, &laquo;<i>target</i>, <i>P</i>, <i>descObj</i>&raquo;)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
- <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
- <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
- <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
- <li>If <i>Desc</i> has a [[Configurable]] field and if <i>Desc</i>.[[Configurable]] is <b>false,</b> then
- <ol class="block">
- <li>Let <i>settingConfigFalse</i> be <b>true</b>.</li>
- </ol>
- </li>
- <li>Else let <i>settingConfigFalse</i> be <b>false</b>.</li>
- <li>If <i>targetDesc</i> is <b>undefined</b>, then
- <ol class="block">
- <li>If <i>extensibleTarget</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>If <i>settingConfigFalse</i> is <b>true</b>, throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- <li>Else <i>targetDesc</i> is not <b>undefined<i>,</i></b>
- <ol class="block">
- <li>If <a href="#sec-iscompatiblepropertydescriptor">IsCompatiblePropertyDescriptor</a>(<i>extensibleTarget</i>,
- <i>Desc</i> , <i>targetDesc</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>If <i>settingConfigFalse</i> is <b>true</b> and <i>targetDesc</i>.[[Configurable]] is <b>true</b>, throw a
- <b>TypeError</b> exception.</li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[DefineOwnProperty]] for proxy objects enforces the following invariants:</p>
-
- <ul>
- <li>
- <p>The result of [[DefineOwnProperty]] is a Boolean value.</p>
- </li>
-
- <li>
- <p>A property cannot be added, if the target object is not extensible.</p>
- </li>
-
- <li>
- <p>A property cannot be non-configurable, unless there exists a corresponding non-configurable own property of the
- target object.</p>
- </li>
-
- <li>
- <p>If a property has a corresponding target object property then applying the <a
- href="#sec-property-descriptor-specification-type">Property Descriptor</a> of the property to the target object using
- [[DefineOwnProperty]] will not throw an exception.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p">
- <h1><span class="secnum" id="sec-9.5.7"><a href="#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p"
- title="link to this section">9.5.7</a></span> [[HasProperty]] (P)</h1>
-
- <p>When the [[HasProperty]] internal method of a Proxy exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"has"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[HasProperty]](<i>P</i>).</li>
- </ol>
- </li>
- <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
- <i>handler</i>, &laquo;<i>target</i>, <i>P</i>&raquo;)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
- <li>If <i>booleanTrapResult</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
- <li>If <i>targetDesc</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
- <li>If <i>extensibleTarget</i> is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <i>booleanTrapResult</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[HasProperty]] for proxy objects enforces the following invariants:</p>
-
- <ul>
- <li>
- <p>The result of [[HasProperty]] is a Boolean value.</p>
- </li>
-
- <li>
- <p>A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target
- object.</p>
- </li>
-
- <li>
- <p>A property cannot be reported as non-existent, if it exists as an own property of the target object and the target
- object is not extensible.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver">
- <h1><span class="secnum" id="sec-9.5.8"><a href="#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver"
- title="link to this section">9.5.8</a></span> [[Get]] (P, Receiver)</h1>
-
- <p>When the [[Get]] internal method of a Proxy exotic object <var>O</var> is called with <a href="#sec-object-type">property
- key</a> <var>P</var> and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
- class="nt">Receiver</span> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"get"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[Get]](<i>P</i>, <i>Receiver</i>).</li>
- </ol>
- </li>
- <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>,
- <i>Receiver</i>&raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
- <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
- <li>If <i>targetDesc</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>targetDesc</i>) and <i>targetDesc</i>.[[Configurable]]
- is <b>false</b> and <i>targetDesc</i>.[[Writable]] is <b>false</b>, then
- <ol class="block">
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>trapResult</i>, <i>targetDesc</i>.[[Value]]) is <b>false</b>,
- throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>targetDesc</i>) and
- <i>targetDesc</i>.[[Configurable]] is <b>false</b> and <i>targetDesc</i>.[[Get]] is <b>undefined</b>, then
- <ol class="block">
- <li>If <i>trapResult</i> is not <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <i>trapResult</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[Get]] for proxy objects enforces the following invariants:</p>
-
- <ul>
- <li>
- <p>The value reported for a property must be the same as the value of the corresponding target object property if the
- target object property is a non-writable, non-configurable own data property.</p>
- </li>
-
- <li>
- <p>The value reported for a property must be <b>undefined</b> if the corresponding target object property is a
- non-configurable own accessor property that has <b>undefined</b> as its [[Get]] attribute.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver">
- <h1><span class="secnum" id="sec-9.5.9"><a href="#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver"
- title="link to this section">9.5.9</a></span> [[Set]] ( P, V, Receiver)</h1>
-
- <p>When the [[Set]] internal method of a Proxy exotic object <var>O</var> is called with <a href="#sec-object-type">property
- key</a> <var>P</var>, value <var>V</var>, and <a href="#sec-ecmascript-language-types">ECMAScript language value</a> <span
- class="nt">Receiver</span>, the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"set"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[Set]](<i>P</i>, <i>V</i>, <i>Receiver</i>).</li>
- </ol>
- </li>
- <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
- <i>handler</i>, &laquo;<i>target</i>, <i>P</i>, <i>V</i>, <i>Receiver</i>&raquo;)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
- <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
- <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
- <li>If <i>targetDesc</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>If <a href="#sec-isdatadescriptor">IsDataDescriptor</a>(<i>targetDesc</i>) and <i>targetDesc</i>.[[Configurable]]
- is <b>false</b> and <i>targetDesc</i>.[[Writable]] is <b>false</b>, then
- <ol class="block">
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>V</i>, <i>targetDesc</i>.[[Value]]) is <b>false</b>, throw a
- <b>TypeError</b> exception.</li>
- </ol>
- </li>
- <li>If <a href="#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<i>targetDesc</i>) and
- <i>targetDesc</i>.[[Configurable]] is <b>false</b>, then
- <ol class="block">
- <li>If <i>targetDesc</i>.[[Set]] is <b>undefined</b>, throw a <b>TypeError</b> exception.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[Set]] for proxy objects enforces the following invariants:</p>
-
- <ul>
- <li>
- <p>The result of [[Set]] is a Boolean value.</p>
- </li>
-
- <li>
- <p>Cannot change the value of a property to be different from the value of the corresponding target object property if
- the corresponding target object property is a non-writable, non-configurable own data property.</p>
- </li>
-
- <li>
- <p>Cannot set the value of a property if the corresponding target object property is a non-configurable own accessor
- property that has <b>undefined</b> as its [[Set]] attribute.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-delete-p">
- <h1><span class="secnum" id="sec-9.5.10"><a href="#sec-proxy-object-internal-methods-and-internal-slots-delete-p"
- title="link to this section">9.5.10</a></span> [[Delete]] (P)</h1>
-
- <p>When the [[Delete]] internal method of a Proxy exotic object <var>O</var> is called with <a
- href="#sec-object-type">property key</a> <var>P</var> the following steps are taken:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a href="#sec-ispropertykey">IsPropertyKey</a>(<i>P</i>) is
- <b>true</b>.</li>
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"deleteProperty"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[Delete]](<i>P</i>).</li>
- </ol>
- </li>
- <li>Let <i>booleanTrapResult</i> be <a href="#sec-toboolean">ToBoolean</a>(<a href="#sec-call">Call</a>(<i>trap</i>,
- <i>handler</i>, &laquo;<i>target</i>, <i>P</i>&raquo;)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>booleanTrapResult</i>).</li>
- <li>If <i>booleanTrapResult</i> is <b>false</b>, return <b>false</b>.</li>
- <li>Let <i>targetDesc</i> be <i>target</i>.[[GetOwnProperty]](<i>P</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetDesc</i>).</li>
- <li>If <i>targetDesc</i> is <b>undefined</b>, return <b>true</b>.</li>
- <li>If <i>targetDesc</i>.[[Configurable]] is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[Delete]] for proxy objects enforces the following invariant:</p>
-
- <ul>
- <li>The result of [[Delete]] is a Boolean value.</li>
- <li>A property cannot be reported as deleted, if it exists as a non-configurable own property of the target object.</li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-enumerate">
- <h1><span class="secnum" id="sec-9.5.11"><a href="#sec-proxy-object-internal-methods-and-internal-slots-enumerate"
- title="link to this section">9.5.11</a></span> [[Enumerate]] ()</h1>
-
- <p>When the [[Enumerate]] internal method of a Proxy exotic object <var>O</var> is called the following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"enumerate"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[Enumerate]]().</li>
- </ol>
- </li>
- <li>Let <i>trapResult</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>&raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>trapResult</i>) is not Object, throw a <b>TypeError</b>
- exception.</li>
- <li>Return <i>trapResult</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[Enumerate]] for proxy objects enforces the following invariants:</p>
-
- <ul>
- <li>The result of [[Enumerate]] must be an Object.</li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys">
- <h1><span class="secnum" id="sec-9.5.12"><a href="#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys"
- title="link to this section">9.5.12</a></span> [[OwnPropertyKeys]] ( )</h1>
-
- <p>When the [[OwnPropertyKeys]] internal method of a Proxy exotic object <var>O</var> is called the following steps are
- taken:</p>
-
- <ol class="proc">
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"ownKeys"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <i>target</i>.[[OwnPropertyKeys]]().</li>
- </ol>
- </li>
- <li>Let <i>trapResultArray</i> be <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>,
- &laquo;<i>target</i>&raquo;).</li>
- <li>Let <i>trapResult</i> be <a href="#sec-createlistfromarraylike">CreateListFromArrayLike</a>(<i>trapResultArray</i>,
- &laquo;&zwj;String, Symbol&raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trapResult</i>).</li>
- <li>Let <i>extensibleTarget</i> be <a href="#sec-isextensible-o">IsExtensible</a>(<i>target</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>extensibleTarget</i>).</li>
- <li>Let <i>targetKeys</i> be <i>target</i>.[[OwnPropertyKeys]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>targetKeys</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>targetKeys</i> is a <a
- href="#sec-list-and-record-specification-type">List</a> containing only String and Symbol values.</li>
- <li>Let <i>targetConfigurableKeys</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Let <i>targetNonconfigurableKeys</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Repeat, for each element <i>key</i> of <i>targetKeys</i>,
- <ol class="block">
- <li>Let <i>desc</i> be <i>target</i>.[[GetOwnProperty]](<i>key</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>desc</i>).</li>
- <li>If <i>desc</i> is not <b>undefined</b> and <i>desc.</i>[[Configurable]] is <b>false</b>, then
- <ol class="block">
- <li>Append <i>key</i> as an element of <i>targetNonconfigurableKeys</i>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Append <i>key</i> as an element of <i>targetConfigurableKeys</i>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>If <i>extensibleTarget</i> is <b>true</b> and <i>targetNonconfigurableKeys</i> is empty, then
- <ol class="block">
- <li>Return <i>trapResult</i>.</li>
- </ol>
- </li>
- <li>Let <i>uncheckedResultKeys</i> be a new <a href="#sec-list-and-record-specification-type">List</a> which is a copy of
- <i>trapResult</i>.</li>
- <li>Repeat, for each <i>key</i> that is an element of <i>targetNonconfigurableKeys</i>,
- <ol class="block">
- <li>If <i>key</i> is not an element of <i>uncheckedResultKeys</i>, throw a <b>TypeError</b> exception.</li>
- <li>Remove <i>key</i> from <i>uncheckedResultKeys</i></li>
- </ol>
- </li>
- <li>If <i>extensibleTarget</i> is <b>true</b>, return <i>trapResult</i>.</li>
- <li>Repeat, for each <i>key</i> that is an element of <i>targetConfigurableKeys</i>,
- <ol class="block">
- <li>If <i>key</i> is not an element of <i>uncheckedResultKeys</i>, throw a <b>TypeError</b> exception.</li>
- <li>Remove <i>key</i> from <i>uncheckedResultKeys</i></li>
- </ol>
- </li>
- <li>If <i>uncheckedResultKeys</i> is not empty, throw a <b>TypeError</b> exception.</li>
- <li>Return <i>trapResult</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> [[OwnPropertyKeys]] for proxy objects enforces the following invariants:</p>
-
- <ul>
- <li>
- <p>The result of [[OwnPropertyKeys]] is a <a href="#sec-list-and-record-specification-type">List</a>.</p>
- </li>
-
- <li>
- <p>The Type of each result <a href="#sec-list-and-record-specification-type">List</a> element is either String or
- Symbol.</p>
- </li>
-
- <li>
- <p>The result <a href="#sec-list-and-record-specification-type">List</a> must contain the keys of all non-configurable
- own properties of the target object.</p>
- </li>
-
- <li>
- <p>If the target object is not extensible, then the result <a href="#sec-list-and-record-specification-type">List</a>
- must contain all the keys of the own properties of the target object and no other values.</p>
- </li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist">
- <h1><span class="secnum" id="sec-9.5.13"><a
- href="#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist"
- title="link to this section">9.5.13</a></span> [[Call]] (thisArgument, argumentsList)</h1>
-
- <p>The [[Call]] internal method of a Proxy exotic object <var>O</var> is called with parameters <var>thisArgument</var> and
- <var>argumentsList</var>, a <a href="#sec-list-and-record-specification-type">List</a> of <a
- href="#sec-ecmascript-language-types">ECMAScript language values</a>. The following steps are taken:</p>
-
- <ol class="proc">
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"apply"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li>Return <a href="#sec-call">Call</a>(<i>target</i>, <i>thisArgument</i>, <i>argumentsList</i>).</li>
- </ol>
- </li>
- <li>Let <i>argArray</i> be <a href="#sec-createarrayfromlist">CreateArrayFromList</a>(<i>argumentsList</i>).</li>
- <li>Return <a href="#sec-call">Call</a>(<i>trap</i>, <i>handler</i>, &laquo;<i>target</i>, <i>thisArgument</i>,
- <i>argArray</i>&raquo;).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A Proxy exotic object only has a [[Call]] internal method if the initial value of its
- [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is an object that has a
- [[Call]] internal method.</p>
- </div>
- </section>
-
- <section id="sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget">
- <h1><span class="secnum" id="sec-9.5.14"><a
- href="#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget"
- title="link to this section">9.5.14</a></span> [[Construct]] ( argumentsList, newTarget)</h1>
-
- <p>The [[Construct]] internal method of a Proxy exotic object <var>O</var> is called with parameters
- <var>argumentsList</var> which is a possibly empty <a href="#sec-list-and-record-specification-type">List</a> of <a
- href="#sec-ecmascript-language-types">ECMAScript language values</a> and <var>newTarget</var>. The following steps are
- taken:</p>
-
- <ol class="proc">
- <li>Let <i>handler</i> be the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>If <i>handler</i> is <b>null</b>, throw a <b>TypeError</b> exception.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is Object.</li>
- <li>Let <i>target</i> be the value of the [[ProxyTarget]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>O</i>.</li>
- <li>Let <i>trap</i> be <a href="#sec-getmethod">GetMethod</a>(<i>handler</i>, <code>"construct"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>trap</i>).</li>
- <li>If <i>trap</i> is <b>undefined</b>, then
- <ol class="block">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>target</i> has a [[Construct]] internal method.</li>
- <li>Return <a href="#sec-construct">Construct</a>(<i>target</i>, <i>argumentsList</i>, <i>newTarget</i>).</li>
- </ol>
- </li>
- <li>Let <i>argArray</i> be <a href="#sec-createarrayfromlist">CreateArrayFromList</a>(<i>argumentsList</i>).</li>
- <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>,
- <i>newTarget</i> &raquo;).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>newObj</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>newObj</i>) is not Object, throw a <b>TypeError</b>
- exception.</li>
- <li>Return <i>newObj</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE 1</span> A Proxy exotic object only has a [[Construct]] internal method if the initial value of
- its [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> is an object that has a
- [[Construct]] internal method.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 2</span> [[Construct]] for proxy objects enforces the following invariants:</p>
-
- <ul>
- <li>The result of [[Construct]] must be an Object.</li>
- </ul>
- </div>
- </section>
-
- <section id="sec-proxycreate">
- <h1><span class="secnum" id="sec-9.5.15"><a href="#sec-proxycreate" title="link to this section">9.5.15</a></span>
- ProxyCreate(target, handler)</h1>
-
- <p>The abstract operation ProxyCreate with arguments <var>target</var> and <var>handler</var> is used to specify the
- creation of new Proxy exotic objects. It performs the following steps:</p>
-
- <ol class="proc">
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>target</i>) is not Object, throw a <b>TypeError</b>
- Exception.</li>
- <li>If <i>target</i> is a Proxy exotic object and the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>target</i> is <b>null</b>, throw a
- <b>TypeError</b> exception.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>handler</i>) is not Object, throw a <b>TypeError</b>
- Exception.</li>
- <li>If <i>handler</i> is a Proxy exotic object and the value of the [[ProxyHandler]] <a
- href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>handler</i> is <b>null</b>, throw a
- <b>TypeError</b> exception.</li>
- <li>Let <i>P</i> be a newly created object.</li>
- <li>Set <i>P</i>&rsquo;s essential internal methods (except for [[Call]] and [[Construct]]) to the definitions specified
- in <a href="#sec-proxy-object-internal-methods-and-internal-slots">9.5</a>.</li>
- <li>If <a href="#sec-iscallable">IsCallable</a>(<i>target</i>) is <b>true</b>, then
- <ol class="block">
- <li>Set the [[Call]] internal method of <i>P</i> as specified in <a
- href="#sec-proxy-object-internal-methods-and-internal-slots-call-thisargument-argumentslist">9.5.13</a>.</li>
- <li>If <i>target</i> has a [[Construct]] internal method, then
- <ol class="block">
- <li>Set the [[Construct]] internal method of <i>P</i> as specified in <a
- href="#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget">9.5.14</a>.</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Set the [[ProxyTarget]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>P</i> to
- <i>target</i>.</li>
- <li>Set the [[ProxyHandler]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> of <i>P</i> to
- <i>handler</i>.</li>
- <li>Return <i>P</i>.</li>
- </ol>
- </section>
- </section>
-</section>
-
-<section id="sec-ecmascript-language-source-code">
- <div class="front">
- <h1><span class="secnum" id="sec-10"><a href="#sec-ecmascript-language-source-code" title="link to this section">10</a></span>
- ECMAScript Language: Source Code</h1>
- </div>
-
- <section id="sec-source-text">
- <div class="front">
- <h1><span class="secnum" id="sec-10.1"><a href="#sec-source-text" title="link to this section">10.1</a></span> Source
- Text</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SourceCharacter</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="gprose">any Unicode code point</span></div>
- </div>
-
- <p>ECMAScript code is expressed using Unicode, version 5.1 or later. ECMAScript source text is a sequence of code points.
- All Unicode code point values from U+0000 to U+10FFFF, including surrogate code points, may occur in source text where
- permitted by the ECMAScript grammars. The actual encodings used to store and interchange ECMAScript source text is not
- relevant to this specification. Regardless of the external source text encoding, a conforming ECMAScript implementation
- processes the source text as if it was an equivalent sequence of <span class="nt">SourceCharacter</span> values. Each <span
- class="nt">SourceCharacter</span> being a Unicode code point. Conforming ECMAScript implementations are not required to
- perform any normalization of source text, or behave as though they were performing normalization of source text.</p>
-
- <p>The components of a combining character sequence are treated as individual Unicode code points even though a user might
- think of the whole sequence as a single character.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> In string literals, regular expression literals, template literals and identifiers, any
- Unicode code point may also be expressed using Unicode escape sequences that explicitly express a code point&rsquo;s
- numeric value. Within a comment, such an escape sequence is effectively ignored as part of the comment.</p>
-
- <p>ECMAScript differs from the Java programming language in the behaviour of Unicode escape sequences. In a Java program,
- if the Unicode escape sequence <code>\u000A</code>, for example, occurs within a single-line comment, it is interpreted as
- a line terminator (Unicode code point U+000A is line feed (lf)) and therefore the next code point is not part of the
- comment. Similarly, if the Unicode escape sequence <code>\u000A</code> occurs within a string literal in a Java program,
- it is likewise interpreted as a line terminator, which is not allowed within a string literal&mdash;one must write
- <code>\n</code> instead of <code>\u000A</code> to cause a line feed (lf) to be part of the string value of a string
- literal. In an ECMAScript program, a Unicode escape sequence occurring within a comment is never interpreted and therefore
- cannot contribute to termination of the comment. Similarly, a Unicode escape sequence occurring within a string literal in
- an ECMAScript program always contributes to the literal and is never interpreted as a line terminator or as a code point
- that might terminate the string literal.</p>
- </div>
- </div>
-
- <section id="sec-utf16encoding">
- <h1><span class="secnum" id="sec-10.1.1"><a href="#sec-utf16encoding" title="link to this section">10.1.1</a></span> Static
- Semantics: <i>UTF16Encoding ( cp )</i></h1>
-
- <p>The UTF16Encoding of a numeric code point value, <var>cp</var>, is determined as follows:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: 0 &le; <i>cp</i> &le; 0x10FFFF.</li>
- <li>If <i>cp</i> &le; 65535, return <i>cp</i>.</li>
- <li>Let <i>cu1</i> be <a href="#sec-algorithm-conventions">floor</a>((<i>cp</i> &ndash; 65536) / 1024) + 0xD800.</li>
- <li>Let <i>cu2</i> be ((<i>cp</i> &ndash; 65536) <a href="#sec-algorithm-conventions">modulo</a> 1024) + 0xDC00.</li>
- <li>Return the code unit sequence consisting of <i>cu1</i> followed by <i>cu2</i>.</li>
- </ol>
- </section>
-
- <section id="sec-utf16decode">
- <h1><span class="secnum" id="sec-10.1.2"><a href="#sec-utf16decode" title="link to this section">10.1.2</a></span> Static
- Semantics: UTF16Decode( lead, trail )</h1>
-
- <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
- performing the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: 0xD800 &le; <i>lead</i> &le; 0xDBFF and 0xDC00 &le; <i>trail</i> &le;
- 0xDFFF.</li>
- <li>Let <i>cp</i> be (<i>lead</i> &ndash; 0xD800) &times; 1024 + (<i>trail</i> &ndash; 0xDC00) + 0x10000.</li>
- <li>Return the code point <i>cp</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-types-of-source-code">
- <div class="front">
- <h1><span class="secnum" id="sec-10.2"><a href="#sec-types-of-source-code" title="link to this section">10.2</a></span>
- Types of Source Code</h1>
-
- <p>There are four types of ECMAScript code:</p>
-
- <ul>
- <li>
- <p><i>Global code</i> is source text that is treated as an ECMAScript <i>Script</i>. The global code of a particular
- <i>Script</i> does not include any source text that is parsed as part of a <i>FunctionDeclaration</i>,
- <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>, <i>GeneratorExpression</i>, <i>MethodDefinition</i>,
- <i>ArrowFunction, ClassDeclaration</i>, or <i>ClassExpression</i>.</p>
- </li>
-
- <li>
- <p><i>Eval code</i> is the source text supplied to the built-in <code>eval</code> function. More precisely, if the
- parameter to the built-in <code>eval</code> function is a String, it is treated as an ECMAScript <i>Script</i>. The eval
- code for a particular invocation of <code>eval</code> is the global code portion of that <i>Script</i>.</p>
- </li>
-
- <li>
- <p><i>Function code</i> is source text that is parsed to supply the value of the [[ECMAScriptCode]] and
- [[FormalParameters]] internal slots (<a href="#sec-ecmascript-function-objects">see 9.2</a>) of an <a
- href="#sec-ecmascript-function-objects">ECMAScript function object</a>. The function code of a particular ECMAScript
- function does not include any source text that is parsed as the function code of a nested <i>FunctionDeclaration</i>,
- <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>, <i>GeneratorExpression</i>, <i>MethodDefinition</i>,
- <i>ArrowFunction, ClassDeclaration</i>, or <i>ClassExpression</i>.</p>
- </li>
-
- <li>
- <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
- directly evaluated when a module is initialized. The module code of a particular module does not include any source text
- that is parsed as part of a nested <i>FunctionDeclaration</i>, <i>FunctionExpression</i>, <i>GeneratorDeclaration</i>,
- <i>GeneratorExpression</i>, <i>MethodDefinition</i>, <i>ArrowFunction, ClassDeclaration</i>, or
- <i>ClassExpression</i>.</p>
- </li>
- </ul>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Function code is generally provided as the bodies of Function Definitions (<a
- href="#sec-function-definitions">14.1</a>), Arrow Function Definitions (<a
- href="#sec-arrow-function-definitions">14.2</a>), Method Definitions (<a href="#sec-method-definitions">14.3</a>) and
- Generator Definitions (<a href="#sec-generator-function-definitions">14.4</a>). Function code is also derived from the
- arguments to the <code>Function</code> constructor (<a href="#sec-function-p1-p2-pn-body">19.2.1.1</a>) and the
- GeneratorFunction constructor (<a href="#sec-generatorfunction">25.2.1.1</a>).</p>
- </div>
- </div>
-
- <section id="sec-strict-mode-code">
- <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>
- Strict Mode Code</h1>
-
- <p>An ECMAScript <span class="nt">Script</span> syntactic unit may be processed using either unrestricted or strict mode
- syntax and semantics. Code is interpreted as <i>strict mode code</i> in the following situations:</p>
-
- <ul>
- <li>
- <p>Global code is strict mode code if it begins with a <a
- href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
- href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a> (see <a
- href="#sec-directive-prologues-and-the-use-strict-directive">14.1.1</a>).</p>
- </li>
-
- <li>
- <p>Module code is always strict mode code.</p>
- </li>
-
- <li>
- <p>All parts of a <span class="nt">ClassDeclaration</span> or a <span class="nt">ClassExpression</span> are strict mode
- code.</p>
- </li>
-
- <li>
- <p>Eval code is strict mode code if it begins with a <a
- href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
- href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a> or if the call to eval is a direct
- eval (<a href="#sec-function-calls-runtime-semantics-evaluation">see 12.3.4.1</a>) that is contained in strict mode
- code.</p>
- </li>
-
- <li>
- <p>Function code is strict mode code if the associated <span class="nt">FunctionDeclaration</span>, <span
- class="nt">FunctionExpression</span>, <span class="nt">GeneratorDeclaration</span>, <span
- class="nt">GeneratorExpression</span>, <span class="nt">MethodDefinition</span>, or <span
- class="nt">ArrowFunction</span> is contained in strict mode code or if the code that produces the value of the
- function&rsquo;s [[ECMAScriptCode]] <a href="#sec-object-internal-methods-and-internal-slots">internal slot</a> begins
- with a <a href="#sec-directive-prologues-and-the-use-strict-directive">Directive Prologue</a> that contains a <a
- href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict Directive</a>.</p>
- </li>
-
- <li>
- <p>Function code that is supplied as the arguments to the built-in <code>Function</code> and <code>Generator</code>
- constructors is strict mode code if the last argument is a String that when processed has a <span
- class="nt">FunctionBody</span> begins with a <a href="#sec-directive-prologues-and-the-use-strict-directive">Directive
- Prologue</a> that contains a <a href="#sec-directive-prologues-and-the-use-strict-directive">Use Strict
- Directive</a>.</p>
- </li>
- </ul>
-
- <p>ECMAScript code that is not strict mode code is called <i>non-strict code</i>.</p>
- </section>
-
- <section id="sec-non-ecmascript-functions">
- <h1><span class="secnum" id="sec-10.2.2"><a href="#sec-non-ecmascript-functions"
- title="link to this section">10.2.2</a></span> Non-ECMAScript Functions</h1>
-
- <p>An ECMAScript implementation may support the evaluation of exotic function objects whose evaluative behaviour is
- expressed in some implementation defined form of executable code other than via ECMAScript code. Whether a function object
- is an ECMAScript code function or a non-ECMAScript function is not semantically observable from the perspective of an
- ECMAScript code function that calls or is called by such a non-ECMAScript function.</p>
- </section>
- </section>
-</section>
-
-<section id="sec-ecmascript-language-lexical-grammar">
- <div class="front">
- <h1><span class="secnum" id="sec-11"><a href="#sec-ecmascript-language-lexical-grammar"
- title="link to this section">11</a></span> ECMAScript Language: Lexical Grammar</h1>
-
- <p>The source text of an ECMAScript <span class="nt">Script</span> or <span class="nt">Module</span> is first converted into a
- sequence of input elements, which are tokens, line terminators, comments, or white space. The source text is scanned from left
- to right, repeatedly taking the longest possible sequence of code points as the next input element.</p>
-
- <p>There are several situations where the identification of lexical input elements is sensitive to the syntactic grammar
- context that is consuming the input elements. This requires multiple goal symbols for the lexical grammar. The <span
- class="nt">InputElementRegExpOrTemplateTail</span> goal is used in syntactic grammar contexts where a
- <var>RegularExpressionLiteral,</var> a <var>TemplateMiddle,</var> or a <span class="nt">TemplateTail</span> is permitted. The
- <span class="nt">InputElementRegExp</span> goal symbol is used in all syntactic grammar contexts where a <span
- class="nt">RegularExpressionLiteral</span> is permitted but neither a <var>TemplateMiddle,</var> nor a <span
- class="nt">TemplateTail</span> is permitted. The <span class="nt">InputElementTemplateTail</span> goal is used in all
- syntactic grammar contexts where a <span class="nt">TemplateMiddle</span> or a <span class="nt">TemplateTail</span> is
- permitted but a <span class="nt">RegularExpressionLiteral</span> is not permitted. In all other contexts, <span
- class="nt">InputElementDiv</span> is used as the lexical goal symbol.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The use of multiple lexical goals ensures that there are no lexical ambiguities that would
- affect <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>. For example, there are no syntactic
- grammar contexts where both a leading division or division-assignment, and a leading <i>RegularExpressionLiteral</i> are
- permitted. This is not affected by semicolon insertion (<a href="#sec-automatic-semicolon-insertion">see 11.9</a>); in
- examples such as the following:</p>
-
- <pre>a = b<br>/hi/g.exec(c).map(d);</pre>
-
- <p>where the first non-whitespace, non-comment code point after a <i>LineTerminator</i> is U+002F (SOLIDUS) and the
- syntactic context allows division or division-assignment, no semicolon is inserted at the <i>LineTerminator</i>. That is,
- the above example is interpreted in the same way as:</p>
-
- <pre>a = b / hi / g.exec(c).map(d);</pre>
- </div>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">InputElementDiv</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">WhiteSpace</span></div>
- <div class="rhs"><span class="nt">LineTerminator</span></div>
- <div class="rhs"><span class="nt">Comment</span></div>
- <div class="rhs"><span class="nt">CommonToken</span></div>
- <div class="rhs"><span class="nt">DivPunctuator</span></div>
- <div class="rhs"><span class="nt">RightBracePunctuator</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">InputElementRegExp</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">WhiteSpace</span></div>
- <div class="rhs"><span class="nt">LineTerminator</span></div>
- <div class="rhs"><span class="nt">Comment</span></div>
- <div class="rhs"><span class="nt">CommonToken</span></div>
- <div class="rhs"><span class="nt">RightBracePunctuator</span></div>
- <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">InputElementRegExpOrTemplateTail</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">WhiteSpace</span></div>
- <div class="rhs"><span class="nt">LineTerminator</span></div>
- <div class="rhs"><span class="nt">Comment</span></div>
- <div class="rhs"><span class="nt">CommonToken</span></div>
- <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
- <div class="rhs"><span class="nt">TemplateSubstitutionTail</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">InputElementTemplateTail</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">WhiteSpace</span></div>
- <div class="rhs"><span class="nt">LineTerminator</span></div>
- <div class="rhs"><span class="nt">Comment</span></div>
- <div class="rhs"><span class="nt">CommonToken</span></div>
- <div class="rhs"><span class="nt">DivPunctuator</span></div>
- <div class="rhs"><span class="nt">TemplateSubstitutionTail</span></div>
- </div>
- </div>
-
- <section id="sec-unicode-format-control-characters">
- <h1><span class="secnum" id="sec-11.1"><a href="#sec-unicode-format-control-characters"
- title="link to this section">11.1</a></span> Unicode Format-Control Characters</h1>
-
- <p>The Unicode format-control characters (i.e., the characters in category &ldquo;Cf&rdquo; in the Unicode Character Database
- 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
- absence of higher-level protocols for this (such as mark-up languages).</p>
-
- <p>It is useful to allow format-control characters in source text to facilitate editing and display. All format control
- characters may be used within comments, and within string literals, template literals, and regular expression literals.</p>
-
- <p>U+200C <span style="font-family: Times New Roman">(</span>Zero width non-joiner<span style="font-family: Times New
- Roman">)</span> and U+200D <span style="font-family: Times New Roman">(</span>Zero width joiner<span style="font-family: Times
- New Roman">)</span> are format-control characters that are used to make necessary distinctions when forming words or phrases
- in certain languages. In ECMAScript source text these code points may also be used in an <span
- class="nt">IdentifierName</span> (<a href="#sec-identifier-names">see 11.6.1</a>) after the first character.</p>
-
- <p>U+FEFF <span style="font-family: Times New Roman">(</span>Zero Width no-break space<span style="font-family: Times New
- Roman">)</span> is a format-control character used primarily at the start of a text to mark it as Unicode and to allow
- detection of the text's encoding and byte order. <span style="font-family: Times New Roman">&lt;ZWNBSP&gt;</span> characters
- intended for this purpose can sometimes also appear after the start of a text, for example as a result of concatenating files.
- In ECMAScript source text &lt;ZWNBSP&gt; code points are treated as white space characters (<a href="#sec-white-space">see
- 11.2</a>).</p>
-
- <p>The special treatment of certain format-control characters outside of comments, string literals, and regular expression
- literals is summarized in <a href="#table-31">Table 31</a>.</p>
-
- <figure>
- <figcaption><span id="table-31">Table 31</span> &mdash; Format-Control Code Point Usage</figcaption>
- <table class="real-table">
- <tr>
- <th>Code Point</th>
- <th>Name</th>
- <th>Abbreviation</th>
- <th>Usage</th>
- </tr>
- <tr>
- <td><code>U+200C</code></td>
- <td>Zero width non-joiner</td>
- <td>&lt;ZWNJ&gt;</td>
- <td><i>IdentifierPart</i></td>
- </tr>
- <tr>
- <td><code>U+200D</code></td>
- <td>Zero width joiner</td>
- <td>&lt;ZWJ&gt;</td>
- <td><i>IdentifierPart</i></td>
- </tr>
- <tr>
- <td><code>U+FEFF</code></td>
- <td>ZERO WIDTH NO-BREAK SPACE</td>
- <td>&lt;ZWNBSP&gt;</td>
- <td><i>WhiteSpace</i></td>
- </tr>
- </table>
- </figure>
- </section>
-
- <section id="sec-white-space">
- <h1><span class="secnum" id="sec-11.2"><a href="#sec-white-space" title="link to this section">11.2</a></span> White
- Space</h1>
-
- <p>White space code points are used to improve source text readability and to separate tokens (indivisible lexical units) from
- each other, but are otherwise insignificant. White space code points may occur between any two tokens and at the start or end
- of input. White space code points may occur within a <span class="nt">StringLiteral</span>, a <span
- class="nt">RegularExpressionLiteral</span>, a <span class="nt">Template</span>, or a <span
- class="nt">TemplateSubstitutionTail</span> where they are considered significant code points forming part of a literal value.
- They may also occur within a <span class="nt">Comment</span>, but cannot appear within any other kind of token.</p>
-
- <p>The ECMAScript white space code points are listed in <a href="#table-32">Table 32</a>.</p>
-
- <figure>
- <figcaption><span id="table-32">Table 32</span> &mdash; White Space Code Points</figcaption>
- <table class="real-table">
- <tr>
- <th>Code Point</th>
- <th>Name</th>
- <th>Abbreviation</th>
- </tr>
- <tr>
- <td><code>U+0009</code></td>
- <td>Character Tabulation</td>
- <td>&lt;TAB&gt;</td>
- </tr>
- <tr>
- <td><code>U+000B</code></td>
- <td>LINE TABULATION</td>
- <td>&lt;VT&gt;</td>
- </tr>
- <tr>
- <td><code>U+000C</code></td>
- <td>Form Feed (ff)</td>
- <td>&lt;FF&gt;</td>
- </tr>
- <tr>
- <td><code>U+0020</code></td>
- <td>Space</td>
- <td>&lt;SP&gt;</td>
- </tr>
- <tr>
- <td><code>U+00A0</code></td>
- <td>No-break space</td>
- <td>&lt;NBSP&gt;</td>
- </tr>
- <tr>
- <td><code>U+FEFF</code></td>
- <td>ZERO wIDTH nO-bREAK SPACE</td>
- <td>&lt;ZWNBSP&gt;</td>
- </tr>
- <tr>
- <td>Other category &ldquo;Zs&rdquo;</td>
- <td>Any other Unicode &ldquo;Separator, space&rdquo; code point</td>
- <td>&lt;USP&gt;</td>
- </tr>
- </table>
- </figure>
-
- <p>ECMAScript implementations must recognize as <span class="nt">WhiteSpace</span> code points listed in the &ldquo;Separator,
- space&rdquo; (Zs) category by Unicode 5.1. ECMAScript implementations may also recognize as <span class="nt">WhiteSpace</span>
- additional category Zs code points from subsequent editions of the Unicode Standard.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Other than for the code points listed in <a href="#table-32">Table 32</a>, ECMAScript
- <i>WhiteSpace</i> intentionally excludes all code points that have the Unicode &ldquo;White_Space&rdquo; property but which
- are not classified in category &ldquo;Zs&rdquo;.</p>
- </div>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">WhiteSpace</span> <span class="geq">::</span></div>
- <div class="rhs">&lt;TAB&gt;</div>
- <div class="rhs">&lt;VT&gt;</div>
- <div class="rhs">&lt;FF&gt;</div>
- <div class="rhs">&lt;SP&gt;</div>
- <div class="rhs">&lt;NBSP&gt;</div>
- <div class="rhs">&lt;zwnbsp&gt;</div>
- <div class="rhs">&lt;USP&gt;</div>
- </div>
- </section>
-
- <section id="sec-line-terminators">
- <h1><span class="secnum" id="sec-11.3"><a href="#sec-line-terminators" title="link to this section">11.3</a></span> Line
- Terminators</h1>
-
- <p>Like white space code points, line terminator code points are used to improve source text readability and to separate
- tokens (indivisible lexical units) from each other. However, unlike white space code points, line terminators have some
- influence over the behaviour of the syntactic grammar. In general, line terminators may occur between any two tokens, but
- there are a few places where they are forbidden by the syntactic grammar. Line terminators also affect the process of <a
- href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a
- href="#sec-automatic-semicolon-insertion">11.9</a>). A line terminator cannot occur within any token except a <span
- class="nt">StringLiteral</span>, <span class="nt">Template</span>, or <span class="nt">TemplateSubstitutionTail</span>. Line
- terminators may only occur within a <span class="nt">StringLiteral</span> token as part of a <span
- class="nt">LineContinuation</span>.</p>
-
- <p>A line terminator can occur within a <span class="nt">MultiLineComment</span> (<a href="#sec-comments">11.4</a>) but cannot
- occur within a <span class="nt">SingleLineComment</span>.</p>
-
- <p>Line terminators are included in the set of white space code points that are matched by the <code>\s</code> class in
- regular expressions.</p>
-
- <p>The ECMAScript line terminator code points are listed in <a href="#table-33">Table 33</a>.</p>
-
- <figure>
- <figcaption><span id="table-33">Table 33</span> &mdash; Line Terminator Code Points</figcaption>
- <table class="real-table">
- <tr>
- <th>Code Point</th>
- <th>Unicode Name</th>
- <th>Abbreviation</th>
- </tr>
- <tr>
- <td><code>U+000A</code></td>
- <td>Line Feed (LF)</td>
- <td>&lt;LF&gt;</td>
- </tr>
- <tr>
- <td><code>U+000D</code></td>
- <td>Carriage Return (CR)</td>
- <td>&lt;CR&gt;</td>
- </tr>
- <tr>
- <td><code>U+2028</code></td>
- <td>Line separator</td>
- <td>&lt;LS&gt;</td>
- </tr>
- <tr>
- <td><code>U+2029</code></td>
- <td>Paragraph separator</td>
- <td>&lt;PS&gt;</td>
- </tr>
- </table>
- </figure>
-
- <p>Only the Unicode code points in <a href="#table-33">Table 33</a> are treated as line terminators. Other new line or line
- breaking Unicode code points are not treated as line terminators but are treated as white space if they meet the requirements
- 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
- be considered a single <span class="nt">SourceCharacter</span> for the purpose of reporting line numbers.</p>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">LineTerminator</span> <span class="geq">::</span></div>
- <div class="rhs">&lt;LF&gt;</div>
- <div class="rhs">&lt;CR&gt;</div>
- <div class="rhs">&lt;LS&gt;</div>
- <div class="rhs">&lt;PS&gt;</div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></div>
- <div class="rhs">&lt;LF&gt;</div>
- <div class="rhs">&lt;CR&gt; <span class="grhsannot">[lookahead &ne; &lt;LF&gt; ]</span></div>
- <div class="rhs">&lt;LS&gt;</div>
- <div class="rhs">&lt;PS&gt;</div>
- <div class="rhs">&lt;CR&gt; &lt;LF&gt;</div>
- </div>
- </section>
-
- <section id="sec-comments">
- <h1><span class="secnum" id="sec-11.4"><a href="#sec-comments" title="link to this section">11.4</a></span> Comments</h1>
-
- <p>Comments can be either single or multi-line. Multi-line comments cannot nest.</p>
-
- <p>Because a single-line comment can contain any Unicode code point except a <span class="nt">LineTerminator</span> code
- point, and because of the general rule that a token is always as long as possible, a single-line comment always consists of
- all code points from the <code>//</code> marker to the end of the line. However, the <span class="nt">LineTerminator</span> at
- the end of the line is not considered to be part of the single-line comment; it is recognized separately by the lexical
- grammar and becomes part of the stream of input elements for the syntactic grammar. This point is very important, because it
- implies that the presence or absence of single-line comments does not affect the process of <a
- href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> (<a href="#sec-automatic-semicolon-insertion">see
- 11.9</a>).</p>
-
- <p>Comments behave like white space and are discarded except that, if a <span class="nt">MultiLineComment</span> contains a
- line terminator code point, then the entire comment is considered to be a <span class="nt">LineTerminator</span> for purposes
- of parsing by the syntactic grammar.</p>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Comment</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">MultiLineComment</span></div>
- <div class="rhs"><span class="nt">SingleLineComment</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MultiLineComment</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">/*</code> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub> <code class="t">*/</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MultiLineCommentChars</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">MultiLineNotAsteriskChar</span> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub></div>
- <div class="rhs"><code class="t">*</code> <span class="nt">PostAsteriskCommentChars</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PostAsteriskCommentChars</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">MultiLineNotForwardSlashOrAsteriskChar</span> <span class="nt">MultiLineCommentChars</span><sub class="g-opt">opt</sub></div>
- <div class="rhs"><code class="t">*</code> <span class="nt">PostAsteriskCommentChars</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MultiLineNotAsteriskChar</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <code class="t">*</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MultiLineNotForwardSlashOrAsteriskChar</span> <span class="geq">::</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SingleLineComment</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">//</code> <span class="nt">SingleLineCommentChars</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SingleLineCommentChars</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">SingleLineCommentChar</span> <span class="nt">SingleLineCommentChars</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SingleLineCommentChar</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <span class="nt">LineTerminator</span></div>
- </div>
- </section>
-
- <section id="sec-tokens">
- <h1><span class="secnum" id="sec-11.5"><a href="#sec-tokens" title="link to this section">11.5</a></span> Tokens</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CommonToken</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">IdentifierName</span></div>
- <div class="rhs"><span class="nt">Punctuator</span></div>
- <div class="rhs"><span class="nt">NumericLiteral</span></div>
- <div class="rhs"><span class="nt">StringLiteral</span></div>
- <div class="rhs"><span class="nt">Template</span></div>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The <i>DivPunctuator</i>, <i>RegularExpressionLiteral</i>, <i>RightBracePunctuator,</i> and
- <i>TemplateSubstitutionTail</i> productions derive additional tokens that are not included in the <i>CommonToken</i>
- production.</p>
- </div>
- </section>
-
- <section id="sec-names-and-keywords">
- <div class="front">
- <h1><span class="secnum" id="sec-11.6"><a href="#sec-names-and-keywords" title="link to this section">11.6</a></span> Names
- and Keywords</h1>
-
- <p><span class="nt">IdentifierName</span> and <span class="nt">ReservedWord</span> are tokens that are interpreted according
- to the Default Identifier Syntax given in Unicode Standard Annex #31, Identifier and Pattern Syntax, with some small
- modifications. <span class="nt">ReservedWord</span> is an enumerated subset of <span style="font-family: Times New
- Roman"><i>IdentifierName</i>.</span> The syntactic grammar defines <span class="nt">Identifier</span> as an <span
- class="nt">IdentifierName</span> that is not a <span class="nt">ReservedWord</span> (<a href="#sec-reserved-words">see
- 11.6.2</a>). The Unicode identifier grammar is based on character properties specified by the Unicode Standard. The Unicode
- code points in the specified categories in version 5.1.0 of the Unicode standard must be treated as in those categories by
- all conforming ECMAScript implementations. ECMAScript implementations may recognize identifier code points defined in later
- editions of the Unicode Standard.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> This standard specifies specific code point additions: <span style="font-family:
- sans-serif">U+0024</span> (dollar sign) and <span style="font-family: sans-serif">U+005F</span> (<span style="font-family:
- sans-serif">LOW LINE</span>) are permitted anywhere in an <i>IdentifierName</i><span style="font-family: sans-serif">, and
- the code points</span> <span style="font-family: sans-serif">U+200C (zero-width non-joiner) and U+200D (zero-width joiner)
- are permitted anywhere after the first code point</span> <span style="font-family: sans-serif">of an</span>
- <i>IdentifierName</i>.</p>
- </div>
-
- <p>Unicode escape sequences are permitted in an <span class="nt">IdentifierName</span>, where they contribute a single
- Unicode code point to the <span class="nt">IdentifierName</span>. The code point is expressed by the <span
- class="nt">HexDigits</span> of the <span class="nt">UnicodeEscapeSequence</span> (<a
- href="#sec-literals-string-literals">see 11.8.4</a>). The <code>\</code> preceding the <span
- class="nt">UnicodeEscapeSequence</span> and the <code>u</code> and <code>{ }</code> code units, if they appear, do not
- contribute code points to the <span class="nt">IdentifierName</span>. A <span class="nt">UnicodeEscapeSequence</span> cannot
- be used to put a code point into an <span class="nt">IdentifierName</span> that would otherwise be illegal. In other words,
- if a <code>\</code> <span class="nt">UnicodeEscapeSequence</span> sequence were replaced by the <span
- class="nt">SourceCharacter</span> it contributes, the result must still be a valid <span class="nt">IdentifierName</span>
- that has the exact same sequence of <span class="nt">SourceCharacter</span> elements as the original <span
- class="nt">IdentifierName</span>. All interpretations of <span class="nt">IdentifierName</span> within this specification
- are based upon their actual code points regardless of whether or not an escape sequence was used to contribute any
- particular code point.</p>
-
- <p>Two <span class="nt">IdentifierName</span> that are canonically equivalent according to the Unicode standard are
- <i>not</i> equal unless, after replacement of each <span class="nt">UnicodeEscapeSequence</span>, they are represented by
- the exact same sequence of code points.</p>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">IdentifierName</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">IdentifierStart</span></div>
- <div class="rhs"><span class="nt">IdentifierName</span> <span class="nt">IdentifierPart</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">IdentifierStart</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">UnicodeIDStart</span></div>
- <div class="rhs"><code class="t">$</code></div>
- <div class="rhs"><code class="t">_</code></div>
- <div class="rhs"><code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">IdentifierPart</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">UnicodeIDContinue</span></div>
- <div class="rhs"><code class="t">$</code></div>
- <div class="rhs"><code class="t">_</code></div>
- <div class="rhs"><code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
- <div class="rhs">&lt;ZWNJ&gt;</div>
- <div class="rhs">&lt;ZWJ&gt;</div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">UnicodeIDStart</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="gprose">any Unicode code point with the Unicode property &ldquo;ID_Start&rdquo;</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">UnicodeIDContinue</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="gprose">any Unicode code point with the Unicode property &ldquo;ID_Continue&rdquo;</span></div>
- </div>
-
- <p>The definitions of the nonterminal <span class="nt">UnicodeEscapeSequence</span> is given in <a
- href="#sec-literals-string-literals">11.8.4</a>.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The sets of code points with Unicode properties &ldquo;ID_Start&rdquo; and
- &ldquo;ID_Continue&rdquo; include, respectively, the code points with Unicode properties &ldquo;Other_ID_Start&rdquo; and
- &ldquo;Other_ID_Continue&rdquo;.</p>
- </div>
- </div>
-
- <section id="sec-identifier-names">
- <div class="front">
- <h1><span class="secnum" id="sec-11.6.1"><a href="#sec-identifier-names" title="link to this section">11.6.1</a></span>
- Identifier Names</h1>
- </div>
-
- <section id="sec-identifier-names-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-11.6.1.1"><a href="#sec-identifier-names-static-semantics-early-errors"
- title="link to this section">11.6.1.1</a></span> Static Semantics: Early Errors</h1>
- <div class="gp prod"><span class="nt">IdentifierStart</span> <span class="geq">::</span> <code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
- <ul>
- <li>
- <p>It is a Syntax Error if <span style="font-family: Times New Roman">SV(<i>UnicodeEscapeSequence</i>)</span> is none
- of <code>"$"</code>, or <code>"_"</code>, or the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
- href="#sec-utf16encoding">10.1.1</a>) of a code point that would be matched by the <span
- class="nt">UnicodeIDStart</span> lexical grammar production.</p>
- </li>
- </ul>
- <div class="gp prod"><span class="nt">IdentifierPart</span> <span class="geq">::</span> <code class="t">\</code> <span class="nt">UnicodeEscapeSequence</span></div>
- <ul>
- <li>
- <p>It is a Syntax Error if <span style="font-family: Times New Roman">SV(<i>UnicodeEscapeSequence</i>)</span> is none
- of <code>"$"</code>, or <code>"_"</code>, or the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
- href="#sec-utf16encoding">10.1.1</a>) of either &lt;ZWNJ&gt; or &lt;ZWJ&gt;, or the <a
- href="#sec-utf16encoding">UTF16Encoding</a> of a Unicode code point that would be matched by the <span
- class="nt">UnicodeIDContinue</span> lexical grammar production.</p>
- </li>
- </ul>
- </section>
-
- <section id="sec-identifier-names-static-semantics-stringvalue">
- <h1><span class="secnum" id="sec-11.6.1.2"><a href="#sec-identifier-names-static-semantics-stringvalue"
- title="link to this section">11.6.1.2</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
- <i>StringValue</i></h1>
-
- <p>See also: <a href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>, <a
- href="#sec-identifiers-static-semantics-stringvalue">12.1.4</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">IdentifierName</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">IdentifierStart</span></div>
- <div class="rhs"><span class="nt">IdentifierName</span> <span class="nt">IdentifierPart</span></div>
- </div>
-
- <ol class="proc">
- <li>Return the String value consisting of the sequence of code units corresponding to <i>IdentifierName</i>. In
- determining the sequence any occurrences of <code>\</code> <i>UnicodeEscapeSequence</i> are first replaced with the
- code point represented by the <i>UnicodeEscapeSequence</i> and then the code points of the entire
- <i>IdentifierName</i> are converted to code units by <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
- href="#sec-utf16encoding">10.1.1</a>) each code point.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-reserved-words">
- <div class="front">
- <h1><span class="secnum" id="sec-11.6.2"><a href="#sec-reserved-words" title="link to this section">11.6.2</a></span>
- Reserved Words</h1>
-
- <p>A reserved word is an <span class="nt">IdentifierName</span> that cannot be used as an <span
- class="nt">Identifier</span>.</p>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ReservedWord</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">Keyword</span></div>
- <div class="rhs"><span class="nt">FutureReservedWord</span></div>
- <div class="rhs"><span class="nt">NullLiteral</span></div>
- <div class="rhs"><span class="nt">BooleanLiteral</span></div>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The <i>ReservedWord</i> definitions are specified as literal sequences of specific
- <i>SourceCharacter</i> elements. A code point in a <i>ReservedWord</i> cannot be expressed by a <code>\</code>
- <i>UnicodeEscapeSequence</i>.</p>
- </div>
- </div>
-
- <section id="sec-keywords">
- <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>
- Keywords</h1>
-
- <p>The following tokens are ECMAScript keywords and may not be used as <span class="nt">Identifiers</span> in ECMAScript
- programs.</p>
-
- <h2>Syntax</h2>
- <div class="gp prod"><span class="nt">Keyword</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
-
- <figure>
- <table class="lightweight-table">
- <tr>
- <td><code>break</code></td>
- <td><code>do</code></td>
- <td><code>in</code></td>
- <td><code>typeof</code></td>
- </tr>
- <tr>
- <td><code>case</code></td>
- <td><code>else</code></td>
- <td><code>instanceof</code></td>
- <td><code>var</code></td>
- </tr>
- <tr>
- <td><code>catch</code></td>
- <td><code>export</code></td>
- <td><code>new</code></td>
- <td><code>void</code></td>
- </tr>
- <tr>
- <td><code>class</code></td>
- <td><code>extends</code></td>
- <td><code>return</code></td>
- <td><code>while</code></td>
- </tr>
- <tr>
- <td><code>const</code></td>
- <td><code>finally</code></td>
- <td><code>super</code></td>
- <td><code>with</code></td>
- </tr>
- <tr>
- <td><code>continue</code></td>
- <td><code>for</code></td>
- <td><code>switch</code></td>
- <td><code>yield</code></td>
- </tr>
- <tr>
- <td><code>debugger</code></td>
- <td><code>function</code></td>
- <td><code>this</code></td>
- <td></td>
- </tr>
- <tr>
- <td><code>default</code></td>
- <td><code>if</code></td>
- <td><code>throw</code></td>
- <td></td>
- </tr>
- <tr>
- <td><code>delete</code></td>
- <td><code>import</code></td>
- <td><code>try</code></td>
- <td></td>
- </tr>
- </table>
- </figure>
-
- <div class="note">
- <p><span class="nh">NOTE</span> In some contexts <code>yield</code> is given the semantics of an <i>Identifier</i>. See
- <a href="#sec-identifiers-static-semantics-early-errors">12.1.1</a>. In <a href="#sec-strict-mode-code">strict mode
- code</a>, <code>let</code> and <code>static</code> are treated as reserved keywords through static semantic restrictions
- (see <a href="#sec-identifiers-static-semantics-early-errors">12.1.1</a>, <a
- href="#sec-let-and-const-declarations-static-semantics-early-errors">13.2.1.1</a>, <a
- href="#sec-for-in-and-for-of-statements-static-semantics-early-errors">13.6.4.1</a>, and <a
- href="#sec-class-definitions-static-semantics-early-errors">14.5.1</a>) rather than the lexical grammar.</p>
- </div>
- </section>
-
- <section id="sec-future-reserved-words">
- <h1><span class="secnum" id="sec-11.6.2.2"><a href="#sec-future-reserved-words"
- title="link to this section">11.6.2.2</a></span> Future Reserved Words</h1>
-
- <p>The following tokens are reserved for used as keywords in future language extensions.</p>
-
- <h2>Syntax</h2>
- <div class="gp prod"><span class="nt">FutureReservedWord</span> <span class="geq">::</span></div>
-
- <figure>
- <table class="lightweight-table">
- <tr>
- <td><code>enum<br>await</code></td>
- <td></td>
- <td></td>
- <td></td>
- </tr>
- </table>
- </figure>
-
- <p><code>await</code> is only treated as a <span class="nt">FutureReservedWord</span> when <span class="nt">Module</span>
- is the goal symbol of the syntactic grammar.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Use of the following tokens within <a href="#sec-strict-mode-code">strict mode code</a>
- (<a href="#sec-strict-mode-code">see 10.2.1</a>) is also reserved. That usage is restricted using static semantic
- restrictions (<a href="#sec-identifiers-static-semantics-early-errors">see 12.1.1</a>) rather than the lexical
- grammar:</p>
- </div>
-
- <figure>
- <table class="lightweight-table">
- <tr>
- <td><code>implements</code></td>
- <td><code>package</code></td>
- <td><code>protected</code></td>
- <td></td>
- </tr>
- <tr>
- <td><code>interface</code></td>
- <td><code>private</code></td>
- <td><code>public</code></td>
- <td></td>
- </tr>
- </table>
- </figure>
- </section>
- </section>
- </section>
-
- <section id="sec-punctuators">
- <h1><span class="secnum" id="sec-11.7"><a href="#sec-punctuators" title="link to this section">11.7</a></span>
- Punctuators</h1>
- <h2>Syntax</h2>
- <div class="gp prod"><span class="nt">Punctuator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
-
- <figure>
- <table class="lightweight-table">
- <tr>
- <td><code>{</code></td>
- <td><code>(</code></td>
- <td><code>)</code></td>
- <td><code>[</code></td>
- <td><code>]</code></td>
- <td><code>.</code></td>
- </tr>
- <tr>
- <td><code>...</code></td>
- <td><code>;</code></td>
- <td><code>,</code></td>
- <td><code>&lt;</code></td>
- <td><code>&gt;</code></td>
- <td><code>&lt;=</code></td>
- </tr>
- <tr>
- <td><code>&gt;=</code></td>
- <td><code>==</code></td>
- <td><code>!=</code></td>
- <td><code>===</code></td>
- <td><code>!==</code></td>
- <td></td>
- </tr>
- <tr>
- <td><code>+</code></td>
- <td><code>-</code></td>
- <td><code>*</code></td>
- <td><code>%</code></td>
- <td><code>++</code></td>
- <td><code>--</code></td>
- </tr>
- <tr>
- <td><code>&lt;&lt;</code></td>
- <td><code>&gt;&gt;</code></td>
- <td><code>&gt;&gt;&gt;</code></td>
- <td><code>&amp;</code></td>
- <td><code>|</code></td>
- <td><code>^</code></td>
- </tr>
- <tr>
- <td><code>!</code></td>
- <td><code>~</code></td>
- <td><code>&amp;&amp;</code></td>
- <td><code>||</code></td>
- <td><code>?</code></td>
- <td><code>:</code></td>
- </tr>
- <tr>
- <td><code>=</code></td>
- <td><code>+=</code></td>
- <td><code>-=</code></td>
- <td><code>*=</code></td>
- <td><code>%=</code></td>
- <td><code>&lt;&lt;=</code></td>
- </tr>
- <tr>
- <td><code>&gt;&gt;=</code></td>
- <td><code>&gt;&gt;&gt;=</code></td>
- <td><code>&amp;=</code></td>
- <td><code>|=</code></td>
- <td><code>^=</code></td>
- <td><code>=&gt;</code></td>
- </tr>
- </table>
- </figure>
-
- <div class="gp prod"><span class="nt">DivPunctuator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
-
- <figure>
- <table class="lightweight-table">
- <tr>
- <td><code>/</code></td>
- <td><code>/=</code></td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- </tr>
- </table>
- </figure>
-
- <div class="gp prod"><span class="nt">RightBracePunctuator</span> <span class="geq">::</span></div>
-
- <figure>
- <table class="lightweight-table">
- <tr>
- <td><code>}</code></td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
- </tr>
- </table>
- </figure>
- </section>
-
- <section id="sec-ecmascript-language-lexical-grammar-literals">
- <div class="front">
- <h1><span class="secnum" id="sec-11.8"><a href="#sec-ecmascript-language-lexical-grammar-literals"
- title="link to this section">11.8</a></span> Literals</h1>
- </div>
-
- <section id="sec-null-literals">
- <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
- Literals</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NullLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">null</code></div>
- </div>
- </section>
-
- <section id="sec-boolean-literals">
- <h1><span class="secnum" id="sec-11.8.2"><a href="#sec-boolean-literals" title="link to this section">11.8.2</a></span>
- Boolean Literals</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">BooleanLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">true</code></div>
- <div class="rhs"><code class="t">false</code></div>
- </div>
- </section>
-
- <section id="sec-literals-numeric-literals">
- <div class="front">
- <h1><span class="secnum" id="sec-11.8.3"><a href="#sec-literals-numeric-literals"
- title="link to this section">11.8.3</a></span> Numeric Literals</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NumericLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">DecimalLiteral</span></div>
- <div class="rhs"><span class="nt">BinaryIntegerLiteral</span></div>
- <div class="rhs"><span class="nt">OctalIntegerLiteral</span></div>
- <div class="rhs"><span class="nt">HexIntegerLiteral</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DecimalLiteral</span> <span class="geq">::</span></div>
- <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>
- <div class="rhs"><code class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
- <div class="rhs"><span class="nt">DecimalIntegerLiteral</span> <span class="nt">ExponentPart</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">0</code></div>
- <div class="rhs"><span class="nt">NonZeroDigit</span> <span class="nt">DecimalDigits</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DecimalDigits</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">DecimalDigit</span></div>
- <div class="rhs"><span class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NonZeroDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ExponentPart</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ExponentIndicator</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <div class="rhs"><code class="t">e</code> <code class="t">E</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SignedInteger</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">DecimalDigits</span></div>
- <div class="rhs"><code class="t">+</code> <span class="nt">DecimalDigits</span></div>
- <div class="rhs"><code class="t">-</code> <span class="nt">DecimalDigits</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">0b</code> <span class="nt">BinaryDigits</span></div>
- <div class="rhs"><code class="t">0B</code> <span class="nt">BinaryDigits</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">BinaryDigits</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">BinaryDigit</span></div>
- <div class="rhs"><span class="nt">BinaryDigits</span> <span class="nt">BinaryDigit</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">BinaryDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <div class="rhs"><code class="t">0</code> <code class="t">1</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">0o</code> <span class="nt">OctalDigits</span></div>
- <div class="rhs"><code class="t">0O</code> <span class="nt">OctalDigits</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">OctalDigits</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">OctalDigit</span></div>
- <div class="rhs"><span class="nt">OctalDigits</span> <span class="nt">OctalDigit</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">OctalDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">0x</code> <span class="nt">HexDigits</span></div>
- <div class="rhs"><code class="t">0X</code> <span class="nt">HexDigits</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">HexDigits</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">HexDigit</span></div>
- <div class="rhs"><span class="nt">HexDigits</span> <span class="nt">HexDigit</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">HexDigit</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <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>
- </div>
-
- <p>The <span class="nt">SourceCharacter</span> immediately following a <span class="nt">NumericLiteral</span> must not be
- an <span class="nt">IdentifierStart</span> or <span class="nt">DecimalDigit</span>.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> For example:</p>
-
- <pre>3in</pre>
-
- <p>is an error and not the two input elements <code>3</code> and <code>in</code>.</p>
- </div>
-
- <p>A conforming implementation, when processing <a href="#sec-strict-mode-code">strict mode code</a> (<a
- href="#sec-strict-mode-code">see 10.2.1</a>), must not extend, as described in <a
- href="#sec-additional-syntax-numeric-literals">B.1.1</a>, the syntax of <span class="nt">NumericLiteral</span> to include
- <i>Legacy<span style="font-family: Times New Roman">OctalIntegerLiteral</span></i>, nor extend the syntax of <span
- class="nt">DecimalIntegerLiteral</span> to include <span class="nt">NonOctalDecimalIntegerLiteral</span>.</p>
- </div>
-
- <section id="sec-static-semantics-mv-s">
- <h1><span class="secnum" id="sec-11.8.3.1"><a href="#sec-static-semantics-mv-s"
- title="link to this section">11.8.3.1</a></span> Static Semantics: MV&rsquo;s</h1>
-
- <p>A numeric literal stands for a value of the Number type. This value is determined in two steps: first, a mathematical
- value (MV) is derived from the literal; second, this mathematical value is rounded as described below.</p>
-
- <ul>
- <li>
- <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
- class="nt">DecimalLiteral</span></span> is the MV of <i>DecimalLiteral</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
- class="nt">BinaryIntegerLiteral</span></span> is the MV of <i>BinaryIntegerLiteral</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
- class="nt">OctalIntegerLiteral</span></span> is the MV of <i>OctalIntegerLiteral</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">NumericLiteral</span> <span class="geq">::</span> <span
- class="nt">HexIntegerLiteral</span></span> is the MV of <i>HexIntegerLiteral</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
- class="nt">DecimalIntegerLiteral</span> <code class="t">.</code></span> is the MV of <i>DecimalIntegerLiteral</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
- class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">DecimalDigits</span></span> is the
- MV of <i>DecimalIntegerLiteral</i> plus (the MV of <i>DecimalDigits</i> &times; 10<sup>&ndash;<i>n</i></sup>), where
- <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
- class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">ExponentPart</span></span> is the MV
- of <i>DecimalIntegerLiteral</i> &times; 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
- class="nt">DecimalIntegerLiteral</span> <code class="t">.</code> <span class="nt">DecimalDigits</span> <span
- class="nt">ExponentPart</span></span> is (the MV of <i>DecimalIntegerLiteral</i> plus (the MV of <i>DecimalDigits</i>
- &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
- <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <code
- class="t">.</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i> &times;
- 10<sup>&ndash;<i>n</i></sup>, where <i>n</i> is the number of code points in <i>DecimalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <code
- class="t">.</code> <span class="nt">DecimalDigits</span> <span class="nt">ExponentPart</span></span> is the MV of
- <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
- <i>DecimalDigits</i> and <i>e</i> is the MV of <i>ExponentPart</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
- class="nt">DecimalIntegerLiteral</span></span> is the MV of <i>DecimalIntegerLiteral</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalLiteral</span> <span class="geq">::</span> <span
- class="nt">DecimalIntegerLiteral</span> <span class="nt">ExponentPart</span></span> is the MV of
- <i>DecimalIntegerLiteral</i> &times; 10<sup><i>e</i></sup>, where <i>e</i> is the MV of <i>ExponentPart</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <code
- class="t">0</code></span> is 0.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <span
- class="nt">NonZeroDigit</span></span> is the MV of <i>NonZeroDigit.</i></p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalIntegerLiteral</span> <span class="geq">::</span> <span
- class="nt">NonZeroDigit</span> <span class="nt">DecimalDigits</span></span> is (the MV of <i>NonZeroDigit</i> &times;
- 10<sup><i>n</i></sup>) plus the MV of <i>DecimalDigits</i>, where <i>n</i> is the number of code points in
- <i>DecimalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigits</span> <span class="geq">::</span> <span
- class="nt">DecimalDigit</span></span> is the MV of <i>DecimalDigit</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigits</span> <span class="geq">::</span> <span
- class="nt">DecimalDigits</span> <span class="nt">DecimalDigit</span></span> is (the MV of <i>DecimalDigits</i> &times;
- 10) plus the MV of <i>DecimalDigit</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">ExponentPart</span> <span class="geq">::</span> <span
- class="nt">ExponentIndicator</span> <span class="nt">SignedInteger</span></span> is the MV of
- <i>SignedInteger</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <span
- class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <code
- class="t">+</code> <span class="nt">DecimalDigits</span></span> is the MV of <i>DecimalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">SignedInteger</span> <span class="geq">::</span> <code
- class="t">-</code> <span class="nt">DecimalDigits</span></span> is the negative of the MV of <i>DecimalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">0</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">0</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span class="geq">::</span>
- <code class="t">0</code></span> or of <span class="prod"><span class="nt">BinaryDigit</span> <span
- class="geq">::</span> <code class="t">0</code></span> is 0.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">1</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">1</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">1</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
- class="geq">::</span> <code class="t">1</code></span> or<br>of <span class="prod"><span class="nt">BinaryDigit</span>
- <span class="geq">::</span> <code class="t">1</code></span> is 1.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">2</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">2</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">2</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
- class="geq">::</span> <code class="t">2</code></span> is 2.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">3</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">3</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">3</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
- class="geq">::</span> <code class="t">3</code></span> is 3.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">4</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">4</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">4</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
- class="geq">::</span> <code class="t">4</code></span> is 4.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">5</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">5</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">5</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
- class="geq">::</span> <code class="t">5</code></span> is 5.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">6</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">6</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">6</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
- class="geq">::</span> <code class="t">6</code></span> is 6.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">7</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">7</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">7</code></span> or of <span class="prod"><span class="nt">OctalDigit</span> <span
- class="geq">::</span> <code class="t">7</code></span> is 7.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">8</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">8</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">8</code></span> is 8.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">DecimalDigit</span> <span class="geq">::</span> <code
- class="t">9</code></span> or of <span class="prod"><span class="nt">NonZeroDigit</span> <span class="geq">::</span>
- <code class="t">9</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span>
- <code class="t">9</code></span> is 9.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">a</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">A</code></span> is 10.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">b</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">B</code></span> is 11.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">c</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">C</code></span> is 12.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">d</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">D</code></span> is 13.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">e</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">E</code></span> is 14.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">f</code></span> or of <span class="prod"><span class="nt">HexDigit</span> <span class="geq">::</span> <code
- class="t">F</code></span> is 15.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span> <code
- class="t">0b</code> <span class="nt">BinaryDigits</span></span> is the MV of <i>BinaryDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">BinaryIntegerLiteral</span> <span class="geq">::</span> <code
- class="t">0B</code> <span class="nt">BinaryDigits</span></span> is the MV of <i>BinaryDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">BinaryDigits</span> <span class="geq">::</span> <span
- class="nt">BinaryDigit</span></span> is the MV of <i>BinaryDigit</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">BinaryDigits</span> <span class="geq">::</span> <span
- class="nt">BinaryDigits</span> <span class="nt">BinaryDigit</span></span> is (the MV of <i>BinaryDigits</i> &times; 2)
- plus the MV of <i>BinaryDigit</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span> <code
- class="t">0o</code> <span class="nt">OctalDigits</span></span> is the MV of <i>OctalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">OctalIntegerLiteral</span> <span class="geq">::</span> <code
- class="t">0O</code> <span class="nt">OctalDigits</span></span> is the MV of <i>OctalDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">OctalDigits</span> <span class="geq">::</span> <span
- class="nt">OctalDigit</span></span> is the MV of <i>OctalDigit</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">OctalDigits</span> <span class="geq">::</span> <span
- class="nt">OctalDigits</span> <span class="nt">OctalDigit</span></span> is (the MV of <i>OctalDigits</i> &times; 8)
- plus the MV of <i>OctalDigit</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span> <code
- class="t">0x</code> <span class="nt">HexDigits</span></span> is the MV of <i>HexDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexIntegerLiteral</span> <span class="geq">::</span> <code
- class="t">0X</code> <span class="nt">HexDigits</span></span> is the MV of <i>HexDigits</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
- class="nt">HexDigit</span></span> is the MV of <i>HexDigit</i>.</p>
- </li>
-
- <li>
- <p>The MV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
- class="nt">HexDigits</span> <span class="nt">HexDigit</span></span> is (the MV of <i>HexDigits</i> &times; 16) plus
- the MV of <i>HexDigit</i>.</p>
- </li>
- </ul>
-
- <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
- MV is 0, then the rounded value is <span class="value">+0</span>; otherwise, the rounded value must be the Number value
- for the MV (as specified in <a href="#sec-ecmascript-language-types-number-type">6.1.6</a>), unless the literal is a <span
- class="nt">DecimalLiteral</span> and the literal has more than 20 significant digits, in which case the Number value may
- be either the Number value for the MV of a literal produced by replacing each significant digit after the 20th with a
- <code>0</code> digit or the Number value for the MV of a literal produced by replacing each significant digit after the
- 20th with a <code>0</code> digit and then incrementing the literal at the 20th significant digit position. A digit is
- <i>significant</i> if it is not part of an <span class="nt">ExponentPart</span> and</p>
-
- <ul>
- <li>it is not <code>0</code>; or</li>
- <li>there is a nonzero digit to its left and there is a nonzero digit, not in the <i>ExponentPart</i>, to its
- right.</li>
- </ul>
- </section>
- </section>
-
- <section id="sec-literals-string-literals">
- <div class="front">
- <h1><span class="secnum" id="sec-11.8.4"><a href="#sec-literals-string-literals"
- title="link to this section">11.8.4</a></span> String Literals</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A string literal is zero or more Unicode code points enclosed in single or double
- quotes. Unicode code points may also be represented by an escape sequence. All <span style="font-family:
- sans-serif">code points</span> may appear literally in a string literal except for the closing quote <span
- style="font-family: sans-serif">code points</span>, U+005C (REVERSE SOLIDUS), U+000D (carriage return), U+2028 (line
- separator), U+2029 (paragraph separator), and U+000A (line feed). Any <span style="font-family: sans-serif">code
- points</span> may appear in the form of an escape sequence. String literals evaluate to ECMAScript String values. When
- generating these string values Unicode code points are UTF-16 encoded as defined in <a
- href="#sec-utf16encoding">10.1.1</a>. Code points belonging to the Basic Multilingual Plane are encoded as a single code
- unit element of the string. All other code points are encoded as two code unit elements of the string.</p>
- </div>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StringLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">"</code> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">"</code></div>
- <div class="rhs"><code class="t">'</code> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">'</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">DoubleStringCharacter</span> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">SingleStringCharacter</span> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span></div>
- <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>
- <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
- <div class="rhs"><span class="nt">LineContinuation</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span></div>
- <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>
- <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
- <div class="rhs"><span class="nt">LineContinuation</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">LineContinuation</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">\</code> <span class="nt">LineTerminatorSequence</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">EscapeSequence</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">CharacterEscapeSequence</span></div>
- <div class="rhs"><code class="t">0</code> <span class="grhsannot">[lookahead &notin; <span class="nt">DecimalDigit</span>]</span></div>
- <div class="rhs"><span class="nt">HexEscapeSequence</span></div>
- <div class="rhs"><span class="nt">UnicodeEscapeSequence</span></div>
- </div>
-
- <p>A conforming implementation, when processing <a href="#sec-strict-mode-code">strict mode code</a> (<a
- href="#sec-strict-mode-code">see 10.2.1</a>), must not extend the syntax of <span class="nt">EscapeSequence</span> to
- include <i>Legacy<span style="font-family: Times New Roman">OctalEscapeSequence</span></i> as described in <a
- href="#sec-additional-syntax-string-literals">B.1.2</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">SingleEscapeCharacter</span></div>
- <div class="rhs"><span class="nt">NonEscapeCharacter</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SingleEscapeCharacter</span> <span class="geq">::</span> <span class="grhsmod">one of</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NonEscapeCharacter</span> <span class="geq">::</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">EscapeCharacter</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">SingleEscapeCharacter</span></div>
- <div class="rhs"><span class="nt">DecimalDigit</span></div>
- <div class="rhs"><code class="t">x</code></div>
- <div class="rhs"><code class="t">u</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">u</code> <span class="nt">Hex4Digits</span></div>
- <div class="rhs"><code class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Hex4Digits</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></div>
- </div>
-
- <p>The definition of the nonterminal <span class="nt">HexDigit</span> is given in <a
- href="#sec-literals-numeric-literals">11.8.3</a>. <span class="nt">SourceCharacter</span> is defined in <a
- href="#sec-source-text">10.1</a>.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A line terminator <span style="font-family: sans-serif">code point</span> cannot appear
- in a string literal, except as part of a <i>LineContinuation</i> to produce the empty <span style="font-family:
- sans-serif">code points</span> sequence. The proper way to cause a line terminator <span style="font-family:
- sans-serif">code point</span> to be part of the String value of a string literal is to use an escape sequence such as
- <code>\n</code> or <code>\u000A</code>.</p>
- </div>
- </div>
-
- <section id="sec-string-literals-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-11.8.4.1"><a href="#sec-string-literals-static-semantics-early-errors"
- title="link to this section">11.8.4.1</a></span> Static Semantics: Early Errors</h1>
- <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>
- <ul>
- <li>It is a Syntax Error if the MV of <span class="nt">HexDigits</span> &gt; <span style="font-family: Times New
- Roman">1114111<i>.</i></span></li>
- </ul>
- </section>
-
- <section id="sec-string-literals-static-semantics-stringvalue">
- <h1><span class="secnum" id="sec-11.8.4.2"><a href="#sec-string-literals-static-semantics-stringvalue"
- title="link to this section">11.8.4.2</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
- <i>StringValue</i></h1>
-
- <p>See also: <a href="#sec-identifier-names-static-semantics-stringvalue">11.6.1.2</a>, <a
- href="#sec-identifiers-static-semantics-stringvalue">12.1.4</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">StringLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">"</code> <span class="nt">DoubleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">"</code></div>
- <div class="rhs"><code class="t">'</code> <span class="nt">SingleStringCharacters</span><sub class="g-opt">opt</sub> <code class="t">'</code></div>
- </div>
-
- <ol class="proc">
- <li>Return the String value whose elements are the SV of this <i>StringLiteral</i>.</li>
- </ol>
- </section>
-
- <section id="sec-static-semantics-sv-s">
- <h1><span class="secnum" id="sec-11.8.4.3"><a href="#sec-static-semantics-sv-s"
- title="link to this section">11.8.4.3</a></span> Static Semantics: <i>SV&rsquo;s</i></h1>
-
- <p>A string literal stands for a value of the String type. The String value (SV) of the literal is described in terms of
- code unit values contributed by the various parts of the string literal. As part of this process, some Unicode code points
- within the string literal are interpreted as having a mathematical value (MV), as described below or in <a
- href="#sec-literals-numeric-literals">11.8.3</a>.</p>
-
- <ul>
- <li>
- <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
- class="t">""</code></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
- class="t">''</code></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
- class="t">"</code> <span class="nt">DoubleStringCharacters</span> <code class="t">"</code></span> is the SV of
- <i>DoubleStringCharacters</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">StringLiteral</span> <span class="geq">::</span> <code
- class="t">'</code> <span class="nt">SingleStringCharacters</span> <code class="t">'</code></span> is the SV of
- <i>SingleStringCharacters</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span> <span
- class="nt">DoubleStringCharacter</span></span> is a sequence of one or two code units that is the SV of
- <i>DoubleStringCharacter</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacters</span> <span class="geq">::</span> <span
- class="nt">DoubleStringCharacter</span> <span class="nt">DoubleStringCharacters</span></span> is a sequence of one or
- two code units that is the SV of <i>DoubleStringCharacter</i> followed by all the code units in the SV of
- <i>DoubleStringCharacters</i> in order.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span> <span
- class="nt">SingleStringCharacter</span></span> is a sequence of one or two code units that is the SV of
- <i>SingleStringCharacter</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">SingleStringCharacters</span> <span class="geq">::</span> <span
- class="nt">SingleStringCharacter</span> <span class="nt">SingleStringCharacters</span></span> is a sequence of one or
- two code units that is the SV of <i>SingleStringCharacter</i> followed by all the code units in the SV of
- <i>SingleStringCharacters</i> in order.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <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></span> is the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
- href="#sec-utf16encoding">10.1.1</a>) of the code point value of <i>SourceCharacter</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <code
- class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of the <i>EscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">DoubleStringCharacter</span> <span class="geq">::</span> <span
- class="nt">LineContinuation</span></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <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></span> is the <a href="#sec-utf16encoding">UTF16Encoding</a> (<a
- href="#sec-utf16encoding">10.1.1</a>) of the code point value of <i>SourceCharacter</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <code
- class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of the <i>EscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">SingleStringCharacter</span> <span class="geq">::</span> <span
- class="nt">LineContinuation</span></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
- class="nt">CharacterEscapeSequence</span></span> is the SV of the <i>CharacterEscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <code
- class="t">0</code></span> is the code unit value 0.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
- class="nt">HexEscapeSequence</span></span> is the SV of the <i>HexEscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
- class="nt">UnicodeEscapeSequence</span></span> is the SV of the <i>UnicodeEscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
- class="nt">SingleEscapeCharacter</span></span> is the code unit whose value is determined by the
- <i>SingleEscapeCharacter</i> according to { REF _Ref365803173 \h }<a href="#table-34">Table 34</a>.</p>
- </li>
- </ul>
-
- <figure>
- <figcaption><span id="table-34">Table 34</span> &mdash; String Single Character Escape Sequences</figcaption>
- <table class="real-table">
- <tr>
- <th>Escape Sequence</th>
- <th>Code Unit Value</th>
- <th>Unicode Character Name</th>
- <th>Symbol</th>
- </tr>
- <tr>
- <td><code>\b</code></td>
- <td><code>0x0008</code></td>
- <td>BACKSPACE</td>
- <td>&lt;BS&gt;</td>
- </tr>
- <tr>
- <td><code>\t</code></td>
- <td><code>0x0009</code></td>
- <td>CHARACTER TABULATION</td>
- <td>&lt;HT&gt;</td>
- </tr>
- <tr>
- <td><code>\n</code></td>
- <td><code>0x000A</code></td>
- <td>line feed (lf)</td>
- <td>&lt;LF&gt;</td>
- </tr>
- <tr>
- <td><code>\v</code></td>
- <td><code>0x000B</code></td>
- <td>LINE TABULATION</td>
- <td>&lt;VT&gt;</td>
- </tr>
- <tr>
- <td><code>\f</code></td>
- <td><code>0x000C</code></td>
- <td>form feed (ff)</td>
- <td>&lt;FF&gt;</td>
- </tr>
- <tr>
- <td><code>\r</code></td>
- <td><code>0x000D</code></td>
- <td>carriage return (cr)</td>
- <td>&lt;CR&gt;</td>
- </tr>
- <tr>
- <td><code>\"</code></td>
- <td><code>0x0022</code></td>
- <td>quotation Mark</td>
- <td><code>"</code></td>
- </tr>
- <tr>
- <td><code>\'</code></td>
- <td><code>0x0027</code></td>
- <td>apostrophe</td>
- <td><code>'</code></td>
- </tr>
- <tr>
- <td><code>\\</code></td>
- <td><code>0x005C</code></td>
- <td>REverse Solidus</td>
- <td><code>\</code></td>
- </tr>
- </table>
- </figure>
-
- <ul>
- <li>
- <p>The SV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
- class="nt">NonEscapeCharacter</span></span> is the SV of the <i>NonEscapeCharacter</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">NonEscapeCharacter</span> <span class="geq">::</span> <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></span> is the <a
- href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
- <i>SourceCharacter</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span> <code
- class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></span> is the code unit value
- that is (16 times the MV of the first <i>HexDigit</i>) plus the MV of the second <i>HexDigit</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
- class="t">u</code> <span class="nt">Hex4Digits</span></span> is the SV of <var>Hex4Digits.</var></p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">Hex4Digits</span> <span class="geq">::</span> <span
- class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span
- class="nt">HexDigit</span></span> is the code unit value that is (4096 times the MV of the first <i>HexDigit</i>) plus
- (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
- the fourth <i>HexDigit</i>.</p>
- </li>
-
- <li>
- <p>The SV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
- class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></span> is the <a
- href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the MV of
- <i>HexDigits</i>.</p>
- </li>
- </ul>
- </section>
- </section>
-
- <section id="sec-literals-regular-expression-literals">
- <div class="front">
- <h1><span class="secnum" id="sec-11.8.5"><a href="#sec-literals-regular-expression-literals"
- title="link to this section">11.8.5</a></span> Regular Expression Literals</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A regular expression literal is an input element that is converted to a RegExp object
- (<a href="#sec-regexp-regular-expression-objects">see 21.2</a>) each time the literal is evaluated. Two regular
- expression literals in a program evaluate to regular expression objects that never compare as <code>===</code> to each
- other even if the two literals' contents are identical. A RegExp object may also be created at runtime by <code>new
- RegExp</code> or calling the <code>RegExp</code> constructor as a function (<a href="#sec-regexp-constructor">see
- 21.2.3</a>).</p>
- </div>
-
- <p>The productions below describe the syntax for a regular expression literal and are used by the input element scanner to
- find the end of the regular expression literal. The source text comprising the <span
- class="nt">RegularExpressionBody</span> and the <span class="nt">RegularExpressionFlags</span> are subsequently parsed
- again using the more stringent ECMAScript Regular Expression grammar (<a href="#sec-patterns">21.2.1</a>).</p>
-
- <p>An implementation may extend the ECMAScript Regular Expression grammar defined in <a href="#sec-patterns">21.2.1</a>,
- but it must not extend the <span class="nt">RegularExpressionBody</span> and <span
- class="nt">RegularExpressionFlags</span> productions defined below or the productions used by these productions.</p>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionLiteral</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">/</code> <span class="nt">RegularExpressionBody</span> <code class="t">/</code> <span class="nt">RegularExpressionFlags</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionBody</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">RegularExpressionFirstChar</span> <span class="nt">RegularExpressionChars</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionChars</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="grhsannot">[empty]</span></div>
- <div class="rhs"><span class="nt">RegularExpressionChars</span> <span class="nt">RegularExpressionChar</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionFirstChar</span> <span class="geq">::</span></div>
- <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>
- <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
- <div class="rhs"><span class="nt">RegularExpressionClass</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionChar</span> <span class="geq">::</span></div>
- <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>
- <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
- <div class="rhs"><span class="nt">RegularExpressionClass</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionBackslashSequence</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">\</code> <span class="nt">RegularExpressionNonTerminator</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionNonTerminator</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">SourceCharacter</span> <span class="grhsmod">but not</span> <span class="nt">LineTerminator</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionClass</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">[</code> <span class="nt">RegularExpressionClassChars</span> <code class="t">]</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionClassChars</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="grhsannot">[empty]</span></div>
- <div class="rhs"><span class="nt">RegularExpressionClassChars</span> <span class="nt">RegularExpressionClassChar</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionClassChar</span> <span class="geq">::</span></div>
- <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>
- <div class="rhs"><span class="nt">RegularExpressionBackslashSequence</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">RegularExpressionFlags</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="grhsannot">[empty]</span></div>
- <div class="rhs"><span class="nt">RegularExpressionFlags</span> <span class="nt">IdentifierPart</span></div>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Regular expression literals may not be empty; instead of representing an empty regular
- expression literal, the code unit sequence <code>//</code> starts a single-line comment. To specify an empty regular
- expression, use: <code>/(?:)/</code>.</p>
- </div>
- </div>
-
- <section id="sec-literals-regular-expression-literals-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-11.8.5.1"><a
- href="#sec-literals-regular-expression-literals-static-semantics-early-errors"
- title="link to this section">11.8.5.1</a></span> Static Semantics: Early Errors</h1>
- <div class="gp prod"><span class="nt">RegularExpressionFlags</span> <span class="geq">::</span> <span class="nt">RegularExpressionFlags</span> <span class="nt">IdentifierPart</span></div>
- <ul>
- <li>It is a Syntax Error if <span class="nt">IdentifierPart</span> contains a Unicode escape sequence<var>.</var></li>
- </ul>
- </section>
-
- <section id="sec-static-semantics-bodytext">
- <h1><span class="secnum" id="sec-11.8.5.2"><a href="#sec-static-semantics-bodytext"
- title="link to this section">11.8.5.2</a></span> Static Semantics: <i>BodyText</i></h1>
- <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>
- <ol class="proc">
- <li>Return the source text that was recognized as <i>RegularExpressionBody</i>.</li>
- </ol>
- </section>
-
- <section id="sec-static-semantics-flagtext">
- <h1><span class="secnum" id="sec-11.8.5.3"><a href="#sec-static-semantics-flagtext"
- title="link to this section">11.8.5.3</a></span> Static Semantics: <i>FlagText</i></h1>
- <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>
- <ol class="proc">
- <li>Return the source text that was recognized as <i>RegularExpressionFlags</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-template-literal-lexical-components">
- <div class="front">
- <h1><span class="secnum" id="sec-11.8.6"><a href="#sec-template-literal-lexical-components"
- title="link to this section">11.8.6</a></span> Template Literal Lexical Components</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Template</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">NoSubstitutionTemplate</span></div>
- <div class="rhs"><span class="nt">TemplateHead</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">`</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">`</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateHead</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">`</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">${</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateSubstitutionTail</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">TemplateMiddle</span></div>
- <div class="rhs"><span class="nt">TemplateTail</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateMiddle</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">}</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">${</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateTail</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">}</code> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub> <code class="t">`</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateCharacters</span> <span class="geq">::</span></div>
- <div class="rhs"><span class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span><sub class="g-opt">opt</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateCharacter</span> <span class="geq">::</span></div>
- <div class="rhs"><code class="t">$</code> <span class="grhsannot">[lookahead &ne; { ]</span></div>
- <div class="rhs"><code class="t">\</code> <span class="nt">EscapeSequence</span></div>
- <div class="rhs"><span class="nt">LineContinuation</span></div>
- <div class="rhs"><span class="nt">LineTerminatorSequence</span></div>
- <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>
- </div>
-
- <p>A conforming implementation must not use the extended definition of <span class="nt">EscapeSequence</span> described in
- <a href="#sec-additional-syntax-string-literals">B.1.2</a> when parsing a <span class="nt">TemplateCharacter</span>.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> <i>TemplateSubstitutionTail</i> is used by the <i>InputElementTemplateTail</i>
- alternative lexical goal.</p>
- </div>
- </div>
-
- <section id="sec-static-semantics-tv-s-and-trv-s">
- <h1><span class="secnum" id="sec-11.8.6.1"><a href="#sec-static-semantics-tv-s-and-trv-s"
- title="link to this section">11.8.6.1</a></span> Static Semantics: <i>TV&rsquo;s and TRV&rsquo;s</i></h1>
-
- <p>A template literal component is interpreted as a sequence of Unicode code points. The Template Value (TV) of a literal
- component is described in terms of code unit values (SV, <a href="#sec-literals-string-literals">11.8.4</a>) contributed
- by the various parts of the template literal component. As part of this process, some Unicode code points within the
- template component are interpreted as having a mathematical value (MV, <a
- href="#sec-literals-numeric-literals">11.8.3</a>). In determining a TV, escape sequences are replaced by the UTF-16 code
- unit(s) of the Unicode code point represented by the escape sequence. The Template Raw Value (TRV) is similar to a
- Template Value with the difference that in TRVs escape sequences are interpreted literally.</p>
-
- <ul>
- <li>
- <p>The TV and TRV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span>
- <code class="t">``</code></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The TV and TRV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
- class="t">`${</code></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The TV and TRV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
- class="t">}${</code></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The TV and TRV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
- class="t">}`</code></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span> <code
- class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TV of
- <i>TemplateCharacters</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
- class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TV of
- <i>TemplateCharacters</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
- class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TV of
- <i>TemplateCharacters</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
- class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TV of
- <i>TemplateCharacters</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
- class="nt">TemplateCharacter</span></span> is the TV of <i>TemplateCharacter</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
- class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span></span> is a sequence consisting of the
- code units in the TV of <i>TemplateCharacter</i> followed by all the code units in the TV of <i>TemplateCharacters</i>
- in order.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <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></span> is the <a
- href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
- <i>SourceCharacter</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
- class="t">$</code></span> is the code unit value 0x0024.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
- class="t">\</code> <span class="nt">EscapeSequence</span></span> is the SV of <i>EscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
- class="nt">LineContinuation</span></span> is the TV of <i>LineContinuation</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
- class="nt">LineTerminatorSequence</span></span> is the TRV of <i>LineTerminatorSequence</i>.</p>
- </li>
-
- <li>
- <p>The TV of <span class="prod"><span class="nt">LineContinuation</span> <span class="geq">::</span> <code
- class="t">\</code> <span class="nt">LineTerminatorSequence</span></span> is the empty code unit sequence.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">NoSubstitutionTemplate</span> <span class="geq">::</span> <code
- class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TRV of
- <i>TemplateCharacters</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateHead</span> <span class="geq">::</span> <code
- class="t">`</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TRV of
- <i>TemplateCharacters</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateMiddle</span> <span class="geq">::</span> <code
- class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">${</code></span> is the TRV of
- <i>TemplateCharacters</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateTail</span> <span class="geq">::</span> <code
- class="t">}</code> <span class="nt">TemplateCharacters</span> <code class="t">`</code></span> is the TRV of
- <i>TemplateCharacters</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
- class="nt">TemplateCharacter</span></span> is the TRV of <i>TemplateCharacter</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateCharacters</span> <span class="geq">::</span> <span
- class="nt">TemplateCharacter</span> <span class="nt">TemplateCharacters</span></span> is a sequence consisting of the
- code units in the TRV of <i>TemplateCharacter</i> followed by all the code units in the TRV of
- <i>TemplateCharacters,</i> in order.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <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></span> is the <a
- href="#sec-utf16encoding">UTF16Encoding</a> (<a href="#sec-utf16encoding">10.1.1</a>) of the code point value of
- <i>SourceCharacter</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
- class="t">$</code></span> is the code unit value 0x0024.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <code
- class="t">\</code> <span class="nt">EscapeSequence</span></span> is the sequence consisting of the code unit value
- 0x005C followed by the code units of TRV of <i>EscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
- class="nt">LineContinuation</span></span> is the TRV of <i>LineContinuation</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">TemplateCharacter</span> <span class="geq">::</span> <span
- class="nt">LineTerminatorSequence</span></span> is the TRV of <i>LineTerminatorSequence</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
- class="nt">CharacterEscapeSequence</span></span> is the TRV of the <i>CharacterEscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <code
- class="t">0</code></span> is the code unit value 0x0030.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
- class="nt">HexEscapeSequence</span></span> is the TRV of the <i>HexEscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">EscapeSequence</span> <span class="geq">::</span> <span
- class="nt">UnicodeEscapeSequence</span></span> is the TRV of the <i>UnicodeEscapeSequence</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
- class="nt">SingleEscapeCharacter</span></span> is the TRV of the <i>SingleEscapeCharacter</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">CharacterEscapeSequence</span> <span class="geq">::</span> <span
- class="nt">NonEscapeCharacter</span></span> is the SV of the <i>NonEscapeCharacter</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">SingleEscapeCharacter</span> <span class="geq">::</span> <span
- class="grhsmod">one of</span> <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></span> is the SV of the <i>SourceCharacter</i> that is that single code point.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">HexEscapeSequence</span> <span class="geq">::</span> <code
- class="t">x</code> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span></span> is the sequence
- consisting of code unit value 0x0078 followed by TRV of the first <i>HexDigit</i> followed by the TRV of the second
- <i>HexDigit</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
- class="t">u</code> <span class="nt">Hex4Digits</span></span> is the sequence consisting of code unit value 0x0075
- followed by TRV of <span class="nt">Hex4Digits</span>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">UnicodeEscapeSequence</span> <span class="geq">::</span> <code
- class="t">u{</code> <span class="nt">HexDigits</span> <code class="t">}</code></span> is the sequence consisting of
- code unit value 0x0075 followed by code unit value 0x007B followed by TRV of <i>HexDigits</i> followed by code unit
- value 0x007D.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">Hex4Digits</span> <span class="geq">::</span> <span
- class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span class="nt">HexDigit</span> <span
- class="nt">HexDigit</span></span> is the sequence consisting of the TRV of the first <i>HexDigit</i> followed by the
- TRV of the second <i>HexDigit</i> followed by the TRV of the third <i>HexDigit</i> followed by the TRV of the fourth
- <span class="nt">HexDigit</span>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
- class="nt">HexDigit</span></span> is the TRV of <i>HexDigit</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">HexDigits</span> <span class="geq">::</span> <span
- class="nt">HexDigits</span> <span class="nt">HexDigit</span></span> is the sequence consisting of TRV of
- <i>HexDigits</i> followed by TRV of <i>HexDigit</i>.</p>
- </li>
-
- <li>
- <p>The TRV of a <i>HexDigit</i> is the SV of the <i>SourceCharacter</i> that is that <i>HexDigit</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">LineContinuation</span> <span class="geq">::</span> <code
- class="t">\</code> <span class="nt">LineTerminatorSequence</span></span> is the sequence consisting of the code unit
- value 0x005C followed by the code units of TRV of <i>LineTerminatorSequence</i>.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
- &lt;LF&gt; is the code unit value 0x000A.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
- &lt;CR&gt; is the code unit value 0x000A.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
- &lt;LS&gt; is the code unit value 0x2028.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
- &lt;PS&gt; is the code unit value 0x2029.</p>
- </li>
-
- <li>
- <p>The TRV of <span class="prod"><span class="nt">LineTerminatorSequence</span> <span class="geq">::</span></span>
- &lt;CR&gt;&lt;LF&gt; is the sequence consisting of the code unit value 0x000A.</p>
- </li>
- </ul>
-
- <div class="note">
- <p><span class="nh">NOTE</span> TV excludes the code units of <i>LineContinuation</i> while TRV includes them.
- &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
- explicit <i>EscapeSequence</i> is needed to include a &lt;CR&gt; or &lt;CR&gt;&lt;LF&gt; sequence.</p>
- </div>
- </section>
- </section>
- </section>
-
- <section id="sec-automatic-semicolon-insertion">
- <div class="front">
- <h1><span class="secnum" id="sec-11.9"><a href="#sec-automatic-semicolon-insertion"
- title="link to this section">11.9</a></span> Automatic Semicolon Insertion</h1>
-
- <p>Certain ECMAScript statements (empty statement, <code>let</code>, <code>const</code>, <code>import</code>, and
- <code>export</code> declarations, variable statement, expression statement, <code>debugger</code> statement,
- <code>continue</code> statement, <code>break</code> statement, <code>return</code> statement, and <code>throw</code>
- statement) must be terminated with semicolons. Such semicolons may always appear explicitly in the source text. For
- convenience, however, such semicolons may be omitted from the source text in certain situations. These situations are
- described by saying that semicolons are automatically inserted into the source code token stream in those situations.</p>
- </div>
-
- <section id="sec-rules-of-automatic-semicolon-insertion">
- <h1><span class="secnum" id="sec-11.9.1"><a href="#sec-rules-of-automatic-semicolon-insertion"
- title="link to this section">11.9.1</a></span> Rules of Automatic Semicolon Insertion</h1>
-
- <p>In the following rules, &ldquo;token&rdquo; means the actual recognized lexical token determined using the current
- lexical goal symbol as described in <a href="#sec-ecmascript-language-lexical-grammar">clause 11</a>.</p>
-
- <p>There are three basic rules of semicolon insertion:</p>
-
- <ol class="proc">
- <li>When, as a <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
- right, a token (called the <i>offending token</i>) is encountered that is not allowed by any production of the
- grammar, then a semicolon is automatically inserted before the offending token if one or more of the following
- conditions is true:
- <ul>
- <li>
- <p>The offending token is separated from the previous token by at least one <i>LineTerminator</i>.</p>
- </li>
-
- <li>
- <p>The offending token is <code>}</code>.</p>
- </li>
-
- <li>
- <p>The previous token is <code>)</code> and the inserted semicolon would then be parsed as the terminating semicolon
- of a do-while statement (<a href="#sec-do-while-statement">13.6.1</a>).</p>
- </li>
- </ul>
- </li>
- <li>When, as the <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
- right, the end of the input stream of tokens is encountered and the parser is unable to parse the input token stream
- as a single complete ECMAScript <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span>, then
- a semicolon is automatically inserted at the end of the input stream.</li>
- <li>When, as the <span style="font-family: Times New Roman"><i>Script</i> or <i>Module</i></span> is parsed from left to
- right, a token is encountered that is allowed by some production of the grammar, but the production is a <i>restricted
- production</i> and the token would be the first token for a terminal or nonterminal immediately following the
- annotation <span style="font-family: Times New Roman">&ldquo;</span>[no&nbsp;<span style="font-family: Times New
- Roman"><i>LineTerminator</i></span> here]&rdquo; within the restricted production (and therefore such a token is
- called a restricted token), and the restricted token is separated from the previous token by at least one <span
- class="nt">LineTerminator</span>, then a semicolon is automatically inserted before the restricted token.</li>
- </ol>
-
- <p>However, there is an additional overriding condition on the preceding rules: a semicolon is never inserted automatically
- if the semicolon would then be parsed as an empty statement or if that semicolon would become one of the two semicolons in
- the header of a <code>for</code> statement (<a href="#sec-for-statement">see 13.6.3</a>).</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The following are the only restricted productions in the grammar:</p>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PostfixExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <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>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ContinueStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">continue;</code></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">BreakStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">break</code> <code class="t">;</code></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ReturnStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <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>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ThrowStatement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ArrowFunction</span><sub class="g-params">[In, Yield]</sub> <span class="geq">:</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">YieldExpression</span><sub class="g-params">[In]</sub> <span class="geq">:</span></div>
- <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>
- <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>
- </div>
-
- <p>The practical effect of these restricted productions is as follows:</p>
-
- <p>When a <code>++</code> or <code>--</code> token is encountered where the parser would treat it as a postfix operator, and
- at least one <span class="nt">LineTerminator</span> occurred between the preceding token and the <code>++</code> or
- <code>--</code> token, then a semicolon is automatically inserted before the <code>++</code> or <code>--</code> token.</p>
-
- <p>When a <code>continue</code>, <code>break</code>, <code>return</code>, <code>throw</code>, or <code>yield</code> token is
- encountered and a <span class="nt">LineTerminator</span> is encountered before the next token, a semicolon is automatically
- inserted after the <code>continue</code>, <code>break</code>, <code>return</code>, <code>throw</code>, or <code>yield</code>
- token.</p>
-
- <p>The resulting practical advice to ECMAScript programmers is:</p>
-
- <p>A postfix <code>++</code> or <code>--</code> operator should appear on the same line as its operand.</p>
-
- <p>An <span class="nt">Expression</span> in a <code>return</code> or <code>throw</code> statement or an <span
- class="nt">AssignmentExpression</span> in a <code>yield</code> expression should start on the same line as the
- <code>return</code>, <code>throw</code>, or <code>yield</code> token.</p>
-
- <p>An <span class="nt">IdentifierReference</span> in a <code>break</code> or <code>continue</code> statement should be on
- the same line as the <code>break</code> or <code>continue</code> token.</p>
- </section>
-
- <section id="sec-examples-of-automatic-semicolon-insertion">
- <h1><span class="secnum" id="sec-11.9.2"><a href="#sec-examples-of-automatic-semicolon-insertion"
- title="link to this section">11.9.2</a></span> Examples of Automatic Semicolon Insertion</h1>
-
- <p>The source</p>
-
- <pre>{ 1 2 } 3</pre>
-
- <p>is not a valid sentence in the ECMAScript grammar, even with the <a href="#sec-automatic-semicolon-insertion">automatic
- semicolon insertion</a> rules. In contrast, the source</p>
-
- <pre>{ 1<br>2 } 3</pre>
-
- <p>is also not a valid ECMAScript sentence, but is transformed by <a href="#sec-automatic-semicolon-insertion">automatic
- semicolon insertion</a> into the following:</p>
-
- <pre>{ 1<br>;2 ;} 3;</pre>
-
- <p>which is a valid ECMAScript sentence.</p>
-
- <p>The source</p>
-
- <pre>for (a; b<br>)</pre>
-
- <p>is not a valid ECMAScript sentence and is not altered by <a href="#sec-automatic-semicolon-insertion">automatic semicolon
- insertion</a> because the semicolon is needed for the header of a <code>for</code> statement. Automatic semicolon insertion
- never inserts one of the two semicolons in the header of a <code>for</code> statement.</p>
-
- <p>The source</p>
-
- <pre>return<br>a + b</pre>
-
- <p>is transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> into the following:</p>
-
- <pre>return;<br>a + b;</pre>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The expression <code>a + b</code> is not treated as a value to be returned by the
- <code>return</code> statement, because a <i>LineTerminator</i> separates it from the token <code>return</code>.</p>
- </div>
-
- <p>The source</p>
-
- <pre>a = b<br>++c</pre>
-
- <p>is transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a> into the following:</p>
-
- <pre>a = b;<br>++c;</pre>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The token <code>++</code> is not treated as a postfix operator applying to the variable
- <code>b</code>, because a <i>LineTerminator</i> occurs between <code>b</code> and <code>++</code>.</p>
- </div>
-
- <p>The source</p>
-
- <pre>if (a &gt; b)<br>else c = d</pre>
-
- <p>is not a valid ECMAScript sentence and is not altered by <a href="#sec-automatic-semicolon-insertion">automatic semicolon
- insertion</a> before the <code>else</code> token, even though no production of the grammar applies at that point, because an
- automatically inserted semicolon would then be parsed as an empty statement.</p>
-
- <p>The source</p>
-
- <pre>a = b + c<br>(d + e).print()</pre>
-
- <p>is <i>not</i> transformed by <a href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>, because the
- parenthesized expression that begins the second line can be interpreted as an argument list for a function call:</p>
-
- <pre>a = b + c(d + e).print()</pre>
-
- <p>In the circumstance that an assignment statement must begin with a left parenthesis, it is a good idea for the programmer
- to provide an explicit semicolon at the end of the preceding statement rather than to rely on <a
- href="#sec-automatic-semicolon-insertion">automatic semicolon insertion</a>.</p>
- </section>
- </section>
-</section>
-
-<section id="sec-ecmascript-language-expressions">
- <div class="front">
- <h1><span class="secnum" id="sec-12"><a href="#sec-ecmascript-language-expressions" title="link to this section">12</a></span>
- ECMAScript Language: Expressions</h1>
- </div>
-
- <section id="sec-identifiers">
- <div class="front">
- <h1><span class="secnum" id="sec-12.1"><a href="#sec-identifiers" title="link to this section">12.1</a></span>
- Identifiers</h1>
-
- <p><b>Syntax</b></p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">IdentifierReference</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">Identifier</span></div>
- <div class="rhs"><span class="grhsannot">[~Yield]</span> <code class="t">yield</code></div>
- </div>
-
- <p><i>BindingIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub></span> <b>:</b></p>
-
- <p><span style="font-family: Times New Roman"><i>Identifier<br></i></span>[~Yield] <code>yield</code></p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">LabelIdentifier</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">Identifier</span></div>
- <div class="rhs"><span class="grhsannot">[~Yield]</span> <code class="t">yield</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Identifier</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">IdentifierName</span> <span class="grhsmod">but not</span> <span class="nt">ReservedWord</span></div>
- </div>
- </div>
-
- <section id="sec-identifiers-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-12.1.1"><a href="#sec-identifiers-static-semantics-early-errors"
- title="link to this section">12.1.1</a></span> Static Semantics: Early Errors</h1>
- <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
- <ul>
- <li>
- <p>It is a Syntax Error if the code matched by this production is contained in <a href="#sec-strict-mode-code">strict
- mode code</a> and the StringValue of <span class="nt">Identifier</span> is <code>"arguments"</code> or
- <code>"eval"</code>.</p>
- </li>
- </ul>
-
- <p><span class="prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code
- class="t">yield</code></span></p>
-
- <p><span class="prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code
- class="t">yield</code></span></p>
-
- <div class="gp prod"><span class="nt">LabelIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
- <ul>
- <li>
- <p>It is a Syntax Error if the code matched by this production is contained in <a href="#sec-strict-mode-code">strict
- code</a><var>.</var></p>
- </li>
- </ul>
-
- <p><i>IdentifierReference</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
-
- <p><i>BindingIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
-
- <p><i>LabelIdentifier</i><span style="font-family: sans-serif"><sub>[Yield]</sub> <b>:</b></span> <i>Identifier</i></p>
-
- <ul>
- <li>
- <p>It is a Syntax Error if this production has a <sub>[Yield]</sub> parameter and StringValue of <span
- class="nt">Identifier</span> is <code>"yield"</code>.</p>
- </li>
- </ul>
- <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>
- <ul>
- <li>
- <p>It is a Syntax Error if this phrase is contained in <a href="#sec-strict-mode-code">strict mode code</a> and the
- StringValue of <span class="nt">IdentifierName</span> is: <code>"implements"</code>, <code>"interface"</code>,
- <code>"let"</code>, <code>"package"</code>, <code>"private"</code>, <code>"protected"</code>, <code>"public"</code>,
- <code>"static"</code>, or <code>"yield"</code>.</p>
- </li>
-
- <li>
- <p>It is a Syntax Error if StringValue of <span class="nt">IdentifierName</span> is the same string value as the
- StringValue of any <span class="nt">ReservedWord</span> except for <code>yield</code>.</p>
- </li>
- </ul>
-
- <div class="note">
- <p><span class="nh">NOTE</span> <span style="font-family: sans-serif">StringValue of</span> <i>IdentifierName</i>
- normalizes any Unicode escape sequences in <i>IdentifierName</i> hence such escapes cannot be used to write an
- <i>Identifier</i> whose code point sequence is the same as a <i>ReservedWord</i>.</p>
- </div>
- </section>
-
- <section id="sec-identifiers-static-semantics-boundnames">
- <h1><span class="secnum" id="sec-12.1.2"><a href="#sec-identifiers-static-semantics-boundnames"
- title="link to this section">12.1.2</a></span> Static Semantics: BoundNames</h1>
-
- <p>See also: <a href="#sec-let-and-const-declarations-static-semantics-boundnames">13.2.1.2</a>, <a
- href="#sec-variable-statement-static-semantics-boundnames">13.2.2.1</a>, <a
- href="#sec-destructuring-binding-patterns-static-semantics-boundnames">13.2.3.1</a>, <a
- href="#sec-for-in-and-for-of-statements-static-semantics-boundnames">13.6.4.2</a>, <a
- href="#sec-function-definitions-static-semantics-boundnames">14.1.3</a>, <a
- href="#sec-arrow-function-definitions-static-semantics-boundnames">14.2.2</a>, <a
- href="#sec-generator-function-definitions-static-semantics-boundnames">14.4.2</a>, <a
- href="#sec-class-definitions-static-semantics-boundnames">14.5.2</a>, <a
- href="#sec-imports-static-semantics-boundnames">15.2.2.2</a>, <a
- href="#sec-exports-static-semantics-boundnames">15.2.3.2</a>.</p>
-
- <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
- <ol class="proc">
- <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing the StringValue of
- <i>Identifier</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
- <ol class="proc">
- <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing <code>"yield"</code>.</li>
- </ol>
- </section>
-
- <section id="sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">
- <h1><span class="secnum" id="sec-12.1.3"><a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget"
- title="link to this section">12.1.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
-
- <p>See also: <a href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
- href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
- href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
- href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
- href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
- href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
- href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
- href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
- href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
- href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
- href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
-
- <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
- <ol class="proc">
- <li>If this <i>IdentifierReference</i> is contained in <a href="#sec-strict-mode-code">strict mode code</a> and
- StringValue of <i>Identifier</i> is <code>"eval"</code> or <code>"arguments"</code>, return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code class="t">yield</code></div>
- <ol class="proc">
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-identifiers-static-semantics-stringvalue">
- <h1><span class="secnum" id="sec-12.1.4"><a href="#sec-identifiers-static-semantics-stringvalue"
- title="link to this section">12.1.4</a></span> Static Semantics<span style="font-family: sans-serif">:</span>
- <i>StringValue</i></h1>
-
- <p>See also: <a href="#sec-identifier-names-static-semantics-stringvalue">11.6.1.2</a>, <a
- href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>.</p>
-
- <p><span class="prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code
- class="t">yield</code></span></p>
-
- <p><span class="prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code
- class="t">yield</code></span></p>
-
- <div class="gp prod"><span class="nt">LabelIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
- <ol class="proc">
- <li>Return <code>"yield"</code>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Return the StringValue of <i>IdentifierName</i>.</li>
- </ol>
- </section>
-
- <section id="sec-identifiers-runtime-semantics-bindinginitialization">
- <div class="front">
- <h1><span class="secnum" id="sec-12.1.5"><a href="#sec-identifiers-runtime-semantics-bindinginitialization"
- title="link to this section">12.1.5</a></span> Runtime Semantics: BindingInitialization</h1>
-
- <p>With arguments <var>value</var> and <var>environment</var>.</p>
-
- <p>See also: <a href="#sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization">13.2.3.5</a>, <a
- href="#sec-for-in-and-for-of-statements-runtime-semantics-bindinginitialization">13.6.4.9</a>.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> <b>undefined</b> is passed for <var>environment</var> to indicate that a <a
- href="#sec-putvalue">PutValue</a> operation should be used to assign the initialization value. This is the case for
- <code>var</code> statements and formal parameter lists of some non-strict functions (See <a
- href="#sec-functiondeclarationinstantiation">9.2.12</a>). In those cases a lexical binding is hoisted and preinitialized
- prior to evaluation of its initializer.</p>
- </div>
-
- <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
- <ol class="proc">
- <li>Let <i>name</i> be StringValue of <i>Identifier</i>.</li>
- <li>Return <a href="#sec-initializeboundname">InitializeBoundName</a>( <i>name</i>, <i>value</i>,
- <i>environment</i>).</li>
- </ol>
- <div class="gp prod"><span class="nt">BindingIdentifier</span> <span class="geq">:</span> <code class="t">yield</code></div>
- <ol class="proc">
- <li>Return <a href="#sec-initializeboundname">InitializeBoundName</a>(<code>"yield"</code>, <i>value</i>,
- <i>environment</i>).</li>
- </ol>
- </div>
-
- <section id="sec-initializeboundname">
- <h1><span class="secnum" id="sec-12.1.5.1"><a href="#sec-initializeboundname"
- title="link to this section">12.1.5.1</a></span> Runtime Semantics: InitializeBoundName(name, value, environment)</h1>
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>name</i>) is String.</li>
- <li>If <i>environment</i> is not <b>undefined</b>, then
- <ol class="block">
- <li>Let <i>env</i> be the EnvironmentRecord component of <i>environment</i>.</li>
- <li>Perform <i>env</i>.InitializeBinding(<i>name</i>, <i>value</i>).</li>
- <li>Return <a href="#sec-normalcompletion">NormalCompletion</a>(<b>undefined</b>).</li>
- </ol>
- </li>
- <li>Else
- <ol class="block">
- <li>Let <i>lhs</i> be <a href="#sec-resolvebinding">ResolveBinding</a>(<i>name</i>).</li>
- <li>Return <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>value</i>).</li>
- </ol>
- </li>
- </ol>
- </section>
- </section>
-
- <section id="sec-identifiers-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.1.6"><a href="#sec-identifiers-runtime-semantics-evaluation"
- title="link to this section">12.1.6</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <span class="nt">Identifier</span></div>
- <ol class="proc">
- <li>Return <a href="#sec-resolvebinding">ResolveBinding</a>(StringValue of <i>Identifier</i>).</li>
- </ol>
- <div class="gp prod"><span class="nt">IdentifierReference</span> <span class="geq">:</span> <code class="t">yield</code></div>
- <ol class="proc">
- <li>Return <a href="#sec-resolvebinding">ResolveBinding</a>(<code>"yield"</code>).</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE 1:</span> The result of evaluating an <i>IdentifierReference</i> is always a value of type <a
- href="#sec-reference-specification-type">Reference</a>.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 2:</span> In non-<a href="#sec-strict-mode-code">strict code</a>, the keyword <code>yield</code>
- may be used as an identifier. Evaluating the <i>IdentifierReference</i> production resolves the binding of
- <code>yield</code> as if it was an <i>Identifier</i>. Early Error restriction ensures that such an evaluation only can
- occur for non-<a href="#sec-strict-mode-code">strict code</a>. See <a href="#sec-let-and-const-declarations">13.2.1</a>
- for the handling of <code>yield</code> in binding creation contexts.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-primary-expression">
- <div class="front">
- <h1><span class="secnum" id="sec-12.2"><a href="#sec-primary-expression" title="link to this section">12.2</a></span>
- Primary Expression</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PrimaryExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">this</code></div>
- <div class="rhs"><span class="nt">IdentifierReference</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><span class="nt">Literal</span></div>
- <div class="rhs"><span class="nt">ArrayLiteral</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><span class="nt">ObjectLiteral</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><span class="nt">FunctionExpression</span></div>
- <div class="rhs"><span class="nt">ClassExpression</span></div>
- <div class="rhs"><span class="nt">GeneratorExpression</span></div>
- <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
- <div class="rhs"><span class="nt">TemplateLiteral</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub class="g-params">[?Yield]</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">(</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">)</code></div>
- <div class="rhs"><code class="t">(</code> <code class="t">)</code></div>
- <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>
- <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>
- </div>
-
- <h2>Supplemental Syntax</h2>
-
- <p>When processing the production</p>
-
- <p><span class="nt">PrimaryExpression</span><sub>[Yield]</sub> <b>:</b> <span
- class="nt">CoverParenthesizedExpressionAndArrowParameterList</span><sub>[?Yield]</sub><span style="font-family: Times New
- Roman"><i><br></i></span>the interpretation of <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> is
- refined using the following grammar:</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ParenthesizedExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">(</code> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">)</code></div>
- </div>
- </div>
-
- <section id="sec-primary-expression-semantics">
- <div class="front">
- <h1><span class="secnum" id="sec-12.2.0"><a href="#sec-primary-expression-semantics"
- title="link to this section">12.2.0</a></span> Semantics</h1>
- </div>
-
- <section id="sec-static-semantics-coveredparenthesizedexpression">
- <h1><span class="secnum" id="sec-12.2.0.1"><a href="#sec-static-semantics-coveredparenthesizedexpression"
- title="link to this section">12.2.0.1</a></span> Static Semantics: CoveredParenthesizedExpression</h1>
- <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>
- <ol class="proc">
- <li>Return the result of parsing the lexical token stream matched by
- <i>CoverParenthesizedExpressionAndArrowParameterList</i><sub>[Yield]</sub> using either
- <i>ParenthesizedExpression</i> or <i>ParenthesizedExpression</i><sub>[Yield]</sub> as the goal symbol depending upon
- whether the <sub>[Yield]</sub> grammar parameter was present when
- <i>CoverParenthesizedExpressionAndArrowParameterList was matched.</i></li>
- </ol>
- </section>
-
- <section id="sec-semantics-static-semantics-isfunctiondefinition">
- <h1><span class="secnum" id="sec-12.2.0.2"><a href="#sec-semantics-static-semantics-isfunctiondefinition"
- title="link to this section">12.2.0.2</a></span> Static Semantics: IsFunctionDefinition</h1>
-
- <p>See also: <a href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
- href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
- href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
- href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
- href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
- href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
- href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
- href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
- href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
- href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
- href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
- href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
- href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">this</code></div>
- <div class="rhs"><span class="nt">IdentifierReference</span></div>
- <div class="rhs"><span class="nt">Literal</span></div>
- <div class="rhs"><span class="nt">ArrayLiteral</span></div>
- <div class="rhs"><span class="nt">ObjectLiteral</span></div>
- <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
- <div class="rhs"><span class="nt">TemplateLiteral</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
- <li>Return IsFunctionDefinition of <i>expr</i>.</li>
- </ol>
- </section>
-
- <section id="sec-semantics-static-semantics-isidentifierref">
- <h1><span class="secnum" id="sec-12.2.0.3"><a href="#sec-semantics-static-semantics-isidentifierref"
- title="link to this section">12.2.0.3</a></span> Static Semantics: IsIdentifierRef</h1>
-
- <p>See also: <a href="#sec-static-semantics-static-semantics-isidentifierref">12.3.1.4</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">IdentifierReference</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">this</code></div>
- <div class="rhs"><span class="nt">Literal</span></div>
- <div class="rhs"><span class="nt">ArrayLiteral</span></div>
- <div class="rhs"><span class="nt">ObjectLiteral</span></div>
- <div class="rhs"><span class="nt">FunctionExpression</span></div>
- <div class="rhs"><span class="nt">ClassExpression</span></div>
- <div class="rhs"><span class="nt">GeneratorExpression</span></div>
- <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
- <div class="rhs"><span class="nt">TemplateLiteral</span></div>
- <div class="rhs"><span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-semantics-static-semantics-isvalidsimpleassignmenttarget">
- <h1><span class="secnum" id="sec-12.2.0.4"><a href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget"
- title="link to this section">12.2.0.4</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
-
- <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
- href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
- href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
- href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
- href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
- href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
- href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
- href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
- href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
- href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
- href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">this</code></div>
- <div class="rhs"><span class="nt">Literal</span></div>
- <div class="rhs"><span class="nt">ArrayLiteral</span></div>
- <div class="rhs"><span class="nt">ObjectLiteral</span></div>
- <div class="rhs"><span class="nt">FunctionExpression</span></div>
- <div class="rhs"><span class="nt">ClassExpression</span></div>
- <div class="rhs"><span class="nt">GeneratorExpression</span></div>
- <div class="rhs"><span class="nt">RegularExpressionLiteral</span></div>
- <div class="rhs"><span class="nt">TemplateLiteral</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
- <li>Return IsValidSimpleAssignmentTarget of <i>expr</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-this-keyword">
- <div class="front">
- <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
- <code>this</code> Keyword</h1>
- </div>
-
- <section id="sec-this-keyword-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.2.1.1"><a href="#sec-this-keyword-runtime-semantics-evaluation"
- title="link to this section">12.2.1.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <code class="t">this</code></div>
- <ol class="proc">
- <li>Return <a href="#sec-resolvethisbinding">ResolveThisBinding</a>( ) .</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-identifier-reference">
- <h1><span class="secnum" id="sec-12.2.2"><a href="#sec-identifier-reference" title="link to this section">12.2.2</a></span>
- Identifier Reference</h1>
-
- <p>See <a href="#sec-identifiers">12.1</a> for <span class="nt">IdentifierReference</span>.</p>
- </section>
-
- <section id="sec-primary-expression-literals">
- <div class="front">
- <h1><span class="secnum" id="sec-12.2.3"><a href="#sec-primary-expression-literals"
- title="link to this section">12.2.3</a></span> Literals</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Literal</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">NullLiteral</span></div>
- <div class="rhs"><span class="nt">BooleanLiteral</span></div>
- <div class="rhs"><span class="nt">NumericLiteral</span></div>
- <div class="rhs"><span class="nt">StringLiteral</span></div>
- </div>
- </div>
-
- <section id="sec-literals-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.2.3.1"><a href="#sec-literals-runtime-semantics-evaluation"
- title="link to this section">12.2.3.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">NullLiteral</span></div>
- <ol class="proc">
- <li>Return <b>null</b>.</li>
- </ol>
- <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">BooleanLiteral</span></div>
- <ol class="proc">
- <li>Return <b>false</b> if <i>BooleanLiteral</i> is the token <code>false</code>.</li>
- <li>Return <b>true</b> if <i>BooleanLiteral</i> is the token <code>true</code>.</li>
- </ol>
- <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
- <ol class="proc">
- <li>Return the number whose value is MV of <i>NumericLiteral</i> as defined in <a
- href="#sec-literals-numeric-literals">11.8.3</a>.</li>
- </ol>
- <div class="gp prod"><span class="nt">Literal</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
- <ol class="proc">
- <li>Return the StringValue of <i>StringLiteral</i> as defined in <a
- href="#sec-string-literals-static-semantics-stringvalue">11.8.4.2</a>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-array-initializer">
- <div class="front">
- <h1><span class="secnum" id="sec-12.2.4"><a href="#sec-array-initializer" title="link to this section">12.2.4</a></span>
- Array Initializer</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> An <i>ArrayLiteral</i> is an expression describing the initialization of an Array
- object, using a list, of zero or more expressions each of which represents an array element, enclosed in square
- brackets. The elements need not be literals; they are evaluated each time the array initializer is evaluated.</p>
- </div>
-
- <p>Array elements may be elided at the beginning, middle or end of the element list. Whenever a comma in the element list
- is not preceded by an <span class="nt">AssignmentExpression</span> (i.e., a comma at the beginning or after another
- comma), the missing array element contributes to the length of the Array and increases the index of subsequent elements.
- Elided array elements are not defined. If an element is elided at the end of an array, that element does not contribute to
- the length of the Array.</p>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ArrayLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">[</code> <span class="nt">Elision</span><sub class="g-opt">opt</sub> <code class="t">]</code></div>
- <div class="rhs"><code class="t">[</code> <span class="nt">ElementList</span><sub class="g-params">[?Yield]</sub> <code class="t">]</code></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ElementList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <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>
- <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>
- <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>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Elision</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">,</code></div>
- <div class="rhs"><span class="nt">Elision</span> <code class="t">,</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SpreadElement</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">...</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
- </div>
- </div>
-
- <section id="sec-static-semantics-elisionwidth">
- <h1><span class="secnum" id="sec-12.2.4.1"><a href="#sec-static-semantics-elisionwidth"
- title="link to this section">12.2.4.1</a></span> Static Semantics: ElisionWidth</h1>
- <div class="gp prod"><span class="nt">Elision</span> <span class="geq">:</span> <code class="t">,</code></div>
- <ol class="proc">
- <li>Return the numeric value 1.</li>
- </ol>
- <div class="gp prod"><span class="nt">Elision</span> <span class="geq">:</span> <span class="nt">Elision</span> <code class="t">,</code></div>
- <ol class="proc">
- <li>Let <i>preceding</i> be the ElisionWidth of <i>Elision</i>.</li>
- <li>Return <i>preceding</i>+1.</li>
- </ol>
- </section>
-
- <section id="sec-runtime-semantics-arrayaccumulation">
- <h1><span class="secnum" id="sec-12.2.4.2"><a href="#sec-runtime-semantics-arrayaccumulation"
- title="link to this section">12.2.4.2</a></span> Runtime Semantics: ArrayAccumulation</h1>
-
- <p>With parameters <var>array</var> and <var>nextIndex</var>.</p>
-
- <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>
- <ol class="proc">
- <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
- zero.</li>
- <li>Let <i>initResult</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>initValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>initResult</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initValue</i>).</li>
- <li>Let <i>created</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
- href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>nextIndex+padding</i>)),
- <i>initValue</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>created</i> is <b>true</b><i>.</i></li>
- <li>Return <i>nextIndex+padding+</i>1.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
- zero.</li>
- <li>Return the result of performing ArrayAccumulation for <i>SpreadElement</i> with arguments <i>array</i> and
- <i>nextIndex</i>+<i>padding</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>postIndex</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments
- <i>array</i> and <i>nextIndex</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>postIndex</i>).</li>
- <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
- zero.</li>
- <li>Let <i>initResult</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>initValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>initResult</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>initValue</i>).</li>
- <li>Let <i>created</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
- href="#sec-tostring">ToString</a>(<a href="#sec-touint32">ToUint32</a>(<i>postIndex</i>+<i>padding</i>)),
- <i>initValue</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>created</i> is <b>true</b>.</li>
- <li>Return <i>postIndex</i>+<i>padding+</i>1.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>postIndex</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments
- <i>array</i> and <i>nextIndex</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>postIndex</i>).</li>
- <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
- zero.</li>
- <li>Return the result of performing ArrayAccumulation for <i>SpreadElement</i> with arguments <i>array</i> and
- <i>postIndex</i>+<i>padding</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">SpreadElement</span> <span class="geq">:</span> <code class="t">...</code> <span class="nt">AssignmentExpression</span></div>
- <ol class="proc">
- <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>spreadObj</i> be <a href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>).</li>
- <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<i>spreadObj</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
- <li>Repeat
- <ol class="block">
- <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
- <li>If <i>next</i> is <b>false</b>, return <i>nextIndex</i>.</li>
- <li>Let <i>nextValue</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextValue</i>).</li>
- <li>Let <i>status</i> be <a href="#sec-createdataproperty">CreateDataProperty</a>(<i>array</i>, <a
- href="#sec-tostring">ToString</a>(<i>nextIndex</i>), <i>nextValue</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>status</i> is <b>true</b> .</li>
- <li>Let <i>nextIndex</i> be <i>nextIndex</i> + 1.</li>
- </ol>
- </li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> <a href="#sec-createdataproperty">CreateDataProperty</a> is used to ensure that own
- properties are defined for the array even if the standard built-in Array prototype object has been modified in a manner
- that would preclude the creation of new own properties using [[Set]].</p>
- </div>
- </section>
-
- <section id="sec-array-initializer-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.2.4.3"><a href="#sec-array-initializer-runtime-semantics-evaluation"
- title="link to this section">12.2.4.3</a></span> Runtime Semantics: Evaluation</h1>
- <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>
- <ol class="proc">
- <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
- <li>Let <i>pad</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
- zero.</li>
- <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>
- <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
- href="#sec-arraycreate">ArrayCreate</a>.</li>
- <li>Return <i>array</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
- <li>Let <i>len</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments <i>array</i> and
- 0.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
- <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>
- <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
- href="#sec-arraycreate">ArrayCreate</a>.</li>
- <li>Return <i>array</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>array</i> be <a href="#sec-arraycreate">ArrayCreate</a>(0).</li>
- <li>Let <i>len</i> be the result of performing ArrayAccumulation for <i>ElementList</i> with arguments <i>array</i> and
- 0.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>len</i>).</li>
- <li>Let <i>padding</i> be the ElisionWidth of <i>Elision</i>; if <i>Elision</i> is not present, use the numeric value
- zero.</li>
- <li>Perform <a href="#sec-set-o-p-v-throw">Set</a>(<i>array</i>, <code>"length"</code>, <a
- href="#sec-touint32">ToUint32</a>(<i>padding</i>+<i>len</i>), <b>false</b>).</li>
- <li>NOTE: The above Set cannot fail because of the nature of the object returned by <a
- href="#sec-arraycreate">ArrayCreate</a>.</li>
- <li>Return <i>array</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-object-initializer">
- <div class="front">
- <h1><span class="secnum" id="sec-12.2.5"><a href="#sec-object-initializer" title="link to this section">12.2.5</a></span>
- Object Initializer</h1>
-
- <div class="note">
- <p><span class="nh">NOTE 1</span> An object initializer is an expression describing the initialization of an Object,
- written in a form resembling a literal. It is a list of zero or more pairs of property keys and associated values,
- enclosed in curly brackets. The values need not be literals; they are evaluated each time the object initializer is
- evaluated.</p>
- </div>
-
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ObjectLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">{</code> <code class="t">}</code></div>
- <div class="rhs"><code class="t">{</code> <span class="nt">PropertyDefinitionList</span><sub class="g-params">[?Yield]</sub> <code class="t">}</code></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PropertyDefinitionList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">PropertyDefinition</span><sub class="g-params">[?Yield]</sub></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PropertyDefinition</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">IdentifierReference</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><span class="nt">CoverInitializedName</span><sub class="g-params">[?Yield]</sub></div>
- <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>
- <div class="rhs"><span class="nt">MethodDefinition</span><sub class="g-params">[?Yield]</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PropertyName</span><sub class="g-params">[Yield,GeneratorParameter]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">LiteralPropertyName</span></div>
- <div class="rhs"><span class="grhsannot">[+GeneratorParameter]</span> <span class="nt">ComputedPropertyName</span></div>
- <div class="rhs"><span class="grhsannot">[~GeneratorParameter]</span> <span class="nt">ComputedPropertyName</span><sub class="g-params">[?Yield]</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">IdentifierName</span></div>
- <div class="rhs"><span class="nt">StringLiteral</span></div>
- <div class="rhs"><span class="nt">NumericLiteral</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ComputedPropertyName</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">[</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub> <code class="t">]</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CoverInitializedName</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Initializer</span><sub class="g-params">[In, Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">=</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[?In, ?Yield]</sub></div>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 2</span> <i>MethodDefinition</i> is defined in <a href="#sec-method-definitions">14.3</a>.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 3</span> In certain contexts, <i>ObjectLiteral</i> is used as a cover grammar for a more
- restricted secondary grammar. The <i>CoverInitializedName</i> production is necessary to fully cover these secondary
- grammars. However, use of this production results in an early Syntax Error in normal contexts where an actual
- <i>ObjectLiteral</i> is expected.</p>
- </div>
- </div>
-
- <section id="sec-object-initializer-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-12.2.5.1"><a href="#sec-object-initializer-static-semantics-early-errors"
- title="link to this section">12.2.5.1</a></span> Static Semantics: Early Errors</h1>
- <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">MethodDefinition</span></div>
- <ul>
- <li>It is a Syntax Error if HasDirectSuper of <span class="nt">MethodDefinition</span> is <span style="font-family:
- Times New Roman"><b><i>true</i></b></span>.</li>
- </ul>
-
- <p>In addition to describing an actual object initializer the <span class="nt">ObjectLiteral</span> productions are also
- used as a cover grammar for <span class="nt">ObjectAssignmentPattern</span> (<a
- href="#sec-destructuring-assignment">12.14.5</a>). and may be recognized as part of a <span
- class="nt">CoverParenthesizedExpressionAndArrowParameterList</span>. When <span class="nt">ObjectLiteral</span> appears in
- a context where <span class="nt">ObjectAssignmentPattern</span> is required the following Early Error rules are <b>not</b>
- applied. In addition, they are not applied when initially parsing a
- <var>CoverParenthesizedExpressionAndArrowParameterList.</var></p>
-
- <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">CoverInitializedName</span></div>
- <ul>
- <li>Always throw a Syntax Error if code matches <span style="font-family: Times New Roman">this production.</span></li>
- </ul>
-
- <div class="note">
- <p><span class="nh">NOTE</span> This production exists so that <i>ObjectLiteral</i> can serve as a cover grammar for
- <i>ObjectAssignmentPattern</i> (<a href="#sec-destructuring-assignment">12.14.5</a>). It cannot occur in an actual
- object initializer.</p>
- </div>
- </section>
-
- <section id="sec-object-initializer-static-semantics-computedpropertycontains">
- <h1><span class="secnum" id="sec-12.2.5.2"><a href="#sec-object-initializer-static-semantics-computedpropertycontains"
- title="link to this section">12.2.5.2</a></span> Static Semantics: ComputedPropertyContains</h1>
-
- <p>With parameter <var>symbol</var>.</p>
-
- <p>See also: <a href="#sec-method-definitions-static-semantics-computedpropertycontains">14.3.2</a>, <a
- href="#sec-generator-function-definitions-static-semantics-computedpropertycontains">14.4.3</a>, <a
- href="#sec-class-definitions-static-semantics-computedpropertycontains">14.5.5</a>.</p>
-
- <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">LiteralPropertyName</span></div>
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">ComputedPropertyName</span></div>
- <ol class="proc">
- <li>Return the result of <i>ComputedPropertyName</i> Contains <i>symbol</i>.</li>
- </ol>
- </section>
-
- <section id="sec-object-initializer-static-semantics-contains">
- <h1><span class="secnum" id="sec-12.2.5.3"><a href="#sec-object-initializer-static-semantics-contains"
- title="link to this section">12.2.5.3</a></span> Static Semantics: Contains</h1>
-
- <p>With parameter <var>symbol</var>.</p>
-
- <p>See also: <a href="#sec-static-semantic-rules">5.3</a>, <a
- href="#sec-static-semantics-static-semantics-contains">12.3.1.1</a>, <a
- href="#sec-function-definitions-static-semantics-contains">14.1.4</a>, <a
- href="#sec-arrow-function-definitions-static-semantics-contains">14.2.3</a>, <a
- href="#sec-generator-function-definitions-static-semantics-contains">14.4.4</a>, <a
- href="#sec-class-definitions-static-semantics-contains">14.5.4</a>.</p>
-
- <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">MethodDefinition</span></div>
- <ol class="proc">
- <li>If <i>symbol</i> is <i>MethodDefinition</i>, return <b>true</b>.</li>
- <li>Return the result of ComputedPropertyContains for <i>MethodDefinition</i> with argument <i>symbol</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Static semantic rules that depend upon substructure generally do not look into function
- definitions.</p>
- </div>
-
- <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
- <ol class="proc">
- <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
- <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
- <i>IdentifierName</i>, return <b>true</b>;</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-object-initializer-static-semantics-hascomputedpropertykey">
- <h1><span class="secnum" id="sec-12.2.5.4"><a href="#sec-object-initializer-static-semantics-hascomputedpropertykey"
- title="link to this section">12.2.5.4</a></span> Static Semantics: HasComputedPropertyKey</h1>
-
- <p>See also: <a href="#sec-method-definitions-static-semantics-hascomputedpropertykey">14.3.4</a>, <a
- href="#sec-generator-function-definitions-static-semantics-hascomputedpropertykey">14.4.5</a></p>
-
- <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>
- <ol class="proc">
- <li>If HasComputedPropertyKey of <i>PropertyDefinitionList</i> is <b>true</b>, return <b>true</b>.</li>
- <li>Return HasComputedPropertyKey of <i>PropertyDefinition</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Return IsComputedPropertyKey of <i>PropertyName</i>.</li>
- </ol>
- </section>
-
- <section id="sec-static-semantics-iscomputedpropertykey">
- <h1><span class="secnum" id="sec-12.2.5.5"><a href="#sec-static-semantics-iscomputedpropertykey"
- title="link to this section">12.2.5.5</a></span> Static Semantics: IsComputedPropertyKey</h1>
- <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">LiteralPropertyName</span></div>
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- <div class="gp prod"><span class="nt">PropertyName</span> <span class="geq">:</span> <span class="nt">ComputedPropertyName</span></div>
- <ol class="proc">
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
-
- <section id="sec-object-initializer-static-semantics-propname">
- <h1><span class="secnum" id="sec-12.2.5.6"><a href="#sec-object-initializer-static-semantics-propname"
- title="link to this section">12.2.5.6</a></span> Static Semantics: <i>PropName</i></h1>
-
- <p>See also: <a href="#sec-method-definitions-static-semantics-propname">14.3.6</a>, <a
- href="#sec-generator-function-definitions-static-semantics-propname">14.4.10</a>, <a
- href="#sec-class-definitions-static-semantics-propname">14.5.12</a></p>
-
- <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
- <ol class="proc">
- <li>Return StringValue of <i>IdentifierReference</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Return PropName of <i>PropertyName</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
- <ol class="proc">
- <li>Return StringValue of <i>IdentifierName</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
- <ol class="proc">
- <li>Return a String value whose code units are the SV of the <i>StringLiteral</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
- <ol class="proc">
- <li>Let <i>nbr</i> be the result of forming the value of the <i>NumericLiteral</i>.</li>
- <li>Return <a href="#sec-tostring">ToString</a>(<i>nbr</i>).</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Return <span style="font-family: sans-serif">empty</span>.</li>
- </ol>
- </section>
-
- <section id="sec-static-semantics-propertynamelist">
- <h1><span class="secnum" id="sec-12.2.5.7"><a href="#sec-static-semantics-propertynamelist"
- title="link to this section">12.2.5.7</a></span> Static Semantics: PropertyNameList</h1>
- <div class="gp prod"><span class="nt">PropertyDefinitionList</span> <span class="geq">:</span> <span class="nt">PropertyDefinition</span></div>
- <ol class="proc">
- <li>If PropName of <i>PropertyDefinition</i> is <span style="font-family: sans-serif">empty</span>, return a new empty
- <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Return a new <a href="#sec-list-and-record-specification-type">List</a> containing PropName of
- <i>PropertyDefinition</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>list</i> be PropertyNameList of <i>PropertyDefinitionList.</i></li>
- <li>If PropName of <i>PropertyDefinition</i> is <span style="font-family: sans-serif">empty</span>, return
- <i>list</i>.</li>
- <li>Append PropName of <i>PropertyDefinition</i> to the end of <i>list</i>.</li>
- <li>Return <i>list</i>.</li>
- </ol>
- </section>
-
- <section id="sec-object-initializer-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.2.5.8"><a href="#sec-object-initializer-runtime-semantics-evaluation"
- title="link to this section">12.2.5.8</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">ObjectLiteral</span> <span class="geq">:</span> <code class="t">{</code> <code class="t">}</code></div>
- <ol class="proc">
- <li>Return <a href="#sec-objectcreate">ObjectCreate</a>(<span style="font-family:
- sans-serif">%ObjectPrototype%</span>).</li>
- </ol>
-
- <p><span class="prod"><span class="nt">ObjectLiteral</span> <span class="geq">:</span></span><br>&#x9;<code>{</code> <span
- class="nt">PropertyDefinitionList</span> <code>}</code><span style="font-family: Times New
- Roman"><i><br></i></span>&#x9;<code>{</code> <span class="nt">PropertyDefinitionList</span> <code>,</code>
- <code>}</code></p>
-
- <ol class="proc">
- <li>Let <i>obj</i> be <a href="#sec-objectcreate">ObjectCreate</a>(%ObjectPrototype%).</li>
- <li>Let <i>status</i> be the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinitionList</i> with
- arguments <i>obj</i> and <b>true</b>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Return <i>obj</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">IdentifierName</span></div>
- <ol class="proc">
- <li>Return StringValue of <i>IdentifierName</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">StringLiteral</span></div>
- <ol class="proc">
- <li>Return a String value whose code units are the SV of the <i>StringLiteral</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">LiteralPropertyName</span> <span class="geq">:</span> <span class="nt">NumericLiteral</span></div>
- <ol class="proc">
- <li>Let <i>nbr</i> be the result of forming the value of the <i>NumericLiteral</i>.</li>
- <li>Return <a href="#sec-tostring">ToString</a>(<i>nbr</i>).</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>exprValue</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>propName</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propName</i>).</li>
- <li>Return <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propName</i>).</li>
- </ol>
- </section>
-
- <section id="sec-object-initializer-runtime-semantics-propertydefinitionevaluation">
- <h1><span class="secnum" id="sec-12.2.5.9"><a
- href="#sec-object-initializer-runtime-semantics-propertydefinitionevaluation"
- title="link to this section">12.2.5.9</a></span> Runtime Semantics: PropertyDefinitionEvaluation</h1>
-
- <p>With parameter <var>object</var> and <span style="font-family: Times New Roman"><i>enumerable</i>.</span></p>
-
- <p>See also: <a href="#sec-method-definitions-runtime-semantics-propertydefinitionevaluation">14.3.9</a>, <a
- href="#sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation">14.4.13</a>, B.3.1</p>
-
- <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>
- <ol class="proc">
- <li>Let <i>status</i> be the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinitionList</i> with
- arguments <i>object</i> and <i>enumerable</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Return the result of performing PropertyDefinitionEvaluation of <i>PropertyDefinition</i> with arguments
- <i>object</i> and <i>enumerable</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">PropertyDefinition</span> <span class="geq">:</span> <span class="nt">IdentifierReference</span></div>
- <ol class="proc">
- <li>Let <i>propName</i> be StringValue of <i>IdentifierReference</i>.</li>
- <li>Let <i>exprValue</i> be the result of evaluating <i>IdentifierReference</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>exprValue</i>).</li>
- <li>Let <i>propValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propValue</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>enumerable</i> is <b>true</b>.</li>
- <li>Return <a href="#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a>(<i>object</i>, <i>propName</i>,
- <i>propValue</i>).</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>propKey</i> be the result of evaluating <i>PropertyName</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propKey</i>).</li>
- <li>Let <i>exprValueRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>propValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>exprValueRef</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propValue</i>).</li>
- <li>If <a href="#sec-isanonymousfunctiondefinition">IsAnonymousFunctionDefinition</a>(<i>AssignmentExpression)</i> is
- <b>true</b>, then
- <ol class="block">
- <li>Let <i>hasNameProperty</i> be <a href="#sec-hasownproperty">HasOwnProperty</a>(<i>propValue</i>,
- <code>"name"</code>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>hasNameProperty</i>).</li>
- <li>If <i>hasNameProperty</i> is <b>false</b>, perform <a
- href="#sec-setfunctionname">SetFunctionName</a>(<i>propValue</i>, <i>propKey</i>).</li>
- </ol>
- </li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>enumerable</i> is <b>true</b>.</li>
- <li>Return <a href="#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a>(<i>object</i>, <i>propKey</i>,
- <i>propValue</i>).</li>
- </ol>
-
- <p class="Note"><i>NOTE&#x9;An alternative semantics for this production is given in <a
- href="#sec-__proto__-property-names-in-object-initializers">B.3.1</a>.</i></p>
- </section>
- </section>
-
- <section id="sec-function-defining-expressions">
- <h1><span class="secnum" id="sec-12.2.6"><a href="#sec-function-defining-expressions"
- title="link to this section">12.2.6</a></span> Function Defining Expressions</h1>
-
- <p>See <a href="#sec-function-definitions">14.1</a> for <span class="prod"><span class="nt">PrimaryExpression</span> <span
- class="geq">:</span> <span class="nt">FunctionExpression</span></span> .</p>
-
- <p>See <a href="#sec-generator-function-definitions">14.4</a> for <span class="prod"><span
- class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">GeneratorExpression</span></span> .</p>
-
- <p>See <a href="#sec-class-definitions">14.5</a> for <span class="prod"><span class="nt">PrimaryExpression</span> <span
- class="geq">:</span> <span class="nt">ClassExpression</span></span> .</p>
- </section>
-
- <section id="sec-primary-expression-regular-expression-literals">
- <div class="front">
- <h1><span class="secnum" id="sec-12.2.7"><a href="#sec-primary-expression-regular-expression-literals"
- title="link to this section">12.2.7</a></span> Regular Expression Literals</h1>
- <h2>Syntax</h2>
-
- <p>See <a href="#sec-literals-string-literals">11.8.4</a>.</p>
- </div>
-
- <section id="sec-primary-expression-regular-expression-literals-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-12.2.7.1"><a
- href="#sec-primary-expression-regular-expression-literals-static-semantics-early-errors"
- title="link to this section">12.2.7.1</a></span> Static Semantics: Early Errors</h1>
- <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">RegularExpressionLiteral</span></div>
- <ul>
- <li>
- <p>It is a Syntax Error if <span style="font-family: Times New Roman">BodyText</span> of <span
- class="nt">RegularExpressionLiteral</span> cannot be recognized using the goal symbol <span class="nt">Pattern</span>
- of the ECMAScript RegExp grammar specified in <a href="#sec-patterns">21.2.1</a><var>.</var></p>
- </li>
-
- <li>
- <p>It is a Syntax Error if <span style="font-family: Times New Roman">FlagText</span> of <span
- class="nt">RegularExpressionLiteral</span> contains any code points other than <code>"g"</code>, <code>"i"</code>,
- <code>"m"</code>, <code>"u"</code>, or <code>"y"</code>, or if it contains the same code point more than once.</p>
- </li>
- </ul>
- </section>
-
- <section id="sec-regular-expression-literals-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.2.7.2"><a href="#sec-regular-expression-literals-runtime-semantics-evaluation"
- title="link to this section">12.2.7.2</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">RegularExpressionLiteral</span></div>
- <ol class="proc">
- <li>Let <i>pattern</i> be the string value consisting of the <a href="#sec-utf16encoding">UTF16Encoding</a> of each code
- point of BodyText of <i>RegularExpressionLiteral</i>.</li>
- <li>Let <i>flags</i> be the string value consisting of the <a href="#sec-utf16encoding">UTF16Encoding</a> of each code
- point of FlagText of <i>RegularExpressionLiteral</i>.</li>
- <li>Return <a href="#sec-regexpcreate">RegExpCreate</a>(<i>pattern</i>, <i>flags</i>).</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-template-literals">
- <div class="front">
- <h1><span class="secnum" id="sec-12.2.8"><a href="#sec-template-literals" title="link to this section">12.2.8</a></span>
- Template Literals</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateLiteral</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">NoSubstitutionTemplate</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateSpans</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">TemplateTail</span></div>
- <div class="rhs"><span class="nt">TemplateMiddleList</span><sub class="g-params">[?Yield]</sub> <span class="nt">TemplateTail</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">TemplateMiddleList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">TemplateMiddle</span> <span class="nt">Expression</span><sub class="g-params">[In, ?Yield]</sub></div>
- <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>
- </div>
- </div>
-
- <section id="sec-static-semantics-templatestrings">
- <h1><span class="secnum" id="sec-12.2.8.1"><a href="#sec-static-semantics-templatestrings"
- title="link to this section">12.2.8.1</a></span> Static Semantics: TemplateStrings</h1>
-
- <p>With parameter <var>raw</var>.</p>
-
- <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
- <ol class="proc">
- <li>If <i>raw</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>string</i> be the TV of <i>NoSubstitutionTemplate</i>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>string</i> be the TRV of <i>NoSubstitutionTemplate</i>.</li>
- </ol>
- </li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element,
- <i>string</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>If <i>raw</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>head</i> be the TV of <i>TemplateHead</i>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>head</i> be the TRV of <i>TemplateHead</i>.</li>
- </ol>
- </li>
- <li>Let <i>tail</i> be TemplateStrings of <i>TemplateSpans</i> with argument <i>raw</i>.</li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing <i>head</i> followed by the element,
- in order of <i>tail</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
- <ol class="proc">
- <li>If <i>raw</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>tail</i> be the TV of <i>TemplateTail</i>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>tail</i> be the TRV of <i>TemplateTail</i>.</li>
- </ol>
- </li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element, <i>tail</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
- <ol class="proc">
- <li>Let <i>middle</i> be TemplateStrings of <i>TemplateMiddleList</i> with argument <i>raw</i>.</li>
- <li>If <i>raw</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>tail</i> be the TV of <i>TemplateTail</i>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>tail</i> be the TRV of <i>TemplateTail</i>.</li>
- </ol>
- </li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the elements, in order, of
- <i>middle</i> followed by <i>tail</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
- <ol class="proc">
- <li>If <i>raw</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>string</i> be the TV of <i>TemplateMiddle</i>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>string</i> be the TRV of <i>TemplateMiddle</i>.</li>
- </ol>
- </li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the single element,
- <i>string</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>front</i> be TemplateStrings of <i>TemplateMiddleList</i> with argument <i>raw</i>.</li>
- <li>If <i>raw</i> is <b>false</b>, then
- <ol class="block">
- <li>Let <i>last</i> be the TV of <i>TemplateMiddle</i>.</li>
- </ol>
- </li>
- <li>Else,
- <ol class="block">
- <li>Let <i>last</i> be the TRV of <i>TemplateMiddle</i>.</li>
- </ol>
- </li>
- <li>Append <i>last</i> as the last element of the <a href="#sec-list-and-record-specification-type">List</a>
- <i>front</i>.</li>
- <li>Return <i>front</i>.</li>
- </ol>
- </section>
-
- <section id="sec-template-literals-runtime-semantics-argumentlistevaluation">
- <h1><span class="secnum" id="sec-12.2.8.2"><a href="#sec-template-literals-runtime-semantics-argumentlistevaluation"
- title="link to this section">12.2.8.2</a></span> <span style="font-family: sans-serif">Runtime Semantics:</span>
- ArgumentListEvaluation</h1>
-
- <p>See also: <a href="#sec-argument-lists-runtime-semantics-argumentlistevaluation">12.3.6.1</a></p>
-
- <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
- <ol class="proc">
- <li>Let <i>templateLiteral</i> be this <i>TemplateLiteral.</i></li>
- <li>Let <i>siteObj</i> be <a href="#sec-gettemplateobject">GetTemplateObject</a>(<i>templateLiteral</i>).</li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing the one element which is
- <i>siteObj</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>templateLiteral</i> be this <i>TemplateLiteral.</i></li>
- <li>Let <i>siteObj</i> be <a href="#sec-gettemplateobject">GetTemplateObject</a>(<i>templateLiteral</i>).</li>
- <li>Let <i>firstSub</i> be the result of evaluating <i>Expression</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>firstSub</i>).</li>
- <li>Let <i>restSub</i> be SubstitutionEvaluation of <i>TemplateSpans</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>restSub</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>restSub</i> is a <a
- href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> whose first element is <i>siteObj</i>, whose
- second elements is <i>firstSub</i>, and whose subsequent elements are the elements of <i>restSub</i>, in order.
- <i>restSub</i> may contain no elements.</li>
- </ol>
- </section>
-
- <section id="sec-gettemplateobject">
- <h1><span class="secnum" id="sec-12.2.8.3"><a href="#sec-gettemplateobject"
- title="link to this section">12.2.8.3</a></span> Runtime Semantics: GetTemplateObject ( templateLiteral )</h1>
-
- <p>The abstract operation <span style="font-family: Times New Roman">GetTemplateObject</span> is called with a grammar
- production, <var>templateLiteral</var>, as an argument. It performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>rawStrings</i> be TemplateStrings of <i>templateLiteral</i> with argument <b>true</b>.</li>
- <li>Let <i>ctx</i> be <a href="#sec-execution-contexts">the running execution context</a>.</li>
- <li>Let <i>realm</i> be the <i>ctx</i>&rsquo;s <a href="#sec-code-realms">Realm</a>.</li>
- <li>Let <i>templateRegistry</i> be <i>realm</i>.[[templateMap]].</li>
- <li>For each element <i>e</i> of <i>templateRegistry</i>, do
- <ol class="block">
- <li>If <i>e</i>.[[strings]] and <i>rawStrings</i> contain the same values in the same order, then
- <ol class="block">
- <li>Return <i>e.</i>[[array]].</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Let <i>cookedStrings</i> be TemplateStrings of <i>templateLiteral</i> with argument <b>false</b>.</li>
- <li>Let <i>count</i> be the number of elements in the <a href="#sec-list-and-record-specification-type">List</a>
- <i>cookedStrings</i>.</li>
- <li>Let <i>template</i> be <a href="#sec-arraycreate">ArrayCreate</a>(<i>count</i>).</li>
- <li>Let <i>rawObj</i> be <a href="#sec-arraycreate">ArrayCreate</a>(<i>count</i>).</li>
- <li>Let <i>index</i> be 0.</li>
- <li>Repeat while <i>index</i> &lt; <i>count</i>
- <ol class="block">
- <li>Let <i>prop</i> be <a href="#sec-tostring">ToString</a>(<i>index</i>).</li>
- <li>Let <i>cookedValue</i> be the string value <i>cookedStrings</i>[<i>index</i>].</li>
- <li><a href="#sec-call">Call</a> <i>template</i>.[[DefineOwnProperty]](<i>prop</i>, PropertyDescriptor{[[Value]]:
- <i>cookedValue</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>, [[Configurable]]:
- <b>false</b>})<i>.</i></li>
- <li>Let <i>rawValue</i> be the string value <i>rawStrings</i>[<i>index</i>].</li>
- <li><a href="#sec-call">Call</a> <i>rawObj</i>.[[DefineOwnProperty]](<i>prop</i>, PropertyDescriptor{[[Value]]:
- <i>rawValue</i>, [[Enumerable]]: <b>true</b>, [[Writable]]: <b>false</b>, [[Configurable]]:
- <b>false</b>})<i>.</i></li>
- <li>Let <i>index</i> be <i>index</i>+1.</li>
- </ol>
- </li>
- <li>Perform <a href="#sec-setintegritylevel">SetIntegrityLevel</a>(<i>rawObj</i>, <code>"frozen"</code>).</li>
- <li><a href="#sec-call">Call</a> <i>template</i>.[[DefineOwnProperty]](<code>"raw"</code>, PropertyDescriptor{[[Value]]:
- <i>rawObj</i>, [[Writable]]: <b>false</b>, [[Enumerable]]: <b>false</b>, [[Configurable]]:
- <b>false</b>})<i>.</i></li>
- <li>Perform <a href="#sec-setintegritylevel">SetIntegrityLevel</a>(<i>template</i>, <code>"frozen"</code>).</li>
- <li>Append the Record{[[strings]]: <i>rawStrings</i>, [[array]]: <i>template</i>} to <i>templateRegistry</i>.</li>
- <li>Return <i>template</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE 1</span> The creation of a template object cannot result in an <a
- href="#sec-completion-record-specification-type">abrupt completion</a>.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 2</span> Each <i>TemplateLiteral</i> in the program code of a <a
- href="#sec-code-realms">Realm</a> is associated with a unique template object that is used in the evaluation of tagged
- Templates (<a href="#sec-template-literals-runtime-semantics-evaluation">12.2.8.5</a>). The template objects are frozen
- and the same template object is used each time a specific tagged Template is evaluated. Whether template objects are
- created lazily upon first evaluation of the <i>TemplateLiteral</i> or eagerly prior to first evaluation is an
- implementation choice that is not observable to ECMAScript code.</p>
- </div>
-
- <div class="note">
- <p><span class="nh">NOTE 3</span> Future editions of this specification may define additional non-enumerable properties
- of template objects.</p>
- </div>
- </section>
-
- <section id="sec-runtime-semantics-substitutionevaluation">
- <h1><span class="secnum" id="sec-12.2.8.4"><a href="#sec-runtime-semantics-substitutionevaluation"
- title="link to this section">12.2.8.4</a></span> Runtime Semantics: SubstitutionEvaluation</h1>
- <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
- <ol class="proc">
- <li>Return an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- </ol>
- <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
- <ol class="proc">
- <li>Return the result of SubstitutionEvaluation of <i>TemplateMiddleList</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
- <ol class="proc">
- <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>sub</i>).</li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> containing only <i>sub</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>preceding</i> be the result of SubstitutionEvaluation of <i>TemplateMiddleList</i> .</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>preceding</i>).</li>
- <li>Let <i>next</i> be the result of evaluating <i>Expression</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
- <li>Append <i>next</i> as the last element of the <a href="#sec-list-and-record-specification-type">List</a>
- <i>preceding</i>.</li>
- <li>Return <i>preceding</i>.</li>
- </ol>
- </section>
-
- <section id="sec-template-literals-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.2.8.5"><a href="#sec-template-literals-runtime-semantics-evaluation"
- title="link to this section">12.2.8.5</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">TemplateLiteral</span> <span class="geq">:</span> <span class="nt">NoSubstitutionTemplate</span></div>
- <ol class="proc">
- <li>Return the string value whose code units are the elements of the TV of <i>NoSubstitutionTemplate</i> as defined in
- <a href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>head</i> be the TV of <i>TemplateHead</i> as defined in <a
- href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
- <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
- <li>Let <i>middle</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>middle</i>).</li>
- <li>Let <i>tail</i> be the result of evaluating <i>TemplateSpans</i> .</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>tail</i>).</li>
- <li>Return the string value whose code units are the elements of <i>head</i> followed by the elements of <i>middle</i>
- followed by the elements of <i>tail</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
- href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
- </div>
-
- <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateTail</span></div>
- <ol class="proc">
- <li>Let <i>tail</i> be the TV of <i>TemplateTail</i> as defined in <a
- href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
- <li>Return the string consisting of the code units of <i>tail</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">TemplateSpans</span> <span class="geq">:</span> <span class="nt">TemplateMiddleList</span> <span class="nt">TemplateTail</span></div>
- <ol class="proc">
- <li>Let <i>head</i> be the result of evaluating <i>TemplateMiddleList</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>head</i>).</li>
- <li>Let <i>tail</i> be the TV of <i>TemplateTail</i> as defined in <a
- href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
- <li>Return the string whose code units are the elements of <i>head</i> followed by the elements of <i>tail</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">TemplateMiddleList</span> <span class="geq">:</span> <span class="nt">TemplateMiddle</span> <span class="nt">Expression</span></div>
- <ol class="proc">
- <li>Let <i>head</i> be the TV of <i>TemplateMiddle</i> as defined in <a
- href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
- <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
- <li>Let <i>middle</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>middle</i>).</li>
- <li>Return the sequence of code units consisting of the code units of <i>head</i> followed by the elements of
- <i>middle</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
- href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
- </div>
-
- <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>
- <ol class="proc">
- <li>Let <i>rest</i> be the result of evaluating <i>TemplateMiddleList</i> .</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>rest</i>).</li>
- <li>Let <i>middle</i> be the TV of <i>TemplateMiddle</i> as defined in <a
- href="#sec-template-literal-lexical-components">11.8.6</a>.</li>
- <li>Let <i>sub</i> be the result of evaluating <i>Expression</i>.</li>
- <li>Let <i>last</i> be <a href="#sec-tostring">ToString</a>(<i>sub</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>last</i>).</li>
- <li>Return the sequence of code units consisting of the elements of <i>rest</i> followed by the code units of
- <i>middle</i> followed by the elements of <i>last</i>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The string conversion semantics applied to the <i>Expression</i> value are like <code><a
- href="#sec-string.prototype.concat">String.prototype.concat</a></code> rather than the <code>+</code> operator.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-grouping-operator">
- <div class="front">
- <h1><span class="secnum" id="sec-12.2.9"><a href="#sec-grouping-operator" title="link to this section">12.2.9</a></span>
- The Grouping Operator</h1>
- </div>
-
- <section id="sec-grouping-operator-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-12.2.9.1"><a href="#sec-grouping-operator-static-semantics-early-errors"
- title="link to this section">12.2.9.1</a></span> Static Semantics: Early Errors</h1>
- <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
- <ul>
- <li>
- <p>It is a Syntax Error if the lexical token sequence matched by <span
- class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> cannot be parsed with no tokens left over using
- <span class="nt">ParenthesizedExpression</span> as the goal symbol.</p>
- </li>
-
- <li>
- <p>All Early Errors rules for <span class="nt">ParenthesizedExpression</span> and its derived productions also apply
- to <span style="font-family: Times New Roman">CoveredParenthesizedExpression</span> of <span
- class="nt">CoverParenthesizedExpressionAndArrowParameterList</span>.</p>
- </li>
- </ul>
- </section>
-
- <section id="sec-grouping-operator-static-semantics-isfunctiondefinition">
- <h1><span class="secnum" id="sec-12.2.9.2"><a href="#sec-grouping-operator-static-semantics-isfunctiondefinition"
- title="link to this section">12.2.9.2</a></span> Static Semantics: IsFunctionDefinition</h1>
-
- <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
- href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
- href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
- href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
- href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
- href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
- href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
- href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
- href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
- href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
- href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
- href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
- href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
-
- <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>
- <ol class="proc">
- <li>Return IsFunctionDefinition of <i>Expression</i>.</li>
- </ol>
- </section>
-
- <section id="sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">
- <h1><span class="secnum" id="sec-12.2.9.3"><a href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget"
- title="link to this section">12.2.9.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
-
- <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
- href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
- href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
- href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
- href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
- href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
- href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
- href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
- href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
- href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
- href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
-
- <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>
- <ol class="proc">
- <li>Return IsValidSimpleAssignmentTarget of <i>Expression</i>.</li>
- </ol>
- </section>
-
- <section id="sec-grouping-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.2.9.4"><a href="#sec-grouping-operator-runtime-semantics-evaluation"
- title="link to this section">12.2.9.4</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span> <span class="nt">CoverParenthesizedExpressionAndArrowParameterList</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be CoveredParenthesizedExpression of <i>CoverParenthesizedExpressionAndArrowParameterList</i>.</li>
- <li>Return the result of evaluating <i>expr</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Return the result of evaluating <i>Expression</i>. This may be of type <a
- href="#sec-reference-specification-type">Reference</a>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> This algorithm does not apply <a href="#sec-getvalue">GetValue</a> to the result of
- evaluating <i>Expression</i>. The principal motivation for this is so that operators such as <code>delete</code> and
- <code>typeof</code> may be applied to parenthesized expressions.</p>
- </div>
- </section>
- </section>
- </section>
-
- <section id="sec-left-hand-side-expressions">
- <div class="front">
- <h1><span class="secnum" id="sec-12.3"><a href="#sec-left-hand-side-expressions"
- title="link to this section">12.3</a></span> Left-Hand-Side Expressions</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MemberExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">PrimaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <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>
- <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- <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>
- <div class="rhs"><span class="nt">SuperProperty</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><span class="nt">MetaProperty</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SuperProperty</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <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>
- <div class="rhs"><code class="t">super</code> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MetaProperty</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">NewTarget</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NewTarget</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">new</code> <code class="t">.</code> <code class="t">target</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NewExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span><sub class="g-params">[?Yield]</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CallExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <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>
- <div class="rhs"><span class="nt">SuperCall</span><sub class="g-params">[?Yield]</sub></div>
- <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>
- <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>
- <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">SuperCall</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">super</code> <span class="nt">Arguments</span><sub class="g-params">[?Yield]</sub></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">Arguments</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">(</code> <code class="t">)</code></div>
- <div class="rhs"><code class="t">(</code> <span class="nt">ArgumentList</span><sub class="g-params">[?Yield]</sub> <code class="t">)</code></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">ArgumentList</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
- <div class="rhs"><code class="t">...</code> <span class="nt">AssignmentExpression</span><sub class="g-params">[In, ?Yield]</sub></div>
- <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>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">NewExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><span class="nt">CallExpression</span><sub class="g-params">[?Yield]</sub></div>
- </div>
- </div>
-
- <section id="sec-static-semantics">
- <div class="front">
- <h1><span class="secnum" id="sec-12.3.1"><a href="#sec-static-semantics" title="link to this section">12.3.1</a></span>
- Static Semantics</h1>
- </div>
-
- <section id="sec-static-semantics-static-semantics-contains">
- <h1><span class="secnum" id="sec-12.3.1.1"><a href="#sec-static-semantics-static-semantics-contains"
- title="link to this section">12.3.1.1</a></span> Static Semantics: Contains</h1>
-
- <p>With parameter <var>symbol</var>.</p>
-
- <p>See also: <a href="#sec-static-semantic-rules">5.3</a>, <a
- href="#sec-object-initializer-static-semantics-contains">12.2.5.3</a>, <a
- href="#sec-function-definitions-static-semantics-contains">14.1.4</a>, <a
- href="#sec-arrow-function-definitions-static-semantics-contains">14.2.3</a>, <a
- href="#sec-generator-function-definitions-static-semantics-contains">14.4.4</a>, <a
- href="#sec-class-definitions-static-semantics-contains">14.5.4</a></p>
-
- <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>
- <ol class="proc">
- <li>If <i>MemberExpression</i> Contains <i>symbol</i> is <b>true</b>, return <b>true</b>.</li>
- <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
- <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
- <i>IdentifierName</i>, return <b>true</b>;</li>
- <li>Return <b>false</b>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>If <i>symbol</i> is the <i>ReservedWord</i> <code>super</code>, return <b>true</b>.</li>
- <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
- <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
- <i>IdentifierName</i>, return <b>true</b>;</li>
- <li>Return <b>false</b>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>If <i>CallExpression</i> Contains <i>symbol</i> is <b>true</b>, return <b>true</b>.</li>
- <li>If <i>symbol</i> is a <i>ReservedWord</i>, return <b>false</b>.</li>
- <li>If <i>symbol</i> is an <i>Identifier</i> and StringValue of <i>symbol</i> is the same value as the StringValue of
- <i>IdentifierName</i>, return <b>true</b>;</li>
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-static-semantics-static-semantics-isfunctiondefinition">
- <h1><span class="secnum" id="sec-12.3.1.2"><a href="#sec-static-semantics-static-semantics-isfunctiondefinition"
- title="link to this section">12.3.1.2</a></span> Static Semantics: IsFunctionDefinition</h1>
-
- <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
- href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
- href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
- href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
- href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
- href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
- href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
- href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
- href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
- href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
- href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
- href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
- href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
- <div class="rhs"><span class="nt">SuperProperty</span></div>
- <div class="rhs"><span class="nt">MetaProperty</span></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
- <div class="rhs"><span class="nt">SuperCall</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
- <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-static-semantics-static-semantics-isdestructuring">
- <h1><span class="secnum" id="sec-12.3.1.3"><a href="#sec-static-semantics-static-semantics-isdestructuring"
- title="link to this section">12.3.1.3</a></span> Static Semantics: IsDestructuring</h1>
-
- <p>See also: <a href="#sec-for-in-and-for-of-statements-static-semantics-isdestructuring">13.6.4.6</a>.</p>
-
- <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">PrimaryExpression</span></div>
- <ol class="proc">
- <li>If <i>PrimaryExpression</i> is either an <i>ObjectLiteral</i> or an <i>ArrayLiteral</i>, return <b>true.</b></li>
- <li>Return <b>false</b>.</li>
- </ol>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
- <div class="rhs"><span class="nt">SuperProperty</span></div>
- <div class="rhs"><span class="nt">MetaProperty</span></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
- <div class="rhs"><span class="nt">SuperCall</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
- <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-static-semantics-static-semantics-isidentifierref">
- <h1><span class="secnum" id="sec-12.3.1.4"><a href="#sec-static-semantics-static-semantics-isidentifierref"
- title="link to this section">12.3.1.4</a></span> Static Semantics: IsIdentifierRef</h1>
-
- <p>See also: <a href="#sec-semantics-static-semantics-isidentifierref">12.2.0.3</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">LeftHandSideExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">CallExpression</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
- <div class="rhs"><span class="nt">SuperProperty</span></div>
- <div class="rhs"><span class="nt">MetaProperty</span></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">
- <h1><span class="secnum" id="sec-12.3.1.5"><a href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget"
- title="link to this section">12.3.1.5</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
-
- <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
- href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
- href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
- href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
- href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
- href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
- href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
- href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
- href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
- href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
- href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
- <div class="rhs"><span class="nt">CallExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">[</code> <span class="nt">Expression</span> <code class="t">]</code></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <code class="t">.</code> <span class="nt">IdentifierName</span></div>
- <div class="rhs"><span class="nt">SuperProperty</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>true</b>.</li>
- </ol>
-
- <div class="gp">
- <div class="lhs"><span class="nt">CallExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
- <div class="rhs"><span class="nt">SuperCall</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
- <div class="rhs"><span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NewExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">NewExpression</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MemberExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
- <div class="rhs"><code class="t">new</code> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">NewTarget</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">new</code> <code class="t">.</code> <code class="t">target</code></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-property-accessors">
- <div class="front">
- <h1><span class="secnum" id="sec-12.3.2"><a href="#sec-property-accessors" title="link to this section">12.3.2</a></span>
- Property Accessors</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Properties are accessed by name, using either the dot notation:</p>
- </div>
-
- <div class="lhs">MemberExpression <code>.</code> IdentifierName<br>CallExpression <code>.</code> IdentifierName</div>
-
- <p>or the bracket notation:</p>
-
- <div class="lhs">MemberExpression <code>[</code> Expression <code>]</code><br>CallExpression <code>[</code> Expression <code>]</code></div>
-
- <p>The dot notation is explained by the following syntactic conversion:</p>
-
- <div class="lhs">MemberExpression <code>.</code> IdentifierName</div>
-
- <p>is identical in its behaviour to</p>
-
- <div class="lhs">MemberExpression <code>[</code> &lt;identifier-name-string&gt; <code>]</code></div>
-
- <p>and similarly</p>
-
- <div class="lhs">CallExpression <code>.</code> IdentifierName</div>
-
- <p>is identical in its behaviour to</p>
-
- <div class="lhs">CallExpression <code>[</code> &lt;identifier-name-string&gt; <code>]</code></div>
-
- <p>where <var>&lt;identifier-name-string&gt;</var> is the result of evaluating <span style="font-family: Times New
- Roman">StringValue of</span> <span class="nt">IdentifierName</span>.</p>
- </div>
-
- <section id="sec-property-accessors-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.3.2.1"><a href="#sec-property-accessors-runtime-semantics-evaluation"
- title="link to this section">12.3.2.1</a></span> Runtime Semantics: Evaluation</h1>
- <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>
- <ol class="proc">
- <li>Let <i>baseReference</i> be the result of evaluating <i>MemberExpression</i>.</li>
- <li>Let <i>baseValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>baseReference</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>baseValue</i>).</li>
- <li>Let <i>propertyNameReference</i> be the result of evaluating <i>Expression</i>.</li>
- <li>Let <i>propertyNameValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>propertyNameReference</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyNameValue</i>).</li>
- <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
- <li>Let <i>propertyKey</i> be <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propertyNameValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyKey</i>).</li>
- <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
- mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
- <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i> and
- whose referenced name is <i>propertyKey</i>, and whose strict reference flag is <i>strict</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>baseReference</i> be the result of evaluating <i>MemberExpression</i>.</li>
- <li>Let <i>baseValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>baseReference</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>baseValue</i>).</li>
- <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
- <li>Let <i>propertyNameString</i> be StringValue of <i>IdentifierName</i></li>
- <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
- mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
- <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i> and
- whose referenced name is <i>propertyNameString</i>, and whose strict reference flag is <i>strict</i>.</li>
- </ol>
- <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>
-
- <p>Is evaluated in exactly the same manner as <span class="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></span> except that the contained <span class="nt">CallExpression</span> is evaluated in step
- 1.</p>
-
- <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>
-
- <p>Is evaluated in exactly the same manner as <span class="prod"><span class="nt">MemberExpression</span> <span
- class="geq">:</span> <span class="nt">MemberExpression</span> <code class="t">.</code> <span
- class="nt">IdentifierName</span></span> except that the contained <span class="nt">CallExpression</span> is evaluated in
- step 1.</p>
- </section>
- </section>
-
- <section id="sec-new-operator">
- <div class="front">
- <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
- <code>new</code> Operator</h1>
- </div>
-
- <section id="sec-new-operator-runtime-semantics-evaluation">
- <div class="front">
- <h1><span class="secnum" id="sec-12.3.3.1"><a href="#sec-new-operator-runtime-semantics-evaluation"
- title="link to this section">12.3.3.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">NewExpression</span> <span class="geq">:</span> <code class="t">new</code> <span class="nt">NewExpression</span></div>
- <ol class="proc">
- <li>Return <a href="#sec-evaluatenew">EvaluateNew</a>(<i>NewExpression</i>, <span style="font-family:
- sans-serif">empty</span>).</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Return <a href="#sec-evaluatenew">EvaluateNew</a>(<i>MemberExpression</i>, <i>Arguments</i>).</li>
- </ol>
- </div>
-
- <section id="sec-evaluatenew">
- <h1><span class="secnum" id="sec-12.3.3.1.1"><a href="#sec-evaluatenew"
- title="link to this section">12.3.3.1.1</a></span> Runtime Semantics: EvaluateNew(constructProduction,
- arguments)</h1>
-
- <p>The abstract operation EvaluateNew with arguments <span style="font-family: Times New
- Roman"><i>constructProduction</i>,</span> and <var>arguments</var> performs the following steps:</p>
-
- <ol class="proc">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>constructProduction</i> is either a <i>NewExpression</i> or a
- <i>MemberExpression</i>.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>arguments</i> is either <span style="font-family:
- sans-serif">empty</span> or an <i>Arguments</i> production.</li>
- <li>Let <i>ref</i> be the result of evaluating <i>constructProduction</i>.</li>
- <li>Let <i>constructor</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>constructor</i>).</li>
- <li>If <i>arguments</i> is <span style="font-family: sans-serif">empty</span>, let <i>argList</i> be an empty <a
- href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Else,
- <ol class="block">
- <li>Let <i>argList</i> be ArgumentListEvaluation of <i>arguments</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
- </ol>
- </li>
- <li>If <a href="#sec-isconstructor">IsConstructor</a> (<i>constructor</i>) is <b>false</b>, throw a <b>TypeError</b>
- exception.</li>
- <li>Return <a href="#sec-construct">Construct</a>(<i>constructor</i>, <i>argList</i>).</li>
- </ol>
- </section>
- </section>
- </section>
-
- <section id="sec-function-calls">
- <div class="front">
- <h1><span class="secnum" id="sec-12.3.4"><a href="#sec-function-calls" title="link to this section">12.3.4</a></span>
- Function Calls</h1>
- </div>
-
- <section id="sec-function-calls-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.3.4.1"><a href="#sec-function-calls-runtime-semantics-evaluation"
- title="link to this section">12.3.4.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <span class="nt">Arguments</span></div>
- <ol class="proc">
- <li>Let <i>ref</i> be the result of evaluating <i>MemberExpression</i>.</li>
- <li>Let <i>func</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
- href="#sec-reference-specification-type">Reference</a> and <a
- href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>false</b> and <a
- href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>) <i>is</i> <code>"eval"</code>, then
- <ol class="block">
- <li>If <a href="#sec-samevalue">SameValue</a>(<i>func</i>, %eval%) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>argList</i> be ArgumentListEvaluation(<i>Arguments</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
- <li>If <i>argList</i> has no elements, return <b>undefined.</b></li>
- <li>Let <i>evalText</i> be the first element of <i>argList</i>.</li>
- <li>If the source code matching this <i>CallExpression</i> is <a href="#sec-strict-mode-code">strict code</a>,
- let <i>strictCaller</i> be <b>true.</b> Otherwise let <i>strictCaller</i> be <b>false.</b></li>
- <li>Let <i>evalRealm</i> be <a href="#sec-execution-contexts">the running execution context</a>&rsquo;s <a
- href="#sec-code-realms">Realm</a>.</li>
- <li>Return <a href="#sec-performeval">PerformEval</a>(<i>evalText</i>, <i>evalRealm</i>, <i>strictCaller</i>,
- <b>true</b>). .</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
- href="#sec-reference-specification-type">Reference</a>, then
- <ol class="block">
- <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>thisValue</i> be <a href="#sec-getthisvalue">GetThisValue</a>(<i>ref</i>).</li>
- </ol>
- </li>
- <li>Else, the base of <i>ref</i> is an <a href="#sec-environment-records">Environment Record</a>
- <ol class="block">
- <li>Let <i>refEnv</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
- <li>Let <i>thisValue</i> be <i>refEnv</i>.WithBaseObject().</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Else <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
- href="#sec-reference-specification-type">Reference</a>,
- <ol class="block">
- <li>Let <i>thisValue</i> be <b>undefined</b>.</li>
- </ol>
- </li>
- <li>Let <i>thisCall</i> be this <i>CallExpression</i>.</li>
- <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
- href="#sec-isintailposition">14.6.1</a>)</li>
- <li>Return <a href="#sec-evaluatedirectcall">EvaluateDirectCall</a>(<i>func</i>, <i>thisValue</i>, <i>Arguments</i>,
- <i>tailCall</i>).</li>
- </ol>
-
- <p>A <span class="nt">CallExpression</span> whose evaluation executes step 4.a.vii is a <i>direct eval</i>.</p>
-
- <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <span class="nt">Arguments</span></div>
- <ol class="proc">
- <li>Let <i>ref</i> be the result of evaluating <i>CallExpression</i>.</li>
- <li>Let <i>thisCall</i> be this <i>CallExpression</i></li>
- <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
- href="#sec-isintailposition">14.6.1</a>)</li>
- <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>ref</i>, <i>Arguments</i>, <i>tailCall</i>).</li>
- </ol>
- </section>
-
- <section id="sec-evaluatecall">
- <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>
- Runtime Semantics: EvaluateCall( ref, arguments, tailPosition )</h1>
-
- <p>The abstract operation EvaluateCall takes as arguments a value <var>ref</var>, a syntactic grammar production
- <var>arguments</var>, and a Boolean argument <var>tailPosition</var>. It performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>func</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is <a
- href="#sec-reference-specification-type">Reference</a>, then
- <ol class="block">
- <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
- <ol class="block">
- <li>Let <i>thisValue</i> be <a href="#sec-getthisvalue">GetThisValue</a>(<i>ref</i>).</li>
- </ol>
- </li>
- <li>Else, the base of <i>ref</i> is an <a href="#sec-environment-records">Environment Record</a>
- <ol class="block">
- <li>Let <i>refEnv</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
- <li>Let <i>thisValue</i> be <i>refEnv</i>.WithBaseObject().</li>
- </ol>
- </li>
- </ol>
- </li>
- <li>Else <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
- href="#sec-reference-specification-type">Reference</a>,
- <ol class="block">
- <li>Let <i>thisValue</i> be <b>undefined</b>.</li>
- </ol>
- </li>
- <li>Return <a href="#sec-evaluatedirectcall">EvaluateDirectCall</a>(<i>func</i>, <i>thisValue</i>, <i>arguments</i>,
- <i>tailPosition</i>).</li>
- </ol>
- </section>
-
- <section id="sec-evaluatedirectcall">
- <h1><span class="secnum" id="sec-12.3.4.3"><a href="#sec-evaluatedirectcall"
- title="link to this section">12.3.4.3</a></span> Runtime Semantics: EvaluateDirectCall( func, thisValue, arguments,
- tailPosition )</h1>
-
- <p>The abstract operation EvaluateDirectCall takes as arguments a value <var>func</var>, a value <var>thisValue</var>, a
- syntactic grammar production <var>arguments</var>, and a Boolean argument <var>tailPosition</var>. It performs the
- following steps:</p>
-
- <ol class="proc">
- <li>Let <i>argList</i> be ArgumentListEvaluation(<i>arguments</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>func</i>) is not Object, throw a <b>TypeError</b>
- exception.</li>
- <li>If <a href="#sec-iscallable">IsCallable</a>(<i>func</i>) is <b>false</b>, throw a <b>TypeError</b> exception.</li>
- <li>If <i>tailPosition</i> is <b>true</b>, perform <a href="#sec-preparefortailcall">PrepareForTailCall</a>().</li>
- <li>Let <i>result</i> be <a href="#sec-call">Call</a>(<i>func</i>, <i>thisValue</i>, <i>argList</i>).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>tailPosition</i> is <b>true</b>, the above call will not
- return here, but instead evaluation will continue as if the following return has already occurred.</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: If <i>result</i> is not an <a
- href="#sec-completion-record-specification-type">abrupt completion</a> then <a
- href="#sec-ecmascript-data-types-and-values">Type</a>(<i>result</i>) is an <a
- href="#sec-ecmascript-language-types">ECMAScript language type</a>.</li>
- <li>Return <i>result</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-super-keyword">
- <div class="front">
- <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
- <code>super</code> Keyword</h1>
- </div>
-
- <section id="sec-super-keyword-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.3.5.1"><a href="#sec-super-keyword-runtime-semantics-evaluation"
- title="link to this section">12.3.5.1</a></span> Runtime Semantics: Evaluation</h1>
- <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>
- <ol class="proc">
- <li>Let <i>propertyNameReference</i> be the result of evaluating <i>Expression</i>.</li>
- <li>Let <i>propertyNameValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>propertyNameReference</i>).</li>
- <li>Let <i>propertyKey</i> be <a href="#sec-topropertykey">ToPropertyKey</a>(<i>propertyNameValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>propertyKey</i>).</li>
- <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
- mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
- <li>Return <a href="#sec-makesuperpropertyreference">MakeSuperPropertyReference</a>(<i>propertyKey</i>,
- <i>strict</i>).</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>propertyKey</i> be StringValue of <i>IdentifierName</i>.</li>
- <li>If the code matched by the syntactic production that is being evaluated is <a href="#sec-strict-mode-code">strict
- mode code</a>, let <i>strict</i> be <b>true</b>, else let <i>strict</i> be <b>false</b>.</li>
- <li>Return <a href="#sec-makesuperpropertyreference">MakeSuperPropertyReference</a>(<i>propertyKey</i>,
- <i>strict</i>).</li>
- </ol>
- <div class="gp prod"><span class="nt">SuperCall</span> <span class="geq">:</span> <code class="t">super</code> <span class="nt">Arguments</span></div>
- <ol class="proc">
- <li>Let <i>newTarget</i> be <a href="#sec-getnewtarget">GetNewTarget</a>().</li>
- <li>If <i>newTarget</i> is <b>undefined</b>, throw a <b>ReferenceError</b> exception.</li>
- <li>Let <i>func</i> be <a href="#sec-getsuperconstructor">GetSuperConstructor</a>().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>func</i>).</li>
- <li>Let <i>argList</i> be ArgumentListEvaluation of <i>Arguments</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>argList</i>).</li>
- <li>Let <i>result</i> be <a href="#sec-construct">Construct</a>(<i>func</i>, <i>argList</i>, <i>newTarget</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>result</i>).</li>
- <li>Let <i>thisER</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
- <li>Return <i>thisER</i>.<a href="#sec-bindthisvalue">BindThisValue</a>(<i>result</i>).</li>
- </ol>
- </section>
-
- <section id="sec-getsuperconstructor">
- <h1><span class="secnum" id="sec-12.3.5.2"><a href="#sec-getsuperconstructor"
- title="link to this section">12.3.5.2</a></span> Runtime Semantics: GetSuperConstructor ( )</h1>
-
- <p>The abstract operation GetSuperConstructor performs the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>envRec</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
- <li><a href="#sec-algorithm-conventions">Assert</a>: <i>envRec</i> is a function <a
- href="#sec-environment-records">Environment Record</a>.</li>
- <li>Let <i>activeFunction</i> be <i>envRec</i>.[[FunctionObject]].</li>
- <li>Let <i>superConstructor</i> be <i>activeFunction</i>.[[GetPrototypeOf]]().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>superConstructor</i>).</li>
- <li>If <a href="#sec-isconstructor">IsConstructor</a>(<i>superConstructor</i>) is <b>false</b>, throw a <b>TypeError</b>
- exception.</li>
- <li>Return <i>superConstructor</i>.</li>
- </ol>
- </section>
-
- <section id="sec-makesuperpropertyreference">
- <h1><span class="secnum" id="sec-12.3.5.3"><a href="#sec-makesuperpropertyreference"
- title="link to this section">12.3.5.3</a></span> Runtime Semantics: MakeSuperPropertyReference(propertyKey,
- strict)</h1>
-
- <p>The abstract operation MakeSuperPropertyReference with arguments <var>propertyKey</var> and <var>strict</var> performs
- the following steps:</p>
-
- <ol class="proc">
- <li>Let <i>env</i> be <a href="#sec-getthisenvironment">GetThisEnvironment</a>( ).</li>
- <li>If <i>env</i>.HasSuperBinding() is <b>false</b>, throw a <b>ReferenceError</b> exception.</li>
- <li>Let <i>actualThis</i> be <i>env</i>.GetThisBinding().</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>actualThis</i>).</li>
- <li>Let <i>baseValue</i> be <i>env</i>.<a href="#sec-getsuperbase">GetSuperBase</a>().</li>
- <li>Let <i>bv</i> be <a href="#sec-requireobjectcoercible">RequireObjectCoercible</a>(<i>baseValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>bv</i>).</li>
- <li>Return a value of type <a href="#sec-reference-specification-type">Reference</a> that is a Super <a
- href="#sec-reference-specification-type">Reference</a> whose base value is <i>bv</i>, whose referenced name is
- <i>propertyKey</i>, whose thisValue is <i>actualThis</i>, and whose strict reference flag is <i>strict</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-argument-lists">
- <div class="front">
- <h1><span class="secnum" id="sec-12.3.6"><a href="#sec-argument-lists" title="link to this section">12.3.6</a></span>
- Argument Lists</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The evaluation of an argument list produces a <a
- href="#sec-list-and-record-specification-type">List</a> of values (<a href="#sec-list-and-record-specification-type">see
- 6.2.1</a>).</p>
- </div>
- </div>
-
- <section id="sec-argument-lists-runtime-semantics-argumentlistevaluation">
- <h1><span class="secnum" id="sec-12.3.6.1"><a href="#sec-argument-lists-runtime-semantics-argumentlistevaluation"
- title="link to this section">12.3.6.1</a></span> <span style="font-family: sans-serif">Runtime Semantics:</span>
- ArgumentListEvaluation</h1>
-
- <p>See also: <a href="#sec-template-literals-runtime-semantics-argumentlistevaluation">12.2.8.2</a></p>
-
- <div class="gp prod"><span class="nt">Arguments</span> <span class="geq">:</span> <code class="t">(</code> <code class="t">)</code></div>
- <ol class="proc">
- <li>Return an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- </ol>
- <div class="gp prod"><span class="nt">ArgumentList</span> <span class="geq">:</span> <span class="nt">AssignmentExpression</span></div>
- <ol class="proc">
- <li>Let <i>ref</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>arg</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>arg</i>).</li>
- <li>Return a <a href="#sec-list-and-record-specification-type">List</a> whose sole item is <i>arg</i>.</li>
- </ol>
- <div class="gp prod"><span class="nt">ArgumentList</span> <span class="geq">:</span> <code class="t">...</code> <span class="nt">AssignmentExpression</span></div>
- <ol class="proc">
- <li>Let <i>list</i> be an empty <a href="#sec-list-and-record-specification-type">List</a>.</li>
- <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>spreadObj</i> be <a href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>).</li>
- <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<i>spreadObj</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
- <li>Repeat
- <ol class="block">
- <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
- <li>If <i>next</i> is <b>false</b>, return <i>list</i>.</li>
- <li>Let <i>nextArg</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextArg</i>).</li>
- <li>Append <i>nextArg</i> as the last element of <i>list</i>.</li>
- </ol>
- </li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>precedingArgs</i> be the result of evaluating <i>ArgumentList</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>precedingArgs</i>).</li>
- <li>Let <i>ref</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>arg</i> be <a href="#sec-getvalue">GetValue</a>(<i>ref</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>arg</i>).</li>
- <li>Append <i>arg</i> to the end of <i>precedingArgs</i>.</li>
- <li>Return <i>precedingArgs</i>.</li>
- </ol>
- <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>
- <ol class="proc">
- <li>Let <i>precedingArgs</i> be the result of evaluating <i>ArgumentList</i>.</li>
- <li>Let <i>spreadRef</i> be the result of evaluating <i>AssignmentExpression</i>.</li>
- <li>Let <i>iterator</i> be <a href="#sec-getiterator">GetIterator</a>(<a
- href="#sec-getvalue">GetValue</a>(<i>spreadRef</i>) ).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>iterator</i>).</li>
- <li>Repeat
- <ol class="block">
- <li>Let <i>next</i> be <a href="#sec-iteratorstep">IteratorStep</a>(<i>iterator</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>next</i>).</li>
- <li>If <i>next</i> is <b>false</b>, return <i>precedingArgs</i>.</li>
- <li>Let <i>nextArg</i> be <a href="#sec-iteratorvalue">IteratorValue</a>(<i>next</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>nextArg</i>).</li>
- <li>Append <i>nextArg</i> as the last element of <i>precedingArgs</i>.</li>
- </ol>
- </li>
- </ol>
- </section>
- </section>
-
- <section id="sec-tagged-templates">
- <div class="front">
- <h1><span class="secnum" id="sec-12.3.7"><a href="#sec-tagged-templates" title="link to this section">12.3.7</a></span>
- Tagged Templates</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> A tagged template is a function call where the arguments of the call are derived from a
- <i>TemplateLiteral</i> (<a href="#sec-template-literals">12.2.8</a>). The actual arguments include a template object (<a
- href="#sec-gettemplateobject">12.2.8.3</a>) and the values produced by evaluating the expressions embedded within the
- <i>TemplateLiteral</i>.</p>
- </div>
- </div>
-
- <section id="sec-tagged-templates-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.3.7.1"><a href="#sec-tagged-templates-runtime-semantics-evaluation"
- title="link to this section">12.3.7.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">MemberExpression</span> <span class="geq">:</span> <span class="nt">MemberExpression</span> <span class="nt">TemplateLiteral</span></div>
- <ol class="proc">
- <li>Let <i>tagRef</i> be the result of evaluating <i>MemberExpression</i>.</li>
- <li>Let <i>thisCall</i> be this <i>MemberExpression</i>.</li>
- <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
- href="#sec-isintailposition">14.6.1</a>)</li>
- <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>tagRef</i>, <i>TemplateLiteral</i>, <i>tailCall</i>).</li>
- </ol>
- <div class="gp prod"><span class="nt">CallExpression</span> <span class="geq">:</span> <span class="nt">CallExpression</span> <span class="nt">TemplateLiteral</span></div>
- <ol class="proc">
- <li>Let <i>tagRef</i> be the result of evaluating <i>CallExpression</i>.</li>
- <li>Let <i>thisCall</i> be this <i>CallExpression</i>.</li>
- <li>Let <i>tailCall</i> be <a href="#sec-isintailposition">IsInTailPosition</a>(<i>thisCall</i>). (See <a
- href="#sec-isintailposition">14.6.1</a>)</li>
- <li>Return <a href="#sec-evaluatecall">EvaluateCall</a>(<i>tagRef</i>, <i>TemplateLiteral</i>, <i>tailCall</i>).</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-meta-properties">
- <div class="front">
- <h1><span class="secnum" id="sec-12.3.8"><a href="#sec-meta-properties" title="link to this section">12.3.8</a></span>
- Meta Properties</h1>
- </div>
-
- <section id="sec-meta-properties-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.3.8.1"><a href="#sec-meta-properties-runtime-semantics-evaluation"
- title="link to this section">12.3.8.1</a></span> Runtime Semantics: Evaluation</h1>
- <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>
- <ol class="proc">
- <li>Return <a href="#sec-getnewtarget">GetNewTarget</a>().</li>
- </ol>
- </section>
- </section>
- </section>
-
- <section id="sec-postfix-expressions">
- <div class="front">
- <h1><span class="secnum" id="sec-12.4"><a href="#sec-postfix-expressions" title="link to this section">12.4</a></span>
- Postfix Expressions</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PostfixExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">LeftHandSideExpression</span><sub class="g-params">[?Yield]</sub></div>
- <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>
- <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>
- </div>
- </div>
-
- <section id="sec-postfix-expressions-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-12.4.1"><a href="#sec-postfix-expressions-static-semantics-early-errors"
- title="link to this section">12.4.1</a></span> Static Semantics: Early Errors</h1>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
- <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
- </div>
-
- <ul>
- <li>
- <p>It is an early <a href="#sec-reference-specification-type">Reference</a> Error if <span style="font-family: Times New
- Roman">IsValidSimpleAssignmentTarget</span> of <span class="nt">LeftHandSideExpression</span> is <span
- class="value">false</span>.</p>
- </li>
- </ul>
- </section>
-
- <section id="sec-postfix-expressions-static-semantics-isfunctiondefinition">
- <h1><span class="secnum" id="sec-12.4.2"><a href="#sec-postfix-expressions-static-semantics-isfunctiondefinition"
- title="link to this section">12.4.2</a></span> Static Semantics: IsFunctionDefinition</h1>
-
- <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
- href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
- href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
- href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
- href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
- href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
- href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
- href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
- href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
- href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
- href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
- href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
- href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a></p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
- <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">
- <h1><span class="secnum" id="sec-12.4.3"><a href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget"
- title="link to this section">12.4.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
-
- <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
- href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
- href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
- href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
- href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
- href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
- href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
- href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
- href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
- href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
- href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">PostfixExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
- <div class="rhs"><span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-postfix-increment-operator">
- <div class="front">
- <h1><span class="secnum" id="sec-12.4.4"><a href="#sec-postfix-increment-operator"
- title="link to this section">12.4.4</a></span> Postfix Increment Operator</h1>
- </div>
-
- <section id="sec-postfix-increment-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.4.4.1"><a href="#sec-postfix-increment-operator-runtime-semantics-evaluation"
- title="link to this section">12.4.4.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">PostfixExpression</span> <span class="geq">:</span> <span class="nt">LeftHandSideExpression</span> <code class="t">++</code></div>
- <ol class="proc">
- <li>Let <i>lhs</i> be the result of evaluating <i>LeftHandSideExpression</i>.</li>
- <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>lhs</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
- <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
- the <code>+</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see 12.7.5</a>).</li>
- <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>newValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Return <i>oldValue</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-postfix-decrement-operator">
- <div class="front">
- <h1><span class="secnum" id="sec-12.4.5"><a href="#sec-postfix-decrement-operator"
- title="link to this section">12.4.5</a></span> Postfix Decrement Operator</h1>
- </div>
-
- <section id="sec-postfix-decrement-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.4.5.1"><a href="#sec-postfix-decrement-operator-runtime-semantics-evaluation"
- title="link to this section">12.4.5.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">PostfixExpression</span> <span class="geq">:</span> <span class="nt">LeftHandSideExpression</span> <code class="t">--</code></div>
- <ol class="proc">
- <li>Let <i>lhs</i> be the result of evaluating <i>LeftHandSideExpression</i>.</li>
- <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>lhs</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
- <li>Let <i>newValue</i> be the result of subtracting the value <code>1</code> from <i>oldValue</i>, using the same rules
- as for the <code>-</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">12.7.5</a>).</li>
- <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>lhs</i>, <i>newValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Return <i>oldValue</i>.</li>
- </ol>
- </section>
- </section>
- </section>
-
- <section id="sec-unary-operators">
- <div class="front">
- <h1><span class="secnum" id="sec-12.5"><a href="#sec-unary-operators" title="link to this section">12.5</a></span> Unary
- Operators</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">UnaryExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">PostfixExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- </div>
- </div>
-
- <section id="sec-unary-operators-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-12.5.1"><a href="#sec-unary-operators-static-semantics-early-errors"
- title="link to this section">12.5.1</a></span> Static Semantics: Early Errors</h1>
-
- <div class="gp">
- <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
- </div>
-
- <ul>
- <li>
- <p>It is an early <a href="#sec-reference-specification-type">Reference</a> Error if <span style="font-family: Times New
- Roman">IsValidSimpleAssignmentTarget</span> of <span class="nt">UnaryExpression</span> is <span
- class="value">false</span>.</p>
- </li>
- </ul>
- </section>
-
- <section id="sec-unary-operators-static-semantics-isfunctiondefinition">
- <h1><span class="secnum" id="sec-12.5.2"><a href="#sec-unary-operators-static-semantics-isfunctiondefinition"
- title="link to this section">12.5.2</a></span> Static Semantics: IsFunctionDefinition</h1>
-
- <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
- href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
- href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
- href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition">12.6.1</a>, <a
- href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
- href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
- href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
- href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
- href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
- href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
- href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
- href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
- href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">
- <h1><span class="secnum" id="sec-12.5.3"><a href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget"
- title="link to this section">12.5.3</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
-
- <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
- href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
- href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
- href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
- href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
- href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">12.6.2</a>, <a
- href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
- href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
- href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
- href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
- href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
- href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
-
- <div class="gp">
- <div class="lhs"><span class="nt">UnaryExpression</span> <span class="geq">:</span></div>
- <div class="rhs"><code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">void</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">++</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">--</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">+</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">-</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">~</code> <span class="nt">UnaryExpression</span></div>
- <div class="rhs"><code class="t">!</code> <span class="nt">UnaryExpression</span></div>
- </div>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-delete-operator">
- <div class="front">
- <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
- <code>delete</code> Operator</h1>
- </div>
-
- <section id="sec-delete-operator-static-semantics-early-errors">
- <h1><span class="secnum" id="sec-12.5.4.1"><a href="#sec-delete-operator-static-semantics-early-errors"
- title="link to this section">12.5.4.1</a></span> Static Semantics: Early Errors</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
- <ul>
- <li>
- <p>It is a Syntax Error if the <span class="nt">UnaryExpression</span> is contained in <a
- href="#sec-strict-mode-code">strict mode code</a> and the derived <span class="nt">UnaryExpression</span> is <span
- class="prod"><span class="nt">PrimaryExpression</span> <span class="geq">:</span></span>
- <var>IdentifierReference.</var></p>
- </li>
-
- <li>
- <p>It is a Syntax Error if the derived <span class="nt">UnaryExpression</span> is<br> <span style="font-family:
- Times New Roman"><i>PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList<br></i></span>and <span
- class="nt">CoverParenthesizedExpressionAndArrowParameterList</span> ultimately derives a phrase that, if used in place
- of <var>UnaryExpression,</var> would produce a Syntax Error according to these rules. This rule is recursively
- applied.</p>
- </li>
- </ul>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The last rule means that expressions such as<br>&#x9;&#x9;<code>delete
- (((foo)))</code><br>produce early errors because of recursive application of the first rule.</p>
- </div>
- </section>
-
- <section id="sec-delete-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.4.2"><a href="#sec-delete-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.4.2</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">delete</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>ref</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>ref</i>).</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>ref</i>) is not <a
- href="#sec-reference-specification-type">Reference</a>, return <b>true</b>.</li>
- <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>ref</i>) is <b>true</b>, then
- <ol class="block">
- <li><a href="#sec-algorithm-conventions">Assert</a>: <a
- href="#sec-reference-specification-type">IsStrictReference</a>(<i>ref</i>) is <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </li>
- <li>If <a href="#sec-reference-specification-type">IsPropertyReference</a>(<i>ref</i>) is <b>true</b>, then
- <ol class="block">
- <li>If <a href="#sec-reference-specification-type">IsSuperReference</a>(<i>ref</i>), throw a <b>ReferenceError</b>
- exception.</li>
- <li>Let <i>baseObj</i> be <a href="#sec-toobject">ToObject</a>(<a
- href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>)).</li>
- <li>Let <i>deleteStatus</i> be <i>baseObj</i>.[[Delete]](<a
- href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>deleteStatus</i>).</li>
- <li>If <i>deleteStatus</i> is <b>false</b> and <a
- href="#sec-reference-specification-type">IsStrictReference</a>(<i>ref</i>) is <b>true</b>, throw a
- <b>TypeError</b> exception.</li>
- <li>Return <i>deleteStatus</i>.</li>
- </ol>
- </li>
- <li>Else <i>ref</i> is a <a href="#sec-reference-specification-type">Reference</a> to an <a
- href="#sec-environment-records">Environment Record</a> binding,
- <ol class="block">
- <li>Let <i>bindings</i> be <a href="#sec-reference-specification-type">GetBase</a>(<i>ref</i>).</li>
- <li>Return <i>bindings</i>.DeleteBinding(<a
- href="#sec-reference-specification-type">GetReferencedName</a>(<i>ref</i>)).</li>
- </ol>
- </li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> When a <code>delete</code> operator occurs within <a href="#sec-strict-mode-code">strict
- mode code</a>, a <b>SyntaxError</b> exception is thrown if its <i>UnaryExpression</i> is a direct reference to a
- variable, function argument, or function name. In addition, if a <code>delete</code> operator occurs within <a
- href="#sec-strict-mode-code">strict mode code</a> and the property to be deleted has the attribute { [[Configurable]]:
- <b>false</b> }, a <b>TypeError</b> exception is thrown.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-void-operator">
- <div class="front">
- <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
- <code>void</code> Operator</h1>
- </div>
-
- <section id="sec-void-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.5.1"><a href="#sec-void-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.5.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">void</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>Let <i>status</i> be <a href="#sec-getvalue">GetValue</a>(<i>expr</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Return <b>undefined</b>.</li>
- </ol>
-
- <div class="note">
- <p><span class="nh">NOTE</span> <a href="#sec-getvalue">GetValue</a> must be called even though its value is not used
- because it may have observable side-effects.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-typeof-operator">
- <div class="front">
- <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
- <code>typeof</code> Operator</h1>
- </div>
-
- <section id="sec-typeof-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.6.1"><a href="#sec-typeof-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.6.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">typeof</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>val</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>If <a href="#sec-ecmascript-data-types-and-values">Type</a>(<i>val</i>) is <a
- href="#sec-reference-specification-type">Reference</a>, then
- <ol class="block">
- <li>If <a href="#sec-reference-specification-type">IsUnresolvableReference</a>(<i>val</i>) is <b>true</b>, return
- <code>"undefined"</code>.</li>
- </ol>
- </li>
- <li>Let <i>val</i> be <a href="#sec-getvalue">GetValue</a>(<i>val</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>val</i>).</li>
- <li>Return a String according to <a href="#table-35">Table 35</a>.</li>
- </ol>
-
- <figure>
- <figcaption><span id="table-35">Table 35</span> &mdash; typeof Operator Results</figcaption>
- <table class="real-table">
- <tr>
- <th><b>Type of</b> <span style="font-family: Times New Roman">val</span></th>
- <th>Result</th>
- </tr>
- <tr>
- <td>Undefined</td>
- <td><code>"undefined"</code></td>
- </tr>
- <tr>
- <td>Null</td>
- <td><code>"object"</code></td>
- </tr>
- <tr>
- <td>Boolean</td>
- <td><code>"boolean"</code></td>
- </tr>
- <tr>
- <td>Number</td>
- <td><code>"number"</code></td>
- </tr>
- <tr>
- <td>String</td>
- <td><code>"string"</code></td>
- </tr>
- <tr>
- <td>Symbol</td>
- <td><code>"symbol"</code></td>
- </tr>
- <tr>
- <td>Object (ordinary and does not implement [[Call]])</td>
- <td><code>"object"</code></td>
- </tr>
- <tr>
- <td>Object (standard exotic and does not implement [[Call]])</td>
- <td><code>"object"</code></td>
- </tr>
- <tr>
- <td>Object (implements [[Call]])</td>
- <td><code>"function"</code></td>
- </tr>
- <tr>
- <td>Object (non-standard exotic and does not implement [[Call]])</td>
- <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>
- </tr>
- </table>
- </figure>
-
- <div class="note">
- <p><span class="nh">NOTE</span> Implementations are discouraged from defining new <code>typeof</code> result values for
- non-standard exotic objects. If possible <code>"object"</code>should be used for such objects.</p>
- </div>
- </section>
- </section>
-
- <section id="sec-prefix-increment-operator">
- <div class="front">
- <h1><span class="secnum" id="sec-12.5.7"><a href="#sec-prefix-increment-operator"
- title="link to this section">12.5.7</a></span> Prefix Increment Operator</h1>
- </div>
-
- <section id="sec-prefix-increment-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.7.1"><a href="#sec-prefix-increment-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.7.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">++</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
- <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
- the <code>+</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see 12.7.5</a>).</li>
- <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>expr</i>, <i>newValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Return <i>newValue</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-prefix-decrement-operator">
- <div class="front">
- <h1><span class="secnum" id="sec-12.5.8"><a href="#sec-prefix-decrement-operator"
- title="link to this section">12.5.8</a></span> Prefix Decrement Operator</h1>
- </div>
-
- <section id="sec-prefix-decrement-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.8.1"><a href="#sec-prefix-decrement-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.8.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">--</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
- <li>Let <i>newValue</i> be the result of subtracting the value <code>1</code> from <i>oldValue</i>, using the same
- rules as for the <code>-</code> operator (<a href="#sec-applying-the-additive-operators-to-numbers">see
- 12.7.5</a>).</li>
- <li>Let <i>status</i> be <a href="#sec-putvalue">PutValue</a>(<i>expr</i>, <i>newValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>status</i>).</li>
- <li>Return <i>newValue</i>.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-unary-plus-operator">
- <div class="front">
- <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>
- Unary <code>+</code> Operator</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The unary + operator converts its operand to Number type.</p>
- </div>
- </div>
-
- <section id="sec-unary-plus-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.9.1"><a href="#sec-unary-plus-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.9.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">+</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>Return <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-unary-minus-operator">
- <div class="front">
- <h1><span class="secnum" id="sec-12.5.10"><a href="#sec-unary-minus-operator"
- title="link to this section">12.5.10</a></span> Unary <code>-</code> Operator</h1>
-
- <div class="note">
- <p><span class="nh">NOTE</span> The unary <code>-</code> operator converts its operand to Number type and then negates
- it. Negating <b>+0</b> produces <b>&minus;0</b>, and negating <b>&minus;0</b> produces <b>+0</b>.</p>
- </div>
- </div>
-
- <section id="sec-unary-minus-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.10.1"><a href="#sec-unary-minus-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.10.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">-</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>Let <i>oldValue</i> be <a href="#sec-tonumber">ToNumber</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
- <li>If <i>oldValue</i> is <b>NaN</b>, return <b>NaN</b>.</li>
- <li>Return the result of negating <i>oldValue</i>; that is, compute a Number with the same magnitude but opposite
- sign.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-bitwise-not-operator">
- <div class="front">
- <h1><span class="secnum" id="sec-12.5.11"><a href="#sec-bitwise-not-operator"
- title="link to this section">12.5.11</a></span> Bitwise NOT Operator ( <code>~</code> )</h1>
- </div>
-
- <section id="sec-bitwise-not-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.11.1"><a href="#sec-bitwise-not-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.11.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">~</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>Let <i>oldValue</i> be <a href="#sec-toint32">ToInt32</a>(<a href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
- <li>Return the result of applying bitwise complement to <i>oldValue</i>. The result is a signed 32-bit integer.</li>
- </ol>
- </section>
- </section>
-
- <section id="sec-logical-not-operator">
- <div class="front">
- <h1><span class="secnum" id="sec-12.5.12"><a href="#sec-logical-not-operator"
- title="link to this section">12.5.12</a></span> Logical NOT Operator ( <code>!</code> )</h1>
- </div>
-
- <section id="sec-logical-not-operator-runtime-semantics-evaluation">
- <h1><span class="secnum" id="sec-12.5.12.1"><a href="#sec-logical-not-operator-runtime-semantics-evaluation"
- title="link to this section">12.5.12.1</a></span> Runtime Semantics: Evaluation</h1>
- <div class="gp prod"><span class="nt">UnaryExpression</span> <span class="geq">:</span> <code class="t">!</code> <span class="nt">UnaryExpression</span></div>
- <ol class="proc">
- <li>Let <i>expr</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>Let <i>oldValue</i> be <a href="#sec-toboolean">ToBoolean</a>(<a
- href="#sec-getvalue">GetValue</a>(<i>expr</i>)).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>oldValue</i>).</li>
- <li>If <i>oldValue</i> is <b>true</b>, return <b>false</b>.</li>
- <li>Return <b>true</b>.</li>
- </ol>
- </section>
- </section>
- </section>
-
- <section id="sec-multiplicative-operators">
- <div class="front">
- <h1><span class="secnum" id="sec-12.6"><a href="#sec-multiplicative-operators" title="link to this section">12.6</a></span>
- Multiplicative Operators</h1>
- <h2>Syntax</h2>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MultiplicativeExpression</span><sub class="g-params">[Yield]</sub> <span class="geq">:</span></div>
- <div class="rhs"><span class="nt">UnaryExpression</span><sub class="g-params">[?Yield]</sub></div>
- <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>
- </div>
-
- <div class="gp">
- <div class="lhs"><span class="nt">MultiplicativeOperator</span> <span class="geq">:</span> <span class="grhsmod">one of</span></div>
- <div class="rhs"><code class="t">*</code> <code class="t">/</code> <code class="t">%</code></div>
- </div>
- </div>
-
- <section id="sec-multiplicative-operators-static-semantics-isfunctiondefinition">
- <h1><span class="secnum" id="sec-12.6.1"><a href="#sec-multiplicative-operators-static-semantics-isfunctiondefinition"
- title="link to this section">12.6.1</a></span> Static Semantics: IsFunctionDefinition</h1>
-
- <p>See also: <a href="#sec-semantics-static-semantics-isfunctiondefinition">12.2.0.2</a>, <a
- href="#sec-grouping-operator-static-semantics-isfunctiondefinition">12.2.9.2</a>, <a
- href="#sec-static-semantics-static-semantics-isfunctiondefinition">12.3.1.2</a>, <a
- href="#sec-postfix-expressions-static-semantics-isfunctiondefinition">12.4.2</a>, <a
- href="#sec-unary-operators-static-semantics-isfunctiondefinition">12.5.2</a>, <a
- href="#sec-additive-operators-static-semantics-isfunctiondefinition">12.7.1</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isfunctiondefinition">12.8.1</a>, <a
- href="#sec-relational-operators-static-semantics-isfunctiondefinition">12.9.1</a>, <a
- href="#sec-equality-operators-static-semantics-isfunctiondefinition">12.10.1</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isfunctiondefinition">12.11.1</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isfunctiondefinition">12.12.1</a>, <a
- href="#sec-conditional-operator-static-semantics-isfunctiondefinition">12.13.1</a>, <a
- href="#sec-assignment-operators-static-semantics-isfunctiondefinition">12.14.2</a>, <a
- href="#sec-comma-operator-static-semantics-isfunctiondefinition">12.15.1</a>, <a
- href="#sec-function-definitions-static-semantics-isfunctiondefinition">14.1.11</a>, <a
- href="#sec-generator-function-definitions-static-semantics-isfunctiondefinition">14.4.9</a>, <a
- href="#sec-class-definitions-static-semantics-isfunctiondefinition">14.5.8</a>.</p>
-
- <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
- <i>UnaryExpression</i></p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget">
- <h1><span class="secnum" id="sec-12.6.2"><a
- href="#sec-multiplicative-operators-static-semantics-isvalidsimpleassignmenttarget"
- title="link to this section">12.6.2</a></span> Static Semantics: IsValidSimpleAssignmentTarget</h1>
-
- <p>See also: <a href="#sec-identifiers-static-semantics-isvalidsimpleassignmenttarget">12.1.3</a>, <a
- href="#sec-semantics-static-semantics-isvalidsimpleassignmenttarget">12.2.0.4</a>, <a
- href="#sec-grouping-operator-static-semantics-isvalidsimpleassignmenttarget">12.2.9.3</a>, <a
- href="#sec-static-semantics-static-semantics-isvalidsimpleassignmenttarget">12.3.1.5</a>, <a
- href="#sec-postfix-expressions-static-semantics-isvalidsimpleassignmenttarget">12.4.3</a>, <a
- href="#sec-unary-operators-static-semantics-isvalidsimpleassignmenttarget">12.5.3</a>, <a
- href="#sec-additive-operators-static-semantics-isvalidsimpleassignmenttarget">12.7.2</a>, <a
- href="#sec-bitwise-shift-operators-static-semantics-isvalidsimpleassignmenttarget">12.8.2</a>, <a
- href="#sec-relational-operators-static-semantics-isvalidsimpleassignmenttarget">12.9.2</a>, <a
- href="#sec-equality-operators-static-semantics-isvalidsimpleassignmenttarget">12.10.2</a>, <a
- href="#sec-binary-bitwise-operators-static-semantics-isvalidsimpleassignmenttarget">12.11.2</a>, <a
- href="#sec-binary-logical-operators-static-semantics-isvalidsimpleassignmenttarget">12.12.2</a>, <a
- href="#sec-conditional-operator-static-semantics-isvalidsimpleassignmenttarget">12.13.2</a>, <a
- href="#sec-assignment-operators-static-semantics-isvalidsimpleassignmenttarget">12.14.3</a>, <a
- href="#sec-comma-operator-static-semantics-isvalidsimpleassignmenttarget">12.15.2</a>.</p>
-
- <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
- <i>UnaryExpression</i></p>
-
- <ol class="proc">
- <li>Return <b>false</b>.</li>
- </ol>
- </section>
-
- <section id="sec-multiplicative-operators-runtime-semantics-evaluation">
- <div class="front">
- <h1><span class="secnum" id="sec-12.6.3"><a href="#sec-multiplicative-operators-runtime-semantics-evaluation"
- title="link to this section">12.6.3</a></span> Runtime Semantics: Evaluation</h1>
-
- <p><i>MultiplicativeExpression <b>:</b></i> <i>MultiplicativeExpression</i> <i>MultiplicativeOperator</i>
- <i>UnaryExpression</i></p>
-
- <ol class="proc">
- <li>Let <i>left</i> be the result of evaluating <i>MultiplicativeExpression</i>.</li>
- <li>Let <i>leftValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>left</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>leftValue</i>).</li>
- <li>Let <i>right</i> be the result of evaluating <i>UnaryExpression</i>.</li>
- <li>Let <i>rightValue</i> be <a href="#sec-getvalue">GetValue</a>(<i>right</i>).</li>
- <li>Let <i>lnum</i> be <a href="#sec-tonumber">ToNumber</a>(<i>leftValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>lnum</i>).</li>
- <li>Let <i>rnum</i> be <a href="#sec-tonumber">ToNumber</a>(<i>rightValue</i>).</li>
- <li><a href="#sec-returnifabrupt">ReturnIfAbrupt</a>(<i>rnum</i>).</li>
- <li>Return the result of applying the <i>MultiplicativeOperator</i> (*, /, or %) to <i>lnum</i> and <i>rnum</i> as
- specified in <a href="#sec-applying-the-mul-operator">12.6.3.1</a>, <a
- 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>
- </ol>
- </div>
-
- <section id="sec-applying-the-mul-operator">
- <h1><span class="secnum" id="sec-12.6.3.1"><a href="#sec-applying-the-mul-operator"
- title="link to this section">12.6.3.1</a></span> Applying the <code>*</code> Operator</h1>
-
- <p>The <code>*</code> <span class="nt">MultiplicativeOperator</span> performs multiplication, producing the product of its
- operands. Multiplication is commutative. Multiplication is not always associative in ECMAScript, because of finite
- precision.</p>
-
- <p>The result of a floating-point multiplication is governed by the rules of IEEE 754 binary double-precision
- arithmetic:</p>
-
- <ul>
- <li>
- <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
- </li>
-
- <li>
- <p>The sign of the result is positive if both operands have the same sign, negative if the operands have different
- signs.</p>
- </li>
-
- <li>
- <p>Multiplication of an infinity by a zero results in <b>NaN</b>.</p>
- </li>
-
- <li>
- <p>Multiplication of an infinity by an infinity results in an infinity. The sign is determined by the rule already
- stated above.</p>
- </li>
-
- <li>
- <p>Multiplication of an infinity by a finite nonzero value results in a signed infinity. The sign is determined by the
- rule already stated above.</p>
- </li>
-
- <li>
- <p>In the remaining cases, where neither an infinity nor NaN is involved, the product is computed and rounded to the
- nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too large to represent, the
- result is then an infinity of appropriate sign. If the magnitude is too small to represent, the result is then a zero
- of appropriate sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754.</p>
- </li>
- </ul>
- </section>
-
- <section id="sec-applying-the-div-operator">
- <h1><span class="secnum" id="sec-12.6.3.2"><a href="#sec-applying-the-div-operator"
- title="link to this section">12.6.3.2</a></span> Applying the <code>/</code> Operator</h1>
-
- <p>The <code>/</code> <span class="nt">MultiplicativeOperator</span> performs division, producing the quotient of its
- operands. The left operand is the dividend and the right operand is the divisor. ECMAScript does not perform integer
- division. The operands and result of all division operations are double-precision floating-point numbers. The result of
- division is determined by the specification of IEEE 754 arithmetic:</p>
-
- <ul>
- <li>
- <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
- </li>
-
- <li>
- <p>The sign of the result is positive if both operands have the same sign, negative if the operands have different
- signs.</p>
- </li>
-
- <li>
- <p>Division of an infinity by an infinity results in <b>NaN</b>.</p>
- </li>
-
- <li>
- <p>Division of an infinity by a zero results in an infinity. The sign is determined by the rule already stated
- above.</p>
- </li>
-
- <li>
- <p>Division of an infinity by a nonzero finite value results in a signed infinity. The sign is determined by the rule
- already stated above.</p>
- </li>
-
- <li>
- <p>Division of a finite value by an infinity results in zero. The sign is determined by the rule already stated
- above.</p>
- </li>
-
- <li>
- <p>Division of a zero by a zero results in <b>NaN</b>; division of zero by any other finite value results in zero,
- with the sign determined by the rule already stated above.</p>
- </li>
-
- <li>
- <p>Division of a nonzero finite value by a zero results in a signed infinity. The sign is determined by the rule
- already stated above.</p>
- </li>
-
- <li>
- <p>In the remaining cases, where neither an infinity, nor a zero, nor <b>NaN</b> is involved, the quotient is computed
- and rounded to the nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too large to
- represent, the operation overflows; the result is then an infinity of appropriate sign. If the magnitude is too small
- to represent, the operation underflows and the result is a zero of the appropriate sign. The ECMAScript language
- requires support of gradual underflow as defined by IEEE 754.</p>
- </li>
- </ul>
- </section>
-
- <section id="sec-applying-the-mod-operator">
- <h1><span class="secnum" id="sec-12.6.3.3"><a href="#sec-applying-the-mod-operator"
- title="link to this section">12.6.3.3</a></span> Applying the <code>%</code> Operator</h1>
-
- <p>The <code>%</code> <span class="nt">MultiplicativeOperator</span> yields the remainder of its operands from an implied
- division; the left operand is the dividend and the right operand is the divisor.</p>
-
- <div class="note">
- <p><span class="nh">NOTE</span> In C and C++, the remainder operator accepts only integral operands; in ECMAScript, it
- also accepts floating-point operands.</p>
- </div>
-
- <p>The result of a floating-point remainder operation as computed by the <code>%</code> operator is not the same as the
- &ldquo;remainder&rdquo; operation defined by IEEE 754. The IEEE 754 &ldquo;remainder&rdquo; operation computes the
- remainder from a rounding division, not a truncating division, and so its behaviour is not analogous to that of the usual
- integer remainder operator. Instead the ECMAScript language defines <code>%</code> on floating-point operations to behave
- in a manner analogous to that of the Java integer remainder operator; this may be compared with the C library function
- fmod.</p>
-
- <p>The result of an ECMAScript floating-point remainder operation is determined by the rules of IEEE arithmetic:</p>
-
- <ul>
- <li>
- <p>If either operand is <b>NaN</b>, the result is <b>NaN</b>.</p>
- </li>
-
- <li>
- <p>The sign of the result equals the sign of the dividend.</p>
- </li>
-
- <li>
- <p>If the dividend is an infinity, or the divisor is a zero, or both, the result is <b>NaN</b>.</p>
- </li>
-
- <li>
- <p>If the dividend is finite and the divisor is an infinity, the result equals the dividend.</p>
- </li>
-
- <li>
- <p>If the dividend is a zero and the divisor is nonzero and finite, the result is the same as the dividend.</p>
- </li>
-
- <li>
- <p>In the remaining cases, where neither an infinity, nor a zero, nor <b>NaN</b> is involved, the floating-point
- remainder r from a dividend n and a divisor d is defined by the mathematical relation r = n &minus; (d &times; q)
- where q is an integer that is negative only if n/d is negative and positive only if n/d is positive, and whose
- magnitude is as large as possible without exceeding the magnitude of the true mathematical quotient of n and d. r is
- computed and rounded to the nearest representable value using IEEE 754 round-to-nearest mode.</p>
- </li>
- </ul>
- </section>
- </section>
- </section>
-</section>
-</body>
-</html>