mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 21:31:46 +00:00
1047 lines
276 KiB
HTML
1047 lines
276 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 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 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-abstract-operations"></head>
|
||
<body><div id="spec-container"><emu-clause id="sec-abstract-operations">
|
||
<h1><span class="secnum">7</span> Abstract Operations</h1>
|
||
<p>These operations are not a part of the ECMAScript language; they are defined here solely to aid the specification of the semantics of the ECMAScript language. Other, more specialized <emu-xref href="#sec-algorithm-conventions-abstract-operations" id="_ref_2043"><a href="notational-conventions.html#sec-algorithm-conventions-abstract-operations">abstract operations</a></emu-xref> are defined throughout this specification.</p>
|
||
|
||
<emu-clause id="sec-type-conversion">
|
||
<h1><span class="secnum">7.1</span> Type Conversion</h1>
|
||
<p>The ECMAScript language implicitly performs automatic type conversion as needed. To clarify the semantics of certain constructs it is useful to define a set of conversion <emu-xref href="#sec-algorithm-conventions-abstract-operations" id="_ref_2044"><a href="notational-conventions.html#sec-algorithm-conventions-abstract-operations">abstract operations</a></emu-xref>. The conversion <emu-xref href="#sec-algorithm-conventions-abstract-operations" id="_ref_2045"><a href="notational-conventions.html#sec-algorithm-conventions-abstract-operations">abstract operations</a></emu-xref> are polymorphic; they can accept a value of any <emu-xref href="#sec-ecmascript-language-types" id="_ref_2046"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language type</a></emu-xref>. But no other specification types are used with these operations.</p>
|
||
<p>The <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2047"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">BigInt type</a></emu-xref> has no implicit conversions in the ECMAScript language; programmers must call BigInt explicitly to convert values from other types.</p>
|
||
|
||
<emu-clause id="sec-toprimitive" type="abstract operation" oldids="table-9" aoid="ToPrimitive"><span id="table-9"></span>
|
||
<h1><span class="secnum">7.1.1</span> ToPrimitive ( <var>input</var> [ , <var>preferredType</var> ] )</h1>
|
||
<p>The abstract operation ToPrimitive takes argument <var>input</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2048"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and optional argument <var>preferredType</var> (<emu-const>string</emu-const> or <emu-const>number</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2049"><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_2050"><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_2051"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts its <var>input</var> argument to a non-<emu-xref href="#sec-object-type" id="_ref_2052"><a href="ecmascript-data-types-and-values.html#sec-object-type">Object type</a></emu-xref>. If an object is capable of converting to more than one primitive type, it may use the optional hint <var>preferredType</var> to favour that type. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>input</var> <emu-xref href="#sec-object-type" id="_ref_2053"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Let <var>exoticToPrim</var> be ? <emu-xref aoid="GetMethod" id="_ref_2054"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>input</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_2055"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.toPrimitive%</a></emu-xref>).</li><li>If <var>exoticToPrim</var> is not <emu-val>undefined</emu-val>, then<ol><li>If <var>preferredType</var> is not present, then<ol><li>Let <var>hint</var> be <emu-val>"default"</emu-val>.</li></ol></li><li>Else if <var>preferredType</var> is <emu-const>string</emu-const>, then<ol><li>Let <var>hint</var> be <emu-val>"string"</emu-val>.</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_2056"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>preferredType</var> is <emu-const>number</emu-const>.</li><li>Let <var>hint</var> be <emu-val>"number"</emu-val>.</li></ol></li><li>Let <var>result</var> be ? <emu-xref aoid="Call" id="_ref_2057"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>exoticToPrim</var>, <var>input</var>, « <var>hint</var> »).</li><li>If <var>result</var> <emu-xref href="#sec-object-type" id="_ref_2058"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, return <var>result</var>.</li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>If <var>preferredType</var> is not present, set <var>preferredType</var> to <emu-const>number</emu-const>.</li><li>Return ? <emu-xref aoid="OrdinaryToPrimitive" id="_ref_2059"><a href="abstract-operations.html#sec-ordinarytoprimitive" class="e-user-code">OrdinaryToPrimitive</a></emu-xref>(<var>input</var>, <var>preferredType</var>).</li></ol></li><li>Return <var>input</var>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>When ToPrimitive is called without a hint, then it generally behaves as if the hint were <emu-const>number</emu-const>. However, objects may over-ride this behaviour by defining a <emu-xref href="#sec-well-known-symbols" id="_ref_2060"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.toPrimitive%</a></emu-xref> method. Of the objects defined in this specification only Dates (see <emu-xref href="#sec-date.prototype-%symbol.toprimitive%" id="_ref_201"><a href="numbers-and-dates.html#sec-date.prototype-%symbol.toprimitive%">21.4.4.45</a></emu-xref>) and Symbol objects (see <emu-xref href="#sec-symbol.prototype-%symbol.toprimitive%" id="_ref_202"><a href="fundamental-objects.html#sec-symbol.prototype-%symbol.toprimitive%">20.4.3.5</a></emu-xref>) over-ride the default ToPrimitive behaviour. Dates treat the absence of a hint as if the hint were <emu-const>string</emu-const>.</p>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-ordinarytoprimitive" type="abstract operation" aoid="OrdinaryToPrimitive">
|
||
<h1><span class="secnum">7.1.1.1</span> OrdinaryToPrimitive ( <var>O</var>, <var>hint</var> )</h1>
|
||
<p>The abstract operation OrdinaryToPrimitive takes arguments <var>O</var> (an Object) and <var>hint</var> (<emu-const>string</emu-const> or <emu-const>number</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2061"><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_2062"><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_2063"><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>hint</var> is <emu-const>string</emu-const>, then<ol><li>Let <var>methodNames</var> be « <emu-val>"toString"</emu-val>, <emu-val>"valueOf"</emu-val> ».</li></ol></li><li>Else,<ol><li>Let <var>methodNames</var> be « <emu-val>"valueOf"</emu-val>, <emu-val>"toString"</emu-val> ».</li></ol></li><li>For each element <var>name</var> of <var>methodNames</var>, do<ol><li>Let <var>method</var> be ? <emu-xref aoid="Get" id="_ref_2064"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>O</var>, <var>name</var>).</li><li>If <emu-xref aoid="IsCallable" id="_ref_2065"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>method</var>) is <emu-val>true</emu-val>, then<ol><li>Let <var>result</var> be ? <emu-xref aoid="Call" id="_ref_2066"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>method</var>, <var>O</var>).</li><li>If <var>result</var> <emu-xref href="#sec-object-type" id="_ref_2067"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, return <var>result</var>.</li></ol></li></ol></li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-toboolean" oldids="table-toboolean-conversions,sec-IsHTMLDDA-internal-slot-to-boolean" type="abstract operation" aoid="ToBoolean"><span id="sec-IsHTMLDDA-internal-slot-to-boolean"></span><span id="table-toboolean-conversions"></span>
|
||
<h1><span class="secnum">7.1.2</span> ToBoolean ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToBoolean takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2068"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a Boolean. It converts <var>argument</var> to a value of type Boolean. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type" id="_ref_2070"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-boolean-type">is a Boolean</a></emu-xref>, return <var>argument</var>.</li><li>If <var>argument</var> is one of <emu-val>undefined</emu-val>, <emu-val>null</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub>, <emu-val>-0</emu-val><sub>𝔽</sub>, <emu-val>NaN</emu-val>, <emu-val>0</emu-val><sub>ℤ</sub>, or the empty String, return <emu-val>false</emu-val>.</li><li id="step-to-boolean-web-compat-insertion-point" normative-optional=""><div class="attributes-tag"><emu-xref href="#sec-conformance" id="_ref_2069"><a href="conformance.html#sec-conformance">Normative Optional</a></emu-xref></div>If the <emu-xref href="#host" id="_ref_2071"><a href="overview.html#host">host</a></emu-xref> is a web browser or otherwise supports <emu-xref href="#sec-IsHTMLDDA-internal-slot" title="" id="_ref_203"><a href="additional-ecmascript-features-for-web-browsers.html#sec-IsHTMLDDA-internal-slot">The <var class="field">[[IsHTMLDDA]]</var> Internal Slot</a></emu-xref>, then<ol><li>If <var>argument</var> <emu-xref href="#sec-object-type" id="_ref_2072"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref> and <var>argument</var> has an <var class="field">[[IsHTMLDDA]]</var> internal slot, 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-tonumeric" type="abstract operation" aoid="ToNumeric">
|
||
<h1><span class="secnum">7.1.3</span> ToNumeric ( <var>value</var> )</h1>
|
||
<p>The abstract operation ToNumeric takes argument <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2073"><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_2074"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either a Number or a BigInt, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2075"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It returns <var>value</var> converted to a Number or a BigInt. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>primValue</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2076"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>value</var>, <emu-const>number</emu-const>).</li><li>If <var>primValue</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2077"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, return <var>primValue</var>.</li><li>Return ? <emu-xref aoid="ToNumber" id="_ref_2078"><a href="abstract-operations.html#sec-tonumber">ToNumber</a></emu-xref>(<var>primValue</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-tonumber" oldids="table-tonumber-conversions" type="abstract operation" aoid="ToNumber"><span id="table-tonumber-conversions"></span>
|
||
<h1><span class="secnum">7.1.4</span> ToNumber ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToNumber takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2079"><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_2080"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a Number or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2081"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to a value of type Number. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2082"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, return <var>argument</var>.</li><li>If <var>argument</var> is either a Symbol or a BigInt, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>argument</var> is <emu-val>undefined</emu-val>, return <emu-val>NaN</emu-val>.</li><li>If <var>argument</var> is either <emu-val>null</emu-val> or <emu-val>false</emu-val>, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>If <var>argument</var> is <emu-val>true</emu-val>, return <emu-val>1</emu-val><sub>𝔽</sub>.</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2083"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, return <emu-xref aoid="StringToNumber" id="_ref_2084"><a href="abstract-operations.html#sec-stringtonumber">StringToNumber</a></emu-xref>(<var>argument</var>).</li><li><emu-xref href="#assert" id="_ref_2085"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>argument</var> <emu-xref href="#sec-object-type" id="_ref_2086"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>.</li><li>Let <var>primValue</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2087"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>argument</var>, <emu-const>number</emu-const>).</li><li><emu-xref href="#assert" id="_ref_2088"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>primValue</var> <emu-xref href="#sec-object-type" id="_ref_2089"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>.</li><li>Return ? <emu-xref aoid="ToNumber" id="_ref_2090"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>primValue</var>).</li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-tonumber-applied-to-the-string-type">
|
||
<h1><span class="secnum">7.1.4.1</span> ToNumber Applied to the String Type</h1>
|
||
<p>The abstract operation <emu-xref aoid="StringToNumber" id="_ref_2091"><a href="abstract-operations.html#sec-stringtonumber">StringToNumber</a></emu-xref> specifies how to convert a String value to a Number value, using the following grammar.</p>
|
||
<h2>Syntax</h2>
|
||
<emu-grammar type="definition"><emu-production name="StringNumericLiteral" type="regexp" id="prod-StringNumericLiteral">
|
||
<emu-nt><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="mkvpahdu" id="prod-FDwUUOp8">
|
||
<emu-nt optional="" id="_ref_17761"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="_ljdljxm" id="prod-m-6uXikA">
|
||
<emu-nt optional="" id="_ref_17762"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_17763"><a href="abstract-operations.html#prod-StrNumericLiteral">StrNumericLiteral</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_17764"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="StrWhiteSpace" type="regexp" id="prod-StrWhiteSpace">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="kw6izkq9">
|
||
<emu-nt id="_ref_17765"><a href="abstract-operations.html#prod-StrWhiteSpaceChar">StrWhiteSpaceChar</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_17766"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="StrWhiteSpaceChar" type="regexp" id="prod-StrWhiteSpaceChar">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrWhiteSpaceChar">StrWhiteSpaceChar</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="fctcswat">
|
||
<emu-nt id="_ref_17767"><a href="ecmascript-language-lexical-grammar.html#prod-WhiteSpace">WhiteSpace</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="ozmczrck">
|
||
<emu-nt id="_ref_17768"><a href="ecmascript-language-lexical-grammar.html#prod-LineTerminator">LineTerminator</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="StrNumericLiteral" type="regexp" id="prod-StrNumericLiteral">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrNumericLiteral">StrNumericLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="2zae4kd4">
|
||
<emu-nt id="_ref_17769"><a href="abstract-operations.html#prod-StrDecimalLiteral">StrDecimalLiteral</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="kidoa90l" id="prod-rEUJru-M">
|
||
<emu-nt params="~Sep" id="_ref_17770"><a href="ecmascript-language-lexical-grammar.html#prod-NonDecimalIntegerLiteral">NonDecimalIntegerLiteral</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="StrDecimalLiteral" type="regexp" id="prod-StrDecimalLiteral">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrDecimalLiteral">StrDecimalLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="r3_niz0j">
|
||
<emu-nt id="_ref_17771"><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="o_y5qzvk">
|
||
<emu-t>+</emu-t>
|
||
<emu-nt id="_ref_17772"><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="1g8bpsll" id="prod-glMHXxnX">
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_17773"><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="StrUnsignedDecimalLiteral" type="regexp" id="prod-StrUnsignedDecimalLiteral">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="sv6n-gkb" id="prod-QcF4NRmv">
|
||
<emu-t>Infinity</emu-t>
|
||
</emu-rhs>
|
||
<emu-rhs a="bw_ix5cg" id="prod-0clqUBRw">
|
||
<emu-nt params="~Sep" id="_ref_17774"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
<emu-t>.</emu-t>
|
||
<emu-nt params="~Sep" optional="" id="_ref_17775"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt params="~Sep" optional="" id="_ref_17776"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a><emu-mods><emu-params>[~Sep]</emu-params><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="m3hgvw0t" id="prod-h9Y6iP78">
|
||
<emu-t>.</emu-t>
|
||
<emu-nt params="~Sep" id="_ref_17777"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt params="~Sep" optional="" id="_ref_17778"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a><emu-mods><emu-params>[~Sep]</emu-params><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="eg9cc2yh" id="prod-14bLNUM8">
|
||
<emu-nt params="~Sep" id="_ref_17779"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
<emu-nt params="~Sep" optional="" id="_ref_17780"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a><emu-mods><emu-params>[~Sep]</emu-params><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<p>All grammar symbols not explicitly defined above have the definitions used in the Lexical Grammar for numeric literals (<emu-xref href="#sec-literals-numeric-literals" id="_ref_204"><a href="ecmascript-language-lexical-grammar.html#sec-literals-numeric-literals">12.9.3</a></emu-xref>)</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Some differences should be noted between the syntax of a <emu-nt id="_ref_17781"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> and a <emu-nt id="_ref_17782"><a href="ecmascript-language-lexical-grammar.html#prod-NumericLiteral">NumericLiteral</a></emu-nt>:</p>
|
||
<ul>
|
||
<li>
|
||
A <emu-nt id="_ref_17783"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> may include leading and/or trailing white space and/or line terminators.
|
||
</li>
|
||
<li>
|
||
A <emu-nt id="_ref_17784"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> that is decimal may have any number of leading <code>0</code> digits.
|
||
</li>
|
||
<li>
|
||
A <emu-nt id="_ref_17785"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> that is decimal may include a <code>+</code> or <code>-</code> to indicate its sign.
|
||
</li>
|
||
<li>
|
||
A <emu-nt id="_ref_17786"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> that is empty or contains only white space is converted to <emu-val>+0</emu-val><sub>𝔽</sub>.
|
||
</li>
|
||
<li>
|
||
<code>Infinity</code> and <code>-Infinity</code> are recognized as a <emu-nt id="_ref_17787"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> but not as a <emu-nt id="_ref_17788"><a href="ecmascript-language-lexical-grammar.html#prod-NumericLiteral">NumericLiteral</a></emu-nt>.
|
||
</li>
|
||
<li>
|
||
A <emu-nt id="_ref_17789"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> cannot include a <emu-nt id="_ref_17790"><a href="ecmascript-language-lexical-grammar.html#prod-BigIntLiteralSuffix">BigIntLiteralSuffix</a></emu-nt>.
|
||
</li>
|
||
<li>
|
||
A <emu-nt id="_ref_17791"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> cannot include a <emu-nt id="_ref_17792"><a href="ecmascript-language-lexical-grammar.html#prod-NumericLiteralSeparator">NumericLiteralSeparator</a></emu-nt>.
|
||
</li>
|
||
</ul>
|
||
</div></emu-note>
|
||
|
||
<emu-clause id="sec-stringtonumber" type="abstract operation" aoid="StringToNumber">
|
||
<h1><span class="secnum">7.1.4.1.1</span> StringToNumber ( <var>str</var> )</h1>
|
||
<p>The abstract operation StringToNumber takes argument <var>str</var> (a String) and returns a Number. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>literal</var> be <emu-xref aoid="ParseText" id="_ref_2092"><a href="ecmascript-language-source-code.html#sec-parsetext">ParseText</a></emu-xref>(<var>str</var>, <emu-nt id="_ref_17793"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt>).</li><li>If <var>literal</var> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2093"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of errors, return <emu-val>NaN</emu-val>.</li><li>Return the <emu-xref aoid="StringNumericValue" id="_ref_2094"><a href="abstract-operations.html#sec-runtime-semantics-stringnumericvalue">StringNumericValue</a></emu-xref> of <var>literal</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-runtime-semantics-stringnumericvalue" type="sdo" oldids="sec-runtime-semantics-mv-s" aoid="StringNumericValue"><span id="sec-runtime-semantics-mv-s"></span>
|
||
<h1><span class="secnum">7.1.4.1.2</span> Runtime Semantics: StringNumericValue</h1>
|
||
<p>The <emu-xref href="#sec-algorithm-conventions-syntax-directed-operations" id="_ref_2095"><a href="notational-conventions.html#sec-algorithm-conventions-syntax-directed-operations">syntax-directed operation</a></emu-xref> StringNumericValue takes no arguments and returns a Number.</p>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>The conversion of a <emu-nt id="_ref_17794"><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> to a Number value is similar overall to the determination of the <emu-xref aoid="NumericValue" id="_ref_2096"><a href="ecmascript-language-lexical-grammar.html#sec-numericvalue">NumericValue</a></emu-xref> of a <emu-nt id="_ref_17795"><a href="ecmascript-language-lexical-grammar.html#prod-NumericLiteral">NumericLiteral</a></emu-nt> (see <emu-xref href="#sec-literals-numeric-literals" id="_ref_205"><a href="ecmascript-language-lexical-grammar.html#sec-literals-numeric-literals">12.9.3</a></emu-xref>), but some of the details are different.</p>
|
||
</div></emu-note>
|
||
<p>It is defined piecewise over the following productions:</p>
|
||
<emu-grammar><emu-production name="StringNumericLiteral" type="regexp" collapsed="">
|
||
<emu-nt><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="mkvpahdu" id="prod-_R4wE0aJ"><emu-nt optional="" id="_ref_17796"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-val>+0</emu-val><sub>𝔽</sub>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="StringNumericLiteral" type="regexp" collapsed="">
|
||
<emu-nt><a href="abstract-operations.html#prod-StringNumericLiteral">StringNumericLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="_ljdljxm" id="prod-meFGI9GM">
|
||
<emu-nt optional="" id="_ref_17797"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_17798"><a href="abstract-operations.html#prod-StrNumericLiteral">StrNumericLiteral</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_17799"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return the <emu-xref aoid="StringNumericValue" id="_ref_2097"><a href="abstract-operations.html#sec-runtime-semantics-stringnumericvalue">StringNumericValue</a></emu-xref> of <emu-nt id="_ref_17800"><a href="abstract-operations.html#prod-StrNumericLiteral">StrNumericLiteral</a></emu-nt>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="StrNumericLiteral" type="regexp" collapsed="">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrNumericLiteral">StrNumericLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="6ge3c7dq" id="prod-chPZzOnl"><emu-nt id="_ref_17801"><a href="ecmascript-language-lexical-grammar.html#prod-NonDecimalIntegerLiteral">NonDecimalIntegerLiteral</a></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="𝔽" id="_ref_2098"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(MV of <emu-nt id="_ref_17802"><a href="ecmascript-language-lexical-grammar.html#prod-NonDecimalIntegerLiteral">NonDecimalIntegerLiteral</a></emu-nt>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="StrDecimalLiteral" type="regexp" collapsed="">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrDecimalLiteral">StrDecimalLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="1g8bpsll" id="prod-gjHq7g3y">
|
||
<emu-t>-</emu-t>
|
||
<emu-nt id="_ref_17803"><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>a</var> be the <emu-xref aoid="StringNumericValue" id="_ref_2099"><a href="abstract-operations.html#sec-runtime-semantics-stringnumericvalue">StringNumericValue</a></emu-xref> of <emu-nt id="_ref_17804"><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt>.</li><li>If <var>a</var> is <emu-val>+0</emu-val><sub>𝔽</sub>, return <emu-val>-0</emu-val><sub>𝔽</sub>.</li><li>Return -<var>a</var>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="StrUnsignedDecimalLiteral" type="regexp" collapsed="">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="sv6n-gkb" id="prod-rF3lJM39"><emu-t>Infinity</emu-t></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Return <emu-val>+∞</emu-val><sub>𝔽</sub>.</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="StrUnsignedDecimalLiteral" type="regexp" collapsed="">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="iokglhcc" id="prod-rFHlF9yu">
|
||
<emu-nt id="_ref_17805"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-t>.</emu-t>
|
||
<emu-nt optional="" id="_ref_17806"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt optional="" id="_ref_17807"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>a</var> be the MV of the first <emu-nt id="_ref_17808"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>If the second <emu-nt id="_ref_17809"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt> is present, then<ol><li>Let <var>b</var> be the MV of the second <emu-nt id="_ref_17810"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>Let <var>n</var> be the number of code points in the second <emu-nt id="_ref_17811"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li></ol></li><li>Else,<ol><li>Let <var>b</var> be 0.</li><li>Let <var>n</var> be 0.</li></ol></li><li>If <emu-nt id="_ref_17812"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a></emu-nt> is present, let <var>e</var> be the MV of <emu-nt id="_ref_17813"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a></emu-nt>; else let <var>e</var> be 0.</li><li>Return <emu-xref aoid="RoundMVResult" id="_ref_2100"><a href="abstract-operations.html#sec-roundmvresult">RoundMVResult</a></emu-xref>((<var>a</var> + (<var>b</var> × 10<sup>-<var>n</var></sup>)) × 10<sup><var>e</var></sup>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="StrUnsignedDecimalLiteral" type="regexp" collapsed="">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="xpoqnclz" id="prod-KhQPr5RG">
|
||
<emu-t>.</emu-t>
|
||
<emu-nt id="_ref_17814"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_17815"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>b</var> be the MV of <emu-nt id="_ref_17816"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>If <emu-nt id="_ref_17817"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a></emu-nt> is present, let <var>e</var> be the MV of <emu-nt id="_ref_17818"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a></emu-nt>; else let <var>e</var> be 0.</li><li>Let <var>n</var> be the number of code points in <emu-nt id="_ref_17819"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>Return <emu-xref aoid="RoundMVResult" id="_ref_2101"><a href="abstract-operations.html#sec-roundmvresult">RoundMVResult</a></emu-xref>(<var>b</var> × 10<sup><var>e</var> - <var>n</var></sup>).</li></ol></emu-alg>
|
||
<emu-grammar><emu-production name="StrUnsignedDecimalLiteral" type="regexp" collapsed="">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrUnsignedDecimalLiteral">StrUnsignedDecimalLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="joj696lw" id="prod-0Vf62eUX">
|
||
<emu-nt id="_ref_17820"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_17821"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
<emu-alg><ol><li>Let <var>a</var> be the MV of <emu-nt id="_ref_17822"><a href="ecmascript-language-lexical-grammar.html#prod-DecimalDigits">DecimalDigits</a></emu-nt>.</li><li>If <emu-nt id="_ref_17823"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a></emu-nt> is present, let <var>e</var> be the MV of <emu-nt id="_ref_17824"><a href="ecmascript-language-lexical-grammar.html#prod-ExponentPart">ExponentPart</a></emu-nt>; else let <var>e</var> be 0.</li><li>Return <emu-xref aoid="RoundMVResult" id="_ref_2102"><a href="abstract-operations.html#sec-roundmvresult">RoundMVResult</a></emu-xref>(<var>a</var> × 10<sup><var>e</var></sup>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-roundmvresult" type="abstract operation" aoid="RoundMVResult">
|
||
<h1><span class="secnum">7.1.4.1.3</span> RoundMVResult ( <var>n</var> )</h1>
|
||
<p>The abstract operation RoundMVResult takes argument <var>n</var> (a <emu-xref href="#mathematical-value" id="_ref_2103"><a href="notational-conventions.html#mathematical-value">mathematical value</a></emu-xref>) and returns a Number. It converts <var>n</var> to a Number in an <emu-xref href="#implementation-defined" id="_ref_2104"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref> manner. For the purposes of this abstract operation, a digit is significant if it is not zero or there is a non-zero digit to its left and there is a non-zero digit to its right. For the purposes of this abstract operation, "the <emu-xref href="#mathematical-value" id="_ref_2105"><a href="notational-conventions.html#mathematical-value">mathematical value</a></emu-xref> denoted by" a representation of a <emu-xref href="#mathematical-value" id="_ref_2106"><a href="notational-conventions.html#mathematical-value">mathematical value</a></emu-xref> is the inverse of "the decimal representation of" a <emu-xref href="#mathematical-value" id="_ref_2107"><a href="notational-conventions.html#mathematical-value">mathematical value</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If the decimal representation of <var>n</var> has 20 or fewer significant digits, return <emu-xref aoid="𝔽" id="_ref_2108"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>n</var>).</li><li>Let <var>option1</var> be the <emu-xref href="#mathematical-value" id="_ref_2109"><a href="notational-conventions.html#mathematical-value">mathematical value</a></emu-xref> denoted by the result of replacing each significant digit in the decimal representation of <var>n</var> after the 20th with a 0 digit.</li><li>Let <var>option2</var> be the <emu-xref href="#mathematical-value" id="_ref_2110"><a href="notational-conventions.html#mathematical-value">mathematical value</a></emu-xref> denoted by the result of replacing each significant digit in the decimal representation of <var>n</var> after the 20th with a 0 digit and then incrementing it at the 20th position (with carrying as necessary).</li><li>Let <var>chosen</var> be an <emu-xref href="#implementation-defined" id="_ref_2111"><a href="overview.html#implementation-defined">implementation-defined</a></emu-xref> choice of either <var>option1</var> or <var>option2</var>.</li><li>Return <emu-xref aoid="𝔽" id="_ref_2112"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>chosen</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-tointegerorinfinity" type="abstract operation" oldids="sec-tointeger" aoid="ToIntegerOrInfinity"><span id="sec-tointeger"></span>
|
||
<h1><span class="secnum">7.1.5</span> ToIntegerOrInfinity ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToIntegerOrInfinity takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2113"><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_2114"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either an <emu-xref href="#integer" id="_ref_2115"><a href="notational-conventions.html#integer">integer</a></emu-xref>, +∞, or -∞, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2116"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to an <emu-xref href="#integer" id="_ref_2117"><a href="notational-conventions.html#integer">integer</a></emu-xref> representing its Number value with fractional part truncated, or to +∞ or -∞ when that Number value is infinite. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>number</var> be ? <emu-xref aoid="ToNumber" id="_ref_2118"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If <var>number</var> is one of <emu-val>NaN</emu-val>, <emu-val>+0</emu-val><sub>𝔽</sub>, or <emu-val>-0</emu-val><sub>𝔽</sub>, return 0.</li><li>If <var>number</var> is <emu-val>+∞</emu-val><sub>𝔽</sub>, return +∞.</li><li>If <var>number</var> is <emu-val>-∞</emu-val><sub>𝔽</sub>, return -∞.</li><li>Return <emu-xref aoid="truncate" id="_ref_2119"><a href="notational-conventions.html#eqn-truncate">truncate</a></emu-xref>(<emu-xref aoid="ℝ" id="_ref_2120"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>number</var>)).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<emu-xref aoid="𝔽" id="_ref_2121"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(ToIntegerOrInfinity(<var>x</var>)) never returns <emu-val>-0</emu-val><sub>𝔽</sub> for any value of <var>x</var>. The truncation of the fractional part is performed after converting <var>x</var> to a <emu-xref href="#mathematical-value" id="_ref_2122"><a href="notational-conventions.html#mathematical-value">mathematical value</a></emu-xref>.
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-toint32" type="abstract operation" aoid="ToInt32">
|
||
<h1><span class="secnum">7.1.6</span> ToInt32 ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToInt32 takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2123"><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_2124"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#integral-number" id="_ref_2125"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2126"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to one of 2<sup>32</sup> <emu-xref href="#integral-number" id="_ref_2127"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> values in the <emu-xref href="#inclusive-interval" id="_ref_2128"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-xref aoid="𝔽" id="_ref_2129"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(-2<sup>31</sup>) to <emu-xref aoid="𝔽" id="_ref_2130"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(2<sup>31</sup> - 1). It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>number</var> be ? <emu-xref aoid="ToNumber" id="_ref_2131"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If <var>number</var> is not <emu-xref href="#finite" id="_ref_2132"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref> or <var>number</var> is either <emu-val>+0</emu-val><sub>𝔽</sub> or <emu-val>-0</emu-val><sub>𝔽</sub>, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Let <var>int</var> be <emu-xref aoid="truncate" id="_ref_2133"><a href="notational-conventions.html#eqn-truncate">truncate</a></emu-xref>(<emu-xref aoid="ℝ" id="_ref_2134"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>number</var>)).</li><li>Let <var>int32bit</var> be <var>int</var> <emu-xref aoid="modulo" id="_ref_2135"><a href="notational-conventions.html#eqn-modulo">modulo</a></emu-xref> 2<sup>32</sup>.</li><li>If <var>int32bit</var> ≥ 2<sup>31</sup>, return <emu-xref aoid="𝔽" id="_ref_2136"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int32bit</var> - 2<sup>32</sup>).</li><li>Return <emu-xref aoid="𝔽" id="_ref_2137"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int32bit</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Given the above definition of ToInt32:</p>
|
||
<ul>
|
||
<li>
|
||
The ToInt32 abstract operation is idempotent: if applied to a result that it produced, the second application leaves that value unchanged.
|
||
</li>
|
||
<li>
|
||
ToInt32(<emu-xref aoid="ToUint32" id="_ref_2138"><a href="abstract-operations.html#sec-touint32">ToUint32</a></emu-xref>(<var>x</var>)) is the same value as ToInt32(<var>x</var>) for all values of <var>x</var>. (It is to preserve this latter property that <emu-val>+∞</emu-val><sub>𝔽</sub> and <emu-val>-∞</emu-val><sub>𝔽</sub> are mapped to <emu-val>+0</emu-val><sub>𝔽</sub>.)
|
||
</li>
|
||
<li>
|
||
ToInt32 maps <emu-val>-0</emu-val><sub>𝔽</sub> to <emu-val>+0</emu-val><sub>𝔽</sub>.
|
||
</li>
|
||
</ul>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-touint32" type="abstract operation" aoid="ToUint32">
|
||
<h1><span class="secnum">7.1.7</span> ToUint32 ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToUint32 takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2139"><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_2140"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#integral-number" id="_ref_2141"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2142"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to one of 2<sup>32</sup> <emu-xref href="#integral-number" id="_ref_2143"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> values in the <emu-xref href="#inclusive-interval" id="_ref_2144"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-val>+0</emu-val><sub>𝔽</sub> to <emu-xref aoid="𝔽" id="_ref_2145"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(2<sup>32</sup> - 1). It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>number</var> be ? <emu-xref aoid="ToNumber" id="_ref_2146"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If <var>number</var> is not <emu-xref href="#finite" id="_ref_2147"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref> or <var>number</var> is either <emu-val>+0</emu-val><sub>𝔽</sub> or <emu-val>-0</emu-val><sub>𝔽</sub>, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Let <var>int</var> be <emu-xref aoid="truncate" id="_ref_2148"><a href="notational-conventions.html#eqn-truncate">truncate</a></emu-xref>(<emu-xref aoid="ℝ" id="_ref_2149"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>number</var>)).</li><li>Let <var>int32bit</var> be <var>int</var> <emu-xref aoid="modulo" id="_ref_2150"><a href="notational-conventions.html#eqn-modulo">modulo</a></emu-xref> 2<sup>32</sup>.</li><li id="step-touint32-return">Return <emu-xref aoid="𝔽" id="_ref_2151"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int32bit</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Given the above definition of ToUint32:</p>
|
||
<ul>
|
||
<li>
|
||
Step <emu-xref href="#step-touint32-return" id="_ref_206"><a href="abstract-operations.html#step-touint32-return">5</a></emu-xref> is the only difference between ToUint32 and <emu-xref aoid="ToInt32" id="_ref_2152"><a href="abstract-operations.html#sec-toint32">ToInt32</a></emu-xref>.
|
||
</li>
|
||
<li>
|
||
The ToUint32 abstract operation is idempotent: if applied to a result that it produced, the second application leaves that value unchanged.
|
||
</li>
|
||
<li>
|
||
ToUint32(<emu-xref aoid="ToInt32" id="_ref_2153"><a href="abstract-operations.html#sec-toint32">ToInt32</a></emu-xref>(<var>x</var>)) is the same value as ToUint32(<var>x</var>) for all values of <var>x</var>. (It is to preserve this latter property that <emu-val>+∞</emu-val><sub>𝔽</sub> and <emu-val>-∞</emu-val><sub>𝔽</sub> are mapped to <emu-val>+0</emu-val><sub>𝔽</sub>.)
|
||
</li>
|
||
<li>
|
||
ToUint32 maps <emu-val>-0</emu-val><sub>𝔽</sub> to <emu-val>+0</emu-val><sub>𝔽</sub>.
|
||
</li>
|
||
</ul>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-toint16" type="abstract operation" aoid="ToInt16">
|
||
<h1><span class="secnum">7.1.8</span> ToInt16 ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToInt16 takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2154"><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_2155"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#integral-number" id="_ref_2156"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2157"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to one of 2<sup>16</sup> <emu-xref href="#integral-number" id="_ref_2158"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> values in the <emu-xref href="#inclusive-interval" id="_ref_2159"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-xref aoid="𝔽" id="_ref_2160"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(-2<sup>15</sup>) to <emu-xref aoid="𝔽" id="_ref_2161"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(2<sup>15</sup> - 1). It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>number</var> be ? <emu-xref aoid="ToNumber" id="_ref_2162"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If <var>number</var> is not <emu-xref href="#finite" id="_ref_2163"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref> or <var>number</var> is either <emu-val>+0</emu-val><sub>𝔽</sub> or <emu-val>-0</emu-val><sub>𝔽</sub>, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Let <var>int</var> be <emu-xref aoid="truncate" id="_ref_2164"><a href="notational-conventions.html#eqn-truncate">truncate</a></emu-xref>(<emu-xref aoid="ℝ" id="_ref_2165"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>number</var>)).</li><li>Let <var>int16bit</var> be <var>int</var> <emu-xref aoid="modulo" id="_ref_2166"><a href="notational-conventions.html#eqn-modulo">modulo</a></emu-xref> 2<sup>16</sup>.</li><li>If <var>int16bit</var> ≥ 2<sup>15</sup>, return <emu-xref aoid="𝔽" id="_ref_2167"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int16bit</var> - 2<sup>16</sup>).</li><li>Return <emu-xref aoid="𝔽" id="_ref_2168"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int16bit</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-touint16" type="abstract operation" aoid="ToUint16">
|
||
<h1><span class="secnum">7.1.9</span> ToUint16 ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToUint16 takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2169"><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_2170"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#integral-number" id="_ref_2171"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2172"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to one of 2<sup>16</sup> <emu-xref href="#integral-number" id="_ref_2173"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> values in the <emu-xref href="#inclusive-interval" id="_ref_2174"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-val>+0</emu-val><sub>𝔽</sub> to <emu-xref aoid="𝔽" id="_ref_2175"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(2<sup>16</sup> - 1). It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>number</var> be ? <emu-xref aoid="ToNumber" id="_ref_2176"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If <var>number</var> is not <emu-xref href="#finite" id="_ref_2177"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref> or <var>number</var> is either <emu-val>+0</emu-val><sub>𝔽</sub> or <emu-val>-0</emu-val><sub>𝔽</sub>, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Let <var>int</var> be <emu-xref aoid="truncate" id="_ref_2178"><a href="notational-conventions.html#eqn-truncate">truncate</a></emu-xref>(<emu-xref aoid="ℝ" id="_ref_2179"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>number</var>)).</li><li id="step-touint16-mod">Let <var>int16bit</var> be <var>int</var> <emu-xref aoid="modulo" id="_ref_2180"><a href="notational-conventions.html#eqn-modulo">modulo</a></emu-xref> 2<sup>16</sup>.</li><li>Return <emu-xref aoid="𝔽" id="_ref_2181"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int16bit</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Given the above definition of ToUint16:</p>
|
||
<ul>
|
||
<li>
|
||
The substitution of 2<sup>16</sup> for 2<sup>32</sup> in step <emu-xref href="#step-touint16-mod" id="_ref_207"><a href="abstract-operations.html#step-touint16-mod">4</a></emu-xref> is the only difference between <emu-xref aoid="ToUint32" id="_ref_2182"><a href="abstract-operations.html#sec-touint32">ToUint32</a></emu-xref> and ToUint16.
|
||
</li>
|
||
<li>
|
||
ToUint16 maps <emu-val>-0</emu-val><sub>𝔽</sub> to <emu-val>+0</emu-val><sub>𝔽</sub>.
|
||
</li>
|
||
</ul>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-toint8" type="abstract operation" aoid="ToInt8">
|
||
<h1><span class="secnum">7.1.10</span> ToInt8 ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToInt8 takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2183"><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_2184"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#integral-number" id="_ref_2185"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2186"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to one of 2<sup>8</sup> <emu-xref href="#integral-number" id="_ref_2187"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> values in the <emu-xref href="#inclusive-interval" id="_ref_2188"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-val>-128</emu-val><sub>𝔽</sub> to <emu-val>127</emu-val><sub>𝔽</sub>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>number</var> be ? <emu-xref aoid="ToNumber" id="_ref_2189"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If <var>number</var> is not <emu-xref href="#finite" id="_ref_2190"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref> or <var>number</var> is either <emu-val>+0</emu-val><sub>𝔽</sub> or <emu-val>-0</emu-val><sub>𝔽</sub>, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Let <var>int</var> be <emu-xref aoid="truncate" id="_ref_2191"><a href="notational-conventions.html#eqn-truncate">truncate</a></emu-xref>(<emu-xref aoid="ℝ" id="_ref_2192"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>number</var>)).</li><li>Let <var>int8bit</var> be <var>int</var> <emu-xref aoid="modulo" id="_ref_2193"><a href="notational-conventions.html#eqn-modulo">modulo</a></emu-xref> 2<sup>8</sup>.</li><li>If <var>int8bit</var> ≥ 2<sup>7</sup>, return <emu-xref aoid="𝔽" id="_ref_2194"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int8bit</var> - 2<sup>8</sup>).</li><li>Return <emu-xref aoid="𝔽" id="_ref_2195"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int8bit</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-touint8" type="abstract operation" aoid="ToUint8">
|
||
<h1><span class="secnum">7.1.11</span> ToUint8 ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToUint8 takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2196"><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_2197"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#integral-number" id="_ref_2198"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2199"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to one of 2<sup>8</sup> <emu-xref href="#integral-number" id="_ref_2200"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> values in the <emu-xref href="#inclusive-interval" id="_ref_2201"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-val>+0</emu-val><sub>𝔽</sub> to <emu-val>255</emu-val><sub>𝔽</sub>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>number</var> be ? <emu-xref aoid="ToNumber" id="_ref_2202"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If <var>number</var> is not <emu-xref href="#finite" id="_ref_2203"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref> or <var>number</var> is either <emu-val>+0</emu-val><sub>𝔽</sub> or <emu-val>-0</emu-val><sub>𝔽</sub>, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Let <var>int</var> be <emu-xref aoid="truncate" id="_ref_2204"><a href="notational-conventions.html#eqn-truncate">truncate</a></emu-xref>(<emu-xref aoid="ℝ" id="_ref_2205"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>number</var>)).</li><li>Let <var>int8bit</var> be <var>int</var> <emu-xref aoid="modulo" id="_ref_2206"><a href="notational-conventions.html#eqn-modulo">modulo</a></emu-xref> 2<sup>8</sup>.</li><li>Return <emu-xref aoid="𝔽" id="_ref_2207"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>int8bit</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-touint8clamp" type="abstract operation" aoid="ToUint8Clamp">
|
||
<h1><span class="secnum">7.1.12</span> ToUint8Clamp ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToUint8Clamp takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2208"><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_2209"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#integral-number" id="_ref_2210"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2211"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It clamps and rounds <var>argument</var> to one of 2<sup>8</sup> <emu-xref href="#integral-number" id="_ref_2212"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> values in the <emu-xref href="#inclusive-interval" id="_ref_2213"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-val>+0</emu-val><sub>𝔽</sub> to <emu-val>255</emu-val><sub>𝔽</sub>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>number</var> be ? <emu-xref aoid="ToNumber" id="_ref_2214"><a href="abstract-operations.html#sec-tonumber" class="e-user-code">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If <var>number</var> is <emu-val>NaN</emu-val>, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Let <var>mv</var> be the <emu-xref href="#extended-mathematical-value-of" id="_ref_2215"><a href="notational-conventions.html#extended-mathematical-value-of">extended mathematical value of</a></emu-xref> <var>number</var>.</li><li>Let <var>clamped</var> be the result of <emu-xref href="#clamping" id="_ref_2216"><a href="notational-conventions.html#clamping">clamping</a></emu-xref> <var>mv</var> between 0 and 255.</li><li>Let <var>f</var> be <emu-xref aoid="floor" id="_ref_2217"><a href="notational-conventions.html#eqn-floor">floor</a></emu-xref>(<var>clamped</var>).</li><li>If <var>clamped</var> < <var>f</var> + 0.5, return <emu-xref aoid="𝔽" id="_ref_2218"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>f</var>).</li><li>If <var>clamped</var> > <var>f</var> + 0.5, return <emu-xref aoid="𝔽" id="_ref_2219"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>f</var> + 1).</li><li>If <var>f</var> is even, return <emu-xref aoid="𝔽" id="_ref_2220"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>f</var>).</li><li>Return <emu-xref aoid="𝔽" id="_ref_2221"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>f</var> + 1).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Unlike most other ECMAScript <emu-xref href="#integer" id="_ref_2222"><a href="notational-conventions.html#integer">integer</a></emu-xref> conversion operations, ToUint8Clamp rounds rather than truncates non-integral values. It also uses “round half to even” tie-breaking, which differs from the “round half up” tie-breaking of <emu-xref href="#sec-math.round" id="_ref_208"><a href="numbers-and-dates.html#sec-math.round"><code>Math.round</code></a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-tobigint" type="abstract operation" aoid="ToBigInt">
|
||
<h1><span class="secnum">7.1.13</span> ToBigInt ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToBigInt takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2223"><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_2224"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a BigInt or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2225"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to a BigInt value, or throws if an implicit conversion from Number would be required. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>prim</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2226"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>argument</var>, <emu-const>number</emu-const>).</li><li>Return the value that <var>prim</var> corresponds to in <emu-xref href="#table-tobigint" id="_ref_209"><a href="abstract-operations.html#table-tobigint">Table 12</a></emu-xref>.</li></ol></emu-alg>
|
||
<emu-table id="table-tobigint" caption="BigInt Conversions"><figure><figcaption>Table 12: BigInt Conversions</figcaption>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>
|
||
Argument Type
|
||
</th>
|
||
<th>
|
||
Result
|
||
</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody><tr>
|
||
<td>
|
||
Undefined
|
||
</td>
|
||
<td>
|
||
Throw a <emu-val>TypeError</emu-val> exception.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
Null
|
||
</td>
|
||
<td>
|
||
Throw a <emu-val>TypeError</emu-val> exception.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
Boolean
|
||
</td>
|
||
<td>
|
||
Return <code>1n</code> if <var>prim</var> is <emu-val>true</emu-val> and <code>0n</code> if <var>prim</var> is <emu-val>false</emu-val>.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
BigInt
|
||
</td>
|
||
<td>
|
||
Return <var>prim</var>.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
Number
|
||
</td>
|
||
<td>
|
||
Throw a <emu-val>TypeError</emu-val> exception.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
String
|
||
</td>
|
||
<td>
|
||
<emu-alg><ol><li>Let <var>n</var> be <emu-xref aoid="StringToBigInt" id="_ref_2227"><a href="abstract-operations.html#sec-stringtobigint">StringToBigInt</a></emu-xref>(<var>prim</var>).</li><li>If <var>n</var> is <emu-val>undefined</emu-val>, throw a <emu-val>SyntaxError</emu-val> exception.</li><li>Return <var>n</var>.</li></ol></emu-alg>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
Symbol
|
||
</td>
|
||
<td>
|
||
Throw a <emu-val>TypeError</emu-val> exception.
|
||
</td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-stringtobigint" type="abstract operation" aoid="StringToBigInt">
|
||
<h1><span class="secnum">7.1.14</span> StringToBigInt ( <var>str</var> )</h1>
|
||
<p>The abstract operation StringToBigInt takes argument <var>str</var> (a String) and returns a BigInt or <emu-val>undefined</emu-val>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>literal</var> be <emu-xref aoid="ParseText" id="_ref_2228"><a href="ecmascript-language-source-code.html#sec-parsetext">ParseText</a></emu-xref>(<var>str</var>, <emu-nt id="_ref_17825"><a href="abstract-operations.html#prod-StringIntegerLiteral">StringIntegerLiteral</a></emu-nt>).</li><li>If <var>literal</var> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2229"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of errors, return <emu-val>undefined</emu-val>.</li><li>Let <var>mv</var> be the MV of <var>literal</var>.</li><li><emu-xref href="#assert" id="_ref_2230"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>mv</var> is an <emu-xref href="#integer" id="_ref_2231"><a href="notational-conventions.html#integer">integer</a></emu-xref>.</li><li>Return <emu-xref aoid="ℤ" id="_ref_2232"><a href="notational-conventions.html#%E2%84%A4">ℤ</a></emu-xref>(<var>mv</var>).</li></ol></emu-alg>
|
||
|
||
<emu-clause id="sec-stringintegerliteral-grammar">
|
||
<h1><span class="secnum">7.1.14.1</span> StringIntegerLiteral Grammar</h1>
|
||
<p><emu-xref aoid="StringToBigInt" id="_ref_2233"><a href="abstract-operations.html#sec-stringtobigint">StringToBigInt</a></emu-xref> uses the following grammar.</p>
|
||
<h2>Syntax</h2>
|
||
<emu-grammar type="definition"><emu-production name="StringIntegerLiteral" type="regexp" id="prod-StringIntegerLiteral">
|
||
<emu-nt><a href="abstract-operations.html#prod-StringIntegerLiteral">StringIntegerLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="mkvpahdu">
|
||
<emu-nt optional="" id="_ref_17826"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="7d2sahst">
|
||
<emu-nt optional="" id="_ref_17827"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_17828"><a href="abstract-operations.html#prod-StrIntegerLiteral">StrIntegerLiteral</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_17829"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
<emu-production name="StrIntegerLiteral" type="regexp" id="prod-StrIntegerLiteral">
|
||
<emu-nt><a href="abstract-operations.html#prod-StrIntegerLiteral">StrIntegerLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="6uygnxlw">
|
||
<emu-nt params="~Sep" id="_ref_17830"><a href="ecmascript-language-lexical-grammar.html#prod-SignedInteger">SignedInteger</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
<emu-rhs a="kidoa90l">
|
||
<emu-nt params="~Sep" id="_ref_17831"><a href="ecmascript-language-lexical-grammar.html#prod-NonDecimalIntegerLiteral">NonDecimalIntegerLiteral</a><emu-mods><emu-params>[~Sep]</emu-params></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-runtime-semantics-mv-for-stringintegerliteral">
|
||
<h1><span class="secnum">7.1.14.2</span> Runtime Semantics: MV</h1>
|
||
<ul>
|
||
<li>
|
||
The MV of <emu-grammar><emu-production name="StringIntegerLiteral" type="regexp" collapsed="" class=" inline">
|
||
<emu-nt><a href="abstract-operations.html#prod-StringIntegerLiteral">StringIntegerLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="mkvpahdu"><emu-nt optional="" id="_ref_17832"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt></emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar> is 0.
|
||
</li>
|
||
<li>
|
||
The MV of <emu-grammar><emu-production name="StringIntegerLiteral" type="regexp" collapsed="" class=" inline">
|
||
<emu-nt><a href="abstract-operations.html#prod-StringIntegerLiteral">StringIntegerLiteral</a></emu-nt> <emu-geq>:::</emu-geq> <emu-rhs a="7d2sahst">
|
||
<emu-nt optional="" id="_ref_17833"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
<emu-nt id="_ref_17834"><a href="abstract-operations.html#prod-StrIntegerLiteral">StrIntegerLiteral</a></emu-nt>
|
||
<emu-nt optional="" id="_ref_17835"><a href="abstract-operations.html#prod-StrWhiteSpace">StrWhiteSpace</a><emu-mods><emu-opt>opt</emu-opt></emu-mods></emu-nt>
|
||
</emu-rhs>
|
||
</emu-production>
|
||
</emu-grammar> is the MV of <emu-nt id="_ref_17836"><a href="abstract-operations.html#prod-StrIntegerLiteral">StrIntegerLiteral</a></emu-nt>.
|
||
</li>
|
||
</ul>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-tobigint64" type="abstract operation" aoid="ToBigInt64">
|
||
<h1><span class="secnum">7.1.15</span> ToBigInt64 ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToBigInt64 takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2234"><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_2235"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a BigInt or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2236"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to one of 2<sup>64</sup> BigInt values in the <emu-xref href="#inclusive-interval" id="_ref_2237"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-xref aoid="ℤ" id="_ref_2238"><a href="notational-conventions.html#%E2%84%A4">ℤ</a></emu-xref>(-2<sup>63</sup>) to <emu-xref aoid="ℤ" id="_ref_2239"><a href="notational-conventions.html#%E2%84%A4">ℤ</a></emu-xref>(2<sup>63</sup> - 1). It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>n</var> be ? <emu-xref aoid="ToBigInt" id="_ref_2240"><a href="abstract-operations.html#sec-tobigint" class="e-user-code">ToBigInt</a></emu-xref>(<var>argument</var>).</li><li>Let <var>int64bit</var> be <emu-xref aoid="ℝ" id="_ref_2241"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>n</var>) <emu-xref aoid="modulo" id="_ref_2242"><a href="notational-conventions.html#eqn-modulo">modulo</a></emu-xref> 2<sup>64</sup>.</li><li>If <var>int64bit</var> ≥ 2<sup>63</sup>, return <emu-xref aoid="ℤ" id="_ref_2243"><a href="notational-conventions.html#%E2%84%A4">ℤ</a></emu-xref>(<var>int64bit</var> - 2<sup>64</sup>).</li><li>Return <emu-xref aoid="ℤ" id="_ref_2244"><a href="notational-conventions.html#%E2%84%A4">ℤ</a></emu-xref>(<var>int64bit</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-tobiguint64" type="abstract operation" aoid="ToBigUint64">
|
||
<h1><span class="secnum">7.1.16</span> ToBigUint64 ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToBigUint64 takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2245"><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_2246"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a BigInt or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2247"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to one of 2<sup>64</sup> BigInt values in the <emu-xref href="#inclusive-interval" id="_ref_2248"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from <emu-val>0</emu-val><sub>ℤ</sub> to <emu-xref aoid="ℤ" id="_ref_2249"><a href="notational-conventions.html#%E2%84%A4">ℤ</a></emu-xref>(2<sup>64</sup> - 1). It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>n</var> be ? <emu-xref aoid="ToBigInt" id="_ref_2250"><a href="abstract-operations.html#sec-tobigint" class="e-user-code">ToBigInt</a></emu-xref>(<var>argument</var>).</li><li>Let <var>int64bit</var> be <emu-xref aoid="ℝ" id="_ref_2251"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>n</var>) <emu-xref aoid="modulo" id="_ref_2252"><a href="notational-conventions.html#eqn-modulo">modulo</a></emu-xref> 2<sup>64</sup>.</li><li>Return <emu-xref aoid="ℤ" id="_ref_2253"><a href="notational-conventions.html#%E2%84%A4">ℤ</a></emu-xref>(<var>int64bit</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-tostring" oldids="table-tostring-conversions" type="abstract operation" aoid="ToString"><span id="table-tostring-conversions"></span>
|
||
<h1><span class="secnum">7.1.17</span> ToString ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToString takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2254"><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_2255"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a String or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2256"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to a value of type String. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2257"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, return <var>argument</var>.</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_2258"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>argument</var> is <emu-val>undefined</emu-val>, return <emu-val>"undefined"</emu-val>.</li><li>If <var>argument</var> is <emu-val>null</emu-val>, return <emu-val>"null"</emu-val>.</li><li>If <var>argument</var> is <emu-val>true</emu-val>, return <emu-val>"true"</emu-val>.</li><li>If <var>argument</var> is <emu-val>false</emu-val>, return <emu-val>"false"</emu-val>.</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2259"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, return <emu-xref aoid="Number::toString" id="_ref_2260"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-number-tostring">Number::toString</a></emu-xref>(<var>argument</var>, 10).</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2261"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, return <emu-xref aoid="BigInt::toString" id="_ref_2262"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-bigint-tostring">BigInt::toString</a></emu-xref>(<var>argument</var>, 10).</li><li><emu-xref href="#assert" id="_ref_2263"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>argument</var> <emu-xref href="#sec-object-type" id="_ref_2264"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>.</li><li>Let <var>primValue</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2265"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>argument</var>, <emu-const>string</emu-const>).</li><li><emu-xref href="#assert" id="_ref_2266"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>primValue</var> <emu-xref href="#sec-object-type" id="_ref_2267"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>.</li><li>Return ? <emu-xref aoid="ToString" id="_ref_2268"><a href="abstract-operations.html#sec-tostring" class="e-user-code">ToString</a></emu-xref>(<var>primValue</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-toobject" type="abstract operation" oldids="table-toobject-conversions,table-13" aoid="ToObject"><span id="table-13"></span><span id="table-toobject-conversions"></span>
|
||
<h1><span class="secnum">7.1.18</span> ToObject ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToObject takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2269"><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_2270"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an Object or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2271"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to a value of type Object. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argument</var> is either <emu-val>undefined</emu-val> or <emu-val>null</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type" id="_ref_2272"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-boolean-type">is a Boolean</a></emu-xref>, return a new Boolean object whose <var class="field">[[BooleanData]]</var> internal slot is set to <var>argument</var>. See <emu-xref href="#sec-boolean-objects" id="_ref_210"><a href="fundamental-objects.html#sec-boolean-objects">20.3</a></emu-xref> for a description of Boolean objects.</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2273"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, return a new Number object whose <var class="field">[[NumberData]]</var> internal slot is set to <var>argument</var>. See <emu-xref href="#sec-number-objects" id="_ref_211"><a href="numbers-and-dates.html#sec-number-objects">21.1</a></emu-xref> for a description of Number objects.</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2274"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, return a new String object whose <var class="field">[[StringData]]</var> internal slot is set to <var>argument</var>. See <emu-xref href="#sec-string-objects" id="_ref_212"><a href="text-processing.html#sec-string-objects">22.1</a></emu-xref> for a description of String objects.</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_2275"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref>, return a new Symbol object whose <var class="field">[[SymbolData]]</var> internal slot is set to <var>argument</var>. See <emu-xref href="#sec-symbol-objects" id="_ref_213"><a href="fundamental-objects.html#sec-symbol-objects">20.4</a></emu-xref> for a description of Symbol objects.</li><li>If <var>argument</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2276"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, return a new BigInt object whose <var class="field">[[BigIntData]]</var> internal slot is set to <var>argument</var>. See <emu-xref href="#sec-bigint-objects" id="_ref_214"><a href="numbers-and-dates.html#sec-bigint-objects">21.2</a></emu-xref> for a description of BigInt objects.</li><li><emu-xref href="#assert" id="_ref_2277"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>argument</var> <emu-xref href="#sec-object-type" id="_ref_2278"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>.</li><li>Return <var>argument</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-topropertykey" type="abstract operation" aoid="ToPropertyKey">
|
||
<h1><span class="secnum">7.1.19</span> ToPropertyKey ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToPropertyKey takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2279"><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_2280"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#property-key" id="_ref_2281"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2282"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>argument</var> to a value that can be used as a <emu-xref href="#property-key" id="_ref_2283"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>key</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2284"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>argument</var>, <emu-const>string</emu-const>).</li><li>If <var>key</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_2285"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref>, then<ol><li>Return <var>key</var>.</li></ol></li><li>Return ! <emu-xref aoid="ToString" id="_ref_2286"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<var>key</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-tolength" type="abstract operation" aoid="ToLength">
|
||
<h1><span class="secnum">7.1.20</span> ToLength ( <var>argument</var> )</h1>
|
||
<p>The abstract operation ToLength takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2287"><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_2288"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a non-negative <emu-xref href="#integral-number" id="_ref_2289"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2290"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It clamps and truncates <var>argument</var> to a non-negative <emu-xref href="#integral-number" id="_ref_2291"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref> suitable for use as the length of an <emu-xref href="#sec-lengthofarraylike" id="_ref_2292"><a href="abstract-operations.html#sec-lengthofarraylike">array-like object</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>len</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_2293"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>argument</var>).</li><li>If <var>len</var> ≤ 0, return <emu-val>+0</emu-val><sub>𝔽</sub>.</li><li>Return <emu-xref aoid="𝔽" id="_ref_2294"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<emu-xref aoid="min" id="_ref_2295"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>len</var>, 2<sup>53</sup> - 1)).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-canonicalnumericindexstring" type="abstract operation" aoid="CanonicalNumericIndexString">
|
||
<h1><span class="secnum">7.1.21</span> CanonicalNumericIndexString ( <var>argument</var> )</h1>
|
||
<p>The abstract operation CanonicalNumericIndexString takes argument <var>argument</var> (a String) and returns a Number or <emu-val>undefined</emu-val>. If <var>argument</var> is either <emu-val>"-0"</emu-val> or exactly matches <emu-xref aoid="ToString" id="_ref_2296"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<var>n</var>) for some Number value <var>n</var>, it returns the respective Number value. Otherwise, it returns <emu-val>undefined</emu-val>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argument</var> is <emu-val>"-0"</emu-val>, return <emu-val>-0</emu-val><sub>𝔽</sub>.</li><li>Let <var>n</var> be ! <emu-xref aoid="ToNumber" id="_ref_2297"><a href="abstract-operations.html#sec-tonumber">ToNumber</a></emu-xref>(<var>argument</var>).</li><li>If ! <emu-xref aoid="ToString" id="_ref_2298"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<var>n</var>) is <var>argument</var>, return <var>n</var>.</li><li>Return <emu-val>undefined</emu-val>.</li></ol></emu-alg>
|
||
<p>A <dfn variants="canonical numeric strings" tabindex="-1">canonical numeric string</dfn> is any String for which the CanonicalNumericIndexString abstract operation does not return <emu-val>undefined</emu-val>.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-toindex" type="abstract operation" aoid="ToIndex">
|
||
<h1><span class="secnum">7.1.22</span> ToIndex ( <var>value</var> )</h1>
|
||
<p>The abstract operation ToIndex takes argument <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2299"><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_2300"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a non-negative <emu-xref href="#integer" id="_ref_2301"><a href="notational-conventions.html#integer">integer</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2302"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It converts <var>value</var> to an <emu-xref href="#integer" id="_ref_2303"><a href="notational-conventions.html#integer">integer</a></emu-xref> and returns that <emu-xref href="#integer" id="_ref_2304"><a href="notational-conventions.html#integer">integer</a></emu-xref> if it is non-negative and corresponds with an <emu-xref href="#integer-index" id="_ref_2305"><a href="ecmascript-data-types-and-values.html#integer-index">integer index</a></emu-xref>. Otherwise, it throws an exception. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>integer</var> be ? <emu-xref aoid="ToIntegerOrInfinity" id="_ref_2306"><a href="abstract-operations.html#sec-tointegerorinfinity" class="e-user-code">ToIntegerOrInfinity</a></emu-xref>(<var>value</var>).</li><li>If <var>integer</var> is not in the <emu-xref href="#inclusive-interval" id="_ref_2307"><a href="notational-conventions.html#inclusive-interval">inclusive interval</a></emu-xref> from 0 to 2<sup>53</sup> - 1, throw a <emu-val>RangeError</emu-val> exception.</li><li>Return <var>integer</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-testing-and-comparison-operations">
|
||
<h1><span class="secnum">7.2</span> Testing and Comparison Operations</h1>
|
||
|
||
<emu-clause id="sec-requireobjectcoercible" type="abstract operation" oldids="table-requireobjectcoercible-results,table-14" aoid="RequireObjectCoercible"><span id="table-14"></span><span id="table-requireobjectcoercible-results"></span>
|
||
<h1><span class="secnum">7.2.1</span> RequireObjectCoercible ( <var>argument</var> )</h1>
|
||
<p>The abstract operation RequireObjectCoercible takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2308"><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_2309"><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_2310"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It throws an error if <var>argument</var> is a value that cannot be converted to an Object using <emu-xref aoid="ToObject" id="_ref_2311"><a href="abstract-operations.html#sec-toobject">ToObject</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argument</var> is either <emu-val>undefined</emu-val> or <emu-val>null</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-isarray" type="abstract operation" aoid="IsArray">
|
||
<h1><span class="secnum">7.2.2</span> IsArray ( <var>argument</var> )</h1>
|
||
<p>The abstract operation IsArray takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2312"><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_2313"><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_2314"><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>argument</var> <emu-xref href="#sec-object-type" id="_ref_2315"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, return <emu-val>false</emu-val>.</li><li>If <var>argument</var> is an <emu-xref href="#array-exotic-object" id="_ref_2316"><a href="ordinary-and-exotic-objects-behaviours.html#array-exotic-object">Array exotic object</a></emu-xref>, return <emu-val>true</emu-val>.</li><li>If <var>argument</var> is a <emu-xref href="#proxy-exotic-object" id="_ref_2317"><a href="ordinary-and-exotic-objects-behaviours.html#proxy-exotic-object">Proxy exotic object</a></emu-xref>, then<ol><li>Perform ? <emu-xref aoid="ValidateNonRevokedProxy" id="_ref_2318"><a href="ordinary-and-exotic-objects-behaviours.html#sec-validatenonrevokedproxy">ValidateNonRevokedProxy</a></emu-xref>(<var>argument</var>).</li><li>Let <var>proxyTarget</var> be <var>argument</var>.<var class="field">[[ProxyTarget]]</var>.</li><li>Return ? <emu-xref aoid="IsArray" id="_ref_2319"><a href="abstract-operations.html#sec-isarray">IsArray</a></emu-xref>(<var>proxyTarget</var>).</li></ol></li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iscallable" type="abstract operation" aoid="IsCallable">
|
||
<h1><span class="secnum">7.2.3</span> IsCallable ( <var>argument</var> )</h1>
|
||
<p>The abstract operation IsCallable takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2320"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a Boolean. It determines if <var>argument</var> is a callable function with a <var class="field">[[Call]]</var> internal method. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argument</var> <emu-xref href="#sec-object-type" id="_ref_2321"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, return <emu-val>false</emu-val>.</li><li>If <var>argument</var> has a <var class="field">[[Call]]</var> internal method, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-isconstructor" type="abstract operation" aoid="IsConstructor">
|
||
<h1><span class="secnum">7.2.4</span> IsConstructor ( <var>argument</var> )</h1>
|
||
<p>The abstract operation IsConstructor takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2322"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a Boolean. It determines if <var>argument</var> is a <emu-xref href="#function-object" id="_ref_2323"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> with a <var class="field">[[Construct]]</var> internal method. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argument</var> <emu-xref href="#sec-object-type" id="_ref_2324"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, return <emu-val>false</emu-val>.</li><li>If <var>argument</var> has a <var class="field">[[Construct]]</var> internal method, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-isextensible-o" type="abstract operation" aoid="IsExtensible">
|
||
<h1><span class="secnum">7.2.5</span> IsExtensible ( <var>O</var> )</h1>
|
||
<p>The abstract operation IsExtensible takes argument <var>O</var> (an Object) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2325"><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_2326"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to determine whether additional properties can be added to <var>O</var>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return ? <span class="e-user-code"><var>O</var>.<var class="field">[[IsExtensible]]</var>()</span>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-isregexp" type="abstract operation" aoid="IsRegExp">
|
||
<h1><span class="secnum">7.2.6</span> IsRegExp ( <var>argument</var> )</h1>
|
||
<p>The abstract operation IsRegExp takes argument <var>argument</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2327"><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_2328"><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_2329"><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>argument</var> <emu-xref href="#sec-object-type" id="_ref_2330"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, return <emu-val>false</emu-val>.</li><li>Let <var>matcher</var> be ? <emu-xref aoid="Get" id="_ref_2331"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>argument</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_2332"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.match%</a></emu-xref>).</li><li>If <var>matcher</var> is not <emu-val>undefined</emu-val>, return <emu-xref aoid="ToBoolean" id="_ref_2333"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(<var>matcher</var>).</li><li>If <var>argument</var> has a <var class="field">[[RegExpMatcher]]</var> internal slot, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-isstringwellformedunicode" type="abstract operation" aoid="IsStringWellFormedUnicode">
|
||
<h1><span class="secnum">7.2.7</span> Static Semantics: IsStringWellFormedUnicode ( <var>string</var> )</h1>
|
||
<p>The abstract operation IsStringWellFormedUnicode takes argument <var>string</var> (a String) and returns a Boolean. It interprets <var>string</var> as a sequence of UTF-16 encoded code points, as described in <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_215"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">6.1.4</a></emu-xref>, and determines whether it is a <a href="http://www.unicode.org/glossary/#well_formed_code_unit_sequence">well formed</a> UTF-16 sequence. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>len</var> be the length of <var>string</var>.</li><li>Let <var>k</var> be 0.</li><li>Repeat, while <var>k</var> < <var>len</var>,<ol><li>Let <var>cp</var> be <emu-xref aoid="CodePointAt" id="_ref_2334"><a href="ecmascript-language-source-code.html#sec-codepointat">CodePointAt</a></emu-xref>(<var>string</var>, <var>k</var>).</li><li>If <var>cp</var>.<var class="field">[[IsUnpairedSurrogate]]</var> is <emu-val>true</emu-val>, return <emu-val>false</emu-val>.</li><li>Set <var>k</var> to <var>k</var> + <var>cp</var>.<var class="field">[[CodeUnitCount]]</var>.</li></ol></li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-sametype" type="abstract operation" aoid="SameType">
|
||
<h1><span class="secnum">7.2.8</span> SameType ( <var>x</var>, <var>y</var> )</h1>
|
||
<p>The abstract operation SameType takes arguments <var>x</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2335"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>y</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2336"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a Boolean. It determines whether or not the two arguments are the same type. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>x</var> is <emu-val>undefined</emu-val> and <var>y</var> is <emu-val>undefined</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> is <emu-val>null</emu-val> and <var>y</var> is <emu-val>null</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type" id="_ref_2337"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-boolean-type">is a Boolean</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type" id="_ref_2338"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-boolean-type">is a Boolean</a></emu-xref>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2339"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2340"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2341"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2342"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_2343"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_2344"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2345"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2346"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-object-type" id="_ref_2347"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref> and <var>y</var> <emu-xref href="#sec-object-type" id="_ref_2348"><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>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-samevalue" type="abstract operation" aoid="SameValue">
|
||
<h1><span class="secnum">7.2.9</span> SameValue ( <var>x</var>, <var>y</var> )</h1>
|
||
<p>The abstract operation SameValue takes arguments <var>x</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2349"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>y</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2350"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a Boolean. It determines whether or not the two arguments are the same value. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <emu-xref aoid="SameType" id="_ref_2351"><a href="abstract-operations.html#sec-sametype">SameType</a></emu-xref>(<var>x</var>, <var>y</var>) is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2352"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, then<ol><li>Return <emu-xref aoid="Number::sameValue" id="_ref_2353"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-number-sameValue">Number::sameValue</a></emu-xref>(<var>x</var>, <var>y</var>).</li></ol></li><li>Return <emu-xref aoid="SameValueNonNumber" id="_ref_2354"><a href="abstract-operations.html#sec-samevaluenonnumber">SameValueNonNumber</a></emu-xref>(<var>x</var>, <var>y</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This algorithm differs from the <emu-xref aoid="IsStrictlyEqual" id="_ref_2355"><a href="abstract-operations.html#sec-isstrictlyequal">IsStrictlyEqual</a></emu-xref> Algorithm by treating all <emu-val>NaN</emu-val> values as equivalent and by differentiating <emu-val>+0</emu-val><sub>𝔽</sub> from <emu-val>-0</emu-val><sub>𝔽</sub>.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-samevaluezero" type="abstract operation" aoid="SameValueZero">
|
||
<h1><span class="secnum">7.2.10</span> SameValueZero ( <var>x</var>, <var>y</var> )</h1>
|
||
<p>The abstract operation SameValueZero takes arguments <var>x</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2356"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>y</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2357"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a Boolean. It determines whether or not the two arguments are the same value (ignoring the difference between <emu-val>+0</emu-val><sub>𝔽</sub> and <emu-val>-0</emu-val><sub>𝔽</sub>). It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <emu-xref aoid="SameType" id="_ref_2358"><a href="abstract-operations.html#sec-sametype">SameType</a></emu-xref>(<var>x</var>, <var>y</var>) is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2359"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, then<ol><li>Return <emu-xref aoid="Number::sameValueZero" id="_ref_2360"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-number-sameValueZero">Number::sameValueZero</a></emu-xref>(<var>x</var>, <var>y</var>).</li></ol></li><li>Return <emu-xref aoid="SameValueNonNumber" id="_ref_2361"><a href="abstract-operations.html#sec-samevaluenonnumber">SameValueNonNumber</a></emu-xref>(<var>x</var>, <var>y</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>SameValueZero differs from <emu-xref aoid="SameValue" id="_ref_2362"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref> only in that it treats <emu-val>+0</emu-val><sub>𝔽</sub> and <emu-val>-0</emu-val><sub>𝔽</sub> as equivalent.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-samevaluenonnumber" type="abstract operation" oldids="sec-samevaluenonnumeric" aoid="SameValueNonNumber"><span id="sec-samevaluenonnumeric"></span>
|
||
<h1><span class="secnum">7.2.11</span> SameValueNonNumber ( <var>x</var>, <var>y</var> )</h1>
|
||
<p>The abstract operation SameValueNonNumber takes arguments <var>x</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2363"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>, but not a Number) and <var>y</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2364"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>, but not a Number) and returns a Boolean. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_2365"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <emu-xref aoid="SameType" id="_ref_2366"><a href="abstract-operations.html#sec-sametype">SameType</a></emu-xref>(<var>x</var>, <var>y</var>) is <emu-val>true</emu-val>.</li><li>If <var>x</var> is either <emu-val>undefined</emu-val> or <emu-val>null</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2367"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, then<ol><li>Return <emu-xref aoid="BigInt::equal" id="_ref_2368"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-bigint-equal">BigInt::equal</a></emu-xref>(<var>x</var>, <var>y</var>).</li></ol></li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2369"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, then<ol><li>If <var>x</var> and <var>y</var> have the same length and the same code units in the same positions, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type" id="_ref_2370"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-boolean-type">is a Boolean</a></emu-xref>, then<ol><li>If <var>x</var> and <var>y</var> are both <emu-val>true</emu-val> or both <emu-val>false</emu-val>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></li><li>NOTE: All other <emu-xref href="#sec-ecmascript-language-types" id="_ref_2371"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref> are compared by identity.</li><li>If <var>x</var> is <var>y</var>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
For expository purposes, some cases are handled separately within this algorithm even if it is unnecessary to do so.
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
The specifics of what "<var>x</var> is <var>y</var>" means are detailed in <emu-xref href="#sec-identity" id="_ref_216"><a href="notational-conventions.html#sec-identity">5.2.8</a></emu-xref>.
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-islessthan" type="abstract operation" oldids="sec-abstract-relational-comparison" aoid="IsLessThan"><span id="sec-abstract-relational-comparison"></span>
|
||
<h1><span class="secnum">7.2.12</span> IsLessThan ( <var>x</var>, <var>y</var>, <var>LeftFirst</var> )</h1>
|
||
<p>The abstract operation IsLessThan takes arguments <var>x</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2372"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), <var>y</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2373"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>LeftFirst</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2374"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either a Boolean or <emu-val>undefined</emu-val>, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2375"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It provides the semantics for the comparison <var>x</var> < <var>y</var>, returning <emu-val>true</emu-val>, <emu-val>false</emu-val>, or <emu-val>undefined</emu-val> (which indicates that at least one operand is <emu-val>NaN</emu-val>). The <var>LeftFirst</var> flag is used to control the order in which operations with potentially visible side-effects are performed upon <var>x</var> and <var>y</var>. It is necessary because ECMAScript specifies left to right evaluation of expressions. If <var>LeftFirst</var> is <emu-val>true</emu-val>, the <var>x</var> parameter corresponds to an expression that occurs to the left of the <var>y</var> parameter's corresponding expression. If <var>LeftFirst</var> is <emu-val>false</emu-val>, the reverse is the case and operations must be performed upon <var>y</var> before <var>x</var>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>LeftFirst</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>px</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2376"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>x</var>, <emu-const>number</emu-const>).</li><li>Let <var>py</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2377"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>y</var>, <emu-const>number</emu-const>).</li></ol></li><li>Else,<ol><li>NOTE: The order of evaluation needs to be reversed to preserve left to right evaluation.</li><li>Let <var>py</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2378"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>y</var>, <emu-const>number</emu-const>).</li><li>Let <var>px</var> be ? <emu-xref aoid="ToPrimitive" id="_ref_2379"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>x</var>, <emu-const>number</emu-const>).</li></ol></li><li id="step-arc-string-check">If <var>px</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2380"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> and <var>py</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2381"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, then<ol><li>Let <var>lx</var> be the length of <var>px</var>.</li><li>Let <var>ly</var> be the length of <var>py</var>.</li><li>For each <emu-xref href="#integer" id="_ref_2382"><a href="notational-conventions.html#integer">integer</a></emu-xref> <var>i</var> such that 0 ≤ <var>i</var> < <emu-xref aoid="min" id="_ref_2383"><a href="notational-conventions.html#eqn-min">min</a></emu-xref>(<var>lx</var>, <var>ly</var>), in ascending order, do<ol><li>Let <var>cx</var> be the numeric value of the code unit at index <var>i</var> within <var>px</var>.</li><li>Let <var>cy</var> be the numeric value of the code unit at index <var>i</var> within <var>py</var>.</li><li>If <var>cx</var> < <var>cy</var>, return <emu-val>true</emu-val>.</li><li>If <var>cx</var> > <var>cy</var>, return <emu-val>false</emu-val>.</li></ol></li><li>If <var>lx</var> < <var>ly</var>, return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></li><li>If <var>px</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2384"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref> and <var>py</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2385"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, then<ol><li>Let <var>ny</var> be <emu-xref aoid="StringToBigInt" id="_ref_2386"><a href="abstract-operations.html#sec-stringtobigint">StringToBigInt</a></emu-xref>(<var>py</var>).</li><li>If <var>ny</var> is <emu-val>undefined</emu-val>, return <emu-val>undefined</emu-val>.</li><li>Return <emu-xref aoid="BigInt::lessThan" id="_ref_2387"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-bigint-lessThan">BigInt::lessThan</a></emu-xref>(<var>px</var>, <var>ny</var>).</li></ol></li><li>If <var>px</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2388"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> and <var>py</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2389"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, then<ol><li>Let <var>nx</var> be <emu-xref aoid="StringToBigInt" id="_ref_2390"><a href="abstract-operations.html#sec-stringtobigint">StringToBigInt</a></emu-xref>(<var>px</var>).</li><li>If <var>nx</var> is <emu-val>undefined</emu-val>, return <emu-val>undefined</emu-val>.</li><li>Return <emu-xref aoid="BigInt::lessThan" id="_ref_2391"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-bigint-lessThan">BigInt::lessThan</a></emu-xref>(<var>nx</var>, <var>py</var>).</li></ol></li><li>NOTE: Because <var>px</var> and <var>py</var> are primitive values, evaluation order is not important.</li><li>Let <var>nx</var> be ? <emu-xref aoid="ToNumeric" id="_ref_2392"><a href="abstract-operations.html#sec-tonumeric">ToNumeric</a></emu-xref>(<var>px</var>).</li><li>Let <var>ny</var> be ? <emu-xref aoid="ToNumeric" id="_ref_2393"><a href="abstract-operations.html#sec-tonumeric">ToNumeric</a></emu-xref>(<var>py</var>).</li><li>If <emu-xref aoid="SameType" id="_ref_2394"><a href="abstract-operations.html#sec-sametype">SameType</a></emu-xref>(<var>nx</var>, <var>ny</var>) is <emu-val>true</emu-val>, then<ol><li>If <var>nx</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2395"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, return <emu-xref aoid="Number::lessThan" id="_ref_2396"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-number-lessThan">Number::lessThan</a></emu-xref>(<var>nx</var>, <var>ny</var>).</li><li><emu-xref href="#assert" id="_ref_2397"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>nx</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2398"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>.</li><li>Return <emu-xref aoid="BigInt::lessThan" id="_ref_2399"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-bigint-lessThan">BigInt::lessThan</a></emu-xref>(<var>nx</var>, <var>ny</var>).</li></ol></li><li><emu-xref href="#assert" id="_ref_2400"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>nx</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2401"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref> and <var>ny</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2402"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, or <var>nx</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2403"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref> and <var>ny</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2404"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>.</li><li>If <var>nx</var> or <var>ny</var> is <emu-val>NaN</emu-val>, return <emu-val>undefined</emu-val>.</li><li>If <var>nx</var> is <emu-val>-∞</emu-val><sub>𝔽</sub> or <var>ny</var> is <emu-val>+∞</emu-val><sub>𝔽</sub>, return <emu-val>true</emu-val>.</li><li>If <var>nx</var> is <emu-val>+∞</emu-val><sub>𝔽</sub> or <var>ny</var> is <emu-val>-∞</emu-val><sub>𝔽</sub>, return <emu-val>false</emu-val>.</li><li>If <emu-xref aoid="ℝ" id="_ref_2405"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>nx</var>) < <emu-xref aoid="ℝ" id="_ref_2406"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>ny</var>), return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>Step <emu-xref href="#step-arc-string-check" id="_ref_217"><a href="abstract-operations.html#step-arc-string-check">3</a></emu-xref> differs from step <emu-xref href="#step-binary-op-string-check" id="_ref_218"><a href="ecmascript-language-expressions.html#step-binary-op-string-check">1.c</a></emu-xref> in the algorithm that handles the addition operator <code>+</code> (<emu-xref href="#sec-applystringornumericbinaryoperator" id="_ref_219"><a href="ecmascript-language-expressions.html#sec-applystringornumericbinaryoperator">13.15.3</a></emu-xref>) by using the logical-and operation instead of the logical-or operation.</p>
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>The comparison of Strings uses a simple lexicographic ordering on sequences of UTF-16 code unit values. There is no attempt to use the more complex, semantically oriented definitions of character or string equality and collating order defined in the Unicode specification. Therefore String values that are canonically equal according to the Unicode Standard but not in the same normalization form could test as unequal. Also note that lexicographic ordering by <em>code unit</em> differs from ordering by <em>code point</em> for Strings containing <emu-xref href="#surrogate-pair" id="_ref_2407"><a href="ecmascript-data-types-and-values.html#surrogate-pair">surrogate pairs</a></emu-xref>.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-islooselyequal" type="abstract operation" oldids="sec-abstract-equality-comparison,sec-IsHTMLDDA-internal-slot-aec" aoid="IsLooselyEqual"><span id="sec-IsHTMLDDA-internal-slot-aec"></span><span id="sec-abstract-equality-comparison"></span>
|
||
<h1><span class="secnum">7.2.13</span> IsLooselyEqual ( <var>x</var>, <var>y</var> )</h1>
|
||
<p>The abstract operation IsLooselyEqual takes arguments <var>x</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2408"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>y</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2409"><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_2410"><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_2411"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It provides the semantics for the <code>==</code> operator. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <emu-xref aoid="SameType" id="_ref_2413"><a href="abstract-operations.html#sec-sametype">SameType</a></emu-xref>(<var>x</var>, <var>y</var>) is <emu-val>true</emu-val>, then<ol><li>Return <emu-xref aoid="IsStrictlyEqual" id="_ref_2414"><a href="abstract-operations.html#sec-isstrictlyequal">IsStrictlyEqual</a></emu-xref>(<var>x</var>, <var>y</var>).</li></ol></li><li>If <var>x</var> is <emu-val>null</emu-val> and <var>y</var> is <emu-val>undefined</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> is <emu-val>undefined</emu-val> and <var>y</var> is <emu-val>null</emu-val>, return <emu-val>true</emu-val>.</li><li id="step-abstract-equality-comparison-web-compat-insertion-point" normative-optional=""><div class="attributes-tag"><emu-xref href="#sec-conformance" id="_ref_2412"><a href="conformance.html#sec-conformance">Normative Optional</a></emu-xref></div>If the <emu-xref href="#host" id="_ref_2415"><a href="overview.html#host">host</a></emu-xref> is a web browser or otherwise supports <emu-xref href="#sec-IsHTMLDDA-internal-slot" title="" id="_ref_220"><a href="additional-ecmascript-features-for-web-browsers.html#sec-IsHTMLDDA-internal-slot">The <var class="field">[[IsHTMLDDA]]</var> Internal Slot</a></emu-xref>, then<ol><li>If <var>x</var> <emu-xref href="#sec-object-type" id="_ref_2416"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, <var>x</var> has an <var class="field">[[IsHTMLDDA]]</var> internal slot, and <var>y</var> is either <emu-val>undefined</emu-val> or <emu-val>null</emu-val>, return <emu-val>true</emu-val>.</li><li>If <var>x</var> is either <emu-val>undefined</emu-val> or <emu-val>null</emu-val>, <var>y</var> <emu-xref href="#sec-object-type" id="_ref_2417"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, and <var>y</var> has an <var class="field">[[IsHTMLDDA]]</var> internal slot, return <emu-val>true</emu-val>.</li></ol></li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2418"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2419"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, return ! <emu-xref aoid="IsLooselyEqual" id="_ref_2420"><a href="abstract-operations.html#sec-islooselyequal">IsLooselyEqual</a></emu-xref>(<var>x</var>, ! <emu-xref aoid="ToNumber" id="_ref_2421"><a href="abstract-operations.html#sec-tonumber">ToNumber</a></emu-xref>(<var>y</var>)).</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2422"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2423"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, return ! <emu-xref aoid="IsLooselyEqual" id="_ref_2424"><a href="abstract-operations.html#sec-islooselyequal">IsLooselyEqual</a></emu-xref>(! <emu-xref aoid="ToNumber" id="_ref_2425"><a href="abstract-operations.html#sec-tonumber">ToNumber</a></emu-xref>(<var>x</var>), <var>y</var>).</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2426"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2427"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, then<ol><li>Let <var>n</var> be <emu-xref aoid="StringToBigInt" id="_ref_2428"><a href="abstract-operations.html#sec-stringtobigint">StringToBigInt</a></emu-xref>(<var>y</var>).</li><li>If <var>n</var> is <emu-val>undefined</emu-val>, return <emu-val>false</emu-val>.</li><li>Return ! <emu-xref aoid="IsLooselyEqual" id="_ref_2429"><a href="abstract-operations.html#sec-islooselyequal">IsLooselyEqual</a></emu-xref>(<var>x</var>, <var>n</var>).</li></ol></li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2430"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2431"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, return ! <emu-xref aoid="IsLooselyEqual" id="_ref_2432"><a href="abstract-operations.html#sec-islooselyequal">IsLooselyEqual</a></emu-xref>(<var>y</var>, <var>x</var>).</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type" id="_ref_2433"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-boolean-type">is a Boolean</a></emu-xref>, return ! <emu-xref aoid="IsLooselyEqual" id="_ref_2434"><a href="abstract-operations.html#sec-islooselyequal">IsLooselyEqual</a></emu-xref>(! <emu-xref aoid="ToNumber" id="_ref_2435"><a href="abstract-operations.html#sec-tonumber">ToNumber</a></emu-xref>(<var>x</var>), <var>y</var>).</li><li>If <var>y</var> <emu-xref href="#sec-ecmascript-language-types-boolean-type" id="_ref_2436"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-boolean-type">is a Boolean</a></emu-xref>, return ! <emu-xref aoid="IsLooselyEqual" id="_ref_2437"><a href="abstract-operations.html#sec-islooselyequal">IsLooselyEqual</a></emu-xref>(<var>x</var>, ! <emu-xref aoid="ToNumber" id="_ref_2438"><a href="abstract-operations.html#sec-tonumber">ToNumber</a></emu-xref>(<var>y</var>)).</li><li>If <var>x</var> is either a String, a Number, a BigInt, or a Symbol and <var>y</var> <emu-xref href="#sec-object-type" id="_ref_2439"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, return ! <emu-xref aoid="IsLooselyEqual" id="_ref_2440"><a href="abstract-operations.html#sec-islooselyequal">IsLooselyEqual</a></emu-xref>(<var>x</var>, ? <emu-xref aoid="ToPrimitive" id="_ref_2441"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>y</var>)).</li><li>If <var>x</var> <emu-xref href="#sec-object-type" id="_ref_2442"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref> and <var>y</var> is either a String, a Number, a BigInt, or a Symbol, return ! <emu-xref aoid="IsLooselyEqual" id="_ref_2443"><a href="abstract-operations.html#sec-islooselyequal">IsLooselyEqual</a></emu-xref>(? <emu-xref aoid="ToPrimitive" id="_ref_2444"><a href="abstract-operations.html#sec-toprimitive" class="e-user-code">ToPrimitive</a></emu-xref>(<var>x</var>), <var>y</var>).</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2445"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2446"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, or if <var>x</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2447"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref> and <var>y</var> <emu-xref href="#sec-ecmascript-language-types-bigint-type" id="_ref_2448"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-bigint-type">is a BigInt</a></emu-xref>, then<ol><li>If <var>x</var> is not <emu-xref href="#finite" id="_ref_2449"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref> or <var>y</var> is not <emu-xref href="#finite" id="_ref_2450"><a href="ecmascript-data-types-and-values.html#finite">finite</a></emu-xref>, return <emu-val>false</emu-val>.</li><li>If <emu-xref aoid="ℝ" id="_ref_2451"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>x</var>) = <emu-xref aoid="ℝ" id="_ref_2452"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(<var>y</var>), return <emu-val>true</emu-val>.</li><li>Return <emu-val>false</emu-val>.</li></ol></li><li>Return <emu-val>false</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-isstrictlyequal" type="abstract operation" oldids="sec-strict-equality-comparison" aoid="IsStrictlyEqual"><span id="sec-strict-equality-comparison"></span>
|
||
<h1><span class="secnum">7.2.14</span> IsStrictlyEqual ( <var>x</var>, <var>y</var> )</h1>
|
||
<p>The abstract operation IsStrictlyEqual takes arguments <var>x</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2453"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>y</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2454"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns a Boolean. It provides the semantics for the <code>===</code> operator. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <emu-xref aoid="SameType" id="_ref_2455"><a href="abstract-operations.html#sec-sametype">SameType</a></emu-xref>(<var>x</var>, <var>y</var>) is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>If <var>x</var> <emu-xref href="#sec-ecmascript-language-types-number-type" id="_ref_2456"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-number-type">is a Number</a></emu-xref>, then<ol><li>Return <emu-xref aoid="Number::equal" id="_ref_2457"><a href="ecmascript-data-types-and-values.html#sec-numeric-types-number-equal">Number::equal</a></emu-xref>(<var>x</var>, <var>y</var>).</li></ol></li><li>Return <emu-xref aoid="SameValueNonNumber" id="_ref_2458"><a href="abstract-operations.html#sec-samevaluenonnumber">SameValueNonNumber</a></emu-xref>(<var>x</var>, <var>y</var>).</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This algorithm differs from the <emu-xref aoid="SameValue" id="_ref_2459"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref> Algorithm in its treatment of signed zeroes and NaNs.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-operations-on-objects">
|
||
<h1><span class="secnum">7.3</span> Operations on Objects</h1>
|
||
|
||
<emu-clause id="sec-makebasicobject" type="abstract operation" aoid="MakeBasicObject">
|
||
<h1><span class="secnum">7.3.1</span> MakeBasicObject ( <var>internalSlotsList</var> )</h1>
|
||
<p>The abstract operation MakeBasicObject takes argument <var>internalSlotsList</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2460"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of internal slot names) and returns an Object. It is the source of all ECMAScript objects that are created algorithmically, including both <emu-xref href="#ordinary-object" id="_ref_2461"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary objects</a></emu-xref> and <emu-xref href="#exotic-object" id="_ref_2462"><a href="ecmascript-data-types-and-values.html#exotic-object">exotic objects</a></emu-xref>. It factors out common steps used in creating all objects, and centralizes object creation. It performs the following steps when called:</p>
|
||
|
||
<emu-alg><ol><li>Set <var>internalSlotsList</var> to the <emu-xref href="#list-concatenation" id="_ref_2463"><a href="ecmascript-data-types-and-values.html#list-concatenation">list-concatenation</a></emu-xref> of <var>internalSlotsList</var> and « <var class="field">[[PrivateElements]]</var> ».</li><li>Let <var>obj</var> be a newly created object with an internal slot for each name in <var>internalSlotsList</var>.</li><li>NOTE: As described in <emu-xref href="#sec-object-internal-methods-and-internal-slots" title="" id="_ref_221"><a href="ecmascript-data-types-and-values.html#sec-object-internal-methods-and-internal-slots">Object Internal Methods and Internal Slots</a></emu-xref>, the initial value of each such internal slot is <emu-val>undefined</emu-val> unless specified otherwise.</li><li>Set <var>obj</var>.<var class="field">[[PrivateElements]]</var> to a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2464"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Set <var>obj</var>'s essential internal methods to the default <emu-xref href="#ordinary-object" id="_ref_2465"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary object</a></emu-xref> definitions specified in <emu-xref href="#sec-ordinary-object-internal-methods-and-internal-slots" id="_ref_222"><a href="ordinary-and-exotic-objects-behaviours.html#sec-ordinary-object-internal-methods-and-internal-slots">10.1</a></emu-xref>.</li><li><emu-xref href="#assert" id="_ref_2466"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: If the caller will not be overriding both <var>obj</var>'s <var class="field">[[GetPrototypeOf]]</var> and <var class="field">[[SetPrototypeOf]]</var> essential internal methods, then <var>internalSlotsList</var> contains <var class="field">[[Prototype]]</var>.</li><li><emu-xref href="#assert" id="_ref_2467"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: If the caller will not be overriding all of <var>obj</var>'s <var class="field">[[SetPrototypeOf]]</var>, <var class="field">[[IsExtensible]]</var>, and <var class="field">[[PreventExtensions]]</var> essential internal methods, then <var>internalSlotsList</var> contains <var class="field">[[Extensible]]</var>.</li><li>If <var>internalSlotsList</var> contains <var class="field">[[Extensible]]</var>, set <var>obj</var>.<var class="field">[[Extensible]]</var> to <emu-val>true</emu-val>.</li><li>Return <var>obj</var>.</li></ol></emu-alg>
|
||
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Within this specification, <emu-xref href="#exotic-object" id="_ref_2468"><a href="ecmascript-data-types-and-values.html#exotic-object">exotic objects</a></emu-xref> are created in <emu-xref href="#sec-algorithm-conventions-abstract-operations" id="_ref_2469"><a href="notational-conventions.html#sec-algorithm-conventions-abstract-operations">abstract operations</a></emu-xref> such as <emu-xref aoid="ArrayCreate" id="_ref_2470"><a href="ordinary-and-exotic-objects-behaviours.html#sec-arraycreate">ArrayCreate</a></emu-xref> and <emu-xref aoid="BoundFunctionCreate" id="_ref_2471"><a href="ordinary-and-exotic-objects-behaviours.html#sec-boundfunctioncreate">BoundFunctionCreate</a></emu-xref> by first calling MakeBasicObject to obtain a basic, foundational object, and then overriding some or all of that object's internal methods. In order to encapsulate <emu-xref href="#exotic-object" id="_ref_2472"><a href="ecmascript-data-types-and-values.html#exotic-object">exotic object</a></emu-xref> creation, the object's essential internal methods are never modified outside those operations.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-get-o-p" type="abstract operation" aoid="Get">
|
||
<h1><span class="secnum">7.3.2</span> Get ( <var>O</var>, <var>P</var> )</h1>
|
||
<p>The abstract operation Get takes arguments <var>O</var> (an Object) and <var>P</var> (a <emu-xref href="#property-key" id="_ref_2473"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2474"><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_2475"><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_2476"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to retrieve the value of a specific property of an object. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return ? <span class="e-user-code"><var>O</var>.<var class="field">[[Get]]</var>(<var>P</var>, <var>O</var>)</span>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getv" type="abstract operation" aoid="GetV">
|
||
<h1><span class="secnum">7.3.3</span> GetV ( <var>V</var>, <var>P</var> )</h1>
|
||
<p>The abstract operation GetV takes arguments <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2477"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>P</var> (a <emu-xref href="#property-key" id="_ref_2478"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2479"><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_2480"><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_2481"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to retrieve the value of a specific property of an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2482"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>. If the value is not an object, the property lookup is performed using a wrapper object appropriate for the type of the value. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>O</var> be ? <emu-xref aoid="ToObject" id="_ref_2483"><a href="abstract-operations.html#sec-toobject">ToObject</a></emu-xref>(<var>V</var>).</li><li>Return ? <span class="e-user-code"><var>O</var>.<var class="field">[[Get]]</var>(<var>P</var>, <var>V</var>)</span>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-set-o-p-v-throw" type="abstract operation" aoid="Set">
|
||
<h1><span class="secnum">7.3.4</span> Set ( <var>O</var>, <var>P</var>, <var>V</var>, <var>Throw</var> )</h1>
|
||
<p>The abstract operation Set takes arguments <var>O</var> (an Object), <var>P</var> (a <emu-xref href="#property-key" id="_ref_2484"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>), <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2485"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>Throw</var> (a Boolean) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2486"><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_2487"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to set the value of a specific property of an object. <var>V</var> is the new value for the property. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>success</var> be ? <span class="e-user-code"><var>O</var>.<var class="field">[[Set]]</var>(<var>P</var>, <var>V</var>, <var>O</var>)</span>.</li><li>If <var>success</var> is <emu-val>false</emu-val> and <var>Throw</var> is <emu-val>true</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-createdataproperty" type="abstract operation" aoid="CreateDataProperty">
|
||
<h1><span class="secnum">7.3.5</span> CreateDataProperty ( <var>O</var>, <var>P</var>, <var>V</var> )</h1>
|
||
<p>The abstract operation CreateDataProperty takes arguments <var>O</var> (an Object), <var>P</var> (a <emu-xref href="#property-key" id="_ref_2488"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>), and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2489"><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_2490"><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_2491"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to create a new own property of an object. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>newDesc</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>: <emu-val>true</emu-val> }.</li><li>Return ? <span class="e-user-code"><var>O</var>.<var class="field">[[DefineOwnProperty]]</var>(<var>P</var>, <var>newDesc</var>)</span>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist. If it does exist and is not configurable or if <var>O</var> is not extensible, <var class="field">[[DefineOwnProperty]]</var> will return <emu-val>false</emu-val>.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-createdatapropertyorthrow" type="abstract operation" aoid="CreateDataPropertyOrThrow">
|
||
<h1><span class="secnum">7.3.6</span> CreateDataPropertyOrThrow ( <var>O</var>, <var>P</var>, <var>V</var> )</h1>
|
||
<p>The abstract operation CreateDataPropertyOrThrow takes arguments <var>O</var> (an Object), <var>P</var> (a <emu-xref href="#property-key" id="_ref_2492"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>), and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2493"><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_2494"><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_2495"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to create a new own property of an object. It throws a <emu-val>TypeError</emu-val> exception if the requested property update cannot be performed. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>success</var> be ? <emu-xref aoid="CreateDataProperty" id="_ref_2496"><a href="abstract-operations.html#sec-createdataproperty" class="e-user-code">CreateDataProperty</a></emu-xref>(<var>O</var>, <var>P</var>, <var>V</var>).</li><li>If <var>success</var> is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator. Normally, the property will not already exist. If it does exist and is not configurable or if <var>O</var> is not extensible, <var class="field">[[DefineOwnProperty]]</var> will return <emu-val>false</emu-val> causing this operation to throw a <emu-val>TypeError</emu-val> exception.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-createnonenumerabledatapropertyorthrow" type="abstract operation" aoid="CreateNonEnumerableDataPropertyOrThrow">
|
||
<h1><span class="secnum">7.3.7</span> CreateNonEnumerableDataPropertyOrThrow ( <var>O</var>, <var>P</var>, <var>V</var> )</h1>
|
||
<p>The abstract operation CreateNonEnumerableDataPropertyOrThrow takes arguments <var>O</var> (an Object), <var>P</var> (a <emu-xref href="#property-key" id="_ref_2497"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>), and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2498"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns <emu-const>unused</emu-const>. It is used to create a new non-enumerable own property of an <emu-xref href="#ordinary-object" id="_ref_2499"><a href="ecmascript-data-types-and-values.html#ordinary-object">ordinary object</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_2500"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>O</var> is an ordinary, extensible object with no non-configurable properties.</li><li>Let <var>newDesc</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>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>true</emu-val> }.</li><li>Perform ! <emu-xref aoid="DefinePropertyOrThrow" id="_ref_2501"><a href="abstract-operations.html#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref>(<var>O</var>, <var>P</var>, <var>newDesc</var>).</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator except it is not enumerable. Normally, the property will not already exist. If it does exist, <emu-xref aoid="DefinePropertyOrThrow" id="_ref_2502"><a href="abstract-operations.html#sec-definepropertyorthrow">DefinePropertyOrThrow</a></emu-xref> is guaranteed to complete normally.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-definepropertyorthrow" type="abstract operation" aoid="DefinePropertyOrThrow">
|
||
<h1><span class="secnum">7.3.8</span> DefinePropertyOrThrow ( <var>O</var>, <var>P</var>, <var>desc</var> )</h1>
|
||
<p>The abstract operation DefinePropertyOrThrow takes arguments <var>O</var> (an Object), <var>P</var> (a <emu-xref href="#property-key" id="_ref_2503"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>), and <var>desc</var> (a <emu-xref href="#sec-property-descriptor-specification-type" id="_ref_2504"><a href="ecmascript-data-types-and-values.html#sec-property-descriptor-specification-type">Property Descriptor</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2505"><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_2506"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to call the <var class="field">[[DefineOwnProperty]]</var> internal method of an object in a manner that will throw a <emu-val>TypeError</emu-val> exception if the requested property update cannot be performed. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>success</var> be ? <span class="e-user-code"><var>O</var>.<var class="field">[[DefineOwnProperty]]</var>(<var>P</var>, <var>desc</var>)</span>.</li><li>If <var>success</var> is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-deletepropertyorthrow" type="abstract operation" aoid="DeletePropertyOrThrow">
|
||
<h1><span class="secnum">7.3.9</span> DeletePropertyOrThrow ( <var>O</var>, <var>P</var> )</h1>
|
||
<p>The abstract operation DeletePropertyOrThrow takes arguments <var>O</var> (an Object) and <var>P</var> (a <emu-xref href="#property-key" id="_ref_2507"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2508"><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_2509"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to remove a specific own property of an object. It throws an exception if the property is not configurable. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>success</var> be ? <span class="e-user-code"><var>O</var>.<var class="field">[[Delete]]</var>(<var>P</var>)</span>.</li><li>If <var>success</var> is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getmethod" type="abstract operation" aoid="GetMethod">
|
||
<h1><span class="secnum">7.3.10</span> GetMethod ( <var>V</var>, <var>P</var> )</h1>
|
||
<p>The abstract operation GetMethod takes arguments <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2510"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>P</var> (a <emu-xref href="#property-key" id="_ref_2511"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2512"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either a <emu-xref href="#function-object" id="_ref_2513"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> or <emu-val>undefined</emu-val>, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2514"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to get the value of a specific property of an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2515"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> when the value of the property is expected to be a function. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>func</var> be ? <emu-xref aoid="GetV" id="_ref_2516"><a href="abstract-operations.html#sec-getv" class="e-user-code">GetV</a></emu-xref>(<var>V</var>, <var>P</var>).</li><li>If <var>func</var> is either <emu-val>undefined</emu-val> or <emu-val>null</emu-val>, return <emu-val>undefined</emu-val>.</li><li>If <emu-xref aoid="IsCallable" id="_ref_2517"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>func</var>) is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return <var>func</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-hasproperty" type="abstract operation" aoid="HasProperty">
|
||
<h1><span class="secnum">7.3.11</span> HasProperty ( <var>O</var>, <var>P</var> )</h1>
|
||
<p>The abstract operation HasProperty takes arguments <var>O</var> (an Object) and <var>P</var> (a <emu-xref href="#property-key" id="_ref_2518"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2519"><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_2520"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to determine whether an object has a property with the specified <emu-xref href="#property-key" id="_ref_2521"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>. The property may be either own or inherited. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return ? <span class="e-user-code"><var>O</var>.<var class="field">[[HasProperty]]</var>(<var>P</var>)</span>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-hasownproperty" type="abstract operation" aoid="HasOwnProperty">
|
||
<h1><span class="secnum">7.3.12</span> HasOwnProperty ( <var>O</var>, <var>P</var> )</h1>
|
||
<p>The abstract operation HasOwnProperty takes arguments <var>O</var> (an Object) and <var>P</var> (a <emu-xref href="#property-key" id="_ref_2522"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2523"><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_2524"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to determine whether an object has an own property with the specified <emu-xref href="#property-key" id="_ref_2525"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>desc</var> be ? <span class="e-user-code"><var>O</var>.<var class="field">[[GetOwnProperty]]</var>(<var>P</var>)</span>.</li><li>If <var>desc</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-call" type="abstract operation" aoid="Call">
|
||
<h1><span class="secnum">7.3.13</span> Call ( <var>F</var>, <var>V</var> [ , <var>argumentsList</var> ] )</h1>
|
||
<p>The abstract operation Call takes arguments <var>F</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2526"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2527"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and optional argument <var>argumentsList</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2528"><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_2529"><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_2530"><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_2531"><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_2532"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to call the <var class="field">[[Call]]</var> internal method of a <emu-xref href="#function-object" id="_ref_2533"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>. <var>F</var> is the <emu-xref href="#function-object" id="_ref_2534"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>, <var>V</var> is an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2535"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> that is the <emu-val>this</emu-val> value of the <var class="field">[[Call]]</var>, and <var>argumentsList</var> is the value passed to the corresponding argument of the internal method. If <var>argumentsList</var> is not present, a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2536"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> is used as its value. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>argumentsList</var> is not present, set <var>argumentsList</var> to a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2537"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>If <emu-xref aoid="IsCallable" id="_ref_2538"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>F</var>) is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <span class="e-user-code"><var>F</var>.<var class="field">[[Call]]</var>(<var>V</var>, <var>argumentsList</var>)</span>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-construct" type="abstract operation" aoid="Construct">
|
||
<h1><span class="secnum">7.3.14</span> Construct ( <var>F</var> [ , <var>argumentsList</var> [ , <var>newTarget</var> ] ] )</h1>
|
||
<p>The abstract operation Construct takes argument <var>F</var> (a <emu-xref href="#constructor" id="_ref_2539"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>) and optional arguments <var>argumentsList</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2540"><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_2541"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref>) and <var>newTarget</var> (a <emu-xref href="#constructor" id="_ref_2542"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2543"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an Object or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2544"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to call the <var class="field">[[Construct]]</var> internal method of a <emu-xref href="#function-object" id="_ref_2545"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>. <var>argumentsList</var> and <var>newTarget</var> are the values to be passed as the corresponding arguments of the internal method. If <var>argumentsList</var> is not present, a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2546"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> is used as its value. If <var>newTarget</var> is not present, <var>F</var> is used as its value. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>newTarget</var> is not present, set <var>newTarget</var> to <var>F</var>.</li><li>If <var>argumentsList</var> is not present, set <var>argumentsList</var> to a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2547"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Return ? <span class="e-user-code"><var>F</var>.<var class="field">[[Construct]]</var>(<var>argumentsList</var>, <var>newTarget</var>)</span>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>If <var>newTarget</var> is not present, this operation is equivalent to: <code>new F(...argumentsList)</code></p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-setintegritylevel" type="abstract operation" aoid="SetIntegrityLevel">
|
||
<h1><span class="secnum">7.3.15</span> SetIntegrityLevel ( <var>O</var>, <var>level</var> )</h1>
|
||
<p>The abstract operation SetIntegrityLevel takes arguments <var>O</var> (an Object) and <var>level</var> (<emu-const>sealed</emu-const> or <emu-const>frozen</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2548"><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_2549"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to fix the set of own properties of an object. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>status</var> be ? <var>O</var>.<var class="field">[[PreventExtensions]]</var>().</li><li>If <var>status</var> is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>Let <var>keys</var> be ? <var>O</var>.<var class="field">[[OwnPropertyKeys]]</var>().</li><li>If <var>level</var> is <emu-const>sealed</emu-const>, then<ol><li>For each element <var>k</var> of <var>keys</var>, do<ol><li>Perform ? <emu-xref aoid="DefinePropertyOrThrow" id="_ref_2550"><a href="abstract-operations.html#sec-definepropertyorthrow" class="e-user-code">DefinePropertyOrThrow</a></emu-xref>(<var>O</var>, <var>k</var>, PropertyDescriptor { <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }).</li></ol></li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_2551"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>level</var> is <emu-const>frozen</emu-const>.</li><li>For each element <var>k</var> of <var>keys</var>, do<ol><li>Let <var>currentDesc</var> be ? <span class="e-user-code"><var>O</var>.<var class="field">[[GetOwnProperty]]</var>(<var>k</var>)</span>.</li><li>If <var>currentDesc</var> is not <emu-val>undefined</emu-val>, then<ol><li>If <emu-xref aoid="IsAccessorDescriptor" id="_ref_2552"><a href="ecmascript-data-types-and-values.html#sec-isaccessordescriptor">IsAccessorDescriptor</a></emu-xref>(<var>currentDesc</var>) is <emu-val>true</emu-val>, then<ol><li>Let <var>desc</var> be the PropertyDescriptor { <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val> }.</li></ol></li><li>Else,<ol><li>Let <var>desc</var> be the PropertyDescriptor { <var class="field">[[Configurable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Writable]]</var>: <emu-val>false</emu-val> }.</li></ol></li><li>Perform ? <emu-xref aoid="DefinePropertyOrThrow" id="_ref_2553"><a href="abstract-operations.html#sec-definepropertyorthrow" class="e-user-code">DefinePropertyOrThrow</a></emu-xref>(<var>O</var>, <var>k</var>, <var>desc</var>).</li></ol></li></ol></li></ol></li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-testintegritylevel" type="abstract operation" aoid="TestIntegrityLevel">
|
||
<h1><span class="secnum">7.3.16</span> TestIntegrityLevel ( <var>O</var>, <var>level</var> )</h1>
|
||
<p>The abstract operation TestIntegrityLevel takes arguments <var>O</var> (an Object) and <var>level</var> (<emu-const>sealed</emu-const> or <emu-const>frozen</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2554"><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_2555"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to determine if the set of own properties of an object are fixed. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>extensible</var> be ? <emu-xref aoid="IsExtensible" id="_ref_2556"><a href="abstract-operations.html#sec-isextensible-o" class="e-user-code">IsExtensible</a></emu-xref>(<var>O</var>).</li><li>If <var>extensible</var> is <emu-val>true</emu-val>, return <emu-val>false</emu-val>.</li><li>NOTE: If the object is extensible, none of its properties are examined.</li><li>Let <var>keys</var> be ? <var>O</var>.<var class="field">[[OwnPropertyKeys]]</var>().</li><li>For each element <var>k</var> of <var>keys</var>, do<ol><li>Let <var>currentDesc</var> be ? <span class="e-user-code"><var>O</var>.<var class="field">[[GetOwnProperty]]</var>(<var>k</var>)</span>.</li><li>If <var>currentDesc</var> is not <emu-val>undefined</emu-val>, then<ol><li>If <var>currentDesc</var>.<var class="field">[[Configurable]]</var> is <emu-val>true</emu-val>, return <emu-val>false</emu-val>.</li><li>If <var>level</var> is <emu-const>frozen</emu-const> and <emu-xref aoid="IsDataDescriptor" id="_ref_2557"><a href="ecmascript-data-types-and-values.html#sec-isdatadescriptor">IsDataDescriptor</a></emu-xref>(<var>currentDesc</var>) is <emu-val>true</emu-val>, then<ol><li>If <var>currentDesc</var>.<var class="field">[[Writable]]</var> is <emu-val>true</emu-val>, return <emu-val>false</emu-val>.</li></ol></li></ol></li></ol></li><li>Return <emu-val>true</emu-val>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-createarrayfromlist" type="abstract operation" aoid="CreateArrayFromList">
|
||
<h1><span class="secnum">7.3.17</span> CreateArrayFromList ( <var>elements</var> )</h1>
|
||
<p>The abstract operation CreateArrayFromList takes argument <var>elements</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2558"><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_2559"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref>) and returns an Array. It is used to create an Array whose elements are provided by <var>elements</var>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>array</var> be ! <emu-xref aoid="ArrayCreate" id="_ref_2560"><a href="ordinary-and-exotic-objects-behaviours.html#sec-arraycreate">ArrayCreate</a></emu-xref>(0).</li><li>Let <var>n</var> be 0.</li><li>For each element <var>e</var> of <var>elements</var>, do<ol><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_2561"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>array</var>, ! <emu-xref aoid="ToString" id="_ref_2562"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_2563"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>n</var>)), <var>e</var>).</li><li>Set <var>n</var> to <var>n</var> + 1.</li></ol></li><li>Return <var>array</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-lengthofarraylike" type="abstract operation" aoid="LengthOfArrayLike">
|
||
<h1><span class="secnum">7.3.18</span> LengthOfArrayLike ( <var>obj</var> )</h1>
|
||
<p>The abstract operation LengthOfArrayLike takes argument <var>obj</var> (an Object) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2564"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a non-negative <emu-xref href="#integer" id="_ref_2565"><a href="notational-conventions.html#integer">integer</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2566"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It returns the value of the <emu-val>"length"</emu-val> property of an array-like object. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Return <emu-xref aoid="ℝ" id="_ref_2567"><a href="notational-conventions.html#%E2%84%9D">ℝ</a></emu-xref>(? <emu-xref aoid="ToLength" id="_ref_2568"><a href="abstract-operations.html#sec-tolength" class="e-user-code">ToLength</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_2569"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>obj</var>, <emu-val>"length"</emu-val>))).</li></ol></emu-alg>
|
||
<p>An <dfn variants="array-like objects" tabindex="-1">array-like object</dfn> is any object for which this operation returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2570"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion</a></emu-xref>.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
Typically, an array-like object would also have some properties with <emu-xref href="#integer-index" id="_ref_2571"><a href="ecmascript-data-types-and-values.html#integer-index">integer index</a></emu-xref> names. However, that is not a requirement of this definition.
|
||
</div></emu-note>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
Arrays and String objects are examples of array-like objects.
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-createlistfromarraylike" type="abstract operation" aoid="CreateListFromArrayLike">
|
||
<h1><span class="secnum">7.3.19</span> CreateListFromArrayLike ( <var>obj</var> [ , <var>validElementTypes</var> ] )</h1>
|
||
<p>The abstract operation CreateListFromArrayLike takes argument <var>obj</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2572"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and optional argument <var>validElementTypes</var> (<emu-const>all</emu-const> or <emu-const>property-key</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2573"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2574"><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_2575"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2576"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to create a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2577"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> value whose elements are provided by the indexed properties of <var>obj</var>. <var>validElementTypes</var> indicates the types of values that are allowed as elements. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>validElementTypes</var> is not present, set <var>validElementTypes</var> to <emu-const>all</emu-const>.</li><li>If <var>obj</var> <emu-xref href="#sec-object-type" id="_ref_2578"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>len</var> be ? <emu-xref aoid="LengthOfArrayLike" id="_ref_2579"><a href="abstract-operations.html#sec-lengthofarraylike" class="e-user-code">LengthOfArrayLike</a></emu-xref>(<var>obj</var>).</li><li>Let <var>list</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2580"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>index</var> be 0.</li><li>Repeat, while <var>index</var> < <var>len</var>,<ol><li>Let <var>indexName</var> be ! <emu-xref aoid="ToString" id="_ref_2581"><a href="abstract-operations.html#sec-tostring">ToString</a></emu-xref>(<emu-xref aoid="𝔽" id="_ref_2582"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>index</var>)).</li><li>Let <var>next</var> be ? <emu-xref aoid="Get" id="_ref_2583"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>obj</var>, <var>indexName</var>).</li><li>If <var>validElementTypes</var> is <emu-const>property-key</emu-const> and <var>next</var> is not a <emu-xref href="#property-key" id="_ref_2584"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Append <var>next</var> to <var>list</var>.</li><li>Set <var>index</var> to <var>index</var> + 1.</li></ol></li><li>Return <var>list</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-invoke" type="abstract operation" aoid="Invoke">
|
||
<h1><span class="secnum">7.3.20</span> Invoke ( <var>V</var>, <var>P</var> [ , <var>argumentsList</var> ] )</h1>
|
||
<p>The abstract operation Invoke takes arguments <var>V</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2585"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>P</var> (a <emu-xref href="#property-key" id="_ref_2586"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>) and optional argument <var>argumentsList</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2587"><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_2588"><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_2589"><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_2590"><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_2591"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to call a method property of an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2592"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>. <var>V</var> serves as both the lookup point for the property and the <emu-val>this</emu-val> value of the call. <var>argumentsList</var> is the list of arguments values passed to the method. If <var>argumentsList</var> is not present, a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2593"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> is used as its value. It performs the following steps when called:</p>
|
||
|
||
<emu-alg><ol><li>If <var>argumentsList</var> is not present, set <var>argumentsList</var> to a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2594"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>func</var> be ? <emu-xref aoid="GetV" id="_ref_2595"><a href="abstract-operations.html#sec-getv" class="e-user-code">GetV</a></emu-xref>(<var>V</var>, <var>P</var>).</li><li>Return ? <emu-xref aoid="Call" id="_ref_2596"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>func</var>, <var>V</var>, <var>argumentsList</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-ordinaryhasinstance" type="abstract operation" aoid="OrdinaryHasInstance">
|
||
<h1><span class="secnum">7.3.21</span> OrdinaryHasInstance ( <var>C</var>, <var>O</var> )</h1>
|
||
<p>The abstract operation OrdinaryHasInstance takes arguments <var>C</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2597"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>O</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2598"><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_2599"><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_2600"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It implements the default algorithm for determining if <var>O</var> inherits from the instance object inheritance path provided by <var>C</var>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <emu-xref aoid="IsCallable" id="_ref_2601"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>C</var>) is <emu-val>false</emu-val>, return <emu-val>false</emu-val>.</li><li>If <var>C</var> has a <var class="field">[[BoundTargetFunction]]</var> internal slot, then<ol><li>Let <var>BC</var> be <var>C</var>.<var class="field">[[BoundTargetFunction]]</var>.</li><li>Return ? <emu-xref aoid="InstanceofOperator" id="_ref_2602"><a href="ecmascript-language-expressions.html#sec-instanceofoperator" class="e-user-code">InstanceofOperator</a></emu-xref>(<var>O</var>, <var>BC</var>).</li></ol></li><li>If <var>O</var> <emu-xref href="#sec-object-type" id="_ref_2603"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, return <emu-val>false</emu-val>.</li><li>Let <var>P</var> be ? <emu-xref aoid="Get" id="_ref_2604"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>C</var>, <emu-val>"prototype"</emu-val>).</li><li>If <var>P</var> <emu-xref href="#sec-object-type" id="_ref_2605"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Repeat,<ol><li>Set <var>O</var> to ? <span class="e-user-code"><var>O</var>.<var class="field">[[GetPrototypeOf]]</var>()</span>.</li><li>If <var>O</var> is <emu-val>null</emu-val>, return <emu-val>false</emu-val>.</li><li>If <emu-xref aoid="SameValue" id="_ref_2606"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref>(<var>P</var>, <var>O</var>) is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li></ol></li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-speciesconstructor" type="abstract operation" aoid="SpeciesConstructor">
|
||
<h1><span class="secnum">7.3.22</span> SpeciesConstructor ( <var>O</var>, <var>defaultConstructor</var> )</h1>
|
||
<p>The abstract operation SpeciesConstructor takes arguments <var>O</var> (an Object) and <var>defaultConstructor</var> (a <emu-xref href="#constructor" id="_ref_2607"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2608"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#constructor" id="_ref_2609"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2610"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It is used to retrieve the <emu-xref href="#constructor" id="_ref_2611"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> that should be used to create new objects that are derived from <var>O</var>. <var>defaultConstructor</var> is the <emu-xref href="#constructor" id="_ref_2612"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> to use if a <emu-xref href="#constructor" id="_ref_2613"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> <emu-xref href="#sec-well-known-symbols" id="_ref_2614"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.species%</a></emu-xref> property cannot be found starting from <var>O</var>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>C</var> be ? <emu-xref aoid="Get" id="_ref_2615"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>O</var>, <emu-val>"constructor"</emu-val>).</li><li>If <var>C</var> is <emu-val>undefined</emu-val>, return <var>defaultConstructor</var>.</li><li>If <var>C</var> <emu-xref href="#sec-object-type" id="_ref_2616"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>S</var> be ? <emu-xref aoid="Get" id="_ref_2617"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>C</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_2618"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.species%</a></emu-xref>).</li><li>If <var>S</var> is either <emu-val>undefined</emu-val> or <emu-val>null</emu-val>, return <var>defaultConstructor</var>.</li><li>If <emu-xref aoid="IsConstructor" id="_ref_2619"><a href="abstract-operations.html#sec-isconstructor">IsConstructor</a></emu-xref>(<var>S</var>) is <emu-val>true</emu-val>, return <var>S</var>.</li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-enumerableownproperties" type="abstract operation" oldids="sec-enumerableownpropertynames" aoid="EnumerableOwnProperties"><span id="sec-enumerableownpropertynames"></span>
|
||
<h1><span class="secnum">7.3.23</span> EnumerableOwnProperties ( <var>O</var>, <var>kind</var> )</h1>
|
||
<p>The abstract operation EnumerableOwnProperties takes arguments <var>O</var> (an Object) and <var>kind</var> (<emu-const>key</emu-const>, <emu-const>value</emu-const>, or <emu-const>key+value</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2620"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2621"><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_2622"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2623"><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>ownKeys</var> be ? <span class="e-user-code"><var>O</var>.<var class="field">[[OwnPropertyKeys]]</var>()</span>.</li><li>Let <var>results</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2624"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>For each element <var>key</var> of <var>ownKeys</var>, do<ol><li>If <var>key</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2625"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>, then<ol><li>Let <var>desc</var> be ? <span class="e-user-code"><var>O</var>.<var class="field">[[GetOwnProperty]]</var>(<var>key</var>)</span>.</li><li>If <var>desc</var> is not <emu-val>undefined</emu-val> and <var>desc</var>.<var class="field">[[Enumerable]]</var> is <emu-val>true</emu-val>, then<ol><li>If <var>kind</var> is <emu-const>key</emu-const>, then<ol><li>Append <var>key</var> to <var>results</var>.</li></ol></li><li>Else,<ol><li>Let <var>value</var> be ? <emu-xref aoid="Get" id="_ref_2626"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>O</var>, <var>key</var>).</li><li>If <var>kind</var> is <emu-const>value</emu-const>, then<ol><li>Append <var>value</var> to <var>results</var>.</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_2627"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>kind</var> is <emu-const>key+value</emu-const>.</li><li>Let <var>entry</var> be <emu-xref aoid="CreateArrayFromList" id="_ref_2628"><a href="abstract-operations.html#sec-createarrayfromlist">CreateArrayFromList</a></emu-xref>(« <var>key</var>, <var>value</var> »).</li><li>Append <var>entry</var> to <var>results</var>.</li></ol></li></ol></li></ol></li></ol></li></ol></li><li>Return <var>results</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getfunctionrealm" type="abstract operation" aoid="GetFunctionRealm">
|
||
<h1><span class="secnum">7.3.24</span> GetFunctionRealm ( <var>obj</var> )</h1>
|
||
<p>The abstract operation GetFunctionRealm takes argument <var>obj</var> (a <emu-xref href="#function-object" id="_ref_2629"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2630"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#realm-record" id="_ref_2631"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2632"><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>obj</var> has a <var class="field">[[Realm]]</var> internal slot, then<ol><li>Return <var>obj</var>.<var class="field">[[Realm]]</var>.</li></ol></li><li>If <var>obj</var> is a <emu-xref href="#bound-function-exotic-object" id="_ref_2633"><a href="ordinary-and-exotic-objects-behaviours.html#bound-function-exotic-object">bound function exotic object</a></emu-xref>, then<ol><li>Let <var>boundTargetFunction</var> be <var>obj</var>.<var class="field">[[BoundTargetFunction]]</var>.</li><li>Return ? <emu-xref aoid="GetFunctionRealm" id="_ref_2634"><a href="abstract-operations.html#sec-getfunctionrealm">GetFunctionRealm</a></emu-xref>(<var>boundTargetFunction</var>).</li></ol></li><li>If <var>obj</var> is a <emu-xref href="#proxy-exotic-object" id="_ref_2635"><a href="ordinary-and-exotic-objects-behaviours.html#proxy-exotic-object">Proxy exotic object</a></emu-xref>, then<ol><li>Perform ? <emu-xref aoid="ValidateNonRevokedProxy" id="_ref_2636"><a href="ordinary-and-exotic-objects-behaviours.html#sec-validatenonrevokedproxy">ValidateNonRevokedProxy</a></emu-xref>(<var>obj</var>).</li><li>Let <var>proxyTarget</var> be <var>obj</var>.<var class="field">[[ProxyTarget]]</var>.</li><li><emu-xref href="#assert" id="_ref_2637"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>proxyTarget</var> is a <emu-xref href="#function-object" id="_ref_2638"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>.</li><li>Return ? <emu-xref aoid="GetFunctionRealm" id="_ref_2639"><a href="abstract-operations.html#sec-getfunctionrealm">GetFunctionRealm</a></emu-xref>(<var>proxyTarget</var>).</li></ol></li><li id="step-getfunctionrealm-default-return">Return <emu-xref href="#current-realm" id="_ref_2640"><a href="executable-code-and-execution-contexts.html#current-realm">the current Realm Record</a></emu-xref>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>Step <emu-xref href="#step-getfunctionrealm-default-return" id="_ref_223"><a href="abstract-operations.html#step-getfunctionrealm-default-return">4</a></emu-xref> will only be reached if <var>obj</var> is a non-standard function <emu-xref href="#exotic-object" id="_ref_2641"><a href="ecmascript-data-types-and-values.html#exotic-object">exotic object</a></emu-xref> that does not have a <var class="field">[[Realm]]</var> internal slot.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-copydataproperties" type="abstract operation" aoid="CopyDataProperties">
|
||
<h1><span class="secnum">7.3.25</span> CopyDataProperties ( <var>target</var>, <var>source</var>, <var>excludedItems</var> )</h1>
|
||
<p>The abstract operation CopyDataProperties takes arguments <var>target</var> (an Object), <var>source</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2642"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>excludedItems</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2643"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#property-key" id="_ref_2644"><a href="ecmascript-data-types-and-values.html#property-key">property keys</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2645"><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_2646"><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>source</var> is either <emu-val>undefined</emu-val> or <emu-val>null</emu-val>, return <emu-const>unused</emu-const>.</li><li>Let <var>from</var> be ! <emu-xref aoid="ToObject" id="_ref_2647"><a href="abstract-operations.html#sec-toobject">ToObject</a></emu-xref>(<var>source</var>).</li><li>Let <var>keys</var> be ? <span class="e-user-code"><var>from</var>.<var class="field">[[OwnPropertyKeys]]</var>()</span>.</li><li>For each element <var>nextKey</var> of <var>keys</var>, do<ol><li>Let <var>excluded</var> be <emu-val>false</emu-val>.</li><li>For each element <var>e</var> of <var>excludedItems</var>, do<ol><li>If <emu-xref aoid="SameValue" id="_ref_2648"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref>(<var>e</var>, <var>nextKey</var>) is <emu-val>true</emu-val>, then<ol><li>Set <var>excluded</var> to <emu-val>true</emu-val>.</li></ol></li></ol></li><li>If <var>excluded</var> is <emu-val>false</emu-val>, then<ol><li>Let <var>desc</var> be ? <span class="e-user-code"><var>from</var>.<var class="field">[[GetOwnProperty]]</var>(<var>nextKey</var>)</span>.</li><li>If <var>desc</var> is not <emu-val>undefined</emu-val> and <var>desc</var>.<var class="field">[[Enumerable]]</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>propValue</var> be ? <emu-xref aoid="Get" id="_ref_2649"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>from</var>, <var>nextKey</var>).</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_2650"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>target</var>, <var>nextKey</var>, <var>propValue</var>).</li></ol></li></ol></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>The target passed in here is always a newly created object which is not directly accessible in case of an error being thrown.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-privateelementfind" type="abstract operation" aoid="PrivateElementFind">
|
||
<h1><span class="secnum">7.3.26</span> PrivateElementFind ( <var>O</var>, <var>P</var> )</h1>
|
||
<p>The abstract operation PrivateElementFind takes arguments <var>O</var> (an Object) and <var>P</var> (a <emu-xref href="#sec-private-names" id="_ref_2651"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Name</a></emu-xref>) and returns a <emu-xref href="#sec-privateelement-specification-type" id="_ref_2652"><a href="ecmascript-data-types-and-values.html#sec-privateelement-specification-type">PrivateElement</a></emu-xref> or <emu-const>empty</emu-const>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>If <var>O</var>.<var class="field">[[PrivateElements]]</var> contains a <emu-xref href="#sec-privateelement-specification-type" id="_ref_2653"><a href="ecmascript-data-types-and-values.html#sec-privateelement-specification-type">PrivateElement</a></emu-xref> <var>pe</var> such that <var>pe</var>.<var class="field">[[Key]]</var> is <var>P</var>, then<ol><li>Return <var>pe</var>.</li></ol></li><li>Return <emu-const>empty</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-privatefieldadd" type="abstract operation" aoid="PrivateFieldAdd">
|
||
<h1><span class="secnum">7.3.27</span> PrivateFieldAdd ( <var>O</var>, <var>P</var>, <var>value</var> )</h1>
|
||
<p>The abstract operation PrivateFieldAdd takes arguments <var>O</var> (an Object), <var>P</var> (a <emu-xref href="#sec-private-names" id="_ref_2654"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Name</a></emu-xref>), and <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2655"><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_2656"><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_2657"><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 the <emu-xref href="#host" id="_ref_2658"><a href="overview.html#host">host</a></emu-xref> is a web browser, then<ol><li>Perform ? <emu-xref aoid="HostEnsureCanAddPrivateElement" id="_ref_2659"><a href="abstract-operations.html#sec-hostensurecanaddprivateelement">HostEnsureCanAddPrivateElement</a></emu-xref>(<var>O</var>).</li></ol></li><li>Let <var>entry</var> be <emu-xref aoid="PrivateElementFind" id="_ref_2660"><a href="abstract-operations.html#sec-privateelementfind">PrivateElementFind</a></emu-xref>(<var>O</var>, <var>P</var>).</li><li>If <var>entry</var> is not <emu-const>empty</emu-const>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Append <emu-xref href="#sec-privateelement-specification-type" id="_ref_2661"><a href="ecmascript-data-types-and-values.html#sec-privateelement-specification-type">PrivateElement</a></emu-xref> { <var class="field">[[Key]]</var>: <var>P</var>, <var class="field">[[Kind]]</var>: <emu-const>field</emu-const>, <var class="field">[[Value]]</var>: <var>value</var> } to <var>O</var>.<var class="field">[[PrivateElements]]</var>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-privatemethodoraccessoradd" type="abstract operation" aoid="PrivateMethodOrAccessorAdd">
|
||
<h1><span class="secnum">7.3.28</span> PrivateMethodOrAccessorAdd ( <var>O</var>, <var>method</var> )</h1>
|
||
<p>The abstract operation PrivateMethodOrAccessorAdd takes arguments <var>O</var> (an Object) and <var>method</var> (a <emu-xref href="#sec-privateelement-specification-type" id="_ref_2662"><a href="ecmascript-data-types-and-values.html#sec-privateelement-specification-type">PrivateElement</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2663"><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_2664"><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_2665"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>method</var>.<var class="field">[[Kind]]</var> is either <emu-const>method</emu-const> or <emu-const>accessor</emu-const>.</li><li>If the <emu-xref href="#host" id="_ref_2666"><a href="overview.html#host">host</a></emu-xref> is a web browser, then<ol><li>Perform ? <emu-xref aoid="HostEnsureCanAddPrivateElement" id="_ref_2667"><a href="abstract-operations.html#sec-hostensurecanaddprivateelement">HostEnsureCanAddPrivateElement</a></emu-xref>(<var>O</var>).</li></ol></li><li>Let <var>entry</var> be <emu-xref aoid="PrivateElementFind" id="_ref_2668"><a href="abstract-operations.html#sec-privateelementfind">PrivateElementFind</a></emu-xref>(<var>O</var>, <var>method</var>.<var class="field">[[Key]]</var>).</li><li>If <var>entry</var> is not <emu-const>empty</emu-const>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Append <var>method</var> to <var>O</var>.<var class="field">[[PrivateElements]]</var>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>The values for private methods and accessors are shared across instances. This operation does not create a new copy of the method or accessor.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-hostensurecanaddprivateelement" type="host-defined abstract operation" aoid="HostEnsureCanAddPrivateElement">
|
||
<h1><span class="secnum">7.3.29</span> HostEnsureCanAddPrivateElement ( <var>O</var> )</h1>
|
||
<p>The <emu-xref href="#host-defined" id="_ref_2669"><a href="overview.html#host-defined">host-defined</a></emu-xref> abstract operation HostEnsureCanAddPrivateElement takes argument <var>O</var> (an Object) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2670"><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_2671"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It allows <emu-xref href="#host-environment" id="_ref_2672"><a href="overview.html#host-environment">host environments</a></emu-xref> to prevent the addition of private elements to particular <emu-xref href="#host-defined" id="_ref_2673"><a href="overview.html#host-defined">host-defined</a></emu-xref> <emu-xref href="#exotic-object" id="_ref_2674"><a href="ecmascript-data-types-and-values.html#exotic-object">exotic objects</a></emu-xref>.</p>
|
||
<p>An implementation of HostEnsureCanAddPrivateElement must conform to the following requirements:</p>
|
||
<ul>
|
||
<li>If <var>O</var> is not a <emu-xref href="#host-defined" id="_ref_2675"><a href="overview.html#host-defined">host-defined</a></emu-xref> <emu-xref href="#exotic-object" id="_ref_2676"><a href="ecmascript-data-types-and-values.html#exotic-object">exotic object</a></emu-xref>, this abstract operation must return <emu-xref aoid="NormalCompletion" id="_ref_2677"><a href="ecmascript-data-types-and-values.html#sec-normalcompletion">NormalCompletion</a></emu-xref>(<emu-const>unused</emu-const>) and perform no other steps.</li>
|
||
<li>Any two calls of this abstract operation with the same argument must return the same kind of <emu-xref href="#sec-completion-record-specification-type" id="_ref_2678"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>.</li>
|
||
</ul>
|
||
<p>The default implementation of HostEnsureCanAddPrivateElement is to return <emu-xref aoid="NormalCompletion" id="_ref_2679"><a href="ecmascript-data-types-and-values.html#sec-normalcompletion">NormalCompletion</a></emu-xref>(<emu-const>unused</emu-const>).</p>
|
||
<p>This abstract operation is only invoked by ECMAScript <emu-xref href="#host" id="_ref_2680"><a href="overview.html#host">hosts</a></emu-xref> that are web browsers.</p>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-privateget" type="abstract operation" aoid="PrivateGet">
|
||
<h1><span class="secnum">7.3.30</span> PrivateGet ( <var>O</var>, <var>P</var> )</h1>
|
||
<p>The abstract operation PrivateGet takes arguments <var>O</var> (an Object) and <var>P</var> (a <emu-xref href="#sec-private-names" id="_ref_2681"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Name</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2682"><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_2683"><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_2684"><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>entry</var> be <emu-xref aoid="PrivateElementFind" id="_ref_2685"><a href="abstract-operations.html#sec-privateelementfind">PrivateElementFind</a></emu-xref>(<var>O</var>, <var>P</var>).</li><li>If <var>entry</var> is <emu-const>empty</emu-const>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>entry</var>.<var class="field">[[Kind]]</var> is either <emu-const>field</emu-const> or <emu-const>method</emu-const>, then<ol><li>Return <var>entry</var>.<var class="field">[[Value]]</var>.</li></ol></li><li><emu-xref href="#assert" id="_ref_2686"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>entry</var>.<var class="field">[[Kind]]</var> is <emu-const>accessor</emu-const>.</li><li>If <var>entry</var>.<var class="field">[[Get]]</var> is <emu-val>undefined</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>getter</var> be <var>entry</var>.<var class="field">[[Get]]</var>.</li><li>Return ? <emu-xref aoid="Call" id="_ref_2687"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>getter</var>, <var>O</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-privateset" type="abstract operation" aoid="PrivateSet">
|
||
<h1><span class="secnum">7.3.31</span> PrivateSet ( <var>O</var>, <var>P</var>, <var>value</var> )</h1>
|
||
<p>The abstract operation PrivateSet takes arguments <var>O</var> (an Object), <var>P</var> (a <emu-xref href="#sec-private-names" id="_ref_2688"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Name</a></emu-xref>), and <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2689"><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_2690"><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_2691"><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>entry</var> be <emu-xref aoid="PrivateElementFind" id="_ref_2692"><a href="abstract-operations.html#sec-privateelementfind">PrivateElementFind</a></emu-xref>(<var>O</var>, <var>P</var>).</li><li>If <var>entry</var> is <emu-const>empty</emu-const>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>entry</var>.<var class="field">[[Kind]]</var> is <emu-const>method</emu-const>, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>entry</var>.<var class="field">[[Kind]]</var> is <emu-const>field</emu-const>, then<ol><li>Set <var>entry</var>.<var class="field">[[Value]]</var> to <var>value</var>.</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_2693"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>entry</var>.<var class="field">[[Kind]]</var> is <emu-const>accessor</emu-const>.</li><li>If <var>entry</var>.<var class="field">[[Set]]</var> is <emu-val>undefined</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>setter</var> be <var>entry</var>.<var class="field">[[Set]]</var>.</li><li>Perform ? <emu-xref aoid="Call" id="_ref_2694"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>setter</var>, <var>O</var>, « <var>value</var> »).</li></ol></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-definefield" type="abstract operation" aoid="DefineField">
|
||
<h1><span class="secnum">7.3.32</span> DefineField ( <var>receiver</var>, <var>fieldRecord</var> )</h1>
|
||
<p>The abstract operation DefineField takes arguments <var>receiver</var> (an Object) and <var>fieldRecord</var> (a <emu-xref href="#sec-classfielddefinition-record-specification-type" id="_ref_2695"><a href="ecmascript-data-types-and-values.html#sec-classfielddefinition-record-specification-type">ClassFieldDefinition Record</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2696"><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_2697"><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>fieldName</var> be <var>fieldRecord</var>.<var class="field">[[Name]]</var>.</li><li>Let <var>initializer</var> be <var>fieldRecord</var>.<var class="field">[[Initializer]]</var>.</li><li>If <var>initializer</var> is not <emu-const>empty</emu-const>, then<ol><li>Let <var>initValue</var> be ? <emu-xref aoid="Call" id="_ref_2698"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>initializer</var>, <var>receiver</var>).</li></ol></li><li>Else,<ol><li>Let <var>initValue</var> be <emu-val>undefined</emu-val>.</li></ol></li><li>If <var>fieldName</var> is a <emu-xref href="#sec-private-names" id="_ref_2699"><a href="ecmascript-data-types-and-values.html#sec-private-names">Private Name</a></emu-xref>, then<ol><li>Perform ? <emu-xref aoid="PrivateFieldAdd" id="_ref_2700"><a href="abstract-operations.html#sec-privatefieldadd">PrivateFieldAdd</a></emu-xref>(<var>receiver</var>, <var>fieldName</var>, <var>initValue</var>).</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_2701"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>fieldName</var> is a <emu-xref href="#property-key" id="_ref_2702"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>.</li><li>Perform ? <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_2703"><a href="abstract-operations.html#sec-createdatapropertyorthrow" class="e-user-code">CreateDataPropertyOrThrow</a></emu-xref>(<var>receiver</var>, <var>fieldName</var>, <var>initValue</var>).</li></ol></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-initializeinstanceelements" type="abstract operation" aoid="InitializeInstanceElements">
|
||
<h1><span class="secnum">7.3.33</span> InitializeInstanceElements ( <var>O</var>, <var>constructor</var> )</h1>
|
||
<p>The abstract operation InitializeInstanceElements takes arguments <var>O</var> (an Object) and <var>constructor</var> (an ECMAScript <emu-xref href="#function-object" id="_ref_2704"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> or a built-in <emu-xref href="#function-object" id="_ref_2705"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2706"><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_2707"><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>methods</var> be <var>constructor</var>.<var class="field">[[PrivateMethods]]</var>.</li><li>For each <emu-xref href="#sec-privateelement-specification-type" id="_ref_2708"><a href="ecmascript-data-types-and-values.html#sec-privateelement-specification-type">PrivateElement</a></emu-xref> <var>method</var> of <var>methods</var>, do<ol><li>Perform ? <emu-xref aoid="PrivateMethodOrAccessorAdd" id="_ref_2709"><a href="abstract-operations.html#sec-privatemethodoraccessoradd">PrivateMethodOrAccessorAdd</a></emu-xref>(<var>O</var>, <var>method</var>).</li></ol></li><li>Let <var>fields</var> be <var>constructor</var>.<var class="field">[[Fields]]</var>.</li><li>For each element <var>fieldRecord</var> of <var>fields</var>, do<ol><li>Perform ? <emu-xref aoid="DefineField" id="_ref_2710"><a href="abstract-operations.html#sec-definefield" class="e-user-code">DefineField</a></emu-xref>(<var>O</var>, <var>fieldRecord</var>).</li></ol></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-add-value-to-keyed-group" type="abstract operation" aoid="AddValueToKeyedGroup">
|
||
<h1><span class="secnum">7.3.34</span> AddValueToKeyedGroup ( <var>groups</var>, <var>key</var>, <var>value</var> )</h1>
|
||
<p>The abstract operation AddValueToKeyedGroup takes arguments <var>groups</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2711"><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_2712"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Records</a></emu-xref> with fields <var class="field">[[Key]]</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2713"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var class="field">[[Elements]]</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2714"><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_2715"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref>)), <var>key</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2716"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2717"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and returns <emu-const>unused</emu-const>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>For each <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2718"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Key]]</var>, <var class="field">[[Elements]]</var> } <var>g</var> of <var>groups</var>, do<ol><li>If <emu-xref aoid="SameValue" id="_ref_2719"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref>(<var>g</var>.<var class="field">[[Key]]</var>, <var>key</var>) is <emu-val>true</emu-val>, then<ol><li><emu-xref href="#assert" id="_ref_2720"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: Exactly one element of <var>groups</var> meets this criterion.</li><li>Append <var>value</var> to <var>g</var>.<var class="field">[[Elements]]</var>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></li></ol></li><li>Let <var>group</var> be the <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2721"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> { <var class="field">[[Key]]</var>: <var>key</var>, <var class="field">[[Elements]]</var>: « <var>value</var> » }.</li><li>Append <var>group</var> to <var>groups</var>.</li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-groupby" type="abstract operation" aoid="GroupBy">
|
||
<h1><span class="secnum">7.3.35</span> GroupBy ( <var>items</var>, <var>callback</var>, <var>keyCoercion</var> )</h1>
|
||
<p>The abstract operation GroupBy takes arguments <var>items</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2722"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), <var>callback</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2723"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), and <var>keyCoercion</var> (<emu-const>property</emu-const> or <emu-const>collection</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2724"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2725"><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_2726"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Records</a></emu-xref> with fields <var class="field">[[Key]]</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2727"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var class="field">[[Elements]]</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2728"><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_2729"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref>), or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2730"><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>Perform ? <emu-xref aoid="RequireObjectCoercible" id="_ref_2731"><a href="abstract-operations.html#sec-requireobjectcoercible">RequireObjectCoercible</a></emu-xref>(<var>items</var>).</li><li>If <emu-xref aoid="IsCallable" id="_ref_2732"><a href="abstract-operations.html#sec-iscallable">IsCallable</a></emu-xref>(<var>callback</var>) is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>groups</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2733"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Let <var>iteratorRecord</var> be ? <emu-xref aoid="GetIterator" id="_ref_2734"><a href="abstract-operations.html#sec-getiterator" class="e-user-code">GetIterator</a></emu-xref>(<var>items</var>, <emu-const>sync</emu-const>).</li><li>Let <var>k</var> be 0.</li><li>Repeat,<ol><li>If <var>k</var> ≥ 2<sup>53</sup> - 1, then<ol><li>Let <var>error</var> be <emu-xref aoid="ThrowCompletion" id="_ref_2735"><a href="ecmascript-data-types-and-values.html#sec-throwcompletion">ThrowCompletion</a></emu-xref>(a newly created <emu-val>TypeError</emu-val> object).</li><li>Return ? <emu-xref aoid="IteratorClose" id="_ref_2736"><a href="abstract-operations.html#sec-iteratorclose" class="e-user-code">IteratorClose</a></emu-xref>(<var>iteratorRecord</var>, <var>error</var>).</li></ol></li><li>Let <var>next</var> be ? <emu-xref aoid="IteratorStepValue" id="_ref_2737"><a href="abstract-operations.html#sec-iteratorstepvalue" class="e-user-code">IteratorStepValue</a></emu-xref>(<var>iteratorRecord</var>).</li><li>If <var>next</var> is <emu-const>done</emu-const>, then<ol><li>Return <var>groups</var>.</li></ol></li><li>Let <var>value</var> be <var>next</var>.</li><li>Let <var>key</var> be <emu-xref aoid="Completion" id="_ref_2738"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="Call" id="_ref_2739"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>callback</var>, <emu-val>undefined</emu-val>, « <var>value</var>, <emu-xref aoid="𝔽" id="_ref_2740"><a href="notational-conventions.html#%F0%9D%94%BD">𝔽</a></emu-xref>(<var>k</var>) »)).</li><li><emu-xref aoid="IfAbruptCloseIterator" id="_ref_2741"><a href="abstract-operations.html#sec-ifabruptcloseiterator" class="e-user-code">IfAbruptCloseIterator</a></emu-xref>(<var>key</var>, <var>iteratorRecord</var>).</li><li>If <var>keyCoercion</var> is <emu-const>property</emu-const>, then<ol><li>Set <var>key</var> to <emu-xref aoid="Completion" id="_ref_2742"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="ToPropertyKey" id="_ref_2743"><a href="abstract-operations.html#sec-topropertykey" class="e-user-code">ToPropertyKey</a></emu-xref>(<var>key</var>)).</li><li><emu-xref aoid="IfAbruptCloseIterator" id="_ref_2744"><a href="abstract-operations.html#sec-ifabruptcloseiterator" class="e-user-code">IfAbruptCloseIterator</a></emu-xref>(<var>key</var>, <var>iteratorRecord</var>).</li></ol></li><li>Else,<ol><li><emu-xref href="#assert" id="_ref_2745"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>keyCoercion</var> is <emu-const>collection</emu-const>.</li><li>Set <var>key</var> to <emu-xref aoid="CanonicalizeKeyedCollectionKey" id="_ref_2746"><a href="keyed-collections.html#sec-canonicalizekeyedcollectionkey">CanonicalizeKeyedCollectionKey</a></emu-xref>(<var>key</var>).</li></ol></li><li>Perform <emu-xref aoid="AddValueToKeyedGroup" id="_ref_2747"><a href="abstract-operations.html#sec-add-value-to-keyed-group">AddValueToKeyedGroup</a></emu-xref>(<var>groups</var>, <var>key</var>, <var>value</var>).</li><li>Set <var>k</var> to <var>k</var> + 1.</li></ol></li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getoptionsobject" type="abstract operation" aoid="GetOptionsObject">
|
||
<h1><span class="secnum">7.3.36</span> GetOptionsObject ( <var>options</var> )</h1>
|
||
<p>The abstract operation GetOptionsObject takes argument <var>options</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2748"><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_2749"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an Object or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2750"><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>options</var> is <emu-val>undefined</emu-val>, then<ol><li>Return <emu-xref aoid="OrdinaryObjectCreate" id="_ref_2751"><a href="ordinary-and-exotic-objects-behaviours.html#sec-ordinaryobjectcreate">OrdinaryObjectCreate</a></emu-xref>(<emu-val>null</emu-val>).</li></ol></li><li>If <var>options</var> <emu-xref href="#sec-object-type" id="_ref_2752"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>, then<ol><li>Return <var>options</var>.</li></ol></li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-SetterThatIgnoresPrototypeProperties" type="abstract operation" aoid="SetterThatIgnoresPrototypeProperties">
|
||
<h1><span class="secnum">7.3.37</span> SetterThatIgnoresPrototypeProperties ( <var>thisValue</var>, <var>home</var>, <var>p</var>, <var>v</var> )</h1>
|
||
<p>The abstract operation SetterThatIgnoresPrototypeProperties takes arguments <var>thisValue</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2753"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), <var>home</var> (an Object), <var>p</var> (a <emu-xref href="#property-key" id="_ref_2754"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref>), and <var>v</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2755"><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_2756"><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_2757"><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>thisValue</var> <emu-xref href="#sec-object-type" id="_ref_2758"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, then<ol><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>If <emu-xref aoid="SameValue" id="_ref_2759"><a href="abstract-operations.html#sec-samevalue">SameValue</a></emu-xref>(<var>thisValue</var>, <var>home</var>) is <emu-val>true</emu-val>, then<ol><li>NOTE: Throwing here emulates assignment to a non-writable <emu-xref href="#sec-object-type" id="_ref_2760"><a href="ecmascript-data-types-and-values.html#sec-object-type">data property</a></emu-xref> on the <var>home</var> object in <emu-xref href="#sec-strict-mode-code" id="_ref_2761"><a href="ecmascript-language-source-code.html#sec-strict-mode-code">strict mode code</a></emu-xref>.</li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>Let <var>desc</var> be ? <var>thisValue</var>.<var class="field">[[GetOwnProperty]]</var>(<var>p</var>).</li><li>If <var>desc</var> is <emu-val>undefined</emu-val>, then<ol><li>Perform ? <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_2762"><a href="abstract-operations.html#sec-createdatapropertyorthrow" class="e-user-code">CreateDataPropertyOrThrow</a></emu-xref>(<var>thisValue</var>, <var>p</var>, <var>v</var>).</li></ol></li><li>Else,<ol><li>Perform ? <emu-xref aoid="Set" id="_ref_2763"><a href="abstract-operations.html#sec-set-o-p-v-throw" class="e-user-code">Set</a></emu-xref>(<var>thisValue</var>, <var>p</var>, <var>v</var>, <emu-val>true</emu-val>).</li></ol></li><li>Return <emu-const>unused</emu-const>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-operations-on-iterator-objects">
|
||
<h1><span class="secnum">7.4</span> Operations on Iterator Objects</h1>
|
||
<p>See Common Iteration Interfaces (<emu-xref href="#sec-iteration" id="_ref_224"><a href="control-abstraction-objects.html#sec-iteration">27.1</a></emu-xref>).</p>
|
||
|
||
<emu-clause id="sec-iterator-records">
|
||
<h1><span class="secnum">7.4.1</span> Iterator Records</h1>
|
||
<p>An <dfn variants="Iterator Records" tabindex="-1">Iterator Record</dfn> is a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2764"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">Record</a></emu-xref> value used to encapsulate an <emu-xref href="#sec-iterator-interface" id="_ref_2765"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator</a></emu-xref> or <emu-xref href="#sec-asynciterator-interface" id="_ref_2766"><a href="control-abstraction-objects.html#sec-asynciterator-interface">async iterator</a></emu-xref> along with the <code>next</code> method.</p>
|
||
<p>Iterator Records have the fields listed in <emu-xref href="#table-iterator-record-fields" id="_ref_225"><a href="abstract-operations.html#table-iterator-record-fields">Table 13</a></emu-xref>.</p>
|
||
<emu-table id="table-iterator-record-fields" caption="Iterator Record Fields"><figure><figcaption>Table 13: <emu-xref href="#sec-iterator-records" id="_ref_2767"><a href="abstract-operations.html#sec-iterator-records">Iterator 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">[[Iterator]]</var>
|
||
</td>
|
||
<td>
|
||
an Object
|
||
</td>
|
||
<td>
|
||
An object that conforms to the <emu-xref href="#sec-iterator-interface" id="_ref_2768"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator interface</a></emu-xref> or the <emu-xref href="#sec-asynciterator-interface" id="_ref_2769"><a href="control-abstraction-objects.html#sec-asynciterator-interface">async iterator interface</a></emu-xref>.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<var class="field">[[NextMethod]]</var>
|
||
</td>
|
||
<td>
|
||
an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2770"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>
|
||
</td>
|
||
<td>
|
||
The <code>next</code> method of the <var class="field">[[Iterator]]</var> object.
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td>
|
||
<var class="field">[[Done]]</var>
|
||
</td>
|
||
<td>
|
||
a Boolean
|
||
</td>
|
||
<td>
|
||
Whether the <emu-xref href="#sec-iterator-interface" id="_ref_2771"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator</a></emu-xref> has completed or been closed.
|
||
</td>
|
||
</tr>
|
||
</tbody></table>
|
||
</figure></emu-table>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getiteratordirect" type="abstract operation" aoid="GetIteratorDirect">
|
||
<h1><span class="secnum">7.4.2</span> GetIteratorDirect ( <var>obj</var> )</h1>
|
||
<p>The abstract operation GetIteratorDirect takes argument <var>obj</var> (an Object) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2772"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-iterator-records" id="_ref_2773"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2774"><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>nextMethod</var> be ? <emu-xref aoid="Get" id="_ref_2775"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>obj</var>, <emu-val>"next"</emu-val>).</li><li>Let <var>iteratorRecord</var> be the <emu-xref href="#sec-iterator-records" id="_ref_2776"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref> { <var class="field">[[Iterator]]</var>: <var>obj</var>, <var class="field">[[NextMethod]]</var>: <var>nextMethod</var>, <var class="field">[[Done]]</var>: <emu-val>false</emu-val> }.</li><li>Return <var>iteratorRecord</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getiteratorfrommethod" type="abstract operation" aoid="GetIteratorFromMethod">
|
||
<h1><span class="secnum">7.4.3</span> GetIteratorFromMethod ( <var>obj</var>, <var>method</var> )</h1>
|
||
<p>The abstract operation GetIteratorFromMethod takes arguments <var>obj</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2777"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>method</var> (a <emu-xref href="#function-object" id="_ref_2778"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2779"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-iterator-records" id="_ref_2780"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2781"><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>iterator</var> be ? <emu-xref aoid="Call" id="_ref_2782"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>method</var>, <var>obj</var>).</li><li>If <var>iterator</var> <emu-xref href="#sec-object-type" id="_ref_2783"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <emu-xref aoid="GetIteratorDirect" id="_ref_2784"><a href="abstract-operations.html#sec-getiteratordirect" class="e-user-code">GetIteratorDirect</a></emu-xref>(<var>iterator</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getiterator" type="abstract operation" aoid="GetIterator">
|
||
<h1><span class="secnum">7.4.4</span> GetIterator ( <var>obj</var>, <var>kind</var> )</h1>
|
||
<p>The abstract operation GetIterator takes arguments <var>obj</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2785"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>kind</var> (<emu-const>sync</emu-const> or <emu-const>async</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2786"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-iterator-records" id="_ref_2787"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2788"><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>kind</var> is <emu-const>async</emu-const>, then<ol><li>Let <var>method</var> be ? <emu-xref aoid="GetMethod" id="_ref_2789"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>obj</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_2790"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.asyncIterator%</a></emu-xref>).</li><li>If <var>method</var> is <emu-val>undefined</emu-val>, then<ol><li>Let <var>syncMethod</var> be ? <emu-xref aoid="GetMethod" id="_ref_2791"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>obj</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_2792"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.iterator%</a></emu-xref>).</li><li>If <var>syncMethod</var> is <emu-val>undefined</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>syncIteratorRecord</var> be ? <emu-xref aoid="GetIteratorFromMethod" id="_ref_2793"><a href="abstract-operations.html#sec-getiteratorfrommethod" class="e-user-code">GetIteratorFromMethod</a></emu-xref>(<var>obj</var>, <var>syncMethod</var>).</li><li>Return <emu-xref aoid="CreateAsyncFromSyncIterator" id="_ref_2794"><a href="control-abstraction-objects.html#sec-createasyncfromsynciterator">CreateAsyncFromSyncIterator</a></emu-xref>(<var>syncIteratorRecord</var>).</li></ol></li></ol></li><li>Else,<ol><li>Let <var>method</var> be ? <emu-xref aoid="GetMethod" id="_ref_2795"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>obj</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_2796"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.iterator%</a></emu-xref>).</li></ol></li><li>If <var>method</var> is <emu-val>undefined</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <emu-xref aoid="GetIteratorFromMethod" id="_ref_2797"><a href="abstract-operations.html#sec-getiteratorfrommethod" class="e-user-code">GetIteratorFromMethod</a></emu-xref>(<var>obj</var>, <var>method</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-getiteratorflattenable" type="abstract operation" aoid="GetIteratorFlattenable">
|
||
<h1><span class="secnum">7.4.5</span> GetIteratorFlattenable ( <var>obj</var>, <var>primitiveHandling</var> )</h1>
|
||
<p>The abstract operation GetIteratorFlattenable takes arguments <var>obj</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2798"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>primitiveHandling</var> (<emu-const>iterate-string-primitives</emu-const> or <emu-const>reject-primitives</emu-const>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2799"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an <emu-xref href="#sec-iterator-records" id="_ref_2800"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2801"><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>obj</var> <emu-xref href="#sec-object-type" id="_ref_2802"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, then<ol><li>If <var>primitiveHandling</var> is <emu-const>reject-primitives</emu-const>, throw a <emu-val>TypeError</emu-val> exception.</li><li><emu-xref href="#assert" id="_ref_2803"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>primitiveHandling</var> is <emu-const>iterate-string-primitives</emu-const>.</li><li>If <var>obj</var> <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_2804"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is not a String</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>Let <var>method</var> be ? <emu-xref aoid="GetMethod" id="_ref_2805"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>obj</var>, <emu-xref href="#sec-well-known-symbols" id="_ref_2806"><a href="ecmascript-data-types-and-values.html#sec-well-known-symbols">%Symbol.iterator%</a></emu-xref>).</li><li>If <var>method</var> is <emu-val>undefined</emu-val>, then<ol><li>Let <var>iterator</var> be <var>obj</var>.</li></ol></li><li>Else,<ol><li>Let <var>iterator</var> be ? <emu-xref aoid="Call" id="_ref_2807"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>method</var>, <var>obj</var>).</li></ol></li><li>If <var>iterator</var> <emu-xref href="#sec-object-type" id="_ref_2808"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <emu-xref aoid="GetIteratorDirect" id="_ref_2809"><a href="abstract-operations.html#sec-getiteratordirect" class="e-user-code">GetIteratorDirect</a></emu-xref>(<var>iterator</var>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iteratornext" type="abstract operation" aoid="IteratorNext">
|
||
<h1><span class="secnum">7.4.6</span> IteratorNext ( <var>iteratorRecord</var> [ , <var>value</var> ] )</h1>
|
||
<p>The abstract operation IteratorNext takes argument <var>iteratorRecord</var> (an <emu-xref href="#sec-iterator-records" id="_ref_2810"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>) and optional argument <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2811"><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_2812"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> an Object or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2813"><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>value</var> is not present, then<ol><li>Let <var>result</var> be <emu-xref aoid="Completion" id="_ref_2814"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="Call" id="_ref_2815"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>iteratorRecord</var>.<var class="field">[[NextMethod]]</var>, <var>iteratorRecord</var>.<var class="field">[[Iterator]]</var>)).</li></ol></li><li>Else,<ol><li>Let <var>result</var> be <emu-xref aoid="Completion" id="_ref_2816"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="Call" id="_ref_2817"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>iteratorRecord</var>.<var class="field">[[NextMethod]]</var>, <var>iteratorRecord</var>.<var class="field">[[Iterator]]</var>, « <var>value</var> »)).</li></ol></li><li>If <var>result</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2818"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>, then<ol><li>Set <var>iteratorRecord</var>.<var class="field">[[Done]]</var> to <emu-val>true</emu-val>.</li><li>Return ? <var>result</var>.</li></ol></li><li>Set <var>result</var> to ! <var>result</var>.</li><li>If <var>result</var> <emu-xref href="#sec-object-type" id="_ref_2819"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, then<ol><li>Set <var>iteratorRecord</var>.<var class="field">[[Done]]</var> to <emu-val>true</emu-val>.</li><li>Throw a <emu-val>TypeError</emu-val> exception.</li></ol></li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iteratorcomplete" type="abstract operation" aoid="IteratorComplete">
|
||
<h1><span class="secnum">7.4.7</span> IteratorComplete ( <var>iteratorResult</var> )</h1>
|
||
<p>The abstract operation IteratorComplete takes argument <var>iteratorResult</var> (an Object) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2820"><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_2821"><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>Return <emu-xref aoid="ToBoolean" id="_ref_2822"><a href="abstract-operations.html#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Get" id="_ref_2823"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>iteratorResult</var>, <emu-val>"done"</emu-val>)).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iteratorvalue" type="abstract operation" aoid="IteratorValue">
|
||
<h1><span class="secnum">7.4.8</span> IteratorValue ( <var>iteratorResult</var> )</h1>
|
||
<p>The abstract operation IteratorValue takes argument <var>iteratorResult</var> (an Object) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2824"><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_2825"><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_2826"><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>Return ? <emu-xref aoid="Get" id="_ref_2827"><a href="abstract-operations.html#sec-get-o-p" class="e-user-code">Get</a></emu-xref>(<var>iteratorResult</var>, <emu-val>"value"</emu-val>).</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iteratorstep" type="abstract operation" aoid="IteratorStep">
|
||
<h1><span class="secnum">7.4.9</span> IteratorStep ( <var>iteratorRecord</var> )</h1>
|
||
<p>The abstract operation IteratorStep takes argument <var>iteratorRecord</var> (an <emu-xref href="#sec-iterator-records" id="_ref_2828"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2829"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either an Object or <emu-const>done</emu-const>, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2830"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It requests the next value from <var>iteratorRecord</var>.<var class="field">[[Iterator]]</var> by calling <var>iteratorRecord</var>.<var class="field">[[NextMethod]]</var> and returns either <emu-const>done</emu-const> indicating that the <emu-xref href="#sec-iterator-interface" id="_ref_2831"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator</a></emu-xref> has reached its end or the <emu-xref href="#sec-iteratorresult-interface" id="_ref_2832"><a href="control-abstraction-objects.html#sec-iteratorresult-interface">IteratorResult object</a></emu-xref> if a next value is available. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>result</var> be ? <emu-xref aoid="IteratorNext" id="_ref_2833"><a href="abstract-operations.html#sec-iteratornext" class="e-user-code">IteratorNext</a></emu-xref>(<var>iteratorRecord</var>).</li><li>Let <var>done</var> be <emu-xref aoid="Completion" id="_ref_2834"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="IteratorComplete" id="_ref_2835"><a href="abstract-operations.html#sec-iteratorcomplete" class="e-user-code">IteratorComplete</a></emu-xref>(<var>result</var>)).</li><li>If <var>done</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2836"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>, then<ol><li>Set <var>iteratorRecord</var>.<var class="field">[[Done]]</var> to <emu-val>true</emu-val>.</li><li>Return ? <var>done</var>.</li></ol></li><li>Set <var>done</var> to ! <var>done</var>.</li><li>If <var>done</var> is <emu-val>true</emu-val>, then<ol><li>Set <var>iteratorRecord</var>.<var class="field">[[Done]]</var> to <emu-val>true</emu-val>.</li><li>Return <emu-const>done</emu-const>.</li></ol></li><li>Return <var>result</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iteratorstepvalue" type="abstract operation" aoid="IteratorStepValue">
|
||
<h1><span class="secnum">7.4.10</span> IteratorStepValue ( <var>iteratorRecord</var> )</h1>
|
||
<p>The abstract operation IteratorStepValue takes argument <var>iteratorRecord</var> (an <emu-xref href="#sec-iterator-records" id="_ref_2837"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2838"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> either an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2839"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> or <emu-const>done</emu-const>, or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2840"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>. It requests the next value from <var>iteratorRecord</var>.<var class="field">[[Iterator]]</var> by calling <var>iteratorRecord</var>.<var class="field">[[NextMethod]]</var> and returns either <emu-const>done</emu-const> indicating that the <emu-xref href="#sec-iterator-interface" id="_ref_2841"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator</a></emu-xref> has reached its end or the value from the <emu-xref href="#sec-iteratorresult-interface" id="_ref_2842"><a href="control-abstraction-objects.html#sec-iteratorresult-interface">IteratorResult object</a></emu-xref> if a next value is available. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>result</var> be ? <emu-xref aoid="IteratorStep" id="_ref_2843"><a href="abstract-operations.html#sec-iteratorstep" class="e-user-code">IteratorStep</a></emu-xref>(<var>iteratorRecord</var>).</li><li>If <var>result</var> is <emu-const>done</emu-const>, then<ol><li>Return <emu-const>done</emu-const>.</li></ol></li><li>Let <var>value</var> be <emu-xref aoid="Completion" id="_ref_2844"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="IteratorValue" id="_ref_2845"><a href="abstract-operations.html#sec-iteratorvalue" class="e-user-code">IteratorValue</a></emu-xref>(<var>result</var>)).</li><li>If <var>value</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2846"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>, then<ol><li>Set <var>iteratorRecord</var>.<var class="field">[[Done]]</var> to <emu-val>true</emu-val>.</li></ol></li><li>Return ? <var>value</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iteratorclose" type="abstract operation" aoid="IteratorClose">
|
||
<h1><span class="secnum">7.4.11</span> IteratorClose ( <var>iteratorRecord</var>, <var>completion</var> )</h1>
|
||
<p>The abstract operation IteratorClose takes arguments <var>iteratorRecord</var> (an <emu-xref href="#sec-iterator-records" id="_ref_2847"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>) and <var>completion</var> (a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2848"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>) and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2849"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>. It is used to notify an <emu-xref href="#sec-iterator-interface" id="_ref_2850"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator</a></emu-xref> that it should perform any actions it would normally perform when it has reached its completed state. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_2851"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>iteratorRecord</var>.<var class="field">[[Iterator]]</var> <emu-xref href="#sec-object-type" id="_ref_2852"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>.</li><li>Let <var>iterator</var> be <var>iteratorRecord</var>.<var class="field">[[Iterator]]</var>.</li><li>Let <var>innerResult</var> be <emu-xref aoid="Completion" id="_ref_2853"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="GetMethod" id="_ref_2854"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>iterator</var>, <emu-val>"return"</emu-val>)).</li><li>If <var>innerResult</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2855"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion</a></emu-xref>, then<ol><li>Let <var>return</var> be <var>innerResult</var>.<var class="field">[[Value]]</var>.</li><li>If <var>return</var> is <emu-val>undefined</emu-val>, return ? <var>completion</var>.</li><li>Set <var>innerResult</var> to <emu-xref aoid="Completion" id="_ref_2856"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="Call" id="_ref_2857"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>return</var>, <var>iterator</var>)).</li></ol></li><li>If <var>completion</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2858"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>, return ? <var>completion</var>.</li><li>If <var>innerResult</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2859"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>, return ? <var>innerResult</var>.</li><li>If <var>innerResult</var>.<var class="field">[[Value]]</var> <emu-xref href="#sec-object-type" id="_ref_2860"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>completion</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iteratorcloseall" type="abstract operation" aoid="IteratorCloseAll">
|
||
<h1><span class="secnum">7.4.12</span> IteratorCloseAll ( <var>iters</var>, <var>completion</var> )</h1>
|
||
<p>The abstract operation IteratorCloseAll takes arguments <var>iters</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2861"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> of <emu-xref href="#sec-iterator-records" id="_ref_2862"><a href="abstract-operations.html#sec-iterator-records">Iterator Records</a></emu-xref>) and <var>completion</var> (a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2863"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>) and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2864"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>For each element <var>iter</var> of <var>iters</var>, in reverse <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2865"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref> order, do<ol><li>Set <var>completion</var> to <emu-xref aoid="Completion" id="_ref_2866"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="IteratorClose" id="_ref_2867"><a href="abstract-operations.html#sec-iteratorclose" class="e-user-code">IteratorClose</a></emu-xref>(<var>iter</var>, <var>completion</var>)).</li></ol></li><li>Return ? <var>completion</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-ifabruptcloseiterator" aoid="IfAbruptCloseIterator">
|
||
<h1><span class="secnum">7.4.13</span> IfAbruptCloseIterator ( <var>value</var>, <var>iteratorRecord</var> )</h1>
|
||
<p>IfAbruptCloseIterator is a shorthand for a sequence of algorithm steps that use an <emu-xref href="#sec-iterator-records" id="_ref_2868"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>. An algorithm step of the form:</p>
|
||
<emu-alg><ol><li><emu-xref aoid="IfAbruptCloseIterator" id="_ref_2869"><a href="abstract-operations.html#sec-ifabruptcloseiterator" class="e-user-code">IfAbruptCloseIterator</a></emu-xref>(<var>value</var>, <var>iteratorRecord</var>).</li></ol></emu-alg>
|
||
<p>means the same thing as:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_2870"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>value</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2871"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>.</li><li>If <var>value</var> is an <emu-xref href="#sec-completion-record-specification-type" id="_ref_2872"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">abrupt completion</a></emu-xref>, return ? <emu-xref aoid="IteratorClose" id="_ref_2873"><a href="abstract-operations.html#sec-iteratorclose" class="e-user-code">IteratorClose</a></emu-xref>(<var>iteratorRecord</var>, <var>value</var>).</li><li>Set <var>value</var> to ! <var>value</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-asynciteratorclose" type="abstract operation" aoid="AsyncIteratorClose">
|
||
<h1><span class="secnum">7.4.14</span> AsyncIteratorClose ( <var>iteratorRecord</var>, <var>completion</var> )</h1>
|
||
<p>The abstract operation AsyncIteratorClose takes arguments <var>iteratorRecord</var> (an <emu-xref href="#sec-iterator-records" id="_ref_2874"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>) and <var>completion</var> (a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2875"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>) and returns a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2876"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>. It is used to notify an <emu-xref href="#sec-asynciterator-interface" id="_ref_2877"><a href="control-abstraction-objects.html#sec-asynciterator-interface">async iterator</a></emu-xref> that it should perform any actions it would normally perform when it has reached its completed state. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_2878"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>iteratorRecord</var>.<var class="field">[[Iterator]]</var> <emu-xref href="#sec-object-type" id="_ref_2879"><a href="ecmascript-data-types-and-values.html#sec-object-type">is an Object</a></emu-xref>.</li><li>Let <var>iterator</var> be <var>iteratorRecord</var>.<var class="field">[[Iterator]]</var>.</li><li>Let <var>innerResult</var> be <emu-xref aoid="Completion" id="_ref_2880"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="GetMethod" id="_ref_2881"><a href="abstract-operations.html#sec-getmethod" class="e-user-code">GetMethod</a></emu-xref>(<var>iterator</var>, <emu-val>"return"</emu-val>)).</li><li>If <var>innerResult</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2882"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion</a></emu-xref>, then<ol><li>Let <var>return</var> be <var>innerResult</var>.<var class="field">[[Value]]</var>.</li><li>If <var>return</var> is <emu-val>undefined</emu-val>, return ? <var>completion</var>.</li><li>Set <var>innerResult</var> to <emu-xref aoid="Completion" id="_ref_2883"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="Call" id="_ref_2884"><a href="abstract-operations.html#sec-call" class="e-user-code">Call</a></emu-xref>(<var>return</var>, <var>iterator</var>)).</li><li>If <var>innerResult</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2885"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion</a></emu-xref>, set <var>innerResult</var> to <emu-xref aoid="Completion" id="_ref_2886"><a href="notational-conventions.html#sec-completion-ao">Completion</a></emu-xref>(<emu-xref aoid="Await" id="_ref_2887"><a href="control-abstraction-objects.html#await" class="e-user-code">Await</a></emu-xref>(<var>innerResult</var>.<var class="field">[[Value]]</var>)).</li></ol></li><li>If <var>completion</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2888"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>, return ? <var>completion</var>.</li><li>If <var>innerResult</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2889"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">throw completion</a></emu-xref>, return ? <var>innerResult</var>.</li><li>If <var>innerResult</var>.<var class="field">[[Value]]</var> <emu-xref href="#sec-object-type" id="_ref_2890"><a href="ecmascript-data-types-and-values.html#sec-object-type">is not an Object</a></emu-xref>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>completion</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-ifabruptcloseasynciterator" aoid="IfAbruptCloseAsyncIterator">
|
||
<h1><span class="secnum">7.4.15</span> IfAbruptCloseAsyncIterator ( <var>value</var>, <var>iteratorRecord</var> )</h1>
|
||
<p>IfAbruptCloseAsyncIterator is a shorthand for a sequence of algorithm steps that use an <emu-xref href="#sec-iterator-records" id="_ref_2891"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>. An algorithm step of the form:</p>
|
||
<emu-alg><ol><li><emu-xref aoid="IfAbruptCloseAsyncIterator" id="_ref_2892"><a href="abstract-operations.html#sec-ifabruptcloseasynciterator" class="e-user-code">IfAbruptCloseAsyncIterator</a></emu-xref>(<var>value</var>, <var>iteratorRecord</var>).</li></ol></emu-alg>
|
||
<p>means the same thing as:</p>
|
||
<emu-alg><ol><li><emu-xref href="#assert" id="_ref_2893"><a href="notational-conventions.html#assert">Assert</a></emu-xref>: <var>value</var> is a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2894"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">Completion Record</a></emu-xref>.</li><li>If <var>value</var> is an <emu-xref href="#sec-completion-record-specification-type" id="_ref_2895"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">abrupt completion</a></emu-xref>, return ? <emu-xref aoid="AsyncIteratorClose" id="_ref_2896"><a href="abstract-operations.html#sec-asynciteratorclose" class="e-user-code">AsyncIteratorClose</a></emu-xref>(<var>iteratorRecord</var>, <var>value</var>).</li><li>Set <var>value</var> to ! <var>value</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-createiterresultobject" type="abstract operation" aoid="CreateIteratorResultObject">
|
||
<h1><span class="secnum">7.4.16</span> CreateIteratorResultObject ( <var>value</var>, <var>done</var> )</h1>
|
||
<p>The abstract operation CreateIteratorResultObject takes arguments <var>value</var> (an <emu-xref href="#sec-ecmascript-language-types" id="_ref_2897"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>) and <var>done</var> (a Boolean) and returns an Object that conforms to the <emu-xref href="#sec-iteratorresult-interface" id="_ref_2898"><a href="control-abstraction-objects.html#sec-iteratorresult-interface">IteratorResult interface</a></emu-xref>. It creates an object that conforms to the <emu-xref href="#sec-iteratorresult-interface" id="_ref_2899"><a href="control-abstraction-objects.html#sec-iteratorresult-interface">IteratorResult interface</a></emu-xref>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>obj</var> be <emu-xref aoid="OrdinaryObjectCreate" id="_ref_2900"><a href="ordinary-and-exotic-objects-behaviours.html#sec-ordinaryobjectcreate">OrdinaryObjectCreate</a></emu-xref>(<emu-xref href="#sec-properties-of-the-object-prototype-object" id="_ref_2901"><a href="fundamental-objects.html#sec-properties-of-the-object-prototype-object">%Object.prototype%</a></emu-xref>).</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_2902"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>obj</var>, <emu-val>"value"</emu-val>, <var>value</var>).</li><li>Perform ! <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_2903"><a href="abstract-operations.html#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>obj</var>, <emu-val>"done"</emu-val>, <var>done</var>).</li><li>Return <var>obj</var>.</li></ol></emu-alg>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-createlistiteratorRecord" type="abstract operation" oldids="sec-createlistiterator,sec-listiteratornext-functions,sec-listiterator-next" aoid="CreateListIteratorRecord"><span id="sec-listiterator-next"></span><span id="sec-listiteratornext-functions"></span><span id="sec-createlistiterator"></span>
|
||
<h1><span class="secnum">7.4.17</span> CreateListIteratorRecord ( <var>list</var> )</h1>
|
||
<p>The abstract operation CreateListIteratorRecord takes argument <var>list</var> (a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2904"><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_2905"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref>) and returns an <emu-xref href="#sec-iterator-records" id="_ref_2906"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>. It creates an <emu-xref href="#sec-iterator-records" id="_ref_2907"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref> whose <var class="field">[[NextMethod]]</var> returns the successive elements of <var>list</var>. It performs the following steps when called:</p>
|
||
<emu-alg><ol><li>Let <var>closure</var> be a new <emu-xref href="#sec-abstract-closure" id="_ref_2908"><a href="ecmascript-data-types-and-values.html#sec-abstract-closure">Abstract Closure</a></emu-xref> with no parameters that captures <var>list</var> and performs the following steps when called:<ol><li>For each element <var>E</var> of <var>list</var>, do<ol><li>Perform ? <emu-xref aoid="GeneratorYield" id="_ref_2909"><a href="control-abstraction-objects.html#sec-generatoryield">GeneratorYield</a></emu-xref>(<emu-xref aoid="CreateIteratorResultObject" id="_ref_2910"><a href="abstract-operations.html#sec-createiterresultobject">CreateIteratorResultObject</a></emu-xref>(<var>E</var>, <emu-val>false</emu-val>)).</li></ol></li><li>Return <emu-xref aoid="NormalCompletion" id="_ref_2911"><a href="ecmascript-data-types-and-values.html#sec-normalcompletion">NormalCompletion</a></emu-xref>(<emu-val>undefined</emu-val>).</li></ol></li><li>Let <var>iterator</var> be <emu-xref aoid="CreateIteratorFromClosure" id="_ref_2912"><a href="control-abstraction-objects.html#sec-createiteratorfromclosure">CreateIteratorFromClosure</a></emu-xref>(<var>closure</var>, <emu-const>empty</emu-const>, <emu-xref href="#sec-%iterator.prototype%-object" id="_ref_2913"><a href="control-abstraction-objects.html#sec-%iterator.prototype%-object">%Iterator.prototype%</a></emu-xref>).</li><li>Return the <emu-xref href="#sec-iterator-records" id="_ref_2914"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref> { <var class="field">[[Iterator]]</var>: <var>iterator</var>, <var class="field">[[NextMethod]]</var>: %GeneratorPrototype.next%, <var class="field">[[Done]]</var>: <emu-val>false</emu-val> }.</li></ol></emu-alg>
|
||
<emu-note><span class="note">Note</span><div class="note-contents">
|
||
<p>The list <emu-xref href="#sec-iterator-interface" id="_ref_2915"><a href="control-abstraction-objects.html#sec-iterator-interface">iterator object</a></emu-xref> is never directly accessible to ECMAScript code.</p>
|
||
</div></emu-note>
|
||
</emu-clause>
|
||
|
||
<emu-clause id="sec-iteratortolist" oldids="sec-iterabletolist" type="abstract operation" aoid="IteratorToList"><span id="sec-iterabletolist"></span>
|
||
<h1><span class="secnum">7.4.18</span> IteratorToList ( <var>iteratorRecord</var> )</h1>
|
||
<p>The abstract operation IteratorToList takes argument <var>iteratorRecord</var> (an <emu-xref href="#sec-iterator-records" id="_ref_2916"><a href="abstract-operations.html#sec-iterator-records">Iterator Record</a></emu-xref>) and returns either a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2917"><a href="ecmascript-data-types-and-values.html#sec-completion-record-specification-type">normal completion containing</a></emu-xref> a <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2918"><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_2919"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types">ECMAScript language values</a></emu-xref> or a <emu-xref href="#sec-completion-record-specification-type" id="_ref_2920"><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>values</var> be a new empty <emu-xref href="#sec-list-and-record-specification-type" id="_ref_2921"><a href="ecmascript-data-types-and-values.html#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>Repeat,<ol><li>Let <var>next</var> be ? <emu-xref aoid="IteratorStepValue" id="_ref_2922"><a href="abstract-operations.html#sec-iteratorstepvalue" class="e-user-code">IteratorStepValue</a></emu-xref>(<var>iteratorRecord</var>).</li><li>If <var>next</var> is <emu-const>done</emu-const>, then<ol><li>Return <var>values</var>.</li></ol></li><li>Append <var>next</var> to <var>values</var>.</li></ol></li></ol></emu-alg>
|
||
</emu-clause>
|
||
</emu-clause>
|
||
</emu-clause></div></body></html> |