mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 21:31:46 +00:00
33 lines
17 KiB
HTML
33 lines
17 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-ecmascript-standard-built-in-objects"></head>
|
||
<body><div id="spec-container"><emu-clause id="sec-ecmascript-standard-built-in-objects">
|
||
<h1><span class="secnum">18</span> ECMAScript Standard Built-in Objects</h1>
|
||
<p>There are certain built-in objects available whenever an ECMAScript <emu-nt id="_ref_23787"><a href="ecmascript-language-scripts-and-modules.html#prod-Script">Script</a></emu-nt> or <emu-nt id="_ref_23788"><a href="ecmascript-language-scripts-and-modules.html#prod-Module">Module</a></emu-nt> begins execution. One, the <emu-xref href="#sec-global-object" id="_ref_9483"><a href="global-object.html#sec-global-object">global object</a></emu-xref>, is part of the global environment of the executing program. Others are accessible as initial properties of the <emu-xref href="#sec-global-object" id="_ref_9484"><a href="global-object.html#sec-global-object">global object</a></emu-xref> or indirectly as properties of accessible built-in objects.</p>
|
||
<p>Unless specified otherwise, a built-in object that is callable as a function is a built-in <emu-xref href="#function-object" id="_ref_9485"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> with the characteristics described in <emu-xref href="#sec-built-in-function-objects" id="_ref_526"><a href="ordinary-and-exotic-objects-behaviours.html#sec-built-in-function-objects">10.3</a></emu-xref>. Unless specified otherwise, the <var class="field">[[Extensible]]</var> internal slot of a built-in object initially has the value <emu-val>true</emu-val>. Every built-in <emu-xref href="#function-object" id="_ref_9486"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> has a <var class="field">[[Realm]]</var> internal slot whose value is the <emu-xref href="#realm-record" id="_ref_9487"><a href="executable-code-and-execution-contexts.html#realm-record">Realm Record</a></emu-xref> of the <emu-xref href="#realm" id="_ref_9488"><a href="executable-code-and-execution-contexts.html#realm">realm</a></emu-xref> for which the object was initially created.</p>
|
||
<p>Many built-in objects are functions: they can be invoked with arguments. Some of them furthermore are <emu-xref href="#constructor" id="_ref_9489"><a href="ecmascript-data-types-and-values.html#constructor">constructors</a></emu-xref>: they are functions intended for use with the <code>new</code> operator. For each built-in function, this specification describes the arguments required by that function and the properties of that <emu-xref href="#function-object" id="_ref_9490"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>. For each built-in <emu-xref href="#constructor" id="_ref_9491"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>, this specification furthermore describes properties of the prototype object of that <emu-xref href="#constructor" id="_ref_9492"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> and properties of specific object instances returned by a <code>new</code> expression that invokes that <emu-xref href="#constructor" id="_ref_9493"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>.</p>
|
||
<p>Unless otherwise specified in the description of a particular function, if a built-in function or <emu-xref href="#constructor" id="_ref_9494"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> is given fewer arguments than the function is specified to require, the function or <emu-xref href="#constructor" id="_ref_9495"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> shall behave exactly as if it had been given sufficient additional arguments, each such argument being the <emu-val>undefined</emu-val> value. Such missing arguments are considered to be “not present” and may be identified in that manner by specification algorithms. In the description of a particular function, the terms “<emu-val>this</emu-val> value” and “NewTarget” have the meanings given in <emu-xref href="#sec-built-in-function-objects" id="_ref_527"><a href="ordinary-and-exotic-objects-behaviours.html#sec-built-in-function-objects">10.3</a></emu-xref>.</p>
|
||
<p>Unless otherwise specified in the description of a particular function, if a built-in function or <emu-xref href="#constructor" id="_ref_9496"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> described is given more arguments than the function is specified to allow, the extra arguments are evaluated by the call and then ignored by the function. However, an implementation may define implementation specific behaviour relating to such arguments as long as the behaviour is not the throwing of a <emu-val>TypeError</emu-val> exception that is predicated simply on the presence of an extra argument.</p>
|
||
<emu-note><span class="note">Note 1</span><div class="note-contents">
|
||
<p>Implementations that add additional capabilities to the set of built-in functions are encouraged to do so by adding new functions rather than adding new parameters to existing functions.</p>
|
||
</div></emu-note>
|
||
<p>Unless otherwise specified every built-in function and every built-in <emu-xref href="#constructor" id="_ref_9497"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref> has the <emu-xref href="#sec-properties-of-the-function-prototype-object" id="_ref_9498"><a href="fundamental-objects.html#sec-properties-of-the-function-prototype-object">Function prototype object</a></emu-xref>, which is the initial value of the expression <code>Function.prototype</code> (<emu-xref href="#sec-properties-of-the-function-prototype-object" id="_ref_528"><a href="fundamental-objects.html#sec-properties-of-the-function-prototype-object">20.2.3</a></emu-xref>), as the value of its <var class="field">[[Prototype]]</var> internal slot.</p>
|
||
<p>Unless otherwise specified every built-in prototype object has the <emu-xref href="#sec-properties-of-the-object-prototype-object" id="_ref_9499"><a href="fundamental-objects.html#sec-properties-of-the-object-prototype-object">Object prototype object</a></emu-xref>, which is the initial value of the expression <code>Object.prototype</code> (<emu-xref href="#sec-properties-of-the-object-prototype-object" id="_ref_529"><a href="fundamental-objects.html#sec-properties-of-the-object-prototype-object">20.1.3</a></emu-xref>), as the value of its <var class="field">[[Prototype]]</var> internal slot, except the <emu-xref href="#sec-properties-of-the-object-prototype-object" id="_ref_9500"><a href="fundamental-objects.html#sec-properties-of-the-object-prototype-object">Object prototype object</a></emu-xref> itself.</p>
|
||
<p>If this specification defines a built-in <emu-xref href="#constructor" id="_ref_9501"><a href="ecmascript-data-types-and-values.html#constructor">constructor</a></emu-xref>'s behaviour via algorithm steps, then that is its behaviour for the purposes of both <var class="field">[[Call]]</var> and <var class="field">[[Construct]]</var>. If such an algorithm needs to distinguish the two cases, it checks whether NewTarget is <emu-val>undefined</emu-val>, which indicates a <var class="field">[[Call]]</var> invocation.</p>
|
||
<p>Built-in <emu-xref href="#function-object" id="_ref_9502"><a href="ecmascript-data-types-and-values.html#function-object">function objects</a></emu-xref> that are not identified as <emu-xref href="#constructor" id="_ref_9503"><a href="ecmascript-data-types-and-values.html#constructor">constructors</a></emu-xref> do not implement the <var class="field">[[Construct]]</var> internal method unless otherwise specified in the description of a particular function.</p>
|
||
<p>Built-in <emu-xref href="#function-object" id="_ref_9504"><a href="ecmascript-data-types-and-values.html#function-object">function objects</a></emu-xref> that are not <emu-xref href="#constructor" id="_ref_9505"><a href="ecmascript-data-types-and-values.html#constructor">constructors</a></emu-xref> do not have a <emu-val>"prototype"</emu-val> property unless otherwise specified in the description of a particular function.</p>
|
||
<p>Each built-in function defined in this specification is created by calling the <emu-xref aoid="CreateBuiltinFunction" id="_ref_9506"><a href="ordinary-and-exotic-objects-behaviours.html#sec-createbuiltinfunction">CreateBuiltinFunction</a></emu-xref> abstract operation (<emu-xref href="#sec-createbuiltinfunction" id="_ref_530"><a href="ordinary-and-exotic-objects-behaviours.html#sec-createbuiltinfunction">10.3.4</a></emu-xref>). The values of the <var>length</var> and <var>name</var> parameters are the initial values of the <emu-val>"length"</emu-val> and <emu-val>"name"</emu-val> properties as discussed below. The values of the <var>prefix</var> parameter are similarly discussed below.</p>
|
||
<p>Every built-in <emu-xref href="#function-object" id="_ref_9507"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>, including <emu-xref href="#constructor" id="_ref_9508"><a href="ecmascript-data-types-and-values.html#constructor">constructors</a></emu-xref>, has a <emu-val>"length"</emu-val> property whose value is a non-negative <emu-xref href="#integral-number" id="_ref_9509"><a href="notational-conventions.html#integral-number">integral Number</a></emu-xref>. Unless otherwise specified, this value is the number of required parameters shown in the subclause heading for the function description. Optional parameters and rest parameters are not included in the parameter count.</p>
|
||
<emu-note><span class="note">Note 2</span><div class="note-contents">
|
||
<p>For example, the <emu-xref href="#function-object" id="_ref_9510"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> that is the initial value of the <emu-val>"map"</emu-val> property of the <emu-xref href="#sec-properties-of-the-array-prototype-object" id="_ref_9511"><a href="indexed-collections.html#sec-properties-of-the-array-prototype-object">Array prototype object</a></emu-xref> is described under the subclause heading «Array.prototype.map (callback [ , thisArg])» which shows the two named arguments callback and thisArg, the latter being optional; therefore the value of the <emu-val>"length"</emu-val> property of that <emu-xref href="#function-object" id="_ref_9512"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> is <emu-val>1</emu-val><sub>𝔽</sub>.</p>
|
||
</div></emu-note>
|
||
<p>Unless otherwise specified, the <emu-val>"length"</emu-val> property of a built-in <emu-xref href="#function-object" id="_ref_9513"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>true</emu-val> }.</p>
|
||
<p>Every built-in <emu-xref href="#function-object" id="_ref_9514"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref>, including <emu-xref href="#constructor" id="_ref_9515"><a href="ecmascript-data-types-and-values.html#constructor">constructors</a></emu-xref>, has a <emu-val>"name"</emu-val> property whose value <emu-xref href="#sec-ecmascript-language-types-string-type" id="_ref_9516"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-string-type">is a String</a></emu-xref>. Unless otherwise specified, this value is the name that is given to the function in this specification. Functions that are identified as anonymous functions use the empty String as the value of the <emu-val>"name"</emu-val> property. For functions that are specified as properties of objects, the name value is the <emu-xref href="#property-name" id="_ref_9517"><a href="ecmascript-data-types-and-values.html#property-name">property name</a></emu-xref> string used to access the function. Functions that are specified as get or set accessor functions of built-in properties have <emu-val>"get"</emu-val> or <emu-val>"set"</emu-val> (respectively) passed to the <var>prefix</var> parameter when calling <emu-xref aoid="CreateBuiltinFunction" id="_ref_9518"><a href="ordinary-and-exotic-objects-behaviours.html#sec-createbuiltinfunction">CreateBuiltinFunction</a></emu-xref>.</p>
|
||
<p>The value of the <emu-val>"name"</emu-val> property is explicitly specified for each built-in functions whose <emu-xref href="#property-key" id="_ref_9519"><a href="ecmascript-data-types-and-values.html#property-key">property key</a></emu-xref> <emu-xref href="#sec-ecmascript-language-types-symbol-type" id="_ref_9520"><a href="ecmascript-data-types-and-values.html#sec-ecmascript-language-types-symbol-type">is a Symbol</a></emu-xref> value. If such an explicitly specified value starts with the prefix <emu-val>"get "</emu-val> or <emu-val>"set "</emu-val> and the function for which it is specified is a get or set accessor function of a built-in property, the value without the prefix is passed to the <var>name</var> parameter, and the value <emu-val>"get"</emu-val> or <emu-val>"set"</emu-val> (respectively) is passed to the <var>prefix</var> parameter when calling <emu-xref aoid="CreateBuiltinFunction" id="_ref_9521"><a href="ordinary-and-exotic-objects-behaviours.html#sec-createbuiltinfunction">CreateBuiltinFunction</a></emu-xref>.</p>
|
||
<p>Unless otherwise specified, the <emu-val>"name"</emu-val> property of a built-in <emu-xref href="#function-object" id="_ref_9522"><a href="ecmascript-data-types-and-values.html#function-object">function object</a></emu-xref> has the attributes { <var class="field">[[Writable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>true</emu-val> }.</p>
|
||
<p>Every other <emu-xref href="#sec-object-type" id="_ref_9523"><a href="ecmascript-data-types-and-values.html#sec-object-type">data property</a></emu-xref> described in clauses <emu-xref href="#sec-global-object" id="_ref_531"><a href="global-object.html#sec-global-object">19</a></emu-xref> through <emu-xref href="#sec-reflection" id="_ref_532"><a href="reflection.html#sec-reflection">28</a></emu-xref> and in Annex <emu-xref href="#sec-additional-built-in-properties" id="_ref_533"><a href="additional-ecmascript-features-for-web-browsers.html#sec-additional-built-in-properties">B.2</a></emu-xref> has the attributes { <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> } unless otherwise specified.</p>
|
||
<p>Every <emu-xref href="#sec-object-type" id="_ref_9524"><a href="ecmascript-data-types-and-values.html#sec-object-type">accessor property</a></emu-xref> described in clauses <emu-xref href="#sec-global-object" id="_ref_534"><a href="global-object.html#sec-global-object">19</a></emu-xref> through <emu-xref href="#sec-reflection" id="_ref_535"><a href="reflection.html#sec-reflection">28</a></emu-xref> and in Annex <emu-xref href="#sec-additional-built-in-properties" id="_ref_536"><a href="additional-ecmascript-features-for-web-browsers.html#sec-additional-built-in-properties">B.2</a></emu-xref> has the attributes { <var class="field">[[Enumerable]]</var>: <emu-val>false</emu-val>, <var class="field">[[Configurable]]</var>: <emu-val>true</emu-val> } unless otherwise specified. If only a get accessor function is described, the set accessor function is the default value, <emu-val>undefined</emu-val>. If only a set accessor is described the get accessor is the default value, <emu-val>undefined</emu-val>.</p>
|
||
</emu-clause></div></body></html> |