Files
ask262/spec-built/multipage/executable-code-and-execution-contexts.html

1540 lines
302 KiB
HTML

<!DOCTYPE html><html lang="en-GB-oxendict"><head><meta name="viewport" content="width=device-width, initial-scale=1"><meta charset="utf-8"><meta property="og:image" content="https://tc39.es/ecmarkup/ecma-logo.png"><meta property="og:title" content="ECMAScript® 2026 Language&nbsp;Specification"><meta property="og:description" content="Introduction
This Ecma Standard defines the ECMAScript 2026 Language. It is the seventeenth edition of the ECMAScript Language Specification. ECMAScript is based on several originating technologies, the most well-known being JavaScript (Netscape) and JScript (Microsoft). The language was invent">
<link rel="icon" href="../img/favicon.ico">
<link rel="stylesheet" href="../assets/css/ecmarkup.css"><link rel="stylesheet" href="../assets/css/print.css" media="print">
<title>ECMAScript® 2026 Language&nbsp;Specification</title><script src="../assets/js/multipage.js?cache=Wu2V1pj2" defer=""></script><script src="../assets/js/ecmarkup.js?cache=BPFBckdu" defer=""></script><link rel="canonical" href="../#sec-executable-code-and-execution-contexts"></head>
<body><div id="spec-container"><emu-clause id="sec-executable-code-and-execution-contexts">
<h1><span class="secnum">9</span> Executable Code and Execution Contexts</h1>
<emu-clause id="sec-environment-records" oldids="sec-lexical-environments"><span id="sec-lexical-environments"></span>
<h1><span class="secnum">9.1</span> Environment Records</h1>
<p><dfn variants="Environment Records" tabindex="-1">Environment Record</dfn> is a specification type used to define the association of <emu-nt id="_ref_19437"><a href="ecmascript-language-expressions.html#prod-Identifier">Identifier</a></emu-nt>s to specific variables and functions, based upon the lexical nesting structure of ECMAScript code. Usually an Environment Record is associated with some specific syntactic structure of ECMAScript code such as a <emu-nt id="_ref_19438"><a href="ecmascript-language-functions-and-classes.html#prod-FunctionDeclaration">FunctionDeclaration</a></emu-nt>, a <emu-nt id="_ref_19439"><a href="ecmascript-language-statements-and-declarations.html#prod-BlockStatement">BlockStatement</a></emu-nt>, or a <emu-nt id="_ref_19440"><a href="ecmascript-language-statements-and-declarations.html#prod-Catch">Catch</a></emu-nt> clause of a <emu-nt id="_ref_19441"><a href="ecmascript-language-statements-and-declarations.html#prod-TryStatement">TryStatement</a></emu-nt>. Each time such code is evaluated, a new Environment Record is created to record the identifier bindings that are created by that code.</p>
<p>Every Environment Record has an <var class="field">[[OuterEnv]]</var> field, which is either <emu-val>null</emu-val> or a reference to an outer Environment Record. This is used to model the logical nesting of Environment Record values. The outer reference of an (inner) Environment Record is a reference to the Environment Record that logically surrounds the inner Environment Record. An outer Environment Record may, of course, have its own outer Environment Record. An Environment Record may serve as the outer environment for multiple inner Environment Records. For example, if a <emu-nt id="_ref_19442"><a href="ecmascript-language-functions-and-classes.html#prod-FunctionDeclaration">FunctionDeclaration</a></emu-nt> contains two nested <emu-nt id="_ref_19443"><a href="ecmascript-language-functions-and-classes.html#prod-FunctionDeclaration">FunctionDeclaration</a></emu-nt>s then the Environment Records of each of the nested functions will have as their outer Environment Record the Environment Record of the current evaluation of the surrounding function.</p>
<p>Environment Records 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>
<emu-clause id="sec-the-environment-record-type-hierarchy">
<h1><span class="secnum">9.1.1</span> The Environment Record Type Hierarchy</h1>
<p><emu-xref href="#sec-environment-records" id="_ref_3545"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Records</a></emu-xref> can be thought of as existing in a simple object-oriented hierarchy where <emu-xref href="#sec-environment-records" id="_ref_3546"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> is an abstract class with three concrete subclasses: <emu-xref href="#sec-declarative-environment-records" id="_ref_3547"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref>, <emu-xref href="#sec-object-environment-records" id="_ref_3548"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref>, and <emu-xref href="#sec-global-environment-records" id="_ref_3549"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>. <emu-xref href="#sec-function-environment-records" id="_ref_3550"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Records</a></emu-xref> and <emu-xref href="#sec-module-environment-records" id="_ref_3551"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Records</a></emu-xref> are subclasses of <emu-xref href="#sec-declarative-environment-records" id="_ref_3552"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref>.</p>
<ul>
<li>
<p><emu-xref href="#sec-environment-records" id="_ref_3553"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> (abstract)</p>
<ul>
<li>
<p>A <em><emu-xref href="#sec-declarative-environment-records" id="_ref_3554"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref></em> is used to define the effect of ECMAScript language syntactic elements such as <emu-nt id="_ref_19444"><a href="ecmascript-language-functions-and-classes.html#prod-FunctionDeclaration">FunctionDeclaration</a></emu-nt>s, <emu-nt id="_ref_19445"><a href="ecmascript-language-statements-and-declarations.html#prod-VariableDeclaration">VariableDeclaration</a></emu-nt>s, and <emu-nt id="_ref_19446"><a href="ecmascript-language-statements-and-declarations.html#prod-Catch">Catch</a></emu-nt> clauses that directly associate identifier bindings with <emu-xref href="#sec-ecmascript-language-types" id="_ref_3555"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref>.</p>
<ul>
<li>
<p>A <em><emu-xref href="#sec-function-environment-records" id="_ref_3556"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref></em> corresponds to the invocation of an ECMAScript <emu-xref href="#function-object" id="_ref_3557"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>, and contains bindings for the top-level declarations within that function. It may establish a new <code>this</code> binding. It also captures the state necessary to support <code>super</code> method invocations.</p>
</li>
<li>
<p>A <em><emu-xref href="#sec-module-environment-records" id="_ref_3558"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref></em> contains the bindings for the top-level declarations of a <emu-nt id="_ref_19447"><a href="ecmascript-language-scripts-and-modules.html#prod-Module">Module</a></emu-nt>. It also contains the bindings that are explicitly imported by the <emu-nt id="_ref_19448"><a href="ecmascript-language-scripts-and-modules.html#prod-Module">Module</a></emu-nt>. Its <var class="field">[[OuterEnv]]</var> is a <emu-xref href="#sec-global-environment-records" id="_ref_3559"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>.</p>
</li>
</ul>
</li>
<li>
<p>An <em><emu-xref href="#sec-object-environment-records" id="_ref_3560"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref></em> is used to define the effect of ECMAScript elements such as <emu-nt id="_ref_19449"><a href="ecmascript-language-statements-and-declarations.html#prod-WithStatement">WithStatement</a></emu-nt> that associate identifier bindings with the properties of some object.</p>
</li>
<li>
<p>A <em><emu-xref href="#sec-global-environment-records" id="_ref_3561"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref></em> is used for <emu-nt id="_ref_19450"><a href="ecmascript-language-scripts-and-modules.html#prod-Script">Script</a></emu-nt> global declarations. It does not have an outer environment; its <var class="field">[[OuterEnv]]</var> is <emu-val>null</emu-val>. It may be prepopulated with identifier bindings and it includes an associated <emu-xref href="#sec-global-object" id="_ref_3562"><a href="global-object.html#sec-global-object">global object</a></emu-xref> whose properties provide some of the global environment's identifier bindings. As ECMAScript code is executed, additional properties may be added to the <emu-xref href="#sec-global-object" id="_ref_3563"><a href="global-object.html#sec-global-object">global object</a></emu-xref> and the initial properties may be modified.</p>
</li>
</ul>
</li>
</ul>
<p>The <emu-xref href="#sec-environment-records" id="_ref_3564"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> abstract class includes the abstract specification methods defined in <emu-xref href="#table-abstract-methods-of-environment-records" id="_ref_234"><a href="executable-code-and-execution-contexts.html#table-abstract-methods-of-environment-records">Table 14</a></emu-xref>. These abstract methods have distinct concrete algorithms for each of the concrete subclasses.</p>
<emu-table id="table-abstract-methods-of-environment-records" type="abstract methods" of="Environment Records" oldids="table-15,table-17,table-19,table-20,table-additional-methods-of-function-environment-records,table-additional-methods-of-global-environment-records,table-additional-methods-of-module-environment-records" caption="Abstract Methods of Environment Records"><figure><figcaption>Table 14: Abstract Methods of <emu-xref href="#sec-environment-records" id="_ref_3565"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Records</a></emu-xref></figcaption><span id="table-additional-methods-of-module-environment-records"></span><span id="table-additional-methods-of-global-environment-records"></span><span id="table-additional-methods-of-function-environment-records"></span><span id="table-20"></span><span id="table-19"></span><span id="table-17"></span><span id="table-15"></span>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Purpose
</th>
<th>
Definitions
</th>
</tr>
</thead>
<tbody><tr id="abstract-hasbinding">
<td>HasBinding ( <var>N</var> )</td>
<td><p>The abstract method HasBinding takes argument <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3566"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3567"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
It determines if an <emu-xref href="#sec-environment-records" id="_ref_3568"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> has a binding for <var>N</var>.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="HasBinding"><ul><li><emu-xref href="#sec-declarative-environment-records-hasbinding-n" id="_ref_17566"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-hasbinding-n">9.1.1.1.1 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-hasbinding-n" id="_ref_17567"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-hasbinding-n">9.1.1.2.1 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-hasbinding-n" id="_ref_17568"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-hasbinding-n">9.1.1.4.1 Global Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-createmutablebinding">
<td>CreateMutableBinding ( <var>N</var>, <var>D</var> )</td>
<td><p>The abstract method CreateMutableBinding takes arguments <var>N</var> (a String) and <var>D</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3569"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3570"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
It creates a new but uninitialized mutable binding in an <emu-xref href="#sec-environment-records" id="_ref_3571"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>. <var>N</var> is the text of the bound name. If <var>D</var> is <emu-val>true</emu-val> the binding may be subsequently deleted.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="CreateMutableBinding"><ul><li><emu-xref href="#sec-declarative-environment-records-createmutablebinding-n-d" id="_ref_17569"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-createmutablebinding-n-d">9.1.1.1.2 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-createmutablebinding-n-d" id="_ref_17570"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-createmutablebinding-n-d">9.1.1.2.2 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-createmutablebinding-n-d" id="_ref_17571"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-createmutablebinding-n-d">9.1.1.4.2 Global Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-createimmutablebinding">
<td>CreateImmutableBinding ( <var>N</var>, <var>S</var> )</td>
<td><p>The abstract method CreateImmutableBinding takes arguments <var>N</var> (a String) and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3572"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3573"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
It creates a new but uninitialized immutable binding in an <emu-xref href="#sec-environment-records" id="_ref_3574"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>. <var>N</var> is the text of the bound name. If <var>S</var> is <emu-val>true</emu-val> then attempts to set it after it has been initialized will always throw an exception, regardless of the strict mode setting of operations that reference that binding.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="CreateImmutableBinding"><ul><li><emu-xref href="#sec-declarative-environment-records-createimmutablebinding-n-s" id="_ref_17572"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-createimmutablebinding-n-s">9.1.1.1.3 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-createimmutablebinding-n-s" id="_ref_17573"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-createimmutablebinding-n-s">9.1.1.4.3 Global Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-initializebinding">
<td>InitializeBinding ( <var>N</var>, <var>V</var> )</td>
<td><p>The abstract method InitializeBinding takes arguments <var>N</var> (a String) and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3575"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3576"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3577"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
It sets the value of an already existing but uninitialized binding in an <emu-xref href="#sec-environment-records" id="_ref_3578"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>. <var>N</var> is the text of the bound name. <var>V</var> is the value for the binding.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="InitializeBinding"><ul><li><emu-xref href="#sec-declarative-environment-records-initializebinding-n-v" id="_ref_17574"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-initializebinding-n-v">9.1.1.1.4 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-initializebinding-n-v" id="_ref_17575"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-initializebinding-n-v">9.1.1.2.4 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-initializebinding-n-v" id="_ref_17576"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-initializebinding-n-v">9.1.1.4.4 Global Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-setmutablebinding">
<td>SetMutableBinding ( <var>N</var>, <var>V</var>, <var>S</var> )</td>
<td><p>The abstract method SetMutableBinding takes arguments <var>N</var> (a String), <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3579"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3580"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3581"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
It sets the value of an already existing mutable binding in an <emu-xref href="#sec-environment-records" id="_ref_3582"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>. <var>N</var> is the text of the bound name. <var>V</var> is the value for the binding. If <var>S</var> is <emu-val>true</emu-val> and the binding cannot be set, this will throw a <emu-val>TypeError</emu-val> exception.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="SetMutableBinding"><ul><li><emu-xref href="#sec-declarative-environment-records-setmutablebinding-n-v-s" id="_ref_17577"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-setmutablebinding-n-v-s">9.1.1.1.5 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-setmutablebinding-n-v-s" id="_ref_17578"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-setmutablebinding-n-v-s">9.1.1.2.5 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-setmutablebinding-n-v-s" id="_ref_17579"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-setmutablebinding-n-v-s">9.1.1.4.5 Global Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-getbindingvalue">
<td>GetBindingValue ( <var>N</var>, <var>S</var> )</td>
<td><p>The abstract method GetBindingValue takes arguments <var>N</var> (a String) and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3583"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3584"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3585"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
It returns the value of an already existing binding from an <emu-xref href="#sec-environment-records" id="_ref_3586"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>. <var>N</var> is the text of the bound name. <var>S</var> is used to identify references originating in <emu-xref href="#sec-strict-mode-code" id="_ref_3587"><a href="ecmascript-language-source-code.html#sec-strict-mode-code">strict mode code</a></emu-xref> or that otherwise require strict mode reference semantics. If <var>S</var> is <emu-val>true</emu-val> and the binding does not exist, this will throw a <emu-val>ReferenceError</emu-val> exception. If the binding exists but is uninitialized a <emu-val>ReferenceError</emu-val> is thrown, regardless of the value of <var>S</var>.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="GetBindingValue"><ul><li><emu-xref href="#sec-declarative-environment-records-getbindingvalue-n-s" id="_ref_17580"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-getbindingvalue-n-s">9.1.1.1.6 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-getbindingvalue-n-s" id="_ref_17581"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-getbindingvalue-n-s">9.1.1.2.6 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-getbindingvalue-n-s" id="_ref_17582"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-getbindingvalue-n-s">9.1.1.4.6 Global Environment Record</a></emu-xref></li><li><emu-xref href="#sec-module-environment-records-getbindingvalue-n-s" id="_ref_17583"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records-getbindingvalue-n-s">9.1.1.5.1 Module Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-deletebinding">
<td>DeleteBinding ( <var>N</var> )</td>
<td><p>The abstract method DeleteBinding takes argument <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3588"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3589"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
It deletes a binding from an <emu-xref href="#sec-environment-records" id="_ref_3590"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>. <var>N</var> is the text of the bound name. If a binding for <var>N</var> exists, this removes the binding and returns <emu-val>true</emu-val>. If the binding exists but cannot be removed, this returns <emu-val>false</emu-val>. If the binding does not exist, this returns <emu-val>true</emu-val>.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="DeleteBinding"><ul><li><emu-xref href="#sec-declarative-environment-records-deletebinding-n" id="_ref_17584"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-deletebinding-n">9.1.1.1.7 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-deletebinding-n" id="_ref_17585"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-deletebinding-n">9.1.1.2.7 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-deletebinding-n" id="_ref_17586"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-deletebinding-n">9.1.1.4.7 Global Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-hasthisbinding">
<td>HasThisBinding ( )</td>
<td><p>The abstract method HasThisBinding takes no arguments and returns a Boolean.</p>
It determines if an <emu-xref href="#sec-environment-records" id="_ref_3591"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> establishes a <code>this</code> binding. This returns <emu-val>true</emu-val> if it does and <emu-val>false</emu-val> if it does not.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="HasThisBinding"><ul><li><emu-xref href="#sec-declarative-environment-records-hasthisbinding" id="_ref_17587"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-hasthisbinding">9.1.1.1.8 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-hasthisbinding" id="_ref_17588"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-hasthisbinding">9.1.1.2.8 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-function-environment-records-hasthisbinding" id="_ref_17589"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records-hasthisbinding">9.1.1.3.2 Function Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-hasthisbinding" id="_ref_17590"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-hasthisbinding">9.1.1.4.8 Global Environment Record</a></emu-xref></li><li><emu-xref href="#sec-module-environment-records-hasthisbinding" id="_ref_17591"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records-hasthisbinding">9.1.1.5.3 Module Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-getthisbinding">
<td>GetThisBinding ( )</td>
<td><p>The abstract method GetThisBinding takes no arguments and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3592"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3593"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3594"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
It returns the value of this <emu-xref href="#sec-environment-records" id="_ref_3595"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>'s <code>this</code> binding. It throws a <emu-val>ReferenceError</emu-val> if the <code>this</code> binding has not been initialized.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="GetThisBinding"><ul><li><emu-xref href="#sec-function-environment-records-getthisbinding" id="_ref_17592"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records-getthisbinding">9.1.1.3.3 Function Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-getthisbinding" id="_ref_17593"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-getthisbinding">9.1.1.4.9 Global Environment Record</a></emu-xref></li><li><emu-xref href="#sec-module-environment-records-getthisbinding" id="_ref_17594"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records-getthisbinding">9.1.1.5.4 Module Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-hassuperbinding">
<td>HasSuperBinding ( )</td>
<td><p>The abstract method HasSuperBinding takes no arguments and returns a Boolean.</p>
It determines if an <emu-xref href="#sec-environment-records" id="_ref_3596"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> establishes a <code>super</code> method binding. This returns <emu-val>true</emu-val> if it does and <emu-val>false</emu-val> if it does not. If it returns <emu-val>true</emu-val> it implies that the <emu-xref href="#sec-environment-records" id="_ref_3597"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> is a <emu-xref href="#sec-function-environment-records" id="_ref_3598"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref>, although the reverse implication does not hold.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="HasSuperBinding"><ul><li><emu-xref href="#sec-declarative-environment-records-hassuperbinding" id="_ref_17595"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-hassuperbinding">9.1.1.1.10 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-hassuperbinding" id="_ref_17596"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-hassuperbinding">9.1.1.2.10 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-function-environment-records-hassuperbinding" id="_ref_17597"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records-hassuperbinding">9.1.1.3.4 Function Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-hassuperbinding" id="_ref_17598"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-hassuperbinding">9.1.1.4.10 Global Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
<tr id="abstract-withbaseobject">
<td>WithBaseObject ( )</td>
<td><p>The abstract method WithBaseObject takes no arguments and returns an Object or <emu-val>undefined</emu-val>.</p>
If this <emu-xref href="#sec-environment-records" id="_ref_3599"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> is associated with a <code>with</code> statement, it returns the with object. Otherwise, it returns <emu-val>undefined</emu-val>.
</td>
<td>
It has concrete definitions in the following types:
<emu-concrete-method-dfns for="WithBaseObject"><ul><li><emu-xref href="#sec-declarative-environment-records-withbaseobject" id="_ref_17599"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records-withbaseobject">9.1.1.1.11 Declarative Environment Record</a></emu-xref></li><li><emu-xref href="#sec-object-environment-records-withbaseobject" id="_ref_17600"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records-withbaseobject">9.1.1.2.11 Object Environment Record</a></emu-xref></li><li><emu-xref href="#sec-global-environment-records-withbaseobject" id="_ref_17601"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records-withbaseobject">9.1.1.4.11 Global Environment Record</a></emu-xref></li></ul></emu-concrete-method-dfns>
</td>
</tr>
</tbody></table>
</figure></emu-table>
<emu-clause id="sec-declarative-environment-records">
<h1><span class="secnum">9.1.1.1</span> Declarative Environment Records</h1>
<p>Each <dfn variants="Declarative Environment Records" tabindex="-1">Declarative Environment Record</dfn> is associated with an ECMAScript program scope containing variable, constant, let, class, module, import, and/or function declarations. A Declarative Environment Record binds the set of identifiers defined by the declarations contained within its scope.</p>
<emu-clause id="sec-declarative-environment-records-hasbinding-n" type="concrete method">
<h1><span class="secnum">9.1.1.1.1</span> HasBinding ( <var>N</var> )</h1>
<p>The <emu-xref aoid="HasBinding" id="_ref_3600"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3601"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes argument <var>N</var> (a String) and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3602"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean. It determines if the argument identifier is one of the identifiers bound by the record. It performs the following steps when called:</p>
<emu-alg><ol><li>If <var>envRec</var> has a binding for <var>N</var>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-createmutablebinding-n-d" type="concrete method">
<h1><span class="secnum">9.1.1.1.2</span> CreateMutableBinding ( <var>N</var>, <var>D</var> )</h1>
<p>The <emu-xref aoid="CreateMutableBinding" id="_ref_3603"><a href="executable-code-and-execution-contexts.html#abstract-createmutablebinding">CreateMutableBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3604"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>D</var> (a Boolean) and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3605"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const>. It creates a new mutable binding for the name <var>N</var> that is uninitialized. A binding must not already exist in this <emu-xref href="#sec-environment-records" id="_ref_3606"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> for <var>N</var>. If <var>D</var> is <emu-val>true</emu-val>, the new binding is marked as being subject to deletion. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3607"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var> does not already have a binding for <var>N</var>.</li><li>Create a mutable binding in <var>envRec</var> for <var>N</var> and record that it is uninitialized. If <var>D</var> is <emu-val>true</emu-val>, record that the newly created binding may be deleted by a subsequent <emu-xref aoid="DeleteBinding" id="_ref_3608"><a href="executable-code-and-execution-contexts.html#abstract-deletebinding">DeleteBinding</a></emu-xref> call.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-createimmutablebinding-n-s" type="concrete method">
<h1><span class="secnum">9.1.1.1.3</span> CreateImmutableBinding ( <var>N</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="CreateImmutableBinding" id="_ref_3609"><a href="executable-code-and-execution-contexts.html#abstract-createimmutablebinding">CreateImmutableBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3610"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>S</var> (a Boolean) and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3611"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const>. It creates a new immutable binding for the name <var>N</var> that is uninitialized. A binding must not already exist in this <emu-xref href="#sec-environment-records" id="_ref_3612"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> for <var>N</var>. If <var>S</var> is <emu-val>true</emu-val>, the new binding is marked as a strict binding. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3613"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var> does not already have a binding for <var>N</var>.</li><li>Create an immutable binding in <var>envRec</var> for <var>N</var> and record that it is uninitialized. If <var>S</var> is <emu-val>true</emu-val>, record that the newly created binding is a strict binding.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-initializebinding-n-v" type="concrete method">
<h1><span class="secnum">9.1.1.1.4</span> InitializeBinding ( <var>N</var>, <var>V</var> )</h1>
<p>The <emu-xref aoid="InitializeBinding" id="_ref_3614"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3615"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3616"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3617"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const>. It is used to set the bound value of the current binding of the identifier whose name is <var>N</var> to the value <var>V</var>. An uninitialized binding for <var>N</var> must already exist. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3618"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var> must have an uninitialized binding for <var>N</var>.</li><li>Set the bound value for <var>N</var> in <var>envRec</var> to <var>V</var>.</li><li><emu-not-ref>Record</emu-not-ref> that the binding for <var>N</var> in <var>envRec</var> has been initialized.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-setmutablebinding-n-v-s" type="concrete method">
<h1><span class="secnum">9.1.1.1.5</span> SetMutableBinding ( <var>N</var>, <var>V</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="SetMutableBinding" id="_ref_3619"><a href="executable-code-and-execution-contexts.html#abstract-setmutablebinding">SetMutableBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3620"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String), <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3621"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3622"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3623"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It attempts to change the bound value of the current binding of the identifier whose name is <var>N</var> to the value <var>V</var>. A binding for <var>N</var> normally already exists, but in rare cases it may not. If the binding is an immutable binding, a <emu-val>TypeError</emu-val> is thrown if <var>S</var> is <emu-val>true</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li id="step-setmutablebinding-missing-binding">If <var>envRec</var> does not have a binding for <var>N</var>, then<ol><li>If <var>S</var> is <emu-val>true</emu-val>, throw a <emu-val>ReferenceError</emu-val> exception.</li><li>Perform !&nbsp;<var>envRec</var>.<emu-xref aoid="CreateMutableBinding" id="_ref_3624"><a href="executable-code-and-execution-contexts.html#abstract-createmutablebinding">CreateMutableBinding</a></emu-xref>(<var>N</var>, <emu-val>true</emu-val>).</li><li>Perform !&nbsp;<var>envRec</var>.<emu-xref aoid="InitializeBinding" id="_ref_3625"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref>(<var>N</var>, <var>V</var>).</li><li>Return <emu-const>unused</emu-const>.</li></ol></li><li>If the binding for <var>N</var> in <var>envRec</var> is a strict binding, set <var>S</var> to <emu-val>true</emu-val>.</li><li>If the binding for <var>N</var> in <var>envRec</var> has not yet been initialized, then<ol><li>Throw a <emu-val>ReferenceError</emu-val> exception.</li></ol></li><li>Else if the binding for <var>N</var> in <var>envRec</var> is a mutable binding, then<ol><li>Change its bound value to <var>V</var>.</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_3626"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: This is an attempt to change the value of an immutable binding.</li><li>If <var>S</var> is <emu-val>true</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>An example of ECMAScript code that results in a missing binding at step <emu-xref href="#step-setmutablebinding-missing-binding" id="_ref_235"><a href="executable-code-and-execution-contexts.html#step-setmutablebinding-missing-binding">1</a></emu-xref> is:</p>
<pre><code class="javascript hljs"><span class="hljs-keyword">function</span> <span class="hljs-title function_">f</span>(<span class="hljs-params"></span>) { <span class="hljs-built_in">eval</span>(<span class="hljs-string">"var x; x = (delete x, 0);"</span>); }</code></pre>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-getbindingvalue-n-s" type="concrete method">
<h1><span class="secnum">9.1.1.1.6</span> GetBindingValue ( <var>N</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="GetBindingValue" id="_ref_3627"><a href="executable-code-and-execution-contexts.html#abstract-getbindingvalue">GetBindingValue</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3628"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3629"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3630"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3631"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It returns the value of its bound identifier whose name is <var>N</var>. If the binding exists but is uninitialized a <emu-val>ReferenceError</emu-val> is thrown, regardless of the value of <var>S</var>. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3632"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var> has a binding for <var>N</var>.</li><li>If the binding for <var>N</var> in <var>envRec</var> is an uninitialized binding, throw a <emu-val>ReferenceError</emu-val> exception.</li><li>Return the value currently bound to <var>N</var> in <var>envRec</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-deletebinding-n" type="concrete method">
<h1><span class="secnum">9.1.1.1.7</span> DeleteBinding ( <var>N</var> )</h1>
<p>The <emu-xref aoid="DeleteBinding" id="_ref_3633"><a href="executable-code-and-execution-contexts.html#abstract-deletebinding">DeleteBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3634"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes argument <var>N</var> (a String) and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3635"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean. It can only delete bindings that have been explicitly designated as being subject to deletion. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3636"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var> has a binding for <var>N</var>.</li><li>If the binding for <var>N</var> in <var>envRec</var> cannot be deleted, return <emu-val>false</emu-val>.</li><li>Remove the binding for <var>N</var> from <var>envRec</var>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-hasthisbinding" type="concrete method">
<h1><span class="secnum">9.1.1.1.8</span> HasThisBinding ( )</h1>
<p>The <emu-xref aoid="HasThisBinding" id="_ref_3637"><a href="executable-code-and-execution-contexts.html#abstract-hasthisbinding">HasThisBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3638"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>false</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>A regular <emu-xref href="#sec-declarative-environment-records" id="_ref_3639"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> (i.e., one that is neither a <emu-xref href="#sec-function-environment-records" id="_ref_3640"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref> nor a <emu-xref href="#sec-module-environment-records" id="_ref_3641"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref>) does not provide a <code>this</code> binding.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-getthisbinding">
<h1><span class="secnum">9.1.1.1.9</span> GetThisBinding ( )</h1>
<p>The <emu-xref aoid="GetThisBinding" id="_ref_3642"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3643"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> is never used within this specification.</p>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-hassuperbinding" type="concrete method">
<h1><span class="secnum">9.1.1.1.10</span> HasSuperBinding ( )</h1>
<p>The <emu-xref aoid="HasSuperBinding" id="_ref_3644"><a href="executable-code-and-execution-contexts.html#abstract-hassuperbinding">HasSuperBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3645"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>false</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>A regular <emu-xref href="#sec-declarative-environment-records" id="_ref_3646"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> (i.e., one that is neither a <emu-xref href="#sec-function-environment-records" id="_ref_3647"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref> nor a <emu-xref href="#sec-module-environment-records" id="_ref_3648"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref>) does not provide a <code>super</code> binding.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-declarative-environment-records-withbaseobject" type="concrete method">
<h1><span class="secnum">9.1.1.1.11</span> WithBaseObject ( )</h1>
<p>The <emu-xref aoid="WithBaseObject" id="_ref_3649"><a href="executable-code-and-execution-contexts.html#abstract-withbaseobject">WithBaseObject</a></emu-xref> concrete method of a <emu-xref href="#sec-declarative-environment-records" id="_ref_3650"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>undefined</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>undefined</emu-val>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-object-environment-records">
<h1><span class="secnum">9.1.1.2</span> Object Environment Records</h1>
<p>Each <dfn variants="Object Environment Records" tabindex="-1">Object Environment Record</dfn> is associated with an object called its <em>binding object</em>. An Object Environment Record binds the set of string identifier names that directly correspond to the <emu-xref href="#property-name" id="_ref_3651"><a href="ecmascript-data-types-and-values.html#property-name">property names</a></emu-xref> of its binding object. <emu-xref href="#property-key" id="_ref_3652"><a href="ecmascript-data-types-and-values.html#property-key">Property keys</a></emu-xref> that are not strings in the form of an <emu-nt id="_ref_19451"><a href="ecmascript-language-lexical-grammar.html#prod-IdentifierName">IdentifierName</a></emu-nt> 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 <var class="field">[[Enumerable]]</var> attribute. Because properties can be dynamically added and deleted from objects, the set of identifiers bound by an Object Environment Record 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 is <emu-val>false</emu-val>. Immutable bindings do not exist for Object Environment Records.</p>
<p>Object Environment Records created for <code>with</code> statements (<emu-xref href="#sec-with-statement" id="_ref_236"><a href="ecmascript-language-statements-and-declarations.html#sec-with-statement">14.11</a></emu-xref>) can provide their binding object as an implicit <emu-val>this</emu-val> value for use in function calls. The capability is controlled by a Boolean <var class="field">[[IsWithEnvironment]]</var> field.</p>
<p>Object Environment Records have the additional state fields listed in <emu-xref href="#table-additional-fields-of-object-environment-records" id="_ref_237"><a href="executable-code-and-execution-contexts.html#table-additional-fields-of-object-environment-records">Table 15</a></emu-xref>.</p>
<emu-table id="table-additional-fields-of-object-environment-records" caption="Additional Fields of Object Environment Records"><figure><figcaption>Table 15: Additional Fields of <emu-xref href="#sec-object-environment-records" id="_ref_3653"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Records</a></emu-xref></figcaption>
<table>
<thead>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tbody><tr>
<td>
<var class="field">[[BindingObject]]</var>
</td>
<td>
an Object
</td>
<td>
The binding object of this <emu-xref href="#sec-environment-records" id="_ref_3654"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>.
</td>
</tr>
<tr>
<td>
<var class="field">[[IsWithEnvironment]]</var>
</td>
<td>
a Boolean
</td>
<td>
Indicates whether this <emu-xref href="#sec-environment-records" id="_ref_3655"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> is created for a <code>with</code> statement.
</td>
</tr>
</tbody></table>
</figure></emu-table>
<emu-clause id="sec-object-environment-records-hasbinding-n" type="concrete method">
<h1><span class="secnum">9.1.1.2.1</span> HasBinding ( <var>N</var> )</h1>
<p>The <emu-xref aoid="HasBinding" id="_ref_3656"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3657"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes argument <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3658"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3659"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It determines if its associated binding object has a property whose name is <var>N</var>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>bindingObject</var> be <var>envRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>foundBinding</var> be ?&nbsp;<emu-xref aoid="HasProperty" id="_ref_3660"><a href="abstract-operations.html#sec-hasproperty" class="e-user-code">HasProperty</a></emu-xref>(<var>bindingObject</var>, <var>N</var>).</li><li>If <var>foundBinding</var> is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>If <var>envRec</var>.<var class="field">[[IsWithEnvironment]]</var> is <emu-val>false</emu-val>, return <emu-val>true</emu-val>.</li><li>Let <var>unscopables</var> be ?&nbsp;<emu-xref aoid="Get" id="_ref_3661"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>bindingObject</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_3662"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.unscopables%</a></emu-xref>).</li><li>If <var>unscopables</var> <emu-xref href="#sec-object-type" id="_ref_3663"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Let <var>blocked</var> be <emu-xref aoid="ToBoolean" id="_ref_3664"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_3665"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>unscopables</var>, <var>N</var>)).</li><li>If <var>blocked</var> is <emu-val>true</emu-val>, return <emu-val>false</emu-val>.</li></ol></li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-object-environment-records-createmutablebinding-n-d" type="concrete method">
<h1><span class="secnum">9.1.1.2.2</span> CreateMutableBinding ( <var>N</var>, <var>D</var> )</h1>
<p>The <emu-xref aoid="CreateMutableBinding" id="_ref_3666"><a href="executable-code-and-execution-contexts.html#abstract-createmutablebinding">CreateMutableBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3667"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>D</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3668"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3669"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It creates in an <emu-xref href="#sec-environment-records" id="_ref_3670"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>'s associated binding object a property whose name is <var>N</var> and initializes it to the value <emu-val>undefined</emu-val>. If <var>D</var> is <emu-val>true</emu-val>, the new property's <var class="field">[[Configurable]]</var> attribute is set to <emu-val>true</emu-val>; otherwise it is set to <emu-val>false</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>bindingObject</var> be <var>envRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Perform ?&nbsp;<emu-xref aoid="DefinePropertyOrThrow" id="_ref_3671"><a href="abstract-operations.html#sec-definepropertyorthrow" class="e-user-code">DefinePropertyOrThrow</a></emu-xref>(<var>bindingObject</var>, <var>N</var>, PropertyDescriptor { <var class="field">[[Value]]</var>: <emu-val>undefined</emu-val>, <var class="field">[[Writable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Configurable]]</var>: <var>D</var>&nbsp;}).</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>Normally <var>envRec</var> will not have a binding for <var>N</var> but if it does, the semantics of <emu-xref aoid="DefinePropertyOrThrow" id="_ref_3672"><a href="abstract-operations.html#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref> may result in an existing binding being replaced or shadowed or cause an <emu-xref href="#sec-completion-record-specification-type" id="_ref_3673"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">abrupt completion</a></emu-xref> to be returned.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-object-environment-records-createimmutablebinding-n-s">
<h1><span class="secnum">9.1.1.2.3</span> CreateImmutableBinding ( <var>N</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="CreateImmutableBinding" id="_ref_3674"><a href="executable-code-and-execution-contexts.html#abstract-createimmutablebinding">CreateImmutableBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3675"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> is never used within this specification.</p>
</emu-clause>
<emu-clause id="sec-object-environment-records-initializebinding-n-v" type="concrete method">
<h1><span class="secnum">9.1.1.2.4</span> InitializeBinding ( <var>N</var>, <var>V</var> )</h1>
<p>The <emu-xref aoid="InitializeBinding" id="_ref_3676"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3677"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3678"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3679"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3680"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to set the bound value of the current binding of the identifier whose name is <var>N</var> to the value <var>V</var>. It performs the following steps when called:</p>
<emu-alg><ol><li>Perform ?&nbsp;<span class="e-user-code"><var>envRec</var>.<emu-xref aoid="SetMutableBinding" id="_ref_3681"><a href="executable-code-and-execution-contexts.html#abstract-setmutablebinding">SetMutableBinding</a></emu-xref>(<var>N</var>, <var>V</var>, <emu-val>false</emu-val>)</span>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>In this specification, all uses of <emu-xref aoid="CreateMutableBinding" id="_ref_3682"><a href="executable-code-and-execution-contexts.html#abstract-createmutablebinding">CreateMutableBinding</a></emu-xref> for <emu-xref href="#sec-object-environment-records" id="_ref_3683"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Records</a></emu-xref> are immediately followed by a call to <emu-xref aoid="InitializeBinding" id="_ref_3684"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref> for the same name. Hence, this specification does not explicitly track the initialization state of bindings in <emu-xref href="#sec-object-environment-records" id="_ref_3685"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Records</a></emu-xref>.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-object-environment-records-setmutablebinding-n-v-s" type="concrete method">
<h1><span class="secnum">9.1.1.2.5</span> SetMutableBinding ( <var>N</var>, <var>V</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="SetMutableBinding" id="_ref_3686"><a href="executable-code-and-execution-contexts.html#abstract-setmutablebinding">SetMutableBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3687"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String), <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3688"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3689"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3690"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It attempts to set the value of the <emu-xref href="#sec-environment-records" id="_ref_3691"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>'s associated binding object's property whose name is <var>N</var> to the value <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 <var>S</var>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>bindingObject</var> be <var>envRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>stillExists</var> be ?&nbsp;<emu-xref aoid="HasProperty" id="_ref_3692"><a href="abstract-operations.html#sec-hasproperty" class="e-user-code">HasProperty</a></emu-xref>(<var>bindingObject</var>, <var>N</var>).</li><li>If <var>stillExists</var> is <emu-val>false</emu-val> and <var>S</var> is <emu-val>true</emu-val>, throw a <emu-val>ReferenceError</emu-val> exception.</li><li>Perform ?&nbsp;<emu-xref aoid="Set" id="_ref_3693"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>bindingObject</var>, <var>N</var>, <var>V</var>, <var>S</var>).</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-object-environment-records-getbindingvalue-n-s" type="concrete method">
<h1><span class="secnum">9.1.1.2.6</span> GetBindingValue ( <var>N</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="GetBindingValue" id="_ref_3694"><a href="executable-code-and-execution-contexts.html#abstract-getbindingvalue">GetBindingValue</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3695"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3696"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3697"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3698"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It returns the value of its associated binding object's property whose name is <var>N</var>. The property should already exist but if it does not the result depends upon <var>S</var>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>bindingObject</var> be <var>envRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>value</var> be ?&nbsp;<emu-xref aoid="HasProperty" id="_ref_3699"><a href="abstract-operations.html#sec-hasproperty" class="e-user-code">HasProperty</a></emu-xref>(<var>bindingObject</var>, <var>N</var>).</li><li>If <var>value</var> is <emu-val>false</emu-val>, then<ol><li>If <var>S</var> is <emu-val>false</emu-val>, return <emu-val>undefined</emu-val>.</li><li>Throw a <emu-val>ReferenceError</emu-val> exception.</li></ol></li><li>Return ?&nbsp;<emu-xref aoid="Get" id="_ref_3700"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>bindingObject</var>, <var>N</var>).</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-object-environment-records-deletebinding-n" type="concrete method">
<h1><span class="secnum">9.1.1.2.7</span> DeleteBinding ( <var>N</var> )</h1>
<p>The <emu-xref aoid="DeleteBinding" id="_ref_3701"><a href="executable-code-and-execution-contexts.html#abstract-deletebinding">DeleteBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3702"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes argument <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3703"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3704"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It can only delete bindings that correspond to properties of the environment object whose <var class="field">[[Configurable]]</var> attribute have the value <emu-val>true</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>bindingObject</var> be <var>envRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Return ?&nbsp;<span class="e-user-code"><var>bindingObject</var>.<var class="field">[[Delete]]</var>(<var>N</var>)</span>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-object-environment-records-hasthisbinding" type="concrete method">
<h1><span class="secnum">9.1.1.2.8</span> HasThisBinding ( )</h1>
<p>The <emu-xref aoid="HasThisBinding" id="_ref_3705"><a href="executable-code-and-execution-contexts.html#abstract-hasthisbinding">HasThisBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3706"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>false</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p><emu-xref href="#sec-object-environment-records" id="_ref_3707"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Records</a></emu-xref> do not provide a <code>this</code> binding.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-object-environment-records-getthisbinding">
<h1><span class="secnum">9.1.1.2.9</span> GetThisBinding ( )</h1>
<p>The <emu-xref aoid="GetThisBinding" id="_ref_3708"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3709"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> is never used within this specification.</p>
</emu-clause>
<emu-clause id="sec-object-environment-records-hassuperbinding" type="concrete method">
<h1><span class="secnum">9.1.1.2.10</span> HasSuperBinding ( )</h1>
<p>The <emu-xref aoid="HasSuperBinding" id="_ref_3710"><a href="executable-code-and-execution-contexts.html#abstract-hassuperbinding">HasSuperBinding</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3711"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>false</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p><emu-xref href="#sec-object-environment-records" id="_ref_3712"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Records</a></emu-xref> do not provide a <code>super</code> binding.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-object-environment-records-withbaseobject" type="concrete method">
<h1><span class="secnum">9.1.1.2.11</span> WithBaseObject ( )</h1>
<p>The <emu-xref aoid="WithBaseObject" id="_ref_3713"><a href="executable-code-and-execution-contexts.html#abstract-withbaseobject">WithBaseObject</a></emu-xref> concrete method of an <emu-xref href="#sec-object-environment-records" id="_ref_3714"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns an Object or <emu-val>undefined</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>If <var>envRec</var>.<var class="field">[[IsWithEnvironment]]</var> is <emu-val>true</emu-val>, return <var>envRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Return <emu-val>undefined</emu-val>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-function-environment-records" oldids="function-environment"><span id="function-environment"></span>
<h1><span class="secnum">9.1.1.3</span> Function Environment Records</h1>
<p>A <dfn variants="Function Environment Records" tabindex="-1">Function Environment Record</dfn> is a <emu-xref href="#sec-declarative-environment-records" id="_ref_3715"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> that is used to represent the top-level scope of a function and, if the function is not an <emu-nt id="_ref_19452"><a href="ecmascript-language-functions-and-classes.html#prod-ArrowFunction">ArrowFunction</a></emu-nt>, provides a <code>this</code> binding. If a function is not an <emu-nt id="_ref_19453"><a href="ecmascript-language-functions-and-classes.html#prod-ArrowFunction">ArrowFunction</a></emu-nt> function and references <code>super</code>, its Function Environment Record 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 <emu-xref href="#table-additional-fields-of-function-environment-records" id="_ref_238"><a href="executable-code-and-execution-contexts.html#table-additional-fields-of-function-environment-records">Table 16</a></emu-xref>.</p>
<emu-table id="table-additional-fields-of-function-environment-records" caption="Additional Fields of Function Environment Records" oldids="table-16"><figure><figcaption>Table 16: Additional Fields of <emu-xref href="#sec-function-environment-records" id="_ref_3716"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Records</a></emu-xref></figcaption><span id="table-16"></span>
<table>
<thead>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tbody><tr>
<td>
<var class="field">[[ThisValue]]</var>
</td>
<td>
an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3717"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>
</td>
<td>
This is the <emu-val>this</emu-val> value used for this invocation of the function.
</td>
</tr>
<tr>
<td>
<var class="field">[[ThisBindingStatus]]</var>
</td>
<td>
<emu-const>lexical</emu-const>, <emu-const>initialized</emu-const>, or <emu-const>uninitialized</emu-const>
</td>
<td>
If the value is <emu-const>lexical</emu-const>, this is an <emu-nt id="_ref_19454"><a href="ecmascript-language-functions-and-classes.html#prod-ArrowFunction">ArrowFunction</a></emu-nt> and does not have a local <emu-val>this</emu-val> value.
</td>
</tr>
<tr>
<td>
<var class="field">[[FunctionObject]]</var>
</td>
<td>
an ECMAScript <emu-xref href="#function-object" id="_ref_3718"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>
</td>
<td>
The <emu-xref href="#function-object" id="_ref_3719"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> whose invocation caused this <emu-xref href="#sec-environment-records" id="_ref_3720"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> to be created.
</td>
</tr>
<tr>
<td>
<var class="field">[[NewTarget]]</var>
</td>
<td>
a <emu-xref href="#constructor" id="_ref_3721"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> or <emu-val>undefined</emu-val>
</td>
<td>
If this <emu-xref href="#sec-environment-records" id="_ref_3722"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> was created by the <var class="field">[[Construct]]</var> internal method, <var class="field">[[NewTarget]]</var> is the value of the <var class="field">[[Construct]]</var> <var>newTarget</var> parameter. Otherwise, its value is <emu-val>undefined</emu-val>.
</td>
</tr>
</tbody></table>
</figure></emu-table>
<p>Function Environment Records support all of the <emu-xref href="#sec-declarative-environment-records" id="_ref_3723"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> methods listed in <emu-xref href="#table-abstract-methods-of-environment-records" id="_ref_239"><a href="executable-code-and-execution-contexts.html#table-abstract-methods-of-environment-records">Table 14</a></emu-xref> and share the same specifications for all of those methods except for <emu-xref aoid="HasThisBinding" id="_ref_3724"><a href="executable-code-and-execution-contexts.html#abstract-hasthisbinding">HasThisBinding</a></emu-xref>, <emu-xref aoid="GetThisBinding" id="_ref_3725"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref>, and <emu-xref aoid="HasSuperBinding" id="_ref_3726"><a href="executable-code-and-execution-contexts.html#abstract-hassuperbinding">HasSuperBinding</a></emu-xref>.</p>
<emu-clause id="sec-bindthisvalue" type="abstract operation" aoid="BindThisValue">
<h1><span class="secnum">9.1.1.3.1</span> BindThisValue ( <var>envRec</var>, <var>V</var> )</h1>
<p>The abstract operation BindThisValue takes arguments <var>envRec</var> (a <emu-xref href="#sec-function-environment-records" id="_ref_3727"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref>) and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3728"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3729"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3730"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It sets the <var>envRec</var>.<var class="field">[[ThisValue]]</var> and records that it has been initialized. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3731"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var>.<var class="field">[[ThisBindingStatus]]</var> is not <emu-const>lexical</emu-const>.</li><li>If <var>envRec</var>.<var class="field">[[ThisBindingStatus]]</var> is <emu-const>initialized</emu-const>, throw a <emu-val>ReferenceError</emu-val> exception.</li><li>Set <var>envRec</var>.<var class="field">[[ThisValue]]</var> to <var>V</var>.</li><li>Set <var>envRec</var>.<var class="field">[[ThisBindingStatus]]</var> to <emu-const>initialized</emu-const>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-function-environment-records-hasthisbinding" type="concrete method">
<h1><span class="secnum">9.1.1.3.2</span> HasThisBinding ( )</h1>
<p>The <emu-xref aoid="HasThisBinding" id="_ref_3732"><a href="executable-code-and-execution-contexts.html#abstract-hasthisbinding">HasThisBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-function-environment-records" id="_ref_3733"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns a Boolean. It performs the following steps when called:</p>
<emu-alg><ol><li>If <var>envRec</var>.<var class="field">[[ThisBindingStatus]]</var> is <emu-const>lexical</emu-const>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-function-environment-records-getthisbinding" type="concrete method">
<h1><span class="secnum">9.1.1.3.3</span> GetThisBinding ( )</h1>
<p>The <emu-xref aoid="GetThisBinding" id="_ref_3734"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-function-environment-records" id="_ref_3735"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3736"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3737"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3738"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3739"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var>.<var class="field">[[ThisBindingStatus]]</var> is not <emu-const>lexical</emu-const>.</li><li>If <var>envRec</var>.<var class="field">[[ThisBindingStatus]]</var> is <emu-const>uninitialized</emu-const>, throw a <emu-val>ReferenceError</emu-val> exception.</li><li>Return <var>envRec</var>.<var class="field">[[ThisValue]]</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-function-environment-records-hassuperbinding" type="concrete method">
<h1><span class="secnum">9.1.1.3.4</span> HasSuperBinding ( )</h1>
<p>The <emu-xref aoid="HasSuperBinding" id="_ref_3740"><a href="executable-code-and-execution-contexts.html#abstract-hassuperbinding">HasSuperBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-function-environment-records" id="_ref_3741"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns a Boolean. It performs the following steps when called:</p>
<emu-alg><ol><li>If <var>envRec</var>.<var class="field">[[ThisBindingStatus]]</var> is <emu-const>lexical</emu-const>, return <emu-val>false</emu-val>.</li><li>If <var>envRec</var>.<var class="field">[[FunctionObject]]</var>.<var class="field">[[HomeObject]]</var> is <emu-val>undefined</emu-val>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-getsuperbase" type="abstract operation" aoid="GetSuperBase">
<h1><span class="secnum">9.1.1.3.5</span> GetSuperBase ( <var>envRec</var> )</h1>
<p>The abstract operation GetSuperBase takes argument <var>envRec</var> (a <emu-xref href="#sec-function-environment-records" id="_ref_3742"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref>) and returns an Object, <emu-val>null</emu-val>, or <emu-val>undefined</emu-val>. It returns the object that is the base for <code>super</code> property accesses bound in <var>envRec</var>. The value <emu-val>undefined</emu-val> indicates that such accesses will produce runtime errors. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>home</var> be <var>envRec</var>.<var class="field">[[FunctionObject]]</var>.<var class="field">[[HomeObject]]</var>.</li><li>If <var>home</var> is <emu-val>undefined</emu-val>, return <emu-val>undefined</emu-val>.</li><li><emu-xref href="#assert" id="_ref_3743"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>home</var> is an <emu-xref href="#ordinary-object" id="_ref_3744"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary object</a></emu-xref>.</li><li>Return !&nbsp;<var>home</var>.<var class="field">[[GetPrototypeOf]]</var>().</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-global-environment-records" oldids="global-environment"><span id="global-environment"></span>
<h1><span class="secnum">9.1.1.4</span> Global Environment Records</h1>
<p>A <dfn variants="Global Environment Records" tabindex="-1">Global Environment Record</dfn> is used to represent the outer most scope that is shared by all of the ECMAScript <emu-nt id="_ref_19455"><a href="ecmascript-language-scripts-and-modules.html#prod-Script">Script</a></emu-nt> elements that are processed in a common <emu-xref href="#realm" id="_ref_3745"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>. A Global Environment Record provides the bindings for built-in globals (clause <emu-xref href="#sec-global-object" id="_ref_240"><a href="global-object.html#sec-global-object">19</a></emu-xref>), properties of the <emu-xref href="#sec-global-object" id="_ref_3746"><a href="global-object.html#sec-global-object">global object</a></emu-xref>, and for all top-level declarations (<emu-xref href="#sec-static-semantics-toplevellexicallyscopeddeclarations" id="_ref_241"><a href="syntax-directed-operations.html#sec-static-semantics-toplevellexicallyscopeddeclarations">8.2.9</a></emu-xref>, <emu-xref href="#sec-static-semantics-toplevelvarscopeddeclarations" id="_ref_242"><a href="syntax-directed-operations.html#sec-static-semantics-toplevelvarscopeddeclarations">8.2.11</a></emu-xref>) that occur within a <emu-nt id="_ref_19456"><a href="ecmascript-language-scripts-and-modules.html#prod-Script">Script</a></emu-nt>.</p>
<p>A Global Environment Record is logically a single record but it is specified as a composite encapsulating an <emu-xref href="#sec-object-environment-records" id="_ref_3747"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> and a <emu-xref href="#sec-declarative-environment-records" id="_ref_3748"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref>. The <emu-xref href="#sec-object-environment-records" id="_ref_3749"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> has as its base object the <emu-xref href="#sec-global-object" id="_ref_3750"><a href="global-object.html#sec-global-object">global object</a></emu-xref> of the associated <emu-xref href="#realm-record" id="_ref_3751"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>. This <emu-xref href="#sec-global-object" id="_ref_3752"><a href="global-object.html#sec-global-object">global object</a></emu-xref> is the value returned by the Global Environment Record's <emu-xref aoid="GetThisBinding" id="_ref_3753"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref> concrete method. The <emu-xref href="#sec-object-environment-records" id="_ref_3754"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> component of a Global Environment Record contains the bindings for all built-in globals (clause <emu-xref href="#sec-global-object" id="_ref_243"><a href="global-object.html#sec-global-object">19</a></emu-xref>) and all bindings introduced by a <emu-nt id="_ref_19457"><a href="ecmascript-language-functions-and-classes.html#prod-FunctionDeclaration">FunctionDeclaration</a></emu-nt>, <emu-nt id="_ref_19458"><a href="ecmascript-language-functions-and-classes.html#prod-GeneratorDeclaration">GeneratorDeclaration</a></emu-nt>, <emu-nt id="_ref_19459"><a href="ecmascript-language-functions-and-classes.html#prod-AsyncFunctionDeclaration">AsyncFunctionDeclaration</a></emu-nt>, <emu-nt id="_ref_19460"><a href="ecmascript-language-functions-and-classes.html#prod-AsyncGeneratorDeclaration">AsyncGeneratorDeclaration</a></emu-nt>, or <emu-nt id="_ref_19461"><a href="ecmascript-language-statements-and-declarations.html#prod-VariableStatement">VariableStatement</a></emu-nt> contained in global code. The bindings for all other ECMAScript declarations in global code are contained in the <emu-xref href="#sec-declarative-environment-records" id="_ref_3755"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> component of the Global Environment Record.</p>
<p>Properties may be created directly on a <emu-xref href="#sec-global-object" id="_ref_3756"><a href="global-object.html#sec-global-object">global object</a></emu-xref>. Hence, the <emu-xref href="#sec-object-environment-records" id="_ref_3757"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref> component of a Global Environment Record may contain both bindings created explicitly by <emu-nt id="_ref_19462"><a href="ecmascript-language-functions-and-classes.html#prod-FunctionDeclaration">FunctionDeclaration</a></emu-nt>, <emu-nt id="_ref_19463"><a href="ecmascript-language-functions-and-classes.html#prod-GeneratorDeclaration">GeneratorDeclaration</a></emu-nt>, <emu-nt id="_ref_19464"><a href="ecmascript-language-functions-and-classes.html#prod-AsyncFunctionDeclaration">AsyncFunctionDeclaration</a></emu-nt>, <emu-nt id="_ref_19465"><a href="ecmascript-language-functions-and-classes.html#prod-AsyncGeneratorDeclaration">AsyncGeneratorDeclaration</a></emu-nt>, or <emu-nt id="_ref_19466"><a href="ecmascript-language-statements-and-declarations.html#prod-VariableDeclaration">VariableDeclaration</a></emu-nt> declarations and bindings created implicitly as properties of the <emu-xref href="#sec-global-object" id="_ref_3758"><a href="global-object.html#sec-global-object">global object</a></emu-xref>. In order to identify which bindings were explicitly created using declarations, a Global Environment Record maintains a list of the names bound using the <emu-xref aoid="CreateGlobalVarBinding" id="_ref_3759"><a href="executable-code-and-execution-contexts.html#sec-createglobalvarbinding">CreateGlobalVarBinding</a></emu-xref> and <emu-xref aoid="CreateGlobalFunctionBinding" id="_ref_3760"><a href="executable-code-and-execution-contexts.html#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a></emu-xref> <emu-xref href="#sec-algorithm-conventions-abstract-operations" id="_ref_3761"><a href="notational-conventions.html#sec-algorithm-conventions-abstract-operations">abstract operations</a></emu-xref>.</p>
<p>Global Environment Records have the additional fields listed in <emu-xref href="#table-additional-fields-of-global-environment-records" id="_ref_244"><a href="executable-code-and-execution-contexts.html#table-additional-fields-of-global-environment-records">Table 17</a></emu-xref>.</p>
<emu-table id="table-additional-fields-of-global-environment-records" caption="Additional Fields of Global Environment Records" oldids="table-18"><figure><figcaption>Table 17: Additional Fields of <emu-xref href="#sec-global-environment-records" id="_ref_3762"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Records</a></emu-xref></figcaption><span id="table-18"></span>
<table>
<thead>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tbody><tr>
<td>
<var class="field">[[ObjectRecord]]</var>
</td>
<td>
an <emu-xref href="#sec-object-environment-records" id="_ref_3763"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref>
</td>
<td>
Binding object is the <emu-xref href="#sec-global-object" id="_ref_3764"><a href="global-object.html#sec-global-object">global object</a></emu-xref>. It contains global built-in bindings as well as <emu-nt id="_ref_19467"><a href="ecmascript-language-functions-and-classes.html#prod-FunctionDeclaration">FunctionDeclaration</a></emu-nt>, <emu-nt id="_ref_19468"><a href="ecmascript-language-functions-and-classes.html#prod-GeneratorDeclaration">GeneratorDeclaration</a></emu-nt>, <emu-nt id="_ref_19469"><a href="ecmascript-language-functions-and-classes.html#prod-AsyncFunctionDeclaration">AsyncFunctionDeclaration</a></emu-nt>, <emu-nt id="_ref_19470"><a href="ecmascript-language-functions-and-classes.html#prod-AsyncGeneratorDeclaration">AsyncGeneratorDeclaration</a></emu-nt>, and <emu-nt id="_ref_19471"><a href="ecmascript-language-statements-and-declarations.html#prod-VariableDeclaration">VariableDeclaration</a></emu-nt> bindings in global code for the associated <emu-xref href="#realm" id="_ref_3765"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>.
</td>
</tr>
<tr>
<td>
<var class="field">[[GlobalThisValue]]</var>
</td>
<td>
an Object
</td>
<td>
The value returned by <code>this</code> in global scope. <emu-xref href="#host" id="_ref_3766"><a href="overview.html#host">Hosts</a></emu-xref> may provide any ECMAScript Object value.
</td>
</tr>
<tr>
<td>
<var class="field">[[DeclarativeRecord]]</var>
</td>
<td>
a <emu-xref href="#sec-declarative-environment-records" id="_ref_3767"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref>
</td>
<td>
<emu-not-ref>Contains</emu-not-ref> bindings for all declarations in global code for the associated <emu-xref href="#realm" id="_ref_3768"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> code except for <emu-nt id="_ref_19472"><a href="ecmascript-language-functions-and-classes.html#prod-FunctionDeclaration">FunctionDeclaration</a></emu-nt>, <emu-nt id="_ref_19473"><a href="ecmascript-language-functions-and-classes.html#prod-GeneratorDeclaration">GeneratorDeclaration</a></emu-nt>, <emu-nt id="_ref_19474"><a href="ecmascript-language-functions-and-classes.html#prod-AsyncFunctionDeclaration">AsyncFunctionDeclaration</a></emu-nt>, <emu-nt id="_ref_19475"><a href="ecmascript-language-functions-and-classes.html#prod-AsyncGeneratorDeclaration">AsyncGeneratorDeclaration</a></emu-nt>, and <emu-nt id="_ref_19476"><a href="ecmascript-language-statements-and-declarations.html#prod-VariableDeclaration">VariableDeclaration</a></emu-nt> bindings.
</td>
</tr>
</tbody></table>
</figure></emu-table>
<emu-clause id="sec-global-environment-records-hasbinding-n" type="concrete method">
<h1><span class="secnum">9.1.1.4.1</span> HasBinding ( <var>N</var> )</h1>
<p>The <emu-xref aoid="HasBinding" id="_ref_3769"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3770"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes argument <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3771"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3772"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It determines if the argument identifier is one of the identifiers bound by the record. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>DclRec</var> be <var>envRec</var>.<var class="field">[[DeclarativeRecord]]</var>.</li><li>If !&nbsp;<var>DclRec</var>.<emu-xref aoid="HasBinding" id="_ref_3773"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>) is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Return ?&nbsp;<span class="e-user-code"><var>ObjRec</var>.<emu-xref aoid="HasBinding" id="_ref_3774"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>)</span>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-global-environment-records-createmutablebinding-n-d" type="concrete method">
<h1><span class="secnum">9.1.1.4.2</span> CreateMutableBinding ( <var>N</var>, <var>D</var> )</h1>
<p>The <emu-xref aoid="CreateMutableBinding" id="_ref_3775"><a href="executable-code-and-execution-contexts.html#abstract-createmutablebinding">CreateMutableBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3776"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>D</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3777"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3778"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It 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 <var>D</var> is <emu-val>true</emu-val>, the new binding is marked as being subject to deletion. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>DclRec</var> be <var>envRec</var>.<var class="field">[[DeclarativeRecord]]</var>.</li><li>If !&nbsp;<var>DclRec</var>.<emu-xref aoid="HasBinding" id="_ref_3779"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>) is <emu-val>true</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return !&nbsp;<var>DclRec</var>.<emu-xref aoid="CreateMutableBinding" id="_ref_3780"><a href="executable-code-and-execution-contexts.html#abstract-createmutablebinding">CreateMutableBinding</a></emu-xref>(<var>N</var>, <var>D</var>).</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-global-environment-records-createimmutablebinding-n-s" type="concrete method">
<h1><span class="secnum">9.1.1.4.3</span> CreateImmutableBinding ( <var>N</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="CreateImmutableBinding" id="_ref_3781"><a href="executable-code-and-execution-contexts.html#abstract-createimmutablebinding">CreateImmutableBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3782"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3783"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3784"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It creates a new immutable binding for the name <var>N</var> that is uninitialized. A binding must not already exist in this <emu-xref href="#sec-environment-records" id="_ref_3785"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> for <var>N</var>. If <var>S</var> is <emu-val>true</emu-val>, the new binding is marked as a strict binding. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>DclRec</var> be <var>envRec</var>.<var class="field">[[DeclarativeRecord]]</var>.</li><li>If !&nbsp;<var>DclRec</var>.<emu-xref aoid="HasBinding" id="_ref_3786"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>) is <emu-val>true</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return !&nbsp;<var>DclRec</var>.<emu-xref aoid="CreateImmutableBinding" id="_ref_3787"><a href="executable-code-and-execution-contexts.html#abstract-createimmutablebinding">CreateImmutableBinding</a></emu-xref>(<var>N</var>, <var>S</var>).</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-global-environment-records-initializebinding-n-v" type="concrete method">
<h1><span class="secnum">9.1.1.4.4</span> InitializeBinding ( <var>N</var>, <var>V</var> )</h1>
<p>The <emu-xref aoid="InitializeBinding" id="_ref_3788"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3789"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3790"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3791"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3792"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to set the bound value of the current binding of the identifier whose name is <var>N</var> to the value <var>V</var>. An uninitialized binding for <var>N</var> must already exist. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>DclRec</var> be <var>envRec</var>.<var class="field">[[DeclarativeRecord]]</var>.</li><li>If !&nbsp;<var>DclRec</var>.<emu-xref aoid="HasBinding" id="_ref_3793"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>) is <emu-val>true</emu-val>, then<ol><li>Return !&nbsp;<var>DclRec</var>.<emu-xref aoid="InitializeBinding" id="_ref_3794"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref>(<var>N</var>, <var>V</var>).</li></ol></li><li><emu-xref href="#assert" id="_ref_3795"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: If the binding exists, it must be in the <emu-xref href="#sec-object-environment-records" id="_ref_3796"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref>.</li><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Return ?&nbsp;<span class="e-user-code"><var>ObjRec</var>.<emu-xref aoid="InitializeBinding" id="_ref_3797"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref>(<var>N</var>, <var>V</var>)</span>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-global-environment-records-setmutablebinding-n-v-s" type="concrete method">
<h1><span class="secnum">9.1.1.4.5</span> SetMutableBinding ( <var>N</var>, <var>V</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="SetMutableBinding" id="_ref_3798"><a href="executable-code-and-execution-contexts.html#abstract-setmutablebinding">SetMutableBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3799"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String), <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3800"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3801"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3802"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It attempts to change the bound value of the current binding of the identifier whose name is <var>N</var> to the value <var>V</var>. If the binding is an immutable binding and <var>S</var> is <emu-val>true</emu-val>, a <emu-val>TypeError</emu-val> is thrown. A property named <var>N</var> normally already exists but if it does not or is not currently writable, error handling is determined by <var>S</var>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>DclRec</var> be <var>envRec</var>.<var class="field">[[DeclarativeRecord]]</var>.</li><li>If !&nbsp;<var>DclRec</var>.<emu-xref aoid="HasBinding" id="_ref_3803"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>) is <emu-val>true</emu-val>, then<ol><li>Return ?&nbsp;<var>DclRec</var>.<emu-xref aoid="SetMutableBinding" id="_ref_3804"><a href="executable-code-and-execution-contexts.html#abstract-setmutablebinding">SetMutableBinding</a></emu-xref>(<var>N</var>, <var>V</var>, <var>S</var>).</li></ol></li><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Return ?&nbsp;<span class="e-user-code"><var>ObjRec</var>.<emu-xref aoid="SetMutableBinding" id="_ref_3805"><a href="executable-code-and-execution-contexts.html#abstract-setmutablebinding">SetMutableBinding</a></emu-xref>(<var>N</var>, <var>V</var>, <var>S</var>)</span>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-global-environment-records-getbindingvalue-n-s" type="concrete method">
<h1><span class="secnum">9.1.1.4.6</span> GetBindingValue ( <var>N</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="GetBindingValue" id="_ref_3806"><a href="executable-code-and-execution-contexts.html#abstract-getbindingvalue">GetBindingValue</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3807"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3808"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3809"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3810"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It returns the value of its bound identifier whose name is <var>N</var>. If the binding is an uninitialized binding throw a <emu-val>ReferenceError</emu-val> 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 <var>S</var>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>DclRec</var> be <var>envRec</var>.<var class="field">[[DeclarativeRecord]]</var>.</li><li>If !&nbsp;<var>DclRec</var>.<emu-xref aoid="HasBinding" id="_ref_3811"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>) is <emu-val>true</emu-val>, then<ol><li>Return ?&nbsp;<var>DclRec</var>.<emu-xref aoid="GetBindingValue" id="_ref_3812"><a href="executable-code-and-execution-contexts.html#abstract-getbindingvalue">GetBindingValue</a></emu-xref>(<var>N</var>, <var>S</var>).</li></ol></li><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Return ?&nbsp;<span class="e-user-code"><var>ObjRec</var>.<emu-xref aoid="GetBindingValue" id="_ref_3813"><a href="executable-code-and-execution-contexts.html#abstract-getbindingvalue">GetBindingValue</a></emu-xref>(<var>N</var>, <var>S</var>)</span>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-global-environment-records-deletebinding-n" type="concrete method">
<h1><span class="secnum">9.1.1.4.7</span> DeleteBinding ( <var>N</var> )</h1>
<p>The <emu-xref aoid="DeleteBinding" id="_ref_3814"><a href="executable-code-and-execution-contexts.html#abstract-deletebinding">DeleteBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3815"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes argument <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3816"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3817"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It can only delete bindings that have been explicitly designated as being subject to deletion. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>DclRec</var> be <var>envRec</var>.<var class="field">[[DeclarativeRecord]]</var>.</li><li>If !&nbsp;<var>DclRec</var>.<emu-xref aoid="HasBinding" id="_ref_3818"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>) is <emu-val>true</emu-val>, then<ol><li>Return !&nbsp;<var>DclRec</var>.<emu-xref aoid="DeleteBinding" id="_ref_3819"><a href="executable-code-and-execution-contexts.html#abstract-deletebinding">DeleteBinding</a></emu-xref>(<var>N</var>).</li></ol></li><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Let <var>globalObject</var> be <var>ObjRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>existingProp</var> be ?&nbsp;<emu-xref aoid="HasOwnProperty" id="_ref_3820"><a href="abstract-operations.html#sec-hasownproperty" class="e-user-code">HasOwnProperty</a></emu-xref>(<var>globalObject</var>, <var>N</var>).</li><li>If <var>existingProp</var> is <emu-val>true</emu-val>, then<ol><li>Return ?&nbsp;<span class="e-user-code"><var>ObjRec</var>.<emu-xref aoid="DeleteBinding" id="_ref_3821"><a href="executable-code-and-execution-contexts.html#abstract-deletebinding">DeleteBinding</a></emu-xref>(<var>N</var>)</span>.</li></ol></li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-global-environment-records-hasthisbinding" type="concrete method">
<h1><span class="secnum">9.1.1.4.8</span> HasThisBinding ( )</h1>
<p>The <emu-xref aoid="HasThisBinding" id="_ref_3822"><a href="executable-code-and-execution-contexts.html#abstract-hasthisbinding">HasThisBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3823"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>true</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p><emu-xref href="#sec-global-environment-records" id="_ref_3824"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Records</a></emu-xref> always provide a <code>this</code> binding.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-global-environment-records-getthisbinding" type="concrete method">
<h1><span class="secnum">9.1.1.4.9</span> GetThisBinding ( )</h1>
<p>The <emu-xref aoid="GetThisBinding" id="_ref_3825"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3826"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3827"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an Object. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <var>envRec</var>.<var class="field">[[GlobalThisValue]]</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-global-environment-records-hassuperbinding" type="concrete method">
<h1><span class="secnum">9.1.1.4.10</span> HasSuperBinding ( )</h1>
<p>The <emu-xref aoid="HasSuperBinding" id="_ref_3828"><a href="executable-code-and-execution-contexts.html#abstract-hassuperbinding">HasSuperBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3829"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>false</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p><emu-xref href="#sec-global-environment-records" id="_ref_3830"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Records</a></emu-xref> do not provide a <code>super</code> binding.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-global-environment-records-withbaseobject" type="concrete method">
<h1><span class="secnum">9.1.1.4.11</span> WithBaseObject ( )</h1>
<p>The <emu-xref aoid="WithBaseObject" id="_ref_3831"><a href="executable-code-and-execution-contexts.html#abstract-withbaseobject">WithBaseObject</a></emu-xref> concrete method of a <emu-xref href="#sec-global-environment-records" id="_ref_3832"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>undefined</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>undefined</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-haslexicaldeclaration" type="abstract operation" aoid="HasLexicalDeclaration">
<h1><span class="secnum">9.1.1.4.12</span> HasLexicalDeclaration ( <var>envRec</var>, <var>N</var> )</h1>
<p>The abstract operation HasLexicalDeclaration takes arguments <var>envRec</var> (a <emu-xref href="#sec-global-environment-records" id="_ref_3833"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>) and <var>N</var> (a String) and returns a Boolean. It determines if the argument identifier has a binding in <var>envRec</var> that was created using a lexical declaration such as a <emu-nt id="_ref_19477"><a href="ecmascript-language-statements-and-declarations.html#prod-LexicalDeclaration">LexicalDeclaration</a></emu-nt> or a <emu-nt id="_ref_19478"><a href="ecmascript-language-functions-and-classes.html#prod-ClassDeclaration">ClassDeclaration</a></emu-nt>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>DclRec</var> be <var>envRec</var>.<var class="field">[[DeclarativeRecord]]</var>.</li><li>Return !&nbsp;<var>DclRec</var>.<emu-xref aoid="HasBinding" id="_ref_3834"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>N</var>).</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-hasrestrictedglobalproperty" type="abstract operation" aoid="HasRestrictedGlobalProperty">
<h1><span class="secnum">9.1.1.4.13</span> HasRestrictedGlobalProperty ( <var>envRec</var>, <var>N</var> )</h1>
<p>The abstract operation HasRestrictedGlobalProperty takes arguments <var>envRec</var> (a <emu-xref href="#sec-global-environment-records" id="_ref_3835"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>) and <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3836"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3837"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It determines if the argument identifier is the name of a property of the <emu-xref href="#sec-global-object" id="_ref_3838"><a href="global-object.html#sec-global-object">global object</a></emu-xref> that must not be shadowed by a global lexical binding. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Let <var>globalObject</var> be <var>ObjRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>existingProp</var> be ?&nbsp;<span class="e-user-code"><var>globalObject</var>.<var class="field">[[GetOwnProperty]]</var>(<var>N</var>)</span>.</li><li>If <var>existingProp</var> is <emu-val>undefined</emu-val>, return <emu-val>false</emu-val>.</li><li>If <var>existingProp</var>.<var class="field">[[Configurable]]</var> is <emu-val>true</emu-val>, return <emu-val>false</emu-val>.</li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>Properties may exist upon a <emu-xref href="#sec-global-object" id="_ref_3839"><a href="global-object.html#sec-global-object">global object</a></emu-xref> 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 <emu-xref href="#sec-global-object" id="_ref_3840"><a href="global-object.html#sec-global-object">global object</a></emu-xref>. The global property <emu-val>"undefined"</emu-val> is an example of such a property.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-candeclareglobalvar" type="abstract operation" aoid="CanDeclareGlobalVar">
<h1><span class="secnum">9.1.1.4.14</span> CanDeclareGlobalVar ( <var>envRec</var>, <var>N</var> )</h1>
<p>The abstract operation CanDeclareGlobalVar takes arguments <var>envRec</var> (a <emu-xref href="#sec-global-environment-records" id="_ref_3841"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>) and <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3842"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3843"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It determines if a corresponding <emu-xref aoid="CreateGlobalVarBinding" id="_ref_3844"><a href="executable-code-and-execution-contexts.html#sec-createglobalvarbinding">CreateGlobalVarBinding</a></emu-xref> call would succeed if called for the same argument <var>N</var>. Redundant var declarations and var declarations for pre-existing <emu-xref href="#sec-global-object" id="_ref_3845"><a href="global-object.html#sec-global-object">global object</a></emu-xref> properties are allowed. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Let <var>globalObject</var> be <var>ObjRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>hasProperty</var> be ?&nbsp;<emu-xref aoid="HasOwnProperty" id="_ref_3846"><a href="abstract-operations.html#sec-hasownproperty" class="e-user-code">HasOwnProperty</a></emu-xref>(<var>globalObject</var>, <var>N</var>).</li><li>If <var>hasProperty</var> is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>Return ?&nbsp;<emu-xref aoid="IsExtensible" id="_ref_3847"><a href="abstract-operations.html#sec-isextensible-o" class="e-user-code">IsExtensible</a></emu-xref>(<var>globalObject</var>).</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-candeclareglobalfunction" type="abstract operation" aoid="CanDeclareGlobalFunction">
<h1><span class="secnum">9.1.1.4.15</span> CanDeclareGlobalFunction ( <var>envRec</var>, <var>N</var> )</h1>
<p>The abstract operation CanDeclareGlobalFunction takes arguments <var>envRec</var> (a <emu-xref href="#sec-global-environment-records" id="_ref_3848"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>) and <var>N</var> (a String) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3849"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Boolean or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3850"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It determines if a corresponding <emu-xref aoid="CreateGlobalFunctionBinding" id="_ref_3851"><a href="executable-code-and-execution-contexts.html#sec-createglobalfunctionbinding">CreateGlobalFunctionBinding</a></emu-xref> call would succeed if called for the same argument <var>N</var>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Let <var>globalObject</var> be <var>ObjRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>existingProp</var> be ?&nbsp;<span class="e-user-code"><var>globalObject</var>.<var class="field">[[GetOwnProperty]]</var>(<var>N</var>)</span>.</li><li>If <var>existingProp</var> is <emu-val>undefined</emu-val>, return ?&nbsp;<emu-xref aoid="IsExtensible" id="_ref_3852"><a href="abstract-operations.html#sec-isextensible-o" class="e-user-code">IsExtensible</a></emu-xref>(<var>globalObject</var>).</li><li>If <var>existingProp</var>.<var class="field">[[Configurable]]</var> is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>If <emu-xref aoid="IsDataDescriptor" id="_ref_3853"><a href="ecmascript-data-types-and-values.html#sec-isdatadescriptor">IsDataDescriptor</a></emu-xref>(<var>existingProp</var>) is <emu-val>true</emu-val> and <var>existingProp</var> has attribute values { <var class="field">[[Writable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>true</emu-val>&nbsp;}, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-createglobalvarbinding" type="abstract operation" aoid="CreateGlobalVarBinding">
<h1><span class="secnum">9.1.1.4.16</span> CreateGlobalVarBinding ( <var>envRec</var>, <var>N</var>, <var>D</var> )</h1>
<p>The abstract operation CreateGlobalVarBinding takes arguments <var>envRec</var> (a <emu-xref href="#sec-global-environment-records" id="_ref_3854"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>), <var>N</var> (a String), and <var>D</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3855"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3856"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It creates and initializes a mutable binding in the associated <emu-xref href="#sec-object-environment-records" id="_ref_3857"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref>. If a binding already exists, it is reused and assumed to be initialized. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Let <var>globalObject</var> be <var>ObjRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>hasProperty</var> be ?&nbsp;<emu-xref aoid="HasOwnProperty" id="_ref_3858"><a href="abstract-operations.html#sec-hasownproperty" class="e-user-code">HasOwnProperty</a></emu-xref>(<var>globalObject</var>, <var>N</var>).</li><li>Let <var>extensible</var> be ?&nbsp;<emu-xref aoid="IsExtensible" id="_ref_3859"><a href="abstract-operations.html#sec-isextensible-o" class="e-user-code">IsExtensible</a></emu-xref>(<var>globalObject</var>).</li><li>If <var>hasProperty</var> is <emu-val>false</emu-val> and <var>extensible</var> is <emu-val>true</emu-val>, then<ol><li>Perform ?&nbsp;<span class="e-user-code"><var>ObjRec</var>.<emu-xref aoid="CreateMutableBinding" id="_ref_3860"><a href="executable-code-and-execution-contexts.html#abstract-createmutablebinding">CreateMutableBinding</a></emu-xref>(<var>N</var>, <var>D</var>)</span>.</li><li>Perform ?&nbsp;<span class="e-user-code"><var>ObjRec</var>.<emu-xref aoid="InitializeBinding" id="_ref_3861"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref>(<var>N</var>, <emu-val>undefined</emu-val>)</span>.</li></ol></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-createglobalfunctionbinding" type="abstract operation" aoid="CreateGlobalFunctionBinding">
<h1><span class="secnum">9.1.1.4.17</span> CreateGlobalFunctionBinding ( <var>envRec</var>, <var>N</var>, <var>V</var>, <var>D</var> )</h1>
<p>The abstract operation CreateGlobalFunctionBinding takes arguments <var>envRec</var> (a <emu-xref href="#sec-global-environment-records" id="_ref_3862"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>), <var>N</var> (a String), <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3863"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>D</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3864"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3865"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It creates and initializes a mutable binding in the associated <emu-xref href="#sec-object-environment-records" id="_ref_3866"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref>. If a binding already exists, it is replaced. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>ObjRec</var> be <var>envRec</var>.<var class="field">[[ObjectRecord]]</var>.</li><li>Let <var>globalObject</var> be <var>ObjRec</var>.<var class="field">[[BindingObject]]</var>.</li><li>Let <var>existingProp</var> be ?&nbsp;<span class="e-user-code"><var>globalObject</var>.<var class="field">[[GetOwnProperty]]</var>(<var>N</var>)</span>.</li><li>If <var>existingProp</var> is <emu-val>undefined</emu-val> or <var>existingProp</var>.<var class="field">[[Configurable]]</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>desc</var> be the PropertyDescriptor { <var class="field">[[Value]]</var>: <var>V</var>, <var class="field">[[Writable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>true</emu-val>, <var class="field">[[Configurable]]</var>: <var>D</var>&nbsp;}.</li></ol></li><li>Else,<ol><li>Let <var>desc</var> be the PropertyDescriptor { <var class="field">[[Value]]</var>: <var>V</var>&nbsp;}.</li></ol></li><li>Perform ?&nbsp;<emu-xref aoid="DefinePropertyOrThrow" id="_ref_3867"><a href="abstract-operations.html#sec-definepropertyorthrow" class="e-user-code">DefinePropertyOrThrow</a></emu-xref>(<var>globalObject</var>, <var>N</var>, <var>desc</var>).</li><li id="step-createglobalfunctionbinding-set">Perform ?&nbsp;<emu-xref aoid="Set" id="_ref_3868"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>globalObject</var>, <var>N</var>, <var>V</var>, <emu-val>false</emu-val>).</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>Global function declarations are always represented as own properties of the <emu-xref href="#sec-global-object" id="_ref_3869"><a href="global-object.html#sec-global-object">global object</a></emu-xref>. If possible, an existing own property is reconfigured to have a standard set of attribute values. Step <emu-xref href="#step-createglobalfunctionbinding-set" id="_ref_245"><a href="executable-code-and-execution-contexts.html#step-createglobalfunctionbinding-set">7</a></emu-xref> is equivalent to what calling the <emu-xref aoid="InitializeBinding" id="_ref_3870"><a href="executable-code-and-execution-contexts.html#abstract-initializebinding">InitializeBinding</a></emu-xref> concrete method would do and if <var>globalObject</var> is a Proxy will produce the same sequence of Proxy trap calls.</p>
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-module-environment-records" oldids="module-environment"><span id="module-environment"></span>
<h1><span class="secnum">9.1.1.5</span> Module Environment Records</h1>
<p>A <dfn variants="Module Environment Records" tabindex="-1">Module Environment Record</dfn> is a <emu-xref href="#sec-declarative-environment-records" id="_ref_3871"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> that is used to represent the outer scope of an ECMAScript <emu-nt id="_ref_19479"><a href="ecmascript-language-scripts-and-modules.html#prod-Module">Module</a></emu-nt>. 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 <emu-xref href="#sec-environment-records" id="_ref_3872"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>.</p>
<p>Module Environment Records support all of the <emu-xref href="#sec-declarative-environment-records" id="_ref_3873"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> methods listed in <emu-xref href="#table-abstract-methods-of-environment-records" id="_ref_246"><a href="executable-code-and-execution-contexts.html#table-abstract-methods-of-environment-records">Table 14</a></emu-xref> and share the same specifications for all of those methods except for <emu-xref aoid="GetBindingValue" id="_ref_3874"><a href="executable-code-and-execution-contexts.html#abstract-getbindingvalue">GetBindingValue</a></emu-xref>, <emu-xref aoid="DeleteBinding" id="_ref_3875"><a href="executable-code-and-execution-contexts.html#abstract-deletebinding">DeleteBinding</a></emu-xref>, <emu-xref aoid="HasThisBinding" id="_ref_3876"><a href="executable-code-and-execution-contexts.html#abstract-hasthisbinding">HasThisBinding</a></emu-xref>, and <emu-xref aoid="GetThisBinding" id="_ref_3877"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref>.</p>
<emu-clause id="sec-module-environment-records-getbindingvalue-n-s" type="concrete method">
<h1><span class="secnum">9.1.1.5.1</span> GetBindingValue ( <var>N</var>, <var>S</var> )</h1>
<p>The <emu-xref aoid="GetBindingValue" id="_ref_3878"><a href="executable-code-and-execution-contexts.html#abstract-getbindingvalue">GetBindingValue</a></emu-xref> concrete method of a <emu-xref href="#sec-module-environment-records" id="_ref_3879"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref> <var>envRec</var> takes arguments <var>N</var> (a String) and <var>S</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3880"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_3881"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3882"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It returns the value of its bound identifier whose name is <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 <emu-val>ReferenceError</emu-val> is thrown. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3883"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>S</var> is <emu-val>true</emu-val>.</li><li><emu-xref href="#assert" id="_ref_3884"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var> has a binding for <var>N</var>.</li><li>If the binding for <var>N</var> is an indirect binding, then<ol><li>Let <var>M</var> and <var>N2</var> be the indirection values provided when this binding for <var>N</var> was created.</li><li>Let <var>targetEnv</var> be <var>M</var>.<var class="field">[[Environment]]</var>.</li><li>If <var>targetEnv</var> is <emu-const>empty</emu-const>, throw a <emu-val>ReferenceError</emu-val> exception.</li><li>Return ?&nbsp;<span class="e-user-code"><var>targetEnv</var>.<emu-xref aoid="GetBindingValue" id="_ref_3885"><a href="executable-code-and-execution-contexts.html#abstract-getbindingvalue">GetBindingValue</a></emu-xref>(<var>N2</var>, <emu-val>true</emu-val>)</span>.</li></ol></li><li>If the binding for <var>N</var> in <var>envRec</var> is an uninitialized binding, throw a <emu-val>ReferenceError</emu-val> exception.</li><li>Return the value currently bound to <var>N</var> in <var>envRec</var>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p><var>S</var> will always be <emu-val>true</emu-val> because a <emu-nt id="_ref_19480"><a href="ecmascript-language-scripts-and-modules.html#prod-Module">Module</a></emu-nt> is always <emu-xref href="#sec-strict-mode-code" id="_ref_3886"><a href="ecmascript-language-source-code.html#sec-strict-mode-code">strict mode code</a></emu-xref>.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-module-environment-records-deletebinding-n">
<h1><span class="secnum">9.1.1.5.2</span> DeleteBinding ( <var>N</var> )</h1>
<p>The <emu-xref aoid="DeleteBinding" id="_ref_3887"><a href="executable-code-and-execution-contexts.html#abstract-deletebinding">DeleteBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-module-environment-records" id="_ref_3888"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref> is never used within this specification.</p>
<emu-note><span class="note">Note</span><div class="note-contents">
<p><emu-xref href="#sec-module-environment-records" id="_ref_3889"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Records</a></emu-xref> are only used within strict code and an <emu-xref href="#early-error" id="_ref_3890"><a href="error-handling-and-language-extensions.html#early-error">early error</a></emu-xref> rule prevents the delete operator, in strict code, from being applied to a <emu-xref href="#sec-reference-record-specification-type" id="_ref_3891"><a href="ecmascript-data-types-and-values.html#sec-reference-record-specification-type">Reference Record</a></emu-xref> that would resolve to a <emu-xref href="#sec-module-environment-records" id="_ref_3892"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref> binding. See <emu-xref href="#sec-delete-operator-static-semantics-early-errors" id="_ref_247"><a href="ecmascript-language-expressions.html#sec-delete-operator-static-semantics-early-errors">13.5.1.1</a></emu-xref>.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-module-environment-records-hasthisbinding" type="concrete method">
<h1><span class="secnum">9.1.1.5.3</span> HasThisBinding ( )</h1>
<p>The <emu-xref aoid="HasThisBinding" id="_ref_3893"><a href="executable-code-and-execution-contexts.html#abstract-hasthisbinding">HasThisBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-module-environment-records" id="_ref_3894"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns <emu-val>true</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p><emu-xref href="#sec-module-environment-records" id="_ref_3895"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Records</a></emu-xref> always provide a <code>this</code> binding.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-module-environment-records-getthisbinding" type="concrete method">
<h1><span class="secnum">9.1.1.5.4</span> GetThisBinding ( )</h1>
<p>The <emu-xref aoid="GetThisBinding" id="_ref_3896"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref> concrete method of a <emu-xref href="#sec-module-environment-records" id="_ref_3897"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref> <var>envRec</var> takes no arguments and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3898"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-val>undefined</emu-val>. It performs the following steps when called:</p>
<emu-alg><ol><li>Return <emu-val>undefined</emu-val>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-createimportbinding" type="abstract operation" aoid="CreateImportBinding">
<h1><span class="secnum">9.1.1.5.5</span> CreateImportBinding ( <var>envRec</var>, <var>N</var>, <var>M</var>, <var>N2</var> )</h1>
<p>The abstract operation CreateImportBinding takes arguments <var>envRec</var> (a <emu-xref href="#sec-module-environment-records" id="_ref_3899"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref>), <var>N</var> (a String), <var>M</var> (a <emu-xref href="#sec-abstract-module-records" id="_ref_3900"><a href="ecmascript-language-scripts-and-modules.html#sec-abstract-module-records">Module Record</a></emu-xref>), and <var>N2</var> (a String) and returns <emu-const>unused</emu-const>. It creates a new initialized immutable indirect binding for the name <var>N</var>. A binding must not already exist in <var>envRec</var> for <var>N</var>. <var>N2</var> is the name of a binding that exists in <var>M</var>'s <emu-xref href="#sec-module-environment-records" id="_ref_3901"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref>. Accesses to the value of the new binding will indirectly access the bound value of the target binding. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_3902"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var> does not already have a binding for <var>N</var>.</li><li><emu-xref href="#assert" id="_ref_3903"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: When <var>M</var>.<var class="field">[[Environment]]</var> is instantiated, it will have a direct binding for <var>N2</var>.</li><li>Create an immutable indirect binding in <var>envRec</var> for <var>N</var> that references <var>M</var> and <var>N2</var> as its target binding and record that the binding is initialized.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-environment-record-operations" oldids="sec-lexical-environment-operations"><span id="sec-lexical-environment-operations"></span>
<h1><span class="secnum">9.1.2</span> Environment Record Operations</h1>
<p>The following <emu-xref href="#sec-algorithm-conventions-abstract-operations" id="_ref_3904"><a href="notational-conventions.html#sec-algorithm-conventions-abstract-operations">abstract operations</a></emu-xref> are used in this specification to operate upon <emu-xref href="#sec-environment-records" id="_ref_3905"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Records</a></emu-xref>:</p>
<emu-clause id="sec-getidentifierreference" type="abstract operation" aoid="GetIdentifierReference">
<h1><span class="secnum">9.1.2.1</span> GetIdentifierReference ( <var>env</var>, <var>name</var>, <var>strict</var> )</h1>
<p>The abstract operation GetIdentifierReference takes arguments <var>env</var> (an <emu-xref href="#sec-environment-records" id="_ref_3906"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> or <emu-val>null</emu-val>), <var>name</var> (a String), and <var>strict</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3907"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#sec-reference-record-specification-type" id="_ref_3908"><a href="ecmascript-data-types-and-values.html#sec-reference-record-specification-type">Reference Record</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3909"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>If <var>env</var> is <emu-val>null</emu-val>, then<ol><li>Return the <emu-xref href="#sec-reference-record-specification-type" id="_ref_3910"><a href="ecmascript-data-types-and-values.html#sec-reference-record-specification-type">Reference Record</a></emu-xref> { <var class="field">[[Base]]</var>: <emu-const>unresolvable</emu-const>, <var class="field">[[ReferencedName]]</var>: <var>name</var>, <var class="field">[[Strict]]</var>: <var>strict</var>, <var class="field">[[ThisValue]]</var>: <emu-const>empty</emu-const>&nbsp;}.</li></ol></li><li>Let <var>exists</var> be ?&nbsp;<span class="e-user-code"><var>env</var>.<emu-xref aoid="HasBinding" id="_ref_3911"><a href="executable-code-and-execution-contexts.html#abstract-hasbinding">HasBinding</a></emu-xref>(<var>name</var>)</span>.</li><li>If <var>exists</var> is <emu-val>true</emu-val>, then<ol><li>Return the <emu-xref href="#sec-reference-record-specification-type" id="_ref_3912"><a href="ecmascript-data-types-and-values.html#sec-reference-record-specification-type">Reference Record</a></emu-xref> { <var class="field">[[Base]]</var>: <var>env</var>, <var class="field">[[ReferencedName]]</var>: <var>name</var>, <var class="field">[[Strict]]</var>: <var>strict</var>, <var class="field">[[ThisValue]]</var>: <emu-const>empty</emu-const>&nbsp;}.</li></ol></li><li>Let <var>outer</var> be <var>env</var>.<var class="field">[[OuterEnv]]</var>.</li><li>Return ?&nbsp;<emu-xref aoid="GetIdentifierReference" id="_ref_3913"><a href="executable-code-and-execution-contexts.html#sec-getidentifierreference" class="e-user-code">GetIdentifierReference</a></emu-xref>(<var>outer</var>, <var>name</var>, <var>strict</var>).</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-newdeclarativeenvironment" type="abstract operation" aoid="NewDeclarativeEnvironment">
<h1><span class="secnum">9.1.2.2</span> NewDeclarativeEnvironment ( <var>E</var> )</h1>
<p>The abstract operation NewDeclarativeEnvironment takes argument <var>E</var> (an <emu-xref href="#sec-environment-records" id="_ref_3914"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> or <emu-val>null</emu-val>) and returns a <emu-xref href="#sec-declarative-environment-records" id="_ref_3915"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>env</var> be a new <emu-xref href="#sec-declarative-environment-records" id="_ref_3916"><a href="executable-code-and-execution-contexts.html#sec-declarative-environment-records">Declarative Environment Record</a></emu-xref> containing no bindings.</li><li>Set <var>env</var>.<var class="field">[[OuterEnv]]</var> to <var>E</var>.</li><li>Return <var>env</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-newobjectenvironment" type="abstract operation" aoid="NewObjectEnvironment">
<h1><span class="secnum">9.1.2.3</span> NewObjectEnvironment ( <var>O</var>, <var>W</var>, <var>E</var> )</h1>
<p>The abstract operation NewObjectEnvironment takes arguments <var>O</var> (an Object), <var>W</var> (a Boolean), and <var>E</var> (an <emu-xref href="#sec-environment-records" id="_ref_3917"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> or <emu-val>null</emu-val>) and returns an <emu-xref href="#sec-object-environment-records" id="_ref_3918"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>env</var> be a new <emu-xref href="#sec-object-environment-records" id="_ref_3919"><a href="executable-code-and-execution-contexts.html#sec-object-environment-records">Object Environment Record</a></emu-xref>.</li><li>Set <var>env</var>.<var class="field">[[BindingObject]]</var> to <var>O</var>.</li><li>Set <var>env</var>.<var class="field">[[IsWithEnvironment]]</var> to <var>W</var>.</li><li>Set <var>env</var>.<var class="field">[[OuterEnv]]</var> to <var>E</var>.</li><li>Return <var>env</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-newfunctionenvironment" type="abstract operation" aoid="NewFunctionEnvironment">
<h1><span class="secnum">9.1.2.4</span> NewFunctionEnvironment ( <var>F</var>, <var>newTarget</var> )</h1>
<p>The abstract operation NewFunctionEnvironment takes arguments <var>F</var> (an ECMAScript <emu-xref href="#function-object" id="_ref_3920"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>) and <var>newTarget</var> (an Object or <emu-val>undefined</emu-val>) and returns a <emu-xref href="#sec-function-environment-records" id="_ref_3921"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>env</var> be a new <emu-xref href="#sec-function-environment-records" id="_ref_3922"><a href="executable-code-and-execution-contexts.html#sec-function-environment-records">Function Environment Record</a></emu-xref> containing no bindings.</li><li>Set <var>env</var>.<var class="field">[[FunctionObject]]</var> to <var>F</var>.</li><li>If <var>F</var>.<var class="field">[[ThisMode]]</var> is <emu-const>lexical</emu-const>, set <var>env</var>.<var class="field">[[ThisBindingStatus]]</var> to <emu-const>lexical</emu-const>.</li><li>Else, set <var>env</var>.<var class="field">[[ThisBindingStatus]]</var> to <emu-const>uninitialized</emu-const>.</li><li>Set <var>env</var>.<var class="field">[[NewTarget]]</var> to <var>newTarget</var>.</li><li>Set <var>env</var>.<var class="field">[[OuterEnv]]</var> to <var>F</var>.<var class="field">[[Environment]]</var>.</li><li>Return <var>env</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-newglobalenvironment" type="abstract operation" aoid="NewGlobalEnvironment">
<h1><span class="secnum">9.1.2.5</span> NewGlobalEnvironment ( <var>G</var>, <var>thisValue</var> )</h1>
<p>The abstract operation NewGlobalEnvironment takes arguments <var>G</var> (an Object) and <var>thisValue</var> (an Object) and returns a <emu-xref href="#sec-global-environment-records" id="_ref_3923"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>objRec</var> be <emu-xref aoid="NewObjectEnvironment" id="_ref_3924"><a href="executable-code-and-execution-contexts.html#sec-newobjectenvironment">NewObjectEnvironment</a></emu-xref>(<var>G</var>, <emu-val>false</emu-val>, <emu-val>null</emu-val>).</li><li>Let <var>dclRec</var> be <emu-xref aoid="NewDeclarativeEnvironment" id="_ref_3925"><a href="executable-code-and-execution-contexts.html#sec-newdeclarativeenvironment">NewDeclarativeEnvironment</a></emu-xref>(<emu-val>null</emu-val>).</li><li>Let <var>env</var> be a new <emu-xref href="#sec-global-environment-records" id="_ref_3926"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>.</li><li>Set <var>env</var>.<var class="field">[[ObjectRecord]]</var> to <var>objRec</var>.</li><li>Set <var>env</var>.<var class="field">[[GlobalThisValue]]</var> to <var>thisValue</var>.</li><li>Set <var>env</var>.<var class="field">[[DeclarativeRecord]]</var> to <var>dclRec</var>.</li><li>Set <var>env</var>.<var class="field">[[OuterEnv]]</var> to <emu-val>null</emu-val>.</li><li>Return <var>env</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-newmoduleenvironment" type="abstract operation" aoid="NewModuleEnvironment">
<h1><span class="secnum">9.1.2.6</span> NewModuleEnvironment ( <var>E</var> )</h1>
<p>The abstract operation NewModuleEnvironment takes argument <var>E</var> (an <emu-xref href="#sec-environment-records" id="_ref_3927"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>) and returns a <emu-xref href="#sec-module-environment-records" id="_ref_3928"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>env</var> be a new <emu-xref href="#sec-module-environment-records" id="_ref_3929"><a href="executable-code-and-execution-contexts.html#sec-module-environment-records">Module Environment Record</a></emu-xref> containing no bindings.</li><li>Set <var>env</var>.<var class="field">[[OuterEnv]]</var> to <var>E</var>.</li><li>Return <var>env</var>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-privateenvironment-records">
<h1><span class="secnum">9.2</span> PrivateEnvironment Records</h1>
<p>A <dfn id="privateenvironment-record" variants="PrivateEnvironment Records" tabindex="-1">PrivateEnvironment Record</dfn> is a specification mechanism used to track <emu-xref href="#sec-private-names" id="_ref_3930"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Names</a></emu-xref> based upon the lexical nesting structure of <emu-nt id="_ref_19481"><a href="ecmascript-language-functions-and-classes.html#prod-ClassDeclaration">ClassDeclaration</a></emu-nt>s and <emu-nt id="_ref_19482"><a href="ecmascript-language-functions-and-classes.html#prod-ClassExpression">ClassExpression</a></emu-nt>s in ECMAScript code. They are similar to, but distinct from, <emu-xref href="#sec-environment-records" id="_ref_3931"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Records</a></emu-xref>. Each <emu-xref href="#privateenvironment-record" id="_ref_3932"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> is associated with a <emu-nt id="_ref_19483"><a href="ecmascript-language-functions-and-classes.html#prod-ClassDeclaration">ClassDeclaration</a></emu-nt> or <emu-nt id="_ref_19484"><a href="ecmascript-language-functions-and-classes.html#prod-ClassExpression">ClassExpression</a></emu-nt>. Each time such a class is evaluated, a new <emu-xref href="#privateenvironment-record" id="_ref_3933"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> is created to record the <emu-xref href="#sec-private-names" id="_ref_3934"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Names</a></emu-xref> declared by that class.</p>
<p>Each <emu-xref href="#privateenvironment-record" id="_ref_3935"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> has the fields defined in <emu-xref href="#table-privateenvironment-records" id="_ref_248"><a href="executable-code-and-execution-contexts.html#table-privateenvironment-records">Table 18</a></emu-xref>.</p>
<emu-table id="table-privateenvironment-records" caption="PrivateEnvironment Record Fields"><figure><figcaption>Table 18: <emu-xref href="#privateenvironment-record" id="_ref_3936"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> Fields</figcaption>
<table>
<thead>
<tr>
<th>
Field Name
</th>
<th>
Value Type
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tbody><tr>
<td>
<var class="field">[[OuterPrivateEnvironment]]</var>
</td>
<td>
a <emu-xref href="#privateenvironment-record" id="_ref_3937"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> or <emu-val>null</emu-val>
</td>
<td>
The <emu-xref href="#privateenvironment-record" id="_ref_3938"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> of the nearest containing class. <emu-val>null</emu-val> if the class with which this <emu-xref href="#privateenvironment-record" id="_ref_3939"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> is associated is not contained in any other class.
</td>
</tr>
<tr>
<td>
<var class="field">[[Names]]</var>
</td>
<td>
a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_3940"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-private-names" id="_ref_3941"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Names</a></emu-xref>
</td>
<td>
The <emu-xref href="#sec-private-names" id="_ref_3942"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Names</a></emu-xref> declared by this class.
</td>
</tr>
</tbody></table>
</figure></emu-table>
<emu-clause id="sec-privateenvironment-record-operations">
<h1><span class="secnum">9.2.1</span> PrivateEnvironment Record Operations</h1>
<p>The following <emu-xref href="#sec-algorithm-conventions-abstract-operations" id="_ref_3943"><a href="notational-conventions.html#sec-algorithm-conventions-abstract-operations">abstract operations</a></emu-xref> are used in this specification to operate upon <emu-xref href="#privateenvironment-record" id="_ref_3944"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Records</a></emu-xref>:</p>
<emu-clause id="sec-newprivateenvironment" type="abstract operation" aoid="NewPrivateEnvironment">
<h1><span class="secnum">9.2.1.1</span> NewPrivateEnvironment ( <var>outerPrivateEnv</var> )</h1>
<p>The abstract operation NewPrivateEnvironment takes argument <var>outerPrivateEnv</var> (a <emu-xref href="#privateenvironment-record" id="_ref_3945"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> or <emu-val>null</emu-val>) and returns a <emu-xref href="#privateenvironment-record" id="_ref_3946"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>names</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_3947"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Return the <emu-xref href="#privateenvironment-record" id="_ref_3948"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> { <var class="field">[[OuterPrivateEnvironment]]</var>: <var>outerPrivateEnv</var>, <var class="field">[[Names]]</var>: <var>names</var>&nbsp;}.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-resolve-private-identifier" type="abstract operation" aoid="ResolvePrivateIdentifier">
<h1><span class="secnum">9.2.1.2</span> ResolvePrivateIdentifier ( <var>privateEnv</var>, <var>identifier</var> )</h1>
<p>The abstract operation ResolvePrivateIdentifier takes arguments <var>privateEnv</var> (a <emu-xref href="#privateenvironment-record" id="_ref_3949"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref>) and <var>identifier</var> (a String) and returns a <emu-xref href="#sec-private-names" id="_ref_3950"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Name</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>names</var> be <var>privateEnv</var>.<var class="field">[[Names]]</var>.</li><li>For each <emu-xref href="#sec-private-names" id="_ref_3951"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Name</a></emu-xref> <var>pn</var> of <var>names</var>, do<ol><li>If <var>pn</var>.<var class="field">[[Description]]</var> is <var>identifier</var>, then<ol><li>Return <var>pn</var>.</li></ol></li></ol></li><li>Let <var>outerPrivateEnv</var> be <var>privateEnv</var>.<var class="field">[[OuterPrivateEnvironment]]</var>.</li><li><emu-xref href="#assert" id="_ref_3952"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>outerPrivateEnv</var> is not <emu-val>null</emu-val>.</li><li>Return <emu-xref aoid="ResolvePrivateIdentifier" id="_ref_3953"><a href="executable-code-and-execution-contexts.html#sec-resolve-private-identifier">ResolvePrivateIdentifier</a></emu-xref>(<var>outerPrivateEnv</var>, <var>identifier</var>).</li></ol></emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-code-realms">
<h1><span class="secnum">9.3</span> Realms</h1>
<p>Before it is evaluated, all ECMAScript code must be associated with a <dfn id="realm" variants="realms" tabindex="-1">realm</dfn>. Conceptually, a <emu-xref href="#realm" id="_ref_3954"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> 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 <emu-xref href="#realm" id="_ref_3955"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> is represented in this specification as a <dfn id="realm-record" variants="Realm Records" tabindex="-1">Realm Record</dfn> with the fields specified in <emu-xref href="#table-realm-record-fields" id="_ref_249"><a href="executable-code-and-execution-contexts.html#table-realm-record-fields">Table 19</a></emu-xref>:</p>
<emu-table id="table-realm-record-fields" caption="Realm Record Fields" oldids="table-21"><figure><figcaption>Table 19: <emu-xref href="#realm-record" id="_ref_3956"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref> Fields</figcaption><span id="table-21"></span>
<table>
<thead>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tbody><tr>
<td>
<var class="field">[[AgentSignifier]]</var>
</td>
<td>
an <emu-xref href="#sec-agents" id="_ref_3957"><a href="executable-code-and-execution-contexts.html#sec-agents">agent signifier</a></emu-xref>
</td>
<td>
The <emu-xref href="#agent" id="_ref_3958"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> that owns this <emu-xref href="#realm" id="_ref_3959"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>
</td>
</tr>
<tr>
<td>
<var class="field">[[Intrinsics]]</var>
</td>
<td>
a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_3960"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> whose field names are intrinsic keys and whose values are objects
</td>
<td>
The intrinsic values used by code associated with this <emu-xref href="#realm" id="_ref_3961"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>
</td>
</tr>
<tr>
<td>
<var class="field">[[GlobalObject]]</var>
</td>
<td>
an Object
</td>
<td>
The <emu-xref href="#sec-global-object" id="_ref_3962"><a href="global-object.html#sec-global-object">global object</a></emu-xref> for this <emu-xref href="#realm" id="_ref_3963"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>
</td>
</tr>
<tr>
<td>
<var class="field">[[GlobalEnv]]</var>
</td>
<td>
a <emu-xref href="#sec-global-environment-records" id="_ref_3964"><a href="executable-code-and-execution-contexts.html#sec-global-environment-records">Global Environment Record</a></emu-xref>
</td>
<td>
The global environment for this <emu-xref href="#realm" id="_ref_3965"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>
</td>
</tr>
<tr>
<td>
<var class="field">[[TemplateMap]]</var>
</td>
<td>
a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_3966"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-list-and-record-specification-type" id="_ref_3967"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Records</a></emu-xref> with fields <var class="field">[[Site]]</var> (a <emu-nt id="_ref_19485"><a href="ecmascript-language-expressions.html#prod-TemplateLiteral">TemplateLiteral</a></emu-nt> <emu-xref href="#sec-syntactic-grammar" id="_ref_3968"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref>) and <var class="field">[[Array]]</var> (an Array)
</td>
<td>
<p>Template objects are canonicalized separately for each <emu-xref href="#realm" id="_ref_3969"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> using its <emu-xref href="#realm-record" id="_ref_3970"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>'s <var class="field">[[TemplateMap]]</var>. Each <var class="field">[[Site]]</var> value is a <emu-xref href="#sec-syntactic-grammar" id="_ref_3971"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref> that is a <emu-nt id="_ref_19486"><a href="ecmascript-language-expressions.html#prod-TemplateLiteral">TemplateLiteral</a></emu-nt>. The associated <var class="field">[[Array]]</var> value is the corresponding template object that is passed to a tag function.</p>
<emu-note><span class="note">Note 1</span><div class="note-contents">Once a <emu-xref href="#sec-syntactic-grammar" id="_ref_3972"><a href="notational-conventions.html#sec-syntactic-grammar">Parse Node</a></emu-xref> becomes unreachable, the corresponding <var class="field">[[Array]]</var> is also unreachable, and it would be unobservable if an implementation removed the pair from the <var class="field">[[TemplateMap]]</var> list.</div></emu-note>
</td>
</tr>
<tr>
<td>
<var class="field">[[LoadedModules]]</var>
</td>
<td>
a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_3973"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#loadedmodulerequest-record" id="_ref_3974"><a href="ecmascript-language-scripts-and-modules.html#loadedmodulerequest-record">LoadedModuleRequest Records</a></emu-xref>
</td>
<td>
<p>A map from the specifier strings imported by this <emu-xref href="#realm" id="_ref_3975"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> to the resolved <emu-xref href="#sec-abstract-module-records" id="_ref_3976"><a href="ecmascript-language-scripts-and-modules.html#sec-abstract-module-records">Module Record</a></emu-xref>. The list does not contain two different <emu-xref href="#sec-list-and-record-specification-type" id="_ref_3977"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Records</a></emu-xref> <var>r1</var> and <var>r2</var> such that <emu-xref aoid="ModuleRequestsEqual" id="_ref_3978"><a href="ecmascript-language-scripts-and-modules.html#sec-ModuleRequestsEqual">ModuleRequestsEqual</a></emu-xref>(<var>r1</var>, <var>r2</var>) is <emu-val>true</emu-val>.</p>
<emu-note><span class="note">Note 2</span><div class="note-contents">
As mentioned in <emu-xref aoid="HostLoadImportedModule" id="_ref_3979"><a href="ecmascript-language-scripts-and-modules.html#sec-HostLoadImportedModule">HostLoadImportedModule</a></emu-xref> (<emu-xref href="#note-HostLoadImportedModule-referrer-Realm-Record" id="_ref_250"><a href="ecmascript-language-scripts-and-modules.html#note-HostLoadImportedModule-referrer-Realm-Record">16.2.1.10 Note 1</a></emu-xref>), <var class="field">[[LoadedModules]]</var> in <emu-xref href="#realm-record" id="_ref_3980"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Records</a></emu-xref> is only used when running an <code>import()</code> expression in a context where there is no <emu-xref href="#job-activescriptormodule" id="_ref_3981"><a href="executable-code-and-execution-contexts.html#job-activescriptormodule">active script or module</a></emu-xref>.
</div></emu-note>
</td>
</tr>
<tr>
<td>
<var class="field">[[HostDefined]]</var>
</td>
<td>
anything (default value is <emu-val>undefined</emu-val>)
</td>
<td>
Field reserved for use by <emu-xref href="#host" id="_ref_3982"><a href="overview.html#host">hosts</a></emu-xref> that need to associate additional information with a <emu-xref href="#realm-record" id="_ref_3983"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>.
</td>
</tr>
</tbody></table>
</figure></emu-table>
<emu-clause id="sec-initializehostdefinedrealm" type="abstract operation" oldids="sec-createrealm,sec-setrealmglobalobject" aoid="InitializeHostDefinedRealm"><span id="sec-setrealmglobalobject"></span><span id="sec-createrealm"></span>
<h1><span class="secnum">9.3.1</span> InitializeHostDefinedRealm ( )</h1>
<p>The abstract operation InitializeHostDefinedRealm takes no arguments and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3984"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_3985"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>realm</var> be a new <emu-xref href="#realm-record" id="_ref_3986"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>.</li><li>Perform <emu-xref aoid="CreateIntrinsics" id="_ref_3987"><a href="executable-code-and-execution-contexts.html#sec-createintrinsics">CreateIntrinsics</a></emu-xref>(<var>realm</var>).</li><li>Set <var>realm</var>.<var class="field">[[AgentSignifier]]</var> to <emu-xref aoid="AgentSignifier" id="_ref_3988"><a href="executable-code-and-execution-contexts.html#sec-agentsignifier">AgentSignifier</a></emu-xref>().</li><li>Set <var>realm</var>.<var class="field">[[TemplateMap]]</var> to a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_3989"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>newContext</var> be a new <emu-xref href="#sec-execution-contexts" id="_ref_3990"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref>.</li><li>Set the Function of <var>newContext</var> to <emu-val>null</emu-val>.</li><li>Set the <emu-xref href="#realm" id="_ref_3991"><a href="executable-code-and-execution-contexts.html#realm">Realm</a></emu-xref> of <var>newContext</var> to <var>realm</var>.</li><li>Set the ScriptOrModule of <var>newContext</var> to <emu-val>null</emu-val>.</li><li>Push <var>newContext</var> onto the <emu-xref href="#execution-context-stack" id="_ref_3992"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref>; <var>newContext</var> is now the <emu-xref href="#running-execution-context" id="_ref_3993"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>.</li><li>If the <emu-xref href="#host" id="_ref_3994"><a href="overview.html#host">host</a></emu-xref> requires use of a specific object to serve as <var>realm</var>'s <emu-xref href="#sec-global-object" id="_ref_3995"><a href="global-object.html#sec-global-object">global object</a></emu-xref>, then<ol><li>Let <var>global</var> be such an object created in a <emu-xref href="#host-defined" id="_ref_3996"><a href="overview.html#host-defined">host-defined</a></emu-xref> manner.</li></ol></li><li>Else,<ol><li>Let <var>global</var> be <emu-xref aoid="OrdinaryObjectCreate" id="_ref_3997"><a href="ordinary-and-exotic-objects-behaviours.html#sec-ordinaryobjectcreate">OrdinaryObjectCreate</a></emu-xref>(<var>realm</var>.<var class="field">[[Intrinsics]]</var>.[[<emu-xref href="#sec-properties-of-the-object-prototype-object" id="_ref_3998"><a href="fundamental-objects.html#sec-properties-of-the-object-prototype-object">%Object.prototype%</a></emu-xref>]]).</li></ol></li><li>If the <emu-xref href="#host" id="_ref_3999"><a href="overview.html#host">host</a></emu-xref> requires that the <code>this</code> binding in <var>realm</var>'s global scope return an object other than the <emu-xref href="#sec-global-object" id="_ref_4000"><a href="global-object.html#sec-global-object">global object</a></emu-xref>, then<ol><li>Let <var>thisValue</var> be such an object created in a <emu-xref href="#host-defined" id="_ref_4001"><a href="overview.html#host-defined">host-defined</a></emu-xref> manner.</li></ol></li><li>Else,<ol><li>Let <var>thisValue</var> be <var>global</var>.</li></ol></li><li>Set <var>realm</var>.<var class="field">[[GlobalObject]]</var> to <var>global</var>.</li><li>Set <var>realm</var>.<var class="field">[[GlobalEnv]]</var> to <emu-xref aoid="NewGlobalEnvironment" id="_ref_4002"><a href="executable-code-and-execution-contexts.html#sec-newglobalenvironment">NewGlobalEnvironment</a></emu-xref>(<var>global</var>, <var>thisValue</var>).</li><li>Perform ?&nbsp;<emu-xref aoid="SetDefaultGlobalBindings" id="_ref_4003"><a href="executable-code-and-execution-contexts.html#sec-setdefaultglobalbindings" class="e-user-code">SetDefaultGlobalBindings</a></emu-xref>(<var>realm</var>).</li><li>Create any <emu-xref href="#host-defined" id="_ref_4004"><a href="overview.html#host-defined">host-defined</a></emu-xref> <emu-xref href="#sec-global-object" id="_ref_4005"><a href="global-object.html#sec-global-object">global object</a></emu-xref> properties on <var>global</var>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-createintrinsics" type="abstract operation" aoid="CreateIntrinsics">
<h1><span class="secnum">9.3.2</span> CreateIntrinsics ( <var>realmRec</var> )</h1>
<p>The abstract operation CreateIntrinsics takes argument <var>realmRec</var> (a <emu-xref href="#realm-record" id="_ref_4006"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>) and returns <emu-const>unused</emu-const>. It performs the following steps when called:</p>
<emu-alg><ol><li>Set <var>realmRec</var>.<var class="field">[[Intrinsics]]</var> to a new <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4007"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref>.</li><li declared="steps,name,length,slots,prototype,async">Set fields of <var>realmRec</var>.<var class="field">[[Intrinsics]]</var> with the values listed in <emu-xref href="#table-well-known-intrinsic-objects" id="_ref_251"><a href="ecmascript-data-types-and-values.html#table-well-known-intrinsic-objects">Table 6</a></emu-xref>. The field names are the names listed in the “Intrinsic Name” column 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 <emu-xref href="#sec-global-object" id="_ref_252"><a href="global-object.html#sec-global-object">19</a></emu-xref> through <emu-xref href="#sec-reflection" id="_ref_253"><a href="reflection.html#sec-reflection">28</a></emu-xref>. All object property values are newly created object values. All values that are built-in <emu-xref href="#function-object" id="_ref_4008"><a href="ecmascript-data-types-and-values.html#function-object">function objects</a></emu-xref> are created by performing <emu-xref aoid="CreateBuiltinFunction" id="_ref_4009"><a href="ordinary-and-exotic-objects-behaviours.html#sec-createbuiltinfunction">CreateBuiltinFunction</a></emu-xref>(<var>steps</var>, <var>length</var>, <var>name</var>, <var>slots</var>, <var>realmRec</var>, <var>prototype</var>, <var>async</var>) where <var>steps</var> is the definition of that function provided by this specification, <var>name</var> is the initial value of the function's <emu-val>"name"</emu-val> property, <var>length</var> is the initial value of the function's <emu-val>"length"</emu-val> property, <var>slots</var> is a list of the names, if any, of the function's specified internal slots, <var>prototype</var> is the specified value of the function's <var class="field">[[Prototype]]</var> internal slot, and <var>async</var> is <emu-val>true</emu-val> if the function is described as “async” and <emu-val>false</emu-val> otherwise. 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>Perform <emu-xref aoid="AddRestrictedFunctionProperties" id="_ref_4010"><a href="ordinary-and-exotic-objects-behaviours.html#sec-addrestrictedfunctionproperties">AddRestrictedFunctionProperties</a></emu-xref>(<var>realmRec</var>.<var class="field">[[Intrinsics]]</var>.[[<emu-xref href="#sec-properties-of-the-function-prototype-object" id="_ref_4011"><a href="fundamental-objects.html#sec-properties-of-the-function-prototype-object">%Function.prototype%</a></emu-xref>]], <var>realmRec</var>).</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-setdefaultglobalbindings" type="abstract operation" aoid="SetDefaultGlobalBindings">
<h1><span class="secnum">9.3.3</span> SetDefaultGlobalBindings ( <var>realmRec</var> )</h1>
<p>The abstract operation SetDefaultGlobalBindings takes argument <var>realmRec</var> (a <emu-xref href="#realm-record" id="_ref_4012"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4013"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4014"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>global</var> be <var>realmRec</var>.<var class="field">[[GlobalObject]]</var>.</li><li>For each property of the Global Object specified in clause <emu-xref href="#sec-global-object" id="_ref_254"><a href="global-object.html#sec-global-object">19</a></emu-xref>, do<ol><li>Let <var>name</var> be the String value of the <emu-xref href="#property-name" id="_ref_4015"><a href="ecmascript-data-types-and-values.html#property-name">property name</a></emu-xref>.</li><li>Let <var>desc</var> be the fully populated data <emu-xref href="#sec-property-descriptor-specification-type" id="_ref_4016"><a href="ecmascript-data-types-and-values.html#sec-property-descriptor-specification-type">Property Descriptor</a></emu-xref> for the property, containing the specified attributes for the property. For properties listed in <emu-xref href="#sec-function-properties-of-the-global-object" id="_ref_255"><a href="global-object.html#sec-function-properties-of-the-global-object">19.2</a></emu-xref>, <emu-xref href="#sec-constructor-properties-of-the-global-object" id="_ref_256"><a href="global-object.html#sec-constructor-properties-of-the-global-object">19.3</a></emu-xref>, or <emu-xref href="#sec-other-properties-of-the-global-object" id="_ref_257"><a href="global-object.html#sec-other-properties-of-the-global-object">19.4</a></emu-xref> the value of the <var class="field">[[Value]]</var> attribute is the corresponding intrinsic object from <var>realmRec</var>.</li><li>Perform ?&nbsp;<emu-xref aoid="DefinePropertyOrThrow" id="_ref_4017"><a href="abstract-operations.html#sec-definepropertyorthrow" class="e-user-code">DefinePropertyOrThrow</a></emu-xref>(<var>global</var>, <var>name</var>, <var>desc</var>).</li></ol></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-execution-contexts">
<h1><span class="secnum">9.4</span> Execution Contexts</h1>
<p>An <dfn variants="execution contexts" tabindex="-1">execution context</dfn> 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 per <emu-xref href="#agent" id="_ref_4018"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> that is actually executing code. This is known as the <emu-xref href="#agent" id="_ref_4019"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s <dfn id="running-execution-context" variants="running execution contexts" tabindex="-1">running execution context</dfn>. All references to the <emu-xref href="#running-execution-context" id="_ref_4020"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> in this specification denote the <emu-xref href="#running-execution-context" id="_ref_4021"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> of the <emu-xref href="#surrounding-agent" id="_ref_4022"><a href="executable-code-and-execution-contexts.html#surrounding-agent">surrounding agent</a></emu-xref>.</p>
<p>The <dfn id="execution-context-stack" variants="execution context stacks" tabindex="-1">execution context stack</dfn> is used to track execution contexts. The <emu-xref href="#running-execution-context" id="_ref_4023"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> 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 <emu-xref href="#running-execution-context" id="_ref_4024"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> to executable code that is not associated with that execution context. The newly created execution context is pushed onto the stack and becomes the <emu-xref href="#running-execution-context" id="_ref_4025"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>.</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 <emu-xref href="#table-state-components-for-all-execution-contexts" id="_ref_258"><a href="executable-code-and-execution-contexts.html#table-state-components-for-all-execution-contexts">Table 20</a></emu-xref>.</p>
<emu-table id="table-state-components-for-all-execution-contexts" caption="State Components for All Execution Contexts" oldids="table-22"><figure><figcaption>Table 20: State Components for All Execution Contexts</figcaption><span id="table-22"></span>
<table>
<thead>
<tr>
<th>
Component
</th>
<th>
Purpose
</th>
</tr>
</thead>
<tbody><tr>
<td>
code evaluation state
</td>
<td>
Any state needed to perform, suspend, and resume evaluation of the code associated with this <emu-xref href="#sec-execution-contexts" id="_ref_4026"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref>.
</td>
</tr>
<tr>
<td>
Function
</td>
<td>
If this <emu-xref href="#sec-execution-contexts" id="_ref_4027"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> is evaluating the code of a <emu-xref href="#function-object" id="_ref_4028"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>, then the value of this component is that <emu-xref href="#function-object" id="_ref_4029"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>. If the context is evaluating the code of a <emu-nt id="_ref_19487"><a href="ecmascript-language-scripts-and-modules.html#prod-Script">Script</a></emu-nt> or <emu-nt id="_ref_19488"><a href="ecmascript-language-scripts-and-modules.html#prod-Module">Module</a></emu-nt>, the value is <emu-val>null</emu-val>.
</td>
</tr>
<tr>
<td>
<emu-xref href="#realm" id="_ref_4030"><a href="executable-code-and-execution-contexts.html#realm">Realm</a></emu-xref>
</td>
<td>
The <emu-xref href="#realm-record" id="_ref_4031"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref> from which associated code accesses ECMAScript resources.
</td>
</tr>
<tr>
<td>
ScriptOrModule
</td>
<td>
The <emu-xref href="#sec-abstract-module-records" id="_ref_4032"><a href="ecmascript-language-scripts-and-modules.html#sec-abstract-module-records">Module Record</a></emu-xref> or <emu-xref href="#script-record" id="_ref_4033"><a href="ecmascript-language-scripts-and-modules.html#script-record">Script Record</a></emu-xref> from which associated code originates. If there is no originating script or module, as is the case for the original <emu-xref href="#sec-execution-contexts" id="_ref_4034"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> created in <emu-xref aoid="InitializeHostDefinedRealm" id="_ref_4035"><a href="executable-code-and-execution-contexts.html#sec-initializehostdefinedrealm">InitializeHostDefinedRealm</a></emu-xref>, the value is <emu-val>null</emu-val>.
</td>
</tr>
</tbody></table>
</figure></emu-table>
<p><emu-xref aoid="Evaluation" id="_ref_4036"><a href="syntax-directed-operations.html#sec-evaluation">Evaluation</a></emu-xref> of code by the <emu-xref href="#running-execution-context" id="_ref_4037"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> may be suspended at various points defined within this specification. Once the <emu-xref href="#running-execution-context" id="_ref_4038"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> has been suspended a different execution context may become the <emu-xref href="#running-execution-context" id="_ref_4039"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> and commence evaluating its code. At some later time a suspended execution context may again become the <emu-xref href="#running-execution-context" id="_ref_4040"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> and continue evaluating its code at the point where it had previously been suspended. Transition of the <emu-xref href="#running-execution-context" id="_ref_4041"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> status among execution contexts usually occurs in stack-like last-in/first-out manner. However, some ECMAScript features require non-LIFO transitions of the <emu-xref href="#running-execution-context" id="_ref_4042"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>.</p>
<p>The value of the <emu-xref href="#realm" id="_ref_4043"><a href="executable-code-and-execution-contexts.html#realm">Realm</a></emu-xref> component of the <emu-xref href="#running-execution-context" id="_ref_4044"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> is also called <dfn id="current-realm" tabindex="-1">the current Realm Record</dfn>. The value of the Function component of the <emu-xref href="#running-execution-context" id="_ref_4045"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> is also called the <dfn id="active-function-object" tabindex="-1">active function object</dfn>.</p>
<p><dfn id="ecmascript-code-execution-context" variants="ECMAScript code execution context" tabindex="-1">ECMAScript code execution contexts</dfn> have the additional state components listed in <emu-xref href="#table-additional-state-components-for-ecmascript-code-execution-contexts" id="_ref_259"><a href="executable-code-and-execution-contexts.html#table-additional-state-components-for-ecmascript-code-execution-contexts">Table 21</a></emu-xref>.</p>
<emu-table id="table-additional-state-components-for-ecmascript-code-execution-contexts" caption="Additional State Components for ECMAScript Code Execution Contexts" oldids="table-23"><figure><figcaption>Table 21: Additional State Components for ECMAScript Code Execution Contexts</figcaption><span id="table-23"></span>
<table>
<thead>
<tr>
<th>
Component
</th>
<th>
Purpose
</th>
</tr>
</thead>
<tbody><tr>
<td>
LexicalEnvironment
</td>
<td>
Identifies the <emu-xref href="#sec-environment-records" id="_ref_4046"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> used to resolve identifier references made by code within this <emu-xref href="#sec-execution-contexts" id="_ref_4047"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref>.
</td>
</tr>
<tr>
<td>
VariableEnvironment
</td>
<td>
Identifies the <emu-xref href="#sec-environment-records" id="_ref_4048"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> that holds bindings created by <emu-nt id="_ref_19489"><a href="ecmascript-language-statements-and-declarations.html#prod-VariableStatement">VariableStatement</a></emu-nt>s within this <emu-xref href="#sec-execution-contexts" id="_ref_4049"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref>.
</td>
</tr>
<tr>
<td>
PrivateEnvironment
</td>
<td>
Identifies the <emu-xref href="#privateenvironment-record" id="_ref_4050"><a href="executable-code-and-execution-contexts.html#privateenvironment-record">PrivateEnvironment Record</a></emu-xref> that holds <emu-xref href="#sec-private-names" id="_ref_4051"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Names</a></emu-xref> created by <emu-nt id="_ref_19490"><a href="ecmascript-language-functions-and-classes.html#prod-ClassElement">ClassElement</a></emu-nt>s in the nearest containing class. <emu-val>null</emu-val> if there is no containing class.
</td>
</tr>
</tbody></table>
</figure></emu-table>
<p>The LexicalEnvironment and VariableEnvironment components of an execution context are always <emu-xref href="#sec-environment-records" id="_ref_4052"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Records</a></emu-xref>.</p>
<p>Execution contexts representing the evaluation of Generators have the additional state components listed in <emu-xref href="#table-additional-state-components-for-generator-execution-contexts" id="_ref_260"><a href="executable-code-and-execution-contexts.html#table-additional-state-components-for-generator-execution-contexts">Table 22</a></emu-xref>.</p>
<emu-table id="table-additional-state-components-for-generator-execution-contexts" caption="Additional State Components for Generator Execution Contexts" oldids="table-24"><figure><figcaption>Table 22: Additional State Components for Generator Execution Contexts</figcaption><span id="table-24"></span>
<table>
<thead>
<tr>
<th>
Component
</th>
<th>
Purpose
</th>
</tr>
</thead>
<tbody><tr>
<td>
Generator
</td>
<td>
The Generator that this <emu-xref href="#sec-execution-contexts" id="_ref_4053"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> is evaluating.
</td>
</tr>
</tbody></table>
</figure></emu-table>
<p>In most situations only the <emu-xref href="#running-execution-context" id="_ref_4054"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> (the top of the <emu-xref href="#execution-context-stack" id="_ref_4055"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref>) is directly manipulated by algorithms within this specification. Hence when the terms “LexicalEnvironment”, and “VariableEnvironment” are used without qualification they are in reference to those components of the <emu-xref href="#running-execution-context" id="_ref_4056"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>.</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>
<emu-clause id="sec-getactivescriptormodule" type="abstract operation" aoid="GetActiveScriptOrModule">
<h1><span class="secnum">9.4.1</span> GetActiveScriptOrModule ( )</h1>
<p>The abstract operation GetActiveScriptOrModule takes no arguments and returns a <emu-xref href="#script-record" id="_ref_4057"><a href="ecmascript-language-scripts-and-modules.html#script-record">Script Record</a></emu-xref>, a <emu-xref href="#sec-abstract-module-records" id="_ref_4058"><a href="ecmascript-language-scripts-and-modules.html#sec-abstract-module-records">Module Record</a></emu-xref>, or <emu-val>null</emu-val>. It is used to determine the running script or module, based on the <emu-xref href="#running-execution-context" id="_ref_4059"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>If the <emu-xref href="#execution-context-stack" id="_ref_4060"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref> is empty, return <emu-val>null</emu-val>.</li><li>Let <var>ec</var> be the topmost <emu-xref href="#sec-execution-contexts" id="_ref_4061"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> on the <emu-xref href="#execution-context-stack" id="_ref_4062"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref> whose ScriptOrModule component is not <emu-val>null</emu-val>.</li><li>If no such <emu-xref href="#sec-execution-contexts" id="_ref_4063"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> exists, return <emu-val>null</emu-val>.</li><li>Return <var>ec</var>'s ScriptOrModule.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-resolvebinding" type="abstract operation" aoid="ResolveBinding">
<h1><span class="secnum">9.4.2</span> ResolveBinding ( <var>name</var> [ , <var>env</var> ] )</h1>
<p>The abstract operation ResolveBinding takes argument <var>name</var> (a String) and optional argument <var>env</var> (an <emu-xref href="#sec-environment-records" id="_ref_4064"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> or <emu-val>undefined</emu-val>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4065"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#sec-reference-record-specification-type" id="_ref_4066"><a href="ecmascript-data-types-and-values.html#sec-reference-record-specification-type">Reference Record</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4067"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to determine the binding of <var>name</var>. <var>env</var> can be used to explicitly provide the <emu-xref href="#sec-environment-records" id="_ref_4068"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> that is to be searched for the binding. It performs the following steps when called:</p>
<emu-alg><ol><li>If <var>env</var> is not present or <var>env</var> is <emu-val>undefined</emu-val>, then<ol><li>Set <var>env</var> to the <emu-xref href="#running-execution-context" id="_ref_4069"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>'s LexicalEnvironment.</li></ol></li><li><emu-xref href="#assert" id="_ref_4070"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>env</var> is an <emu-xref href="#sec-environment-records" id="_ref_4071"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>.</li><li>Let <var>strict</var> be <emu-xref aoid="IsStrict" id="_ref_4072"><a href="ecmascript-language-source-code.html#sec-isstrict">IsStrict</a></emu-xref>(the syntactic production that is being evaluated).</li><li>Return ?&nbsp;<emu-xref aoid="GetIdentifierReference" id="_ref_4073"><a href="executable-code-and-execution-contexts.html#sec-getidentifierreference" class="e-user-code">GetIdentifierReference</a></emu-xref>(<var>env</var>, <var>name</var>, <var>strict</var>).</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>The result of ResolveBinding is always a <emu-xref href="#sec-reference-record-specification-type" id="_ref_4074"><a href="ecmascript-data-types-and-values.html#sec-reference-record-specification-type">Reference Record</a></emu-xref> whose <var class="field">[[ReferencedName]]</var> field is <var>name</var>.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-getthisenvironment" type="abstract operation" aoid="GetThisEnvironment">
<h1><span class="secnum">9.4.3</span> GetThisEnvironment ( )</h1>
<p>The abstract operation GetThisEnvironment takes no arguments and returns an <emu-xref href="#sec-environment-records" id="_ref_4075"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref>. It finds the <emu-xref href="#sec-environment-records" id="_ref_4076"><a href="executable-code-and-execution-contexts.html#sec-environment-records">Environment Record</a></emu-xref> that currently supplies the binding of the <emu-xref href="#sec-keywords-and-reserved-words" id="_ref_4077"><a href="ecmascript-language-lexical-grammar.html#sec-keywords-and-reserved-words">keyword</a></emu-xref> <code>this</code>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>env</var> be the <emu-xref href="#running-execution-context" id="_ref_4078"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>'s LexicalEnvironment.</li><li id="step-getthisenvironment-loop">Repeat,<ol><li>Let <var>exists</var> be <var>env</var>.<emu-xref aoid="HasThisBinding" id="_ref_4079"><a href="executable-code-and-execution-contexts.html#abstract-hasthisbinding">HasThisBinding</a></emu-xref>().</li><li>If <var>exists</var> is <emu-val>true</emu-val>, return <var>env</var>.</li><li>Let <var>outer</var> be <var>env</var>.<var class="field">[[OuterEnv]]</var>.</li><li><emu-xref href="#assert" id="_ref_4080"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>outer</var> is not <emu-val>null</emu-val>.</li><li>Set <var>env</var> to <var>outer</var>.</li></ol></li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>The loop in step <emu-xref href="#step-getthisenvironment-loop" id="_ref_261"><a href="executable-code-and-execution-contexts.html#step-getthisenvironment-loop">2</a></emu-xref> will always terminate because the list of environments always ends with the global environment which has a <code>this</code> binding.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-resolvethisbinding" type="abstract operation" aoid="ResolveThisBinding">
<h1><span class="secnum">9.4.4</span> ResolveThisBinding ( )</h1>
<p>The abstract operation ResolveThisBinding takes no arguments and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4081"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_4082"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4083"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It determines the binding of the <emu-xref href="#sec-keywords-and-reserved-words" id="_ref_4084"><a href="ecmascript-language-lexical-grammar.html#sec-keywords-and-reserved-words">keyword</a></emu-xref> <code>this</code> using the LexicalEnvironment of the <emu-xref href="#running-execution-context" id="_ref_4085"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>envRec</var> be <emu-xref aoid="GetThisEnvironment" id="_ref_4086"><a href="executable-code-and-execution-contexts.html#sec-getthisenvironment">GetThisEnvironment</a></emu-xref>().</li><li>Return ?&nbsp;<var>envRec</var>.<emu-xref aoid="GetThisBinding" id="_ref_4087"><a href="executable-code-and-execution-contexts.html#abstract-getthisbinding">GetThisBinding</a></emu-xref>().</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-getnewtarget" type="abstract operation" aoid="GetNewTarget">
<h1><span class="secnum">9.4.5</span> GetNewTarget ( )</h1>
<p>The abstract operation GetNewTarget takes no arguments and returns an Object or <emu-val>undefined</emu-val>. It determines the NewTarget value using the LexicalEnvironment of the <emu-xref href="#running-execution-context" id="_ref_4088"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>envRec</var> be <emu-xref aoid="GetThisEnvironment" id="_ref_4089"><a href="executable-code-and-execution-contexts.html#sec-getthisenvironment">GetThisEnvironment</a></emu-xref>().</li><li><emu-xref href="#assert" id="_ref_4090"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>envRec</var> has a <var class="field">[[NewTarget]]</var> field.</li><li>Return <var>envRec</var>.<var class="field">[[NewTarget]]</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-getglobalobject" type="abstract operation" aoid="GetGlobalObject">
<h1><span class="secnum">9.4.6</span> GetGlobalObject ( )</h1>
<p>The abstract operation GetGlobalObject takes no arguments and returns an Object. It returns the <emu-xref href="#sec-global-object" id="_ref_4091"><a href="global-object.html#sec-global-object">global object</a></emu-xref> used by the currently <emu-xref href="#running-execution-context" id="_ref_4092"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>currentRealm</var> be <emu-xref href="#current-realm" id="_ref_4093"><a href="executable-code-and-execution-contexts.html#current-realm">the current Realm Record</a></emu-xref>.</li><li>Return <var>currentRealm</var>.<var class="field">[[GlobalObject]]</var>.</li></ol></emu-alg>
</emu-clause>
</emu-clause>
<emu-clause id="sec-jobs" oldids="sec-jobs-and-job-queues,sec-enqueuejob,sec-runjobs,job-queue"><span id="job-queue"></span><span id="sec-runjobs"></span><span id="sec-enqueuejob"></span><span id="sec-jobs-and-job-queues"></span>
<h1><span class="secnum">9.5</span> Jobs and Host Operations to Enqueue Jobs</h1>
<p>A <dfn id="job" variants="Jobs" tabindex="-1">Job</dfn> is an <emu-xref href="#sec-abstract-closure" id="_ref_4094"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> with no parameters that initiates an ECMAScript computation when no other ECMAScript computation is currently in progress.</p>
<p><emu-xref href="#job" id="_ref_4095"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref> are scheduled for execution by ECMAScript <emu-xref href="#host-environment" id="_ref_4096"><a href="overview.html#host-environment">host environments</a></emu-xref> in a particular <emu-xref href="#agent" id="_ref_4097"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>. This specification describes the <emu-xref href="#host-hook" id="_ref_4098"><a href="overview.html#host-hook">host hooks</a></emu-xref> <emu-xref aoid="HostEnqueueGenericJob" id="_ref_4099"><a href="executable-code-and-execution-contexts.html#sec-hostenqueuegenericjob">HostEnqueueGenericJob</a></emu-xref>, <emu-xref aoid="HostEnqueueFinalizationRegistryCleanupJob" id="_ref_4100"><a href="executable-code-and-execution-contexts.html#sec-host-cleanup-finalization-registry">HostEnqueueFinalizationRegistryCleanupJob</a></emu-xref>, <emu-xref aoid="HostEnqueuePromiseJob" id="_ref_4101"><a href="executable-code-and-execution-contexts.html#sec-hostenqueuepromisejob">HostEnqueuePromiseJob</a></emu-xref>, and <emu-xref aoid="HostEnqueueTimeoutJob" id="_ref_4102"><a href="executable-code-and-execution-contexts.html#sec-hostenqueuetimeoutjob">HostEnqueueTimeoutJob</a></emu-xref> to schedule jobs. The <emu-xref href="#host-hook" id="_ref_4103"><a href="overview.html#host-hook">host hooks</a></emu-xref> in this specification are organized by the additional constraints imposed on the scheduling of jobs. <emu-xref href="#host" id="_ref_4104"><a href="overview.html#host">Hosts</a></emu-xref> may define additional <emu-xref href="#sec-algorithm-conventions-abstract-operations" id="_ref_4105"><a href="notational-conventions.html#sec-algorithm-conventions-abstract-operations">abstract operations</a></emu-xref> which schedule jobs. Such operations accept a <emu-xref href="#job" id="_ref_4106"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> <emu-xref href="#sec-abstract-closure" id="_ref_4107"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> and a <emu-xref href="#realm" id="_ref_4108"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> (a <emu-xref href="#realm-record" id="_ref_4109"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref> or <emu-val>null</emu-val>) as parameters. If a <emu-xref href="#realm-record" id="_ref_4110"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref> is provided, these operations schedule the job to be performed at some future time in the provided <emu-xref href="#realm" id="_ref_4111"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>, in the <emu-xref href="#agent" id="_ref_4112"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> that owns the <emu-xref href="#realm" id="_ref_4113"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>. If <emu-val>null</emu-val> is provided instead for the <emu-xref href="#realm" id="_ref_4114"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref>, then the job does not evaluate ECMAScript code. Their implementations must conform to the following requirements:</p>
<ul>
<li>At some future point in time, when there is no running context in the <emu-xref href="#agent" id="_ref_4115"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> for which the job is scheduled and that <emu-xref href="#agent" id="_ref_4116"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s <emu-xref href="#execution-context-stack" id="_ref_4117"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref> is empty, the implementation must:
<ol>
<li>Perform any <emu-xref href="#host-defined" id="_ref_4118"><a href="overview.html#host-defined">host-defined</a></emu-xref> preparation steps.</li>
<li><emu-not-ref>Invoke</emu-not-ref> the <emu-xref href="#job" id="_ref_4119"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> <emu-xref href="#sec-abstract-closure" id="_ref_4120"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref>.</li>
<li>Perform any <emu-xref href="#host-defined" id="_ref_4121"><a href="overview.html#host-defined">host-defined</a></emu-xref> cleanup steps, after which the <emu-xref href="#execution-context-stack" id="_ref_4122"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref> must be empty.</li>
</ol>
</li>
<li>Only one <emu-xref href="#job" id="_ref_4123"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> may be actively undergoing evaluation at any point in time in an <emu-xref href="#agent" id="_ref_4124"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>.</li>
<li>Once evaluation of a <emu-xref href="#job" id="_ref_4125"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> starts, it must run to completion before evaluation of any other <emu-xref href="#job" id="_ref_4126"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> starts in an <emu-xref href="#agent" id="_ref_4127"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>.</li>
<li>The <emu-xref href="#sec-abstract-closure" id="_ref_4128"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> must return a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4129"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion</a></emu-xref>, implementing its own handling of errors.</li>
</ul>
<emu-note><span class="note">Note 1</span><div class="note-contents">
<emu-xref href="#host-environment" id="_ref_4130"><a href="overview.html#host-environment">Host environments</a></emu-xref> are not required to treat <emu-xref href="#job" id="_ref_4131"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref> uniformly with respect to scheduling. For example, web browsers and Node.js treat Promise-handling <emu-xref href="#job" id="_ref_4132"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref> as a higher priority than other work; future features may add <emu-xref href="#job" id="_ref_4133"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref> that are not treated at such a high priority.
</div></emu-note>
<p>At any particular time, <var>scriptOrModule</var> (a <emu-xref href="#script-record" id="_ref_4134"><a href="ecmascript-language-scripts-and-modules.html#script-record">Script Record</a></emu-xref>, a <emu-xref href="#sec-abstract-module-records" id="_ref_4135"><a href="ecmascript-language-scripts-and-modules.html#sec-abstract-module-records">Module Record</a></emu-xref>, or <emu-val>null</emu-val>) is the <dfn id="job-activescriptormodule" tabindex="-1">active script or module</dfn> if all of the following conditions are true:</p>
<ul>
<li><emu-xref aoid="GetActiveScriptOrModule" id="_ref_4136"><a href="executable-code-and-execution-contexts.html#sec-getactivescriptormodule">GetActiveScriptOrModule</a></emu-xref>() is <var>scriptOrModule</var>.</li>
<li>If <var>scriptOrModule</var> is a <emu-xref href="#script-record" id="_ref_4137"><a href="ecmascript-language-scripts-and-modules.html#script-record">Script Record</a></emu-xref> or <emu-xref href="#sec-abstract-module-records" id="_ref_4138"><a href="ecmascript-language-scripts-and-modules.html#sec-abstract-module-records">Module Record</a></emu-xref>, let <var>ec</var> be the topmost <emu-xref href="#sec-execution-contexts" id="_ref_4139"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> on the <emu-xref href="#execution-context-stack" id="_ref_4140"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref> whose ScriptOrModule component is <var>scriptOrModule</var>. The <emu-xref href="#realm" id="_ref_4141"><a href="executable-code-and-execution-contexts.html#realm">Realm</a></emu-xref> component of <var>ec</var> is <var>scriptOrModule</var>.<var class="field">[[Realm]]</var>.</li>
</ul>
<p>At any particular time, an execution is <dfn id="job-preparedtoevaluatecode" tabindex="-1">prepared to evaluate ECMAScript code</dfn> if all of the following conditions are true:</p>
<ul>
<li>The <emu-xref href="#execution-context-stack" id="_ref_4142"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref> is not empty.</li>
<li>The <emu-xref href="#realm" id="_ref_4143"><a href="executable-code-and-execution-contexts.html#realm">Realm</a></emu-xref> component of the topmost <emu-xref href="#sec-execution-contexts" id="_ref_4144"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> on the <emu-xref href="#execution-context-stack" id="_ref_4145"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref> is a <emu-xref href="#realm-record" id="_ref_4146"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>.</li>
</ul>
<emu-note><span class="note">Note 2</span><div class="note-contents">
<p><emu-xref href="#host-environment" id="_ref_4147"><a href="overview.html#host-environment">Host environments</a></emu-xref> may prepare an execution to evaluate code by pushing <emu-xref href="#sec-execution-contexts" id="_ref_4148"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution contexts</a></emu-xref> onto the <emu-xref href="#execution-context-stack" id="_ref_4149"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref>. The specific steps are <emu-xref href="#implementation-defined" id="_ref_4150"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref>.</p>
<p>The specific choice of <emu-xref href="#realm" id="_ref_4151"><a href="executable-code-and-execution-contexts.html#realm">Realm</a></emu-xref> is up to the <emu-xref href="#host-environment" id="_ref_4152"><a href="overview.html#host-environment">host environment</a></emu-xref>. This initial <emu-xref href="#sec-execution-contexts" id="_ref_4153"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> and <emu-xref href="#realm" id="_ref_4154"><a href="executable-code-and-execution-contexts.html#realm">Realm</a></emu-xref> is only in use before any callback function is invoked. When a callback function related to a <emu-xref href="#job" id="_ref_4155"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref>, like a Promise handler, is invoked, the invocation pushes its own <emu-xref href="#sec-execution-contexts" id="_ref_4156"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution context</a></emu-xref> and <emu-xref href="#realm" id="_ref_4157"><a href="executable-code-and-execution-contexts.html#realm">Realm</a></emu-xref>.</p>
</div></emu-note>
<p>Particular kinds of <emu-xref href="#job" id="_ref_4158"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref> have additional conformance requirements.</p>
<emu-clause id="sec-jobcallback-records">
<h1><span class="secnum">9.5.1</span> JobCallback Records</h1>
<p>A <dfn variants="JobCallback Records" tabindex="-1">JobCallback Record</dfn> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4159"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> value used to store a <emu-xref href="#function-object" id="_ref_4160"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> and a <emu-xref href="#host-defined" id="_ref_4161"><a href="overview.html#host-defined">host-defined</a></emu-xref> value. <emu-xref href="#function-object" id="_ref_4162"><a href="ecmascript-data-types-and-values.html#function-object">Function objects</a></emu-xref> that are invoked via a <emu-xref href="#job" id="_ref_4163"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> enqueued by the <emu-xref href="#host" id="_ref_4164"><a href="overview.html#host">host</a></emu-xref> may have additional <emu-xref href="#host-defined" id="_ref_4165"><a href="overview.html#host-defined">host-defined</a></emu-xref> context. To propagate the state, <emu-xref href="#job" id="_ref_4166"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> <emu-xref href="#sec-abstract-closure" id="_ref_4167"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closures</a></emu-xref> should not capture and call <emu-xref href="#function-object" id="_ref_4168"><a href="ecmascript-data-types-and-values.html#function-object">function objects</a></emu-xref> directly. Instead, use <emu-xref aoid="HostMakeJobCallback" id="_ref_4169"><a href="executable-code-and-execution-contexts.html#sec-hostmakejobcallback">HostMakeJobCallback</a></emu-xref> and <emu-xref aoid="HostCallJobCallback" id="_ref_4170"><a href="executable-code-and-execution-contexts.html#sec-hostcalljobcallback">HostCallJobCallback</a></emu-xref>.</p>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>The WHATWG HTML specification (<a href="https://html.spec.whatwg.org/">https://html.spec.whatwg.org/</a>), for example, uses the <emu-xref href="#host-defined" id="_ref_4171"><a href="overview.html#host-defined">host-defined</a></emu-xref> value to propagate the incumbent settings object for Promise callbacks.</p>
</div></emu-note>
<p>JobCallback Records have the fields listed in <emu-xref href="#table-jobcallback-records" id="_ref_262"><a href="executable-code-and-execution-contexts.html#table-jobcallback-records">Table 23</a></emu-xref>.</p>
<emu-table id="table-jobcallback-records" caption="JobCallback Record Fields"><figure><figcaption>Table 23: <emu-xref href="#sec-jobcallback-records" id="_ref_4172"><a href="executable-code-and-execution-contexts.html#sec-jobcallback-records">JobCallback Record</a></emu-xref> Fields</figcaption>
<table>
<thead>
<tr>
<th>
Field Name
</th>
<th>
Value
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tbody><tr>
<td>
<var class="field">[[Callback]]</var>
</td>
<td>
a <emu-xref href="#function-object" id="_ref_4173"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>
</td>
<td>
The function to invoke when the <emu-xref href="#job" id="_ref_4174"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> is invoked.
</td>
</tr>
<tr>
<td>
<var class="field">[[HostDefined]]</var>
</td>
<td>
anything (default value is <emu-const>empty</emu-const>)
</td>
<td>
Field reserved for use by <emu-xref href="#host" id="_ref_4175"><a href="overview.html#host">hosts</a></emu-xref>.
</td>
</tr>
</tbody></table>
</figure></emu-table>
</emu-clause>
<emu-clause id="sec-hostmakejobcallback" type="host-defined abstract operation" aoid="HostMakeJobCallback">
<h1><span class="secnum">9.5.2</span> HostMakeJobCallback ( <var>callback</var> )</h1>
<p>The <emu-xref href="#host-defined" id="_ref_4176"><a href="overview.html#host-defined">host-defined</a></emu-xref> abstract operation HostMakeJobCallback takes argument <var>callback</var> (a <emu-xref href="#function-object" id="_ref_4177"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>) and returns a <emu-xref href="#sec-jobcallback-records" id="_ref_4178"><a href="executable-code-and-execution-contexts.html#sec-jobcallback-records">JobCallback Record</a></emu-xref>.</p>
<p>An implementation of HostMakeJobCallback must conform to the following requirements:</p>
<ul>
<li>It must return a <emu-xref href="#sec-jobcallback-records" id="_ref_4179"><a href="executable-code-and-execution-contexts.html#sec-jobcallback-records">JobCallback Record</a></emu-xref> whose <var class="field">[[Callback]]</var> field is <var>callback</var>.</li>
</ul>
<p>The default implementation of HostMakeJobCallback performs the following steps when called:</p>
<emu-alg><ol><li>Return the <emu-xref href="#sec-jobcallback-records" id="_ref_4180"><a href="executable-code-and-execution-contexts.html#sec-jobcallback-records">JobCallback Record</a></emu-xref> { <var class="field">[[Callback]]</var>: <var>callback</var>, <var class="field">[[HostDefined]]</var>: <emu-const>empty</emu-const>&nbsp;}.</li></ol></emu-alg>
<p>ECMAScript <emu-xref href="#host" id="_ref_4181"><a href="overview.html#host">hosts</a></emu-xref> that are not web browsers must use the default implementation of HostMakeJobCallback.</p>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>This is called at the time that the callback is passed to the function that is responsible for its being eventually scheduled and run. For example, <code>promise.then(thenAction)</code> calls MakeJobCallback on <code>thenAction</code> at the time of invoking <code>Promise.prototype.then</code>, not at the time of scheduling the reaction <emu-xref href="#job" id="_ref_4182"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref>.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-hostcalljobcallback" type="host-defined abstract operation" aoid="HostCallJobCallback">
<h1><span class="secnum">9.5.3</span> HostCallJobCallback ( <var>jobCallback</var>, <var>V</var>, <var>argumentsList</var> )</h1>
<p>The <emu-xref href="#host-defined" id="_ref_4183"><a href="overview.html#host-defined">host-defined</a></emu-xref> abstract operation HostCallJobCallback takes arguments <var>jobCallback</var> (a <emu-xref href="#sec-jobcallback-records" id="_ref_4184"><a href="executable-code-and-execution-contexts.html#sec-jobcallback-records">JobCallback Record</a></emu-xref>), <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_4185"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>argumentsList</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4186"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-ecmascript-language-types" id="_ref_4187"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4188"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-ecmascript-language-types" id="_ref_4189"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4190"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>.</p>
<p>An implementation of HostCallJobCallback must conform to the following requirements:</p>
<ul>
<li>It must perform and return the result of <emu-xref aoid="Call" id="_ref_4191"><a href="abstract-operations.html#sec-call">Call</a></emu-xref>(<var>jobCallback</var>.<var class="field">[[Callback]]</var>, <var>V</var>, <var>argumentsList</var>).</li>
</ul>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>This requirement means that <emu-xref href="#host" id="_ref_4192"><a href="overview.html#host">hosts</a></emu-xref> cannot change the <var class="field">[[Call]]</var> behaviour of <emu-xref href="#function-object" id="_ref_4193"><a href="ecmascript-data-types-and-values.html#function-object">function objects</a></emu-xref> defined in this specification.</p>
</div></emu-note>
<p>The default implementation of HostCallJobCallback performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_4194"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <emu-xref aoid="IsCallable" id="_ref_4195"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>jobCallback</var>.<var class="field">[[Callback]]</var>) is <emu-val>true</emu-val>.</li><li>Return ?&nbsp;<emu-xref aoid="Call" id="_ref_4196"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>jobCallback</var>.<var class="field">[[Callback]]</var>, <var>V</var>, <var>argumentsList</var>).</li></ol></emu-alg>
<p>ECMAScript <emu-xref href="#host" id="_ref_4197"><a href="overview.html#host">hosts</a></emu-xref> that are not web browsers must use the default implementation of HostCallJobCallback.</p>
</emu-clause>
<emu-clause id="sec-hostenqueuegenericjob" type="host-defined abstract operation" aoid="HostEnqueueGenericJob">
<h1><span class="secnum">9.5.4</span> HostEnqueueGenericJob ( <var>job</var>, <var>realm</var> )</h1>
<p>The <emu-xref href="#host-defined" id="_ref_4198"><a href="overview.html#host-defined">host-defined</a></emu-xref> abstract operation HostEnqueueGenericJob takes arguments <var>job</var> (a <emu-xref href="#job" id="_ref_4199"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> <emu-xref href="#sec-abstract-closure" id="_ref_4200"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref>) and <var>realm</var> (a <emu-xref href="#realm-record" id="_ref_4201"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>) and returns <emu-const>unused</emu-const>. It schedules <var>job</var> in the <emu-xref href="#realm" id="_ref_4202"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> <var>realm</var> in the <emu-xref href="#agent" id="_ref_4203"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> signified by <var>realm</var>.<var class="field">[[AgentSignifier]]</var> to be performed at some future time. The <emu-xref href="#sec-abstract-closure" id="_ref_4204"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closures</a></emu-xref> used with this algorithm are intended to be scheduled without additional constraints, such as priority and ordering.</p>
<p>An implementation of HostEnqueueGenericJob must conform to the requirements in <emu-xref href="#sec-jobs" id="_ref_263"><a href="executable-code-and-execution-contexts.html#sec-jobs">9.5</a></emu-xref>.</p>
</emu-clause>
<emu-clause id="sec-hostenqueuepromisejob" type="host-defined abstract operation" aoid="HostEnqueuePromiseJob">
<h1><span class="secnum">9.5.5</span> HostEnqueuePromiseJob ( <var>job</var>, <var>realm</var> )</h1>
<p>The <emu-xref href="#host-defined" id="_ref_4205"><a href="overview.html#host-defined">host-defined</a></emu-xref> abstract operation HostEnqueuePromiseJob takes arguments <var>job</var> (a <emu-xref href="#job" id="_ref_4206"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> <emu-xref href="#sec-abstract-closure" id="_ref_4207"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref>) and <var>realm</var> (a <emu-xref href="#realm-record" id="_ref_4208"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref> or <emu-val>null</emu-val>) and returns <emu-const>unused</emu-const>. It schedules <var>job</var> to be performed at some future time. The <emu-xref href="#sec-abstract-closure" id="_ref_4209"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closures</a></emu-xref> used with this algorithm are intended to be related to the handling of Promises, or otherwise, to be scheduled with equal priority to Promise handling operations.</p>
<p>An implementation of HostEnqueuePromiseJob must conform to the requirements in <emu-xref href="#sec-jobs" id="_ref_264"><a href="executable-code-and-execution-contexts.html#sec-jobs">9.5</a></emu-xref> as well as the following:</p>
<ul>
<li>If <var>realm</var> is not <emu-val>null</emu-val>, each time <var>job</var> is invoked the implementation must perform <emu-xref href="#implementation-defined" id="_ref_4210"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref> steps such that execution is <emu-xref href="#job-preparedtoevaluatecode" id="_ref_4211"><a href="executable-code-and-execution-contexts.html#job-preparedtoevaluatecode">prepared to evaluate ECMAScript code</a></emu-xref> at the time of <var>job</var>'s invocation.</li>
<li>Let <var>scriptOrModule</var> be <emu-xref aoid="GetActiveScriptOrModule" id="_ref_4212"><a href="executable-code-and-execution-contexts.html#sec-getactivescriptormodule">GetActiveScriptOrModule</a></emu-xref>() at the time HostEnqueuePromiseJob is invoked. If <var>realm</var> is not <emu-val>null</emu-val>, each time <var>job</var> is invoked the implementation must perform <emu-xref href="#implementation-defined" id="_ref_4213"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref> steps such that <var>scriptOrModule</var> is the <emu-xref href="#job-activescriptormodule" id="_ref_4214"><a href="executable-code-and-execution-contexts.html#job-activescriptormodule">active script or module</a></emu-xref> at the time of <var>job</var>'s invocation.</li>
<li><emu-xref href="#job" id="_ref_4215"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref> must run in the same order as the HostEnqueuePromiseJob invocations that scheduled them.</li>
</ul>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>The <var>realm</var> for <emu-xref href="#job" id="_ref_4216"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref> returned by <emu-xref aoid="NewPromiseResolveThenableJob" id="_ref_4217"><a href="control-abstraction-objects.html#sec-newpromiseresolvethenablejob">NewPromiseResolveThenableJob</a></emu-xref> is usually the result of calling <emu-xref aoid="GetFunctionRealm" id="_ref_4218"><a href="abstract-operations.html#sec-getfunctionrealm">GetFunctionRealm</a></emu-xref> on the <var>then</var> <emu-xref href="#function-object" id="_ref_4219"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>. The <var>realm</var> for <emu-xref href="#job" id="_ref_4220"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref> returned by <emu-xref aoid="NewPromiseReactionJob" id="_ref_4221"><a href="control-abstraction-objects.html#sec-newpromisereactionjob">NewPromiseReactionJob</a></emu-xref> is usually the result of calling <emu-xref aoid="GetFunctionRealm" id="_ref_4222"><a href="abstract-operations.html#sec-getfunctionrealm">GetFunctionRealm</a></emu-xref> on the handler if the handler is not <emu-val>undefined</emu-val>. If the handler is <emu-val>undefined</emu-val>, <var>realm</var> is <emu-val>null</emu-val>. For both kinds of <emu-xref href="#job" id="_ref_4223"><a href="executable-code-and-execution-contexts.html#job">Jobs</a></emu-xref>, when <emu-xref aoid="GetFunctionRealm" id="_ref_4224"><a href="abstract-operations.html#sec-getfunctionrealm">GetFunctionRealm</a></emu-xref> completes abnormally (i.e. called on a revoked Proxy), <var>realm</var> is <emu-xref href="#current-realm" id="_ref_4225"><a href="executable-code-and-execution-contexts.html#current-realm">the current Realm Record</a></emu-xref> at the time of the <emu-xref aoid="GetFunctionRealm" id="_ref_4226"><a href="abstract-operations.html#sec-getfunctionrealm">GetFunctionRealm</a></emu-xref> call. When the <var>realm</var> is <emu-val>null</emu-val>, no user ECMAScript code will be evaluated and no new ECMAScript objects (e.g. Error objects) will be created. The WHATWG HTML specification (<a href="https://html.spec.whatwg.org/">https://html.spec.whatwg.org/</a>), for example, uses <var>realm</var> to check for the ability to run script and for the <a href="https://html.spec.whatwg.org/#entry">entry</a> concept.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-hostenqueuetimeoutjob" type="host-defined abstract operation" aoid="HostEnqueueTimeoutJob">
<h1><span class="secnum">9.5.6</span> HostEnqueueTimeoutJob ( <var>timeoutJob</var>, <var>realm</var>, <var>milliseconds</var> )</h1>
<p>The <emu-xref href="#host-defined" id="_ref_4227"><a href="overview.html#host-defined">host-defined</a></emu-xref> abstract operation HostEnqueueTimeoutJob takes arguments <var>timeoutJob</var> (a <emu-xref href="#job" id="_ref_4228"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> <emu-xref href="#sec-abstract-closure" id="_ref_4229"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref>), <var>realm</var> (a <emu-xref href="#realm-record" id="_ref_4230"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref>), and <var>milliseconds</var> (a non-negative <emu-xref href="#finite" id="_ref_4231"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref> Number) and returns <emu-const>unused</emu-const>. It schedules <var>timeoutJob</var> in the <emu-xref href="#realm" id="_ref_4232"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> <var>realm</var> in the <emu-xref href="#agent" id="_ref_4233"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> signified by <var>realm</var>.<var class="field">[[AgentSignifier]]</var> to be performed after at least <var>milliseconds</var> milliseconds.</p>
<p>An implementation of HostEnqueueTimeoutJob must conform to the requirements in <emu-xref href="#sec-jobs" id="_ref_265"><a href="executable-code-and-execution-contexts.html#sec-jobs">9.5</a></emu-xref>.</p>
</emu-clause>
</emu-clause>
<emu-clause id="sec-agents">
<h1><span class="secnum">9.6</span> Agents</h1>
<p>An <dfn id="agent" variants="agents" tabindex="-1">agent</dfn> comprises a set of ECMAScript <emu-xref href="#sec-execution-contexts" id="_ref_4234"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution contexts</a></emu-xref>, an <emu-xref href="#execution-context-stack" id="_ref_4235"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref>, a <emu-xref href="#running-execution-context" id="_ref_4236"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>, an <dfn id="agent-record" variants="Agent Records" tabindex="-1">Agent Record</dfn>, and an <dfn id="executing-thread" variants="executing threads" tabindex="-1">executing thread</dfn>. Except for the <emu-xref href="#executing-thread" id="_ref_4237"><a href="executable-code-and-execution-contexts.html#executing-thread">executing thread</a></emu-xref>, the constituents of an <emu-xref href="#agent" id="_ref_4238"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> belong exclusively to that <emu-xref href="#agent" id="_ref_4239"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>.</p>
<p>An <emu-xref href="#agent" id="_ref_4240"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s <emu-xref href="#executing-thread" id="_ref_4241"><a href="executable-code-and-execution-contexts.html#executing-thread">executing thread</a></emu-xref> executes algorithmic steps on the <emu-xref href="#agent" id="_ref_4242"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s <emu-xref href="#sec-execution-contexts" id="_ref_4243"><a href="executable-code-and-execution-contexts.html#sec-execution-contexts">execution contexts</a></emu-xref> independently of other <emu-xref href="#agent" id="_ref_4244"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref>, except that an <emu-xref href="#executing-thread" id="_ref_4245"><a href="executable-code-and-execution-contexts.html#executing-thread">executing thread</a></emu-xref> may be used as the <emu-xref href="#executing-thread" id="_ref_4246"><a href="executable-code-and-execution-contexts.html#executing-thread">executing thread</a></emu-xref> by multiple <emu-xref href="#agent" id="_ref_4247"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref>, provided none of the <emu-xref href="#agent" id="_ref_4248"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> sharing the thread have an <emu-xref href="#agent-record" id="_ref_4249"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref> whose <var class="field">[[CanBlock]]</var> field is <emu-val>true</emu-val>.</p>
<emu-note><span class="note">Note 1</span><div class="note-contents">
<p>Some web browsers share a single <emu-xref href="#executing-thread" id="_ref_4250"><a href="executable-code-and-execution-contexts.html#executing-thread">executing thread</a></emu-xref> across multiple unrelated tabs of a browser window, for example.</p>
</div></emu-note>
<p>While an <emu-xref href="#agent" id="_ref_4251"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s <emu-xref href="#executing-thread" id="_ref_4252"><a href="executable-code-and-execution-contexts.html#executing-thread">executing thread</a></emu-xref> is executing algorithmic steps, the <emu-xref href="#agent" id="_ref_4253"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> is the <dfn id="surrounding-agent" variants="surrounding agents" tabindex="-1">surrounding agent</dfn> for those steps. The steps use the <emu-xref href="#surrounding-agent" id="_ref_4254"><a href="executable-code-and-execution-contexts.html#surrounding-agent">surrounding agent</a></emu-xref> to access the specification-level execution objects held within the <emu-xref href="#agent" id="_ref_4255"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>: the <emu-xref href="#running-execution-context" id="_ref_4256"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref>, the <emu-xref href="#execution-context-stack" id="_ref_4257"><a href="executable-code-and-execution-contexts.html#execution-context-stack">execution context stack</a></emu-xref>, and the <emu-xref href="#agent-record" id="_ref_4258"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref>'s fields.</p>
<p>An <dfn variants="agent signifiers" tabindex="-1">agent signifier</dfn> is a globally-unique opaque value used to identify an <emu-xref href="#agent" id="_ref_4259"><a href="executable-code-and-execution-contexts.html#agent">Agent</a></emu-xref>.</p>
<emu-table id="table-agent-record" caption="Agent Record Fields"><figure><figcaption>Table 24: <emu-xref href="#agent-record" id="_ref_4260"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref> Fields</figcaption>
<table>
<thead>
<tr>
<th>Field Name</th>
<th>Value</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td><var class="field">[[LittleEndian]]</var></td>
<td>a Boolean</td>
<td>The default value computed for the <em>isLittleEndian</em> parameter when it is needed by the algorithms <emu-xref aoid="GetValueFromBuffer" id="_ref_4261"><a href="structured-data.html#sec-getvaluefrombuffer">GetValueFromBuffer</a></emu-xref> and <emu-xref aoid="SetValueInBuffer" id="_ref_4262"><a href="structured-data.html#sec-setvalueinbuffer">SetValueInBuffer</a></emu-xref>. The choice is <emu-xref href="#implementation-defined" id="_ref_4263"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref> and should be the alternative that is most efficient for the implementation.</td>
</tr>
<tr>
<td><var class="field">[[CanBlock]]</var></td>
<td>a Boolean</td>
<td>Determines whether the <emu-xref href="#agent" id="_ref_4264"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> can block or not.</td>
</tr>
<tr>
<td><var class="field">[[Signifier]]</var></td>
<td>an <emu-xref href="#sec-agents" id="_ref_4265"><a href="executable-code-and-execution-contexts.html#sec-agents">agent signifier</a></emu-xref></td>
<td>Uniquely identifies the <emu-xref href="#agent" id="_ref_4266"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> within its <emu-xref href="#sec-agent-clusters" id="_ref_4267"><a href="executable-code-and-execution-contexts.html#sec-agent-clusters">agent cluster</a></emu-xref>.</td>
</tr>
<tr>
<td><var class="field">[[IsLockFree1]]</var></td>
<td>a Boolean</td>
<td><emu-val>true</emu-val> if atomic operations on one-<emu-not-ref>byte values</emu-not-ref> are lock-free, <emu-val>false</emu-val> otherwise.</td>
</tr>
<tr>
<td><var class="field">[[IsLockFree2]]</var></td>
<td>a Boolean</td>
<td><emu-val>true</emu-val> if atomic operations on two-<emu-not-ref>byte values</emu-not-ref> are lock-free, <emu-val>false</emu-val> otherwise.</td>
</tr>
<tr>
<td><var class="field">[[IsLockFree8]]</var></td>
<td>a Boolean</td>
<td><emu-val>true</emu-val> if atomic operations on eight-<emu-not-ref>byte values</emu-not-ref> are lock-free, <emu-val>false</emu-val> otherwise.</td>
</tr>
<tr>
<td><var class="field">[[CandidateExecution]]</var></td>
<td>a <emu-xref href="#sec-candidate-executions" id="_ref_4268"><a href="memory-model.html#sec-candidate-executions">candidate execution</a></emu-xref> <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4269"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref></td>
<td>See the <emu-xref href="#sec-memory-model" id="_ref_4270"><a href="memory-model.html#sec-memory-model">memory model</a></emu-xref>.</td>
</tr>
<tr>
<td><var class="field">[[KeptAlive]]</var></td>
<td>a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4271"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of either Objects or Symbols</td>
<td>Initially a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4272"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>, representing the list of objects and/or symbols to be kept alive until the end of the current <emu-xref href="#job" id="_ref_4273"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref></td>
</tr>
<tr>
<td><var class="field">[[ModuleAsyncEvaluationCount]]</var></td>
<td>an <emu-xref href="#integer" id="_ref_4274"><a href="notational-conventions.html#integer">integer</a></emu-xref></td>
<td>Initially 0, used to assign unique incrementing values to the <var class="field">[[AsyncEvaluationOrder]]</var> field of modules that are asynchronous or have asynchronous dependencies.</td>
</tr>
</tbody></table>
</figure></emu-table>
<p>The values of <var class="field">[[LittleEndian]]</var>, <var class="field">[[Signifier]]</var>, <var class="field">[[IsLockFree1]]</var>, <var class="field">[[IsLockFree2]]</var>, and <var class="field">[[IsLockFree8]]</var> cannot change.</p>
<emu-note><span class="note">Note 2</span><div class="note-contents">
<p>The values of <var class="field">[[IsLockFree1]]</var>, <var class="field">[[IsLockFree2]]</var>, and <var class="field">[[IsLockFree8]]</var> are not necessarily determined by the hardware, but may also reflect implementation choices that can vary over time and between ECMAScript implementations.</p>
<p>There is no <var class="field">[[IsLockFree4]]</var> field: 4-byte atomic operations are always lock-free.</p>
<p>In practice, if an atomic operation is implemented with any type of lock the operation is not lock-free. Lock-free does not imply wait-free: there is no upper bound on how many machine steps may be required to complete a lock-free atomic operation.</p>
<p>That an atomic access of size <em>n</em> is lock-free does not imply anything about the (perceived) atomicity of non-atomic accesses of size <em>n</em>, specifically, non-atomic accesses may still be performed as a sequence of several separate memory accesses. See <emu-xref href="#sec-memory-model-fundamentals" id="_ref_4275"><a href="memory-model.html#sec-memory-model-fundamentals">ReadSharedMemory</a></emu-xref> and <emu-xref href="#sec-memory-model-fundamentals" id="_ref_4276"><a href="memory-model.html#sec-memory-model-fundamentals">WriteSharedMemory</a></emu-xref> for details.</p>
</div></emu-note>
<emu-note><span class="note">Note 3</span><div class="note-contents">
<p>An <emu-xref href="#agent" id="_ref_4277"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> is a specification mechanism and need not correspond to any particular artefact of an ECMAScript implementation.</p>
</div></emu-note>
<emu-clause id="sec-agentsignifier" type="abstract operation" aoid="AgentSignifier">
<h1><span class="secnum">9.6.1</span> AgentSignifier ( )</h1>
<p>The abstract operation AgentSignifier takes no arguments and returns an <emu-xref href="#sec-agents" id="_ref_4278"><a href="executable-code-and-execution-contexts.html#sec-agents">agent signifier</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>AR</var> be the <emu-xref href="#agent-record" id="_ref_4279"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref> of the <emu-xref href="#surrounding-agent" id="_ref_4280"><a href="executable-code-and-execution-contexts.html#surrounding-agent">surrounding agent</a></emu-xref>.</li><li>Return <var>AR</var>.<var class="field">[[Signifier]]</var>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-agentcansuspend" type="abstract operation" aoid="AgentCanSuspend">
<h1><span class="secnum">9.6.2</span> AgentCanSuspend ( )</h1>
<p>The abstract operation AgentCanSuspend takes no arguments and returns a Boolean. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>AR</var> be the <emu-xref href="#agent-record" id="_ref_4281"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref> of the <emu-xref href="#surrounding-agent" id="_ref_4282"><a href="executable-code-and-execution-contexts.html#surrounding-agent">surrounding agent</a></emu-xref>.</li><li>Return <var>AR</var>.<var class="field">[[CanBlock]]</var>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>In some environments it may not be reasonable for a given <emu-xref href="#agent" id="_ref_4283"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> to suspend. For example, in a web browser environment, it may be reasonable to disallow suspending a document's main event handling thread, while still allowing workers' event handling threads to suspend.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-IncrementModuleAsyncEvaluationCount" type="abstract operation" aoid="IncrementModuleAsyncEvaluationCount">
<h1><span class="secnum">9.6.3</span> IncrementModuleAsyncEvaluationCount ( )</h1>
<p>The abstract operation IncrementModuleAsyncEvaluationCount takes no arguments and returns an <emu-xref href="#integer" id="_ref_4284"><a href="notational-conventions.html#integer">integer</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>AR</var> be the <emu-xref href="#agent-record" id="_ref_4285"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref> of the <emu-xref href="#surrounding-agent" id="_ref_4286"><a href="executable-code-and-execution-contexts.html#surrounding-agent">surrounding agent</a></emu-xref>.</li><li>Let <var>count</var> be <var>AR</var>.<var class="field">[[ModuleAsyncEvaluationCount]]</var>.</li><li>Set <var>AR</var>.<var class="field">[[ModuleAsyncEvaluationCount]]</var> to <var>count</var> + 1.</li><li>Return <var>count</var>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>This value is only used to keep track of the relative evaluation order between pending modules. An implementation may unobservably reset <var class="field">[[ModuleAsyncEvaluationCount]]</var> to 0 whenever there are no pending modules.</p>
</div></emu-note>
</emu-clause>
</emu-clause>
<emu-clause id="sec-agent-clusters">
<h1><span class="secnum">9.7</span> Agent Clusters</h1>
<p>An <dfn variants="agent clusters" tabindex="-1">agent cluster</dfn> is a maximal set of <emu-xref href="#agent" id="_ref_4287"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> that can communicate by operating on shared memory.</p>
<emu-note><span class="note">Note 1</span><div class="note-contents">
<p>Programs within different <emu-xref href="#agent" id="_ref_4288"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> may share memory by unspecified means. At a minimum, the backing memory for SharedArrayBuffers can be shared among the <emu-xref href="#agent" id="_ref_4289"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> in the cluster.</p>
<p>There may be <emu-xref href="#agent" id="_ref_4290"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> that can communicate by message passing that cannot share memory; they are never in the same agent cluster.</p>
</div></emu-note>
<p>Every <emu-xref href="#agent" id="_ref_4291"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> belongs to exactly one agent cluster.</p>
<emu-note><span class="note">Note 2</span><div class="note-contents">
<p>The <emu-xref href="#agent" id="_ref_4292"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> in a cluster need not all be alive at some particular point in time. If <emu-xref href="#agent" id="_ref_4293"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> <b>A</b> creates another <emu-xref href="#agent" id="_ref_4294"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> <b>B</b>, after which <b>A</b> terminates and <b>B</b> creates <emu-xref href="#agent" id="_ref_4295"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> <b>C</b>, the three <emu-xref href="#agent" id="_ref_4296"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> are in the same cluster if <b>A</b> could share some memory with <b>B</b> and <b>B</b> could share some memory with <b>C</b>.</p>
</div></emu-note>
<p>All <emu-xref href="#agent" id="_ref_4297"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> within a cluster must have the same value for the <var class="field">[[LittleEndian]]</var> field in their respective <emu-xref href="#agent-record" id="_ref_4298"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Records</a></emu-xref>.</p>
<emu-note><span class="note">Note 3</span><div class="note-contents">
<p>If different <emu-xref href="#agent" id="_ref_4299"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> within an agent cluster have different values of <var class="field">[[LittleEndian]]</var> it becomes hard to use shared memory for multi-byte data.</p>
</div></emu-note>
<p>All <emu-xref href="#agent" id="_ref_4300"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> within a cluster must have the same values for the <var class="field">[[IsLockFree1]]</var> field in their respective <emu-xref href="#agent-record" id="_ref_4301"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Records</a></emu-xref>; similarly for the <var class="field">[[IsLockFree2]]</var> and <var class="field">[[IsLockFree8]]</var> fields.</p>
<p>All <emu-xref href="#agent" id="_ref_4302"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> within a cluster must have different values for the <var class="field">[[Signifier]]</var> field in their respective <emu-xref href="#agent-record" id="_ref_4303"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Records</a></emu-xref>.</p>
<p>An embedding may deactivate (stop forward progress) or activate (resume forward progress) an <emu-xref href="#agent" id="_ref_4304"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> without the <emu-xref href="#agent" id="_ref_4305"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s knowledge or cooperation. If the embedding does so, it must not leave some <emu-xref href="#agent" id="_ref_4306"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> in the cluster active while other <emu-xref href="#agent" id="_ref_4307"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> in the cluster are deactivated indefinitely.</p>
<emu-note><span class="note">Note 4</span><div class="note-contents">
<p>The purpose of the preceding restriction is to avoid a situation where an <emu-xref href="#agent" id="_ref_4308"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> deadlocks or starves because another <emu-xref href="#agent" id="_ref_4309"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> has been deactivated. For example, if an HTML shared worker that has a lifetime independent of documents in any windows were allowed to share memory with the dedicated worker of such an independent document, and the document and its dedicated worker were to be deactivated while the dedicated worker holds a lock (say, the document is pushed into its window's history), and the shared worker then tries to acquire the lock, then the shared worker will be blocked until the dedicated worker is activated again, if ever. Meanwhile other workers trying to access the shared worker from other windows will starve.</p>
<p>The implication of the restriction is that it will not be possible to share memory between <emu-xref href="#agent" id="_ref_4310"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> that don't belong to the same suspend/wake collective within the embedding.</p>
</div></emu-note>
<p>An embedding may terminate an <emu-xref href="#agent" id="_ref_4311"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> without any of the <emu-xref href="#agent" id="_ref_4312"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s cluster's other <emu-xref href="#agent" id="_ref_4313"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref>' prior knowledge or cooperation. If an <emu-xref href="#agent" id="_ref_4314"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> is terminated not by programmatic action of its own or of another <emu-xref href="#agent" id="_ref_4315"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> in the cluster but by forces external to the cluster, then the embedding must choose one of two strategies: Either terminate all the <emu-xref href="#agent" id="_ref_4316"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> in the cluster, or provide reliable APIs that allow the <emu-xref href="#agent" id="_ref_4317"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> in the cluster to coordinate so that at least one remaining member of the cluster will be able to detect the termination, with the termination data containing enough information to identify the <emu-xref href="#agent" id="_ref_4318"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> that was terminated.</p>
<emu-note><span class="note">Note 5</span><div class="note-contents">
<p>Examples of that type of termination are: operating systems or users terminating <emu-xref href="#agent" id="_ref_4319"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> that are running in separate processes; the embedding itself terminating an <emu-xref href="#agent" id="_ref_4320"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> that is running in-process with the other <emu-xref href="#agent" id="_ref_4321"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> when per-<emu-xref href="#agent" id="_ref_4322"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> resource accounting indicates that the <emu-xref href="#agent" id="_ref_4323"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> is runaway.</p>
</div></emu-note>
<p>Each of the following specification values, and values transitively reachable from them, belong to exactly one agent cluster.</p>
<ul>
<li><emu-xref href="#sec-candidate-executions" id="_ref_4324"><a href="memory-model.html#sec-candidate-executions">candidate execution</a></emu-xref> <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4325"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref></li>
<li><emu-xref href="#sec-data-blocks" id="_ref_4326"><a href="ecmascript-data-types-and-values.html#sec-data-blocks">Shared Data Block</a></emu-xref></li>
<li><emu-xref href="#sec-waiterlist-records" id="_ref_4327"><a href="structured-data.html#sec-waiterlist-records">WaiterList Record</a></emu-xref></li>
</ul>
<p>Prior to any evaluation of any ECMAScript code by any <emu-xref href="#agent" id="_ref_4328"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> in a cluster, the <var class="field">[[CandidateExecution]]</var> field of the <emu-xref href="#agent-record" id="_ref_4329"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref> for all <emu-xref href="#agent" id="_ref_4330"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> in the cluster is set to the initial <emu-xref href="#sec-candidate-executions" id="_ref_4331"><a href="memory-model.html#sec-candidate-executions">candidate execution</a></emu-xref>. The initial <emu-xref href="#sec-candidate-executions" id="_ref_4332"><a href="memory-model.html#sec-candidate-executions">candidate execution</a></emu-xref> is an <emu-xref href="#sec-candidate-executions" id="_ref_4333"><a href="memory-model.html#sec-candidate-executions">empty candidate execution</a></emu-xref> whose <var class="field">[[EventsRecords]]</var> field is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4334"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> containing, for each <emu-xref href="#agent" id="_ref_4335"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>, an <emu-xref href="#sec-agent-event-records" id="_ref_4336"><a href="memory-model.html#sec-agent-event-records">Agent Events Record</a></emu-xref> whose <var class="field">[[AgentSignifier]]</var> field is that <emu-xref href="#agent" id="_ref_4337"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s <emu-xref href="#sec-agents" id="_ref_4338"><a href="executable-code-and-execution-contexts.html#sec-agents">agent signifier</a></emu-xref>, and whose <var class="field">[[EventList]]</var> and <var class="field">[[AgentSynchronizesWith]]</var> fields are empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4339"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Lists</a></emu-xref>.</p>
<emu-note><span class="note">Note 6</span><div class="note-contents">
<p>All <emu-xref href="#agent" id="_ref_4340"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> in an agent cluster share the same <emu-xref href="#sec-candidate-executions" id="_ref_4341"><a href="memory-model.html#sec-candidate-executions">candidate execution</a></emu-xref> in its <emu-xref href="#agent-record" id="_ref_4342"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref>'s <var class="field">[[CandidateExecution]]</var> field. The <emu-xref href="#sec-candidate-executions" id="_ref_4343"><a href="memory-model.html#sec-candidate-executions">candidate execution</a></emu-xref> is a specification mechanism used by the <emu-xref href="#sec-memory-model" id="_ref_4344"><a href="memory-model.html#sec-memory-model">memory model</a></emu-xref>.</p>
</div></emu-note>
<emu-note><span class="note">Note 7</span><div class="note-contents">
<p>An agent cluster is a specification mechanism and need not correspond to any particular artefact of an ECMAScript implementation.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-forward-progress">
<h1><span class="secnum">9.8</span> Forward Progress</h1>
<p>For an <emu-xref href="#agent" id="_ref_4345"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> to <em>make forward progress</em> is for it to perform an evaluation step according to this specification.</p>
<p>An <emu-xref href="#agent" id="_ref_4346"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> becomes <em>blocked</em> when its <emu-xref href="#running-execution-context" id="_ref_4347"><a href="executable-code-and-execution-contexts.html#running-execution-context">running execution context</a></emu-xref> waits synchronously and indefinitely for an external event. Only <emu-xref href="#agent" id="_ref_4348"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> whose <emu-xref href="#agent-record" id="_ref_4349"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref>'s <var class="field">[[CanBlock]]</var> field is <emu-val>true</emu-val> can become blocked in this sense. An <em>unblocked</em> <emu-xref href="#agent" id="_ref_4350"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> is one that is not blocked.</p>
<p>Implementations must ensure that:</p>
<ul>
<li>every unblocked <emu-xref href="#agent" id="_ref_4351"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> with a dedicated <emu-xref href="#executing-thread" id="_ref_4352"><a href="executable-code-and-execution-contexts.html#executing-thread">executing thread</a></emu-xref> eventually makes forward progress</li>
<li>in a set of <emu-xref href="#agent" id="_ref_4353"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref> that share an <emu-xref href="#executing-thread" id="_ref_4354"><a href="executable-code-and-execution-contexts.html#executing-thread">executing thread</a></emu-xref>, one <emu-xref href="#agent" id="_ref_4355"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> eventually makes forward progress</li>
<li>an <emu-xref href="#agent" id="_ref_4356"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> does not cause another <emu-xref href="#agent" id="_ref_4357"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref> to become blocked except via explicit APIs that provide blocking.</li>
</ul>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>This, along with the liveness guarantee in the <emu-xref href="#sec-memory-model" id="_ref_4358"><a href="memory-model.html#sec-memory-model">memory model</a></emu-xref>, ensures that all <emu-const>seq-cst</emu-const> writes eventually become observable to all <emu-xref href="#agent" id="_ref_4359"><a href="executable-code-and-execution-contexts.html#agent">agents</a></emu-xref>.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-weakref-processing-model">
<h1><span class="secnum">9.9</span> Processing Model of WeakRef and FinalizationRegistry Targets</h1>
<emu-clause id="sec-weakref-invariants">
<h1><span class="secnum">9.9.1</span> Objectives</h1>
<p>This specification does not make any guarantees that any object or symbol will be garbage collected. Objects or symbols which are not <emu-xref href="#sec-liveness" id="_ref_4360"><a href="executable-code-and-execution-contexts.html#sec-liveness">live</a></emu-xref> may be released after long periods of time, or never at all. For this reason, this specification uses the term "may" when describing behaviour triggered by garbage collection.</p>
<p>The semantics of <emu-xref href="#sec-weak-ref-constructor" id="_ref_4361"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRefs</a></emu-xref> and <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4362"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistrys</a></emu-xref> is based on two operations which happen at particular points in time:</p>
<ul>
<li>
When <code>WeakRef.prototype.deref</code> is called, the referent (if <emu-val>undefined</emu-val> is not returned) is kept alive so that subsequent, synchronous accesses also return the same value. This list is reset when synchronous work is done using the <emu-xref aoid="ClearKeptObjects" id="_ref_4363"><a href="executable-code-and-execution-contexts.html#sec-clear-kept-objects">ClearKeptObjects</a></emu-xref> abstract operation.
</li>
<li>
When an object or symbol which is registered with a <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4364"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> becomes unreachable, a call of the <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4365"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref>'s cleanup callback may eventually be made, after synchronous ECMAScript execution completes. The <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4366"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> cleanup is performed with the <emu-xref aoid="CleanupFinalizationRegistry" id="_ref_4367"><a href="executable-code-and-execution-contexts.html#sec-cleanup-finalization-registry">CleanupFinalizationRegistry</a></emu-xref> abstract operation.
</li>
</ul>
<p>Neither of these actions (<emu-xref aoid="ClearKeptObjects" id="_ref_4368"><a href="executable-code-and-execution-contexts.html#sec-clear-kept-objects">ClearKeptObjects</a></emu-xref> or <emu-xref aoid="CleanupFinalizationRegistry" id="_ref_4369"><a href="executable-code-and-execution-contexts.html#sec-cleanup-finalization-registry">CleanupFinalizationRegistry</a></emu-xref>) may interrupt synchronous ECMAScript execution. Because <emu-xref href="#host" id="_ref_4370"><a href="overview.html#host">hosts</a></emu-xref> may assemble longer, synchronous ECMAScript execution runs, this specification defers the scheduling of <emu-xref aoid="ClearKeptObjects" id="_ref_4371"><a href="executable-code-and-execution-contexts.html#sec-clear-kept-objects">ClearKeptObjects</a></emu-xref> and <emu-xref aoid="CleanupFinalizationRegistry" id="_ref_4372"><a href="executable-code-and-execution-contexts.html#sec-cleanup-finalization-registry">CleanupFinalizationRegistry</a></emu-xref> to the <emu-xref href="#host-environment" id="_ref_4373"><a href="overview.html#host-environment">host environment</a></emu-xref>.</p>
<p>Some ECMAScript implementations include garbage collector implementations which run in the background, including when ECMAScript is idle. Letting the <emu-xref href="#host-environment" id="_ref_4374"><a href="overview.html#host-environment">host environment</a></emu-xref> schedule <emu-xref aoid="CleanupFinalizationRegistry" id="_ref_4375"><a href="executable-code-and-execution-contexts.html#sec-cleanup-finalization-registry">CleanupFinalizationRegistry</a></emu-xref> allows it to resume ECMAScript execution in order to run finalizer work, which may free up held values, reducing overall memory usage.</p>
</emu-clause>
<emu-clause id="sec-liveness">
<h1><span class="secnum">9.9.2</span> Liveness</h1>
<p>For some set of objects and/or symbols <var>S</var> a <dfn tabindex="-1">hypothetical WeakRef-oblivious</dfn> execution with respect to <var>S</var> is an execution whereby the abstract operation <emu-xref aoid="WeakRefDeref" id="_ref_4376"><a href="managing-memory.html#sec-weakrefderef">WeakRefDeref</a></emu-xref> of a <emu-xref href="#sec-weak-ref-constructor" id="_ref_4377"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> whose referent is an element of <var>S</var> always returns <emu-val>undefined</emu-val>.</p>
<emu-note><span class="note">Note 1</span><div class="note-contents">
<emu-xref href="#sec-weak-ref-constructor" id="_ref_4378"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref>-obliviousness, together with liveness, capture two notions. One, that a <emu-xref href="#sec-weak-ref-constructor" id="_ref_4379"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> itself does not keep its referent alive. Two, that cycles in liveness does not imply that a value is live. To be concrete, if determining <var>v</var>'s liveness depends on determining the liveness of a <emu-xref href="#sec-weak-ref-constructor" id="_ref_4380"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> referent, <var>r</var>, <var>r</var>'s liveness cannot assume <var>v</var>'s liveness, which would be circular reasoning.
</div></emu-note>
<emu-note><span class="note">Note 2</span><div class="note-contents">
<emu-xref href="#sec-weak-ref-constructor" id="_ref_4381"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref>-obliviousness is defined on sets of objects or symbols instead of individual values to account for cycles. If it were defined on individual values, then a <emu-xref href="#sec-weak-ref-constructor" id="_ref_4382"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> referent in a cycle will be considered live even though its identity is only observed via other <emu-xref href="#sec-weak-ref-constructor" id="_ref_4383"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> referents in the cycle.
</div></emu-note>
<emu-note><span class="note">Note 3</span><div class="note-contents">
Colloquially, we say that an individual object or symbol is live if every set containing it is live.
</div></emu-note>
<p>At any point during evaluation, a set of objects and/or symbols <var>S</var> is considered <dfn tabindex="-1">live</dfn> if either of the following conditions is met:</p>
<ul>
<li>
Any element in <var>S</var> is included in any <emu-xref href="#agent" id="_ref_4384"><a href="executable-code-and-execution-contexts.html#agent">agent</a></emu-xref>'s <var class="field">[[KeptAlive]]</var> <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4385"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.
</li>
<li>
There exists a valid future hypothetical WeakRef-oblivious execution with respect to <var>S</var> that observes the identity of any value in <var>S</var>.
</li>
</ul>
<emu-note><span class="note">Note 4</span><div class="note-contents">
The second condition above intends to capture the intuition that a value is live if its identity is observable via non-<emu-xref href="#sec-weak-ref-constructor" id="_ref_4386"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> means. A value's identity may be observed by observing a strict equality comparison or observing the value being used as key in a Map.
</div></emu-note>
<emu-note><span class="note">Note 5</span><div class="note-contents">
<p>Presence of an object or a symbol in a field, an internal slot, or a property does not imply that the value is live. For example if the value in question is never passed back to the program, then it cannot be observed.</p>
<p>This is the case for keys in a WeakMap, members of a WeakSet, as well as the <var class="field">[[WeakRefTarget]]</var> and <var class="field">[[UnregisterToken]]</var> fields of a <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4387"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> Cell record.</p>
<p>The above definition implies that, if a key in a WeakMap is not live, then its corresponding value is not necessarily live either.</p>
</div></emu-note>
<emu-note><span class="note">Note 6</span><div class="note-contents">
Liveness is the lower bound for guaranteeing which <emu-xref href="#sec-weak-ref-constructor" id="_ref_4388"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRefs</a></emu-xref> engines must not empty. Liveness as defined here is undecidable. In practice, engines use conservative approximations such as reachability. There is expected to be significant implementation leeway.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-weakref-execution">
<h1><span class="secnum">9.9.3</span> Execution</h1>
<p>At any time, if a set of objects and/or symbols <var>S</var> is not <emu-xref href="#sec-liveness" id="_ref_4389"><a href="executable-code-and-execution-contexts.html#sec-liveness">live</a></emu-xref>, an ECMAScript implementation may perform the following steps atomically:</p>
<emu-alg><ol><li>For each element <var>value</var> of <var>S</var>, do<ol><li>For each <emu-xref href="#sec-weak-ref-constructor" id="_ref_4390"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> <var>ref</var> such that <var>ref</var>.<var class="field">[[WeakRefTarget]]</var> is <var>value</var>, do<ol><li>Set <var>ref</var>.<var class="field">[[WeakRefTarget]]</var> to <emu-const>empty</emu-const>.</li></ol></li><li>For each <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4391"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> <var>fg</var> such that <var>fg</var>.<var class="field">[[Cells]]</var> contains a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4392"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> <var>cell</var> such that <var>cell</var>.<var class="field">[[WeakRefTarget]]</var> is <var>value</var>, do<ol><li>Set <var>cell</var>.<var class="field">[[WeakRefTarget]]</var> to <emu-const>empty</emu-const>.</li><li>Optionally, perform <emu-xref aoid="HostEnqueueFinalizationRegistryCleanupJob" id="_ref_4393"><a href="executable-code-and-execution-contexts.html#sec-host-cleanup-finalization-registry" class="e-user-code">HostEnqueueFinalizationRegistryCleanupJob</a></emu-xref>(<var>fg</var>).</li></ol></li><li>For each WeakMap <var>map</var> such that <var>map</var>.<var class="field">[[WeakMapData]]</var> contains a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4394"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> <var>r</var> such that <var>r</var>.<var class="field">[[Key]]</var> is <var>value</var>, do<ol><li>Set <var>r</var>.<var class="field">[[Key]]</var> to <emu-const>empty</emu-const>.</li><li>Set <var>r</var>.<var class="field">[[Value]]</var> to <emu-const>empty</emu-const>.</li></ol></li><li>For each WeakSet <var>set</var> such that <var>set</var>.<var class="field">[[WeakSetData]]</var> contains <var>value</var>, do<ol><li>Replace the element of <var>set</var>.<var class="field">[[WeakSetData]]</var> whose value is <var>value</var> with an element whose value is <emu-const>empty</emu-const>.</li></ol></li></ol></li></ol></emu-alg>
<emu-note><span class="note">Note 1</span><div class="note-contents">
<p>Together with the definition of liveness, this clause prescribes optimizations that an implementation may apply regarding <emu-xref href="#sec-weak-ref-constructor" id="_ref_4395"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRefs</a></emu-xref>.</p>
<p>It is possible to access an object without observing its identity. Optimizations such as dead variable elimination and scalar replacement on properties of non-escaping objects whose identity is not observed are allowed. These optimizations are thus allowed to observably empty <emu-xref href="#sec-weak-ref-constructor" id="_ref_4396"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRefs</a></emu-xref> that point to such objects.</p>
<p>On the other hand, if an object's identity is observable, and that object is in the <var class="field">[[WeakRefTarget]]</var> internal slot of a <emu-xref href="#sec-weak-ref-constructor" id="_ref_4397"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref>, optimizations such as rematerialization that observably empty the <emu-xref href="#sec-weak-ref-constructor" id="_ref_4398"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> are prohibited.</p>
<p>Because calling <emu-xref aoid="HostEnqueueFinalizationRegistryCleanupJob" id="_ref_4399"><a href="executable-code-and-execution-contexts.html#sec-host-cleanup-finalization-registry">HostEnqueueFinalizationRegistryCleanupJob</a></emu-xref> is optional, registered objects in a <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4400"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> do not necessarily hold that <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4401"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> <emu-xref href="#sec-liveness" id="_ref_4402"><a href="executable-code-and-execution-contexts.html#sec-liveness">live</a></emu-xref>. Implementations may omit <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4403"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> callbacks for any reason, e.g., if the <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4404"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref> itself becomes dead, or if the application is shutting down.</p>
</div></emu-note>
<emu-note><span class="note">Note 2</span><div class="note-contents">
<p>Implementations are not obligated to empty <emu-xref href="#sec-weak-ref-constructor" id="_ref_4405"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRefs</a></emu-xref> for maximal sets of non-<emu-xref href="#sec-liveness" id="_ref_4406"><a href="executable-code-and-execution-contexts.html#sec-liveness">live</a></emu-xref> objects or symbols.</p>
<p>If an implementation chooses a non-<emu-xref href="#sec-liveness" id="_ref_4407"><a href="executable-code-and-execution-contexts.html#sec-liveness">live</a></emu-xref> set <var>S</var> in which to empty <emu-xref href="#sec-weak-ref-constructor" id="_ref_4408"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRefs</a></emu-xref>, this definition requires that it empties <emu-xref href="#sec-weak-ref-constructor" id="_ref_4409"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRefs</a></emu-xref> for all values in <var>S</var> simultaneously. In other words, it is not conformant for an implementation to empty a <emu-xref href="#sec-weak-ref-constructor" id="_ref_4410"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref> pointing to a value <var>v</var> without emptying out other <emu-xref href="#sec-weak-ref-constructor" id="_ref_4411"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRefs</a></emu-xref> that, if not emptied, could result in an execution that observes the value of <var>v</var>.</p>
</div></emu-note>
</emu-clause>
<emu-clause id="sec-weakref-host-hooks">
<h1><span class="secnum">9.9.4</span> Host Hooks</h1>
<emu-clause id="sec-host-cleanup-finalization-registry" type="host-defined abstract operation" aoid="HostEnqueueFinalizationRegistryCleanupJob">
<h1><span class="secnum">9.9.4.1</span> HostEnqueueFinalizationRegistryCleanupJob ( <var>finalizationRegistry</var> )</h1>
<p>The <emu-xref href="#host-defined" id="_ref_4412"><a href="overview.html#host-defined">host-defined</a></emu-xref> abstract operation HostEnqueueFinalizationRegistryCleanupJob takes argument <var>finalizationRegistry</var> (a <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4413"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref>) and returns <emu-const>unused</emu-const>.</p>
<p>Let <var>cleanupJob</var> be a new <emu-xref href="#job" id="_ref_4414"><a href="executable-code-and-execution-contexts.html#job">Job</a></emu-xref> <emu-xref href="#sec-abstract-closure" id="_ref_4415"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> with no parameters that captures <var>finalizationRegistry</var> and performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>cleanupResult</var> be <emu-xref aoid="Completion" id="_ref_4416"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="CleanupFinalizationRegistry" id="_ref_4417"><a href="executable-code-and-execution-contexts.html#sec-cleanup-finalization-registry" class="e-user-code">CleanupFinalizationRegistry</a></emu-xref>(<var>finalizationRegistry</var>)).</li><li>If <var>cleanupResult</var> is an <emu-xref href="#sec-completion-record-specification-type" id="_ref_4418"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">abrupt completion</a></emu-xref>, perform any <emu-xref href="#host-defined" id="_ref_4419"><a href="overview.html#host-defined">host-defined</a></emu-xref> steps for reporting the error.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
<p>An implementation of HostEnqueueFinalizationRegistryCleanupJob schedules <var>cleanupJob</var> to be performed at some future time, if possible. It must also conform to the requirements in <emu-xref href="#sec-jobs" id="_ref_266"><a href="executable-code-and-execution-contexts.html#sec-jobs">9.5</a></emu-xref>.</p>
</emu-clause>
</emu-clause>
</emu-clause>
<emu-clause id="sec-clear-kept-objects" type="abstract operation" aoid="ClearKeptObjects">
<h1><span class="secnum">9.10</span> ClearKeptObjects ( )</h1>
<p>The abstract operation ClearKeptObjects takes no arguments and returns <emu-const>unused</emu-const>. ECMAScript implementations are expected to call ClearKeptObjects when a synchronous sequence of ECMAScript executions completes. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>agentRecord</var> be the <emu-xref href="#surrounding-agent" id="_ref_4420"><a href="executable-code-and-execution-contexts.html#surrounding-agent">surrounding agent</a></emu-xref>'s <emu-xref href="#agent-record" id="_ref_4421"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref>.</li><li>Set <var>agentRecord</var>.<var class="field">[[KeptAlive]]</var> to a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4422"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-addtokeptobjects" type="abstract operation" aoid="AddToKeptObjects">
<h1><span class="secnum">9.11</span> AddToKeptObjects ( <var>value</var> )</h1>
<p>The abstract operation AddToKeptObjects takes argument <var>value</var> (an Object or a Symbol) and returns <emu-const>unused</emu-const>. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>agentRecord</var> be the <emu-xref href="#surrounding-agent" id="_ref_4423"><a href="executable-code-and-execution-contexts.html#surrounding-agent">surrounding agent</a></emu-xref>'s <emu-xref href="#agent-record" id="_ref_4424"><a href="executable-code-and-execution-contexts.html#agent-record">Agent Record</a></emu-xref>.</li><li>Append <var>value</var> to <var>agentRecord</var>.<var class="field">[[KeptAlive]]</var>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
When the abstract operation AddToKeptObjects is called with a target object or symbol, it adds the target to a list that will point strongly at the target until <emu-xref aoid="ClearKeptObjects" id="_ref_4425"><a href="executable-code-and-execution-contexts.html#sec-clear-kept-objects">ClearKeptObjects</a></emu-xref> is called.
</div></emu-note>
</emu-clause>
<emu-clause id="sec-cleanup-finalization-registry" type="abstract operation" aoid="CleanupFinalizationRegistry">
<h1><span class="secnum">9.12</span> CleanupFinalizationRegistry ( <var>finalizationRegistry</var> )</h1>
<p>The abstract operation CleanupFinalizationRegistry takes argument <var>finalizationRegistry</var> (a <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4426"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4427"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> <emu-const>unused</emu-const> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_4428"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_4429"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>finalizationRegistry</var> has <var class="field">[[Cells]]</var> and <var class="field">[[CleanupCallback]]</var> internal slots.</li><li>Let <var>callback</var> be <var>finalizationRegistry</var>.<var class="field">[[CleanupCallback]]</var>.</li><li>While <var>finalizationRegistry</var>.<var class="field">[[Cells]]</var> contains a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_4430"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> <var>cell</var> such that <var>cell</var>.<var class="field">[[WeakRefTarget]]</var> is <emu-const>empty</emu-const>, an implementation may perform the following steps:<ol><li>Choose any such <var>cell</var>.</li><li>Remove <var>cell</var> from <var>finalizationRegistry</var>.<var class="field">[[Cells]]</var>.</li><li>Perform ?&nbsp;<emu-xref aoid="HostCallJobCallback" id="_ref_4431"><a href="executable-code-and-execution-contexts.html#sec-hostcalljobcallback" class="e-user-code">HostCallJobCallback</a></emu-xref>(<var>callback</var>, <emu-val>undefined</emu-val>, « <var>cell</var>.<var class="field">[[HeldValue]]</var>&nbsp;»).</li></ol></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
</emu-clause>
<emu-clause id="sec-canbeheldweakly" type="abstract operation" aoid="CanBeHeldWeakly">
<h1><span class="secnum">9.13</span> CanBeHeldWeakly ( <var>v</var> )</h1>
<p>The abstract operation CanBeHeldWeakly takes argument <var>v</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_4432"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a Boolean. It returns <emu-val>true</emu-val> if and only if <var>v</var> is suitable for use as a weak reference. Only values that are suitable for use as a weak reference may be a key of a WeakMap, an element of a WeakSet, the target of a <emu-xref href="#sec-weak-ref-constructor" id="_ref_4433"><a href="managing-memory.html#sec-weak-ref-constructor">WeakRef</a></emu-xref>, or one of the targets of a <emu-xref href="#sec-finalization-registry-constructor" id="_ref_4434"><a href="managing-memory.html#sec-finalization-registry-constructor">FinalizationRegistry</a></emu-xref>. It performs the following steps when called:</p>
<emu-alg><ol><li>If <var>v</var> <emu-xref href="#sec-object-type" id="_ref_4435"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, return <emu-val>true</emu-val>.</li><li>If <var>v</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_4436"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref> and <emu-xref aoid="KeyForSymbol" id="_ref_4437"><a href="fundamental-objects.html#sec-keyforsymbol">KeyForSymbol</a></emu-xref>(<var>v</var>) is <emu-val>undefined</emu-val>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
<emu-note><span class="note">Note</span><div class="note-contents">
<p>A language value without <emu-xref href="#sec-identity" id="_ref_267"><a href="notational-conventions.html#sec-identity">language identity</a></emu-xref> can be manifested without prior reference and is unsuitable for use as a weak reference. A Symbol value produced by <emu-xref href="#sec-symbol.for" id="_ref_268"><a href="fundamental-objects.html#sec-symbol.for">Symbol.for</a></emu-xref>, unlike other Symbol values, does not have language identity and is unsuitable for use as a weak reference. <emu-xref href="#sec-well-known-symbols" id="_ref_269"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">Well-known symbols</a></emu-xref> are likely to never be collected, but are nonetheless treated as suitable for use as a weak reference because they are limited in number and therefore manageable by a variety of implementation approaches. However, any value associated to a well-known symbol in a <emu-xref href="#sec-liveness" id="_ref_4438"><a href="executable-code-and-execution-contexts.html#sec-liveness">live</a></emu-xref> WeakMap is unlikely to be collected and could “leak” memory resources in implementations.</p>
</div></emu-note>
</emu-clause>
</emu-clause></div></body></html>