6 ECMAScript Data Types and Values

Algorithms within this specification manipulate values each of which has an associated type. The possible value types are exactly those defined in this clause. Types are further subclassified into ECMAScript language types and specification types.

Within this specification, the notation “Type(x)” is used as shorthand for “the type of x” where “type” refers to the ECMAScript language and specification types defined in this clause. When the term “empty” is used as if it was naming a value, it is equivalent to saying “no value of any type”.

6.1 ECMAScript Language Types

An ECMAScript language type corresponds to values that are directly manipulated by an ECMAScript programmer using the ECMAScript language. The ECMAScript language types are Undefined, Null, Boolean, String, Symbol, Number, and Object. An ECMAScript language value is a value that is characterized by an ECMAScript language type.

6.1.1 The Undefined Type

The Undefined type has exactly one value, called undefined. Any variable that has not been assigned a value has the value undefined.

6.1.2 The Null Type

The Null type has exactly one value, called null.

6.1.3 The Boolean Type

The Boolean type represents a logical entity having two values, called true and false.

6.1.4 The String Type

The String type is the set of all ordered sequences of zero or more 16-bit unsigned integer values (“elements”) up to a maximum length of 253-1 elements. The String type is generally used to represent textual data in a running ECMAScript program, in which case each element in the String is treated as a UTF-16 code unit value. Each element is regarded as occupying a position within the sequence. These positions are indexed with nonnegative integers. The first element (if any) is at index 0, the next element (if any) at index 1, and so on. The length of a String is the number of elements (i.e., 16-bit values) within it. The empty String has length zero and therefore contains no elements.

Where ECMAScript operations interpret String values, each element is interpreted as a single UTF-16 code unit. However, ECMAScript does not place any restrictions or requirements on the sequence of code units in a String value, so they may be ill-formed when interpreted as UTF-16 code unit sequences. Operations that do not interpret String contents treat them as sequences of undifferentiated 16-bit unsigned integers. The function String.prototype.normalize (see 21.1.3.12) can be used to explicitly normalize a String value. String.prototype.localeCompare (see 21.1.3.10) internally normalizes String values, but no other operations implicitly normalize the strings upon which they operate. Only operations that are explicitly specified to be language or locale sensitive produce language-sensitive results.

NOTE The rationale behind this design was to keep the implementation of Strings as simple and high-performing as possible. If ECMAScript source text is in Normalized Form C, string literals are guaranteed to also be normalized, as long as they do not contain any Unicode escape sequences.

Some operations interpret String contents as UTF-16 encoded Unicode code points. In that case the interpretation is:

  • A code unit in the range 0 to 0xD7FF or in the range 0xE000 to 0xFFFF is interpreted as a code point with the same value.

  • A sequence of two code units, where the first code unit c1 is in the range 0xD800 to 0xDBFF and the second code unit c2 is in the range 0xDC00 to 0xDFFF, is a surrogate pair and is interpreted as a code point with the value (c1 - 0xD800) × 0x400 + (c20xDC00) + 0x10000. (See 10.1.2)

  • A code unit that is in the range 0xD800 to 0xDFFF, but is not part of a surrogate pair, is interpreted as a code point with the same value.

6.1.5 The Symbol Type

The Symbol type is the set of all non-String values that may be used as the key of an Object property (6.1.7).

Each possible Symbol value is unique and immutable.

Each Symbol value immutably holds an associated value called [[Description]] that is either undefined or a String value.

6.1.5.1 Well-Known Symbols

Well-known symbols are built-in Symbol values that are explicitly referenced by algorithms of this specification. They are typically used as the keys of properties whose values serve as extension points of a specification algorithm. Unless otherwise specified, well-known symbols values are shared by all Code Realms (8.2).

Within this specification a well-known symbol is referred to by using a notation of the form @@name, where “name” is one of the values listed in Table 1.

Table 1 — Well-known Symbols
Specification Name [[Description]] Value and Purpose
@@hasInstance "Symbol.hasInstance" A method that determines if a constructor object recognizes an object as one of the constructor’s instances. Called by the semantics of the instanceof operator.
@@isConcatSpreadable "Symbol.isConcatSpreadable" A Boolean valued property that if true indicates that an object should be flattened to its array elements by Array.prototype.concat.
@@iterator "Symbol.iterator" A method that returns the default Iterator for an object. Called by the semantics of the for-of statement.
@@match "Symbol.match" A regular expression method that matches the regular expression against a string. Called by the String.prototype.match method.
@@replace "Symbol.replace" A regular expression method that replaces matched substrings of a string. Called by the String.prototype.replace method.
@@search "Symbol.search" A regular expression method that returns the index within a string that matches the regular expression. Called by the String.prototype.search method.
@@species "Symbol.species" A function valued property that is the constructor function that is used to create derived objects.
@@split "Symbol.split" A regular expression method that splits a string at the indices that match the regular expression. Called by the String.prototype.split method.
@@toPrimitive "Symbol.toPrimitive" A method that converts an object to a corresponding primitive value. Called by the ToPrimitive abstract operation.
@@toStringTag "Symbol.toStringTag" A String valued property that is used in the creation of the default string description of an object. Accessed by the built-in method Object.prototype.toString.
@@unscopables "Symbol.unscopables" An object valued property whose own property names are property names that are excluded from the with environment bindings of the associated object.

6.1.6 The Number Type

The Number type has exactly 18437736874454810627 (that is, 264−253+3) values, representing the double-precision 64-bit format IEEE 754-2008 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic, except that the 9007199254740990 (that is, 253−2) distinct “Not-a-Number” values of the IEEE Standard are represented in ECMAScript as a single special NaN value. (Note that the NaN value is produced by the program expression NaN.) In some implementations, external code might be able to detect a difference between various Not-a-Number values, but such behaviour is implementation-dependent; to ECMAScript code, all NaN values are indistinguishable from each other.

NOTE The bit pattern that might be observed in an ArrayBuffer (see 24.1) after a Number value has been stored into it is not necessarily the same as the internal representation of that Number value used by the ECMAScript implementation.

There are two other special values, called positive Infinity and negative Infinity. For brevity, these values are also referred to for expository purposes by the symbols +∞ and −∞, respectively. (Note that these two infinite Number values are produced by the program expressions +Infinity (or simply Infinity) and -Infinity.)

The other 18437736874454810624 (that is, 264−253) values are called the finite numbers. Half of these are positive numbers and half are negative numbers; for every finite positive Number value there is a corresponding negative value having the same magnitude.

Note that there is both a positive zero and a negative zero. For brevity, these values are also referred to for expository purposes by the symbols +0 and −0, respectively. (Note that these two different zero Number values are produced by the program expressions +0 (or simply 0) and -0.)

The 18437736874454810622 (that is, 264−253−2) finite nonzero values are of two kinds:

18428729675200069632 (that is, 264−254) of them are normalized, having the form

s × m × 2e

where s is +1 or −1, m is a positive integer less than 253 but not less than 252, and e is an integer ranging from −1074 to 971, inclusive.

The remaining 9007199254740990 (that is, 253−2) values are denormalized, having the form

s × m × 2e

where s is +1 or −1, m is a positive integer less than 252, and e is −1074.

Note that all the positive and negative integers whose magnitude is no greater than 253 are representable in the Number type (indeed, the integer 0 has two representations, +0 and -0).

A finite number has an odd significand if it is nonzero and the integer m used to express it (in one of the two forms shown above) is odd. Otherwise, it has an even significand.

In this specification, the phrase “the Number value for x” where x represents an exact nonzero real mathematical quantity (which might even be an irrational number such as π) means a Number value chosen in the following manner. Consider the set of all finite values of the Number type, with −0 removed and with two additional values added to it that are not representable in the Number type, namely 21024 (which is +1 × 253 × 2971) and −21024 (which is −1 × 253 × 2971). Choose the member of this set that is closest in value to x. If two values of the set are equally close, then the one with an even significand is chosen; for this purpose, the two extra values 21024 and −21024 are considered to have even significands. Finally, if 21024 was chosen, replace it with +∞; if −21024 was chosen, replace it with −∞; if +0 was chosen, replace it with −0 if and only if x is less than zero; any other chosen value is used unchanged. The result is the Number value for x. (This procedure corresponds exactly to the behaviour of the IEEE 754-2008 “round to nearest, ties to even” mode.)

Some ECMAScript operators deal only with integers in specific ranges such as −231 through 231−1, inclusive, or in the range 0 through 216−1, inclusive. These operators accept any value of the Number type but first convert each such value to an integer value in the expected range. See the descriptions of the numeric conversion operations in 7.1.

6.1.7 The Object Type

An Object is logically a collection of properties. Each property is either a data property, or an accessor property:

  • A data property associates a key value with an ECMAScript language value and a set of Boolean attributes.

  • An accessor property associates a key value with one or two accessor functions, and a set of Boolean attributes. The accessor functions are used to store or retrieve an ECMAScript language value that is associated with the property.

Properties are identified using key values. A property key value is either an ECMAScript String value or a Symbol value. All String and Symbol values, including the empty string, are valid as property keys. A property name is a property key that is a String value.

An integer index is a String-valued property key that is a canonical numeric String (see 7.1.16) and whose numeric value is either +0 or a positive integer ≤ 253−1. An array index is an integer index whose numeric value i is in the range +0 ≤ i < 232−1.

Property keys are used to access properties and their values. There are two kinds of access for properties: get and set, corresponding to value retrieval and assignment, respectively. The properties accessible via get and set access includes both own properties that are a direct part of an object and inherited properties which are provided by another associated object via a property inheritance relationship. Inherited properties may be either own or inherited properties of the associated object. Each own property of an object must each have a key value that is distinct from the key values of the other own properties of that object.

All objects are logically collections of properties, but there are multiple forms of objects that differ in their semantics for accessing and manipulating their properties. Ordinary objects are the most common form of objects and have the default object semantics. An exotic object is any form of object whose property semantics differ in any way from the default semantics.

6.1.7.1 Property Attributes

Attributes are used in this specification to define and explain the state of Object properties. A data property associates a key value with the attributes listed in Table 2.

Table 2 — Attributes of a Data Property
Attribute Name Value Domain Description
[[Value]] Any ECMAScript language type The value retrieved by a get access of the property.
[[Writable]] Boolean If false, attempts by ECMAScript code to change the property’s [[Value]] attribute using [[Set]] will not succeed.
[[Enumerable]] Boolean If true, the property will be enumerated by a for-in enumeration (see 13.7.5). Otherwise, the property is said to be non-enumerable.
[[Configurable]] Boolean If false, attempts to delete the property, change the property to be an accessor property, or change its attributes (other than [[Value]], or changing [[Writable]] to false) will fail.

An accessor property associates a key value with the attributes listed in Table 3.

Table 3 — Attributes of an Accessor Property
Attribute Name Value Domain Description
[[Get]] Object | Undefined If the value is an Object it must be a function object. The function’s [[Call]] internal method (Table 6) is called with an empty arguments list to retrieve the property value each time a get access of the property is performed.
[[Set]] Object | Undefined If the value is an Object it must be a function object. The function’s [[Call]] internal method (Table 6) is called with an arguments list containing the assigned value as its sole argument each time a set access of the property is performed. The effect of a property's [[Set]] internal method may, but is not required to, have an effect on the value returned by subsequent calls to the property's [[Get]] internal method.
[[Enumerable]] Boolean If true, the property is to be enumerated by a for-in enumeration (see 13.7.5). Otherwise, the property is said to be non-enumerable.
[[Configurable]] Boolean If false, attempts to delete the property, change the property to be a data property, or change its attributes will fail.

If the initial values of a property’s attributes are not explicitly specified by this specification, the default value defined in Table 4 is used.

Table 4 — Default Attribute Values
Attribute Name Default Value
[[Value]] undefined
[[Get]] undefined
[[Set]] undefined
[[Writable]] false
[[Enumerable]] false
[[Configurable]] false

6.1.7.2 Object Internal Methods and Internal Slots

The actual semantics of objects, in ECMAScript, are specified via algorithms called internal methods. Each object in an ECMAScript engine is associated with a set of internal methods that defines its runtime behaviour. These internal methods are not part of the ECMAScript language. They are defined by this specification purely for expository purposes. However, each object within an implementation of ECMAScript must behave as specified by the internal methods associated with it. The exact manner in which this is accomplished is determined by the implementation.

Internal method names are polymorphic. This means that different object values may perform different algorithms when a common internal method name is invoked upon them. That actual object upon which an internal method is invoked is the “target” of the invocation. If, at runtime, the implementation of an algorithm attempts to use an internal method of an object that the object does not support, a TypeError exception is thrown.

Internal slots correspond to internal state that is associated with objects and used by various ECMAScript specification algorithms. Internal slots are not object properties and they are not inherited. Depending upon the specific internal slot specification, such state may consist of values of any ECMAScript language type or of specific ECMAScript specification type values. Unless explicitly specified otherwise, internal slots are allocated as part of the process of creating an object and may not be dynamically added to an object. Unless specified otherwise, the initial value of an internal slot is the value undefined. Various algorithms within this specification create objects that have internal slots. However, the ECMAScript language provides no direct way to associate internal slots with an object.

Internal methods and internal slots are identified within this specification using names enclosed in double square brackets [[ ]].

Table 5 summarizes the essential internal methods used by this specification that are applicable to all objects created or manipulated by ECMAScript code. Every object must have algorithms for all of the essential internal methods. However, all objects do not necessarily use the same algorithms for those methods.

The “Signature” column of Table 5 and other similar tables describes the invocation pattern for each internal method. The invocation pattern always includes a parenthesized list of descriptive parameter names. If a parameter name is the same as an ECMAScript type name then the name describes the required type of the parameter value. If an internal method explicitly returns a value, its parameter list is followed by the symbol “→” and the type name of the returned value. The type names used in signatures refer to the types defined in clause 6 augmented by the following additional names. “any” means the value may be any ECMAScript language type. An internal method implicitly returns a Completion Record as described in 6.2.2. In addition to its parameters, an internal method always has access to the object that is the target of the method invocation.

Table 5 — Essential Internal Methods
Internal Method Signature Description
[[GetPrototypeOf]] () Object | Null Determine the object that provides inherited properties for this object. A null value indicates that there are no inherited properties.
[[SetPrototypeOf]] (Object | Null) Boolean Associate this object with another object that provides inherited properties. Passing null indicates that there are no inherited properties. Returns true indicating that the operation was completed successfully or false indicating that the operation was not successful.
[[IsExtensible]] ( ) Boolean Determine whether it is permitted to add additional properties to this object.
[[PreventExtensions]] ( ) Boolean Control whether new properties may be added to this object. Returns true if the operation was successful or false if the operation was unsuccessful.
[[GetOwnProperty]] (propertyKey) Undefined | Property Descriptor Return a Property Descriptor for the own property of this object whose key is propertyKey, or undefined if no such property exists.
[[HasProperty]] (propertyKey) Boolean Return a Boolean value indicating whether this object already has either an own or inherited property whose key is propertyKey.
[[Get]] (propertyKey, Receiver)
any
Return the value of the property whose key is propertyKey from this object. If any ECMAScript code must be executed to retrieve the property value, Receiver is used as the this value when evaluating the code.
[[Set]] (propertyKey,value, Receiver)
Boolean
Set the value of the property whose key is propertyKey to value. If any ECMAScript code must be executed to set the property value, Receiver is used as the this value when evaluating the code. Returns true if the property value was set or false if it could not be set.
[[Delete]] (propertyKey) Boolean Remove the own property whose key is propertyKey from this object . Return false if the property was not deleted and is still present. Return true if the property was deleted or is not present.
[[DefineOwnProperty]] (propertyKey, PropertyDescriptor)
Boolean
Create or alter the own property, whose key is propertyKey, to have the state described by PropertyDescriptor. Return true if that property was successfully created/updated or false if the property could not be created or updated.
[[Enumerate]] ()Object Return an iterator object that produces the keys of the string-keyed enumerable properties of the object.
[[OwnPropertyKeys]] ()List of propertyKey Return a List whose elements are all of the own property keys for the object.

Table 6 summarizes additional essential internal methods that are supported by objects that may be called as functions. A function object is an object that supports the [[Call]] internal methods. A constructor (also referred to as a constructor function) is a function object that supports the [[Construct]] internal method.

Table 6 — Additional Essential Internal Methods of Function Objects
Internal Method Signature Description
[[Call]] (any, a List of any)
any
Executes code associated with this object. Invoked via a function call expression. The arguments to the internal method are a this value and a list containing the arguments passed to the function by a call expression. Objects that implement this internal method are callable.
[[Construct]] (a List of any, Object)
Object
Creates an object. Invoked via the new or super operators. The first argument to the internal method is a list containing the arguments of the operator. The second argument is the object to which the new operator was initially applied. Objects that implement this internal method are called constructors. A function object is not necessarily a constructor and such non-constructor function objects do not have a [[Construct]] internal method.

The semantics of the essential internal methods for ordinary objects and standard exotic objects are specified in clause 9. If any specified use of an internal method of an exotic object is not supported by an implementation, that usage must throw a TypeError exception when attempted.

6.1.7.3 Invariants of the Essential Internal Methods

The Internal Methods of Objects of an ECMAScript engine must conform to the list of invariants specified below. Ordinary ECMAScript Objects as well as all standard exotic objects in this specification maintain these invariants. ECMAScript Proxy objects maintain these invariants by means of runtime checks on the result of traps invoked on the [[ProxyHandler]] object.

Any implementation provided exotic objects must also maintain these invariants for those objects. Violation of these invariants may cause ECMAScript code to have unpredictable behaviour and create security issues. However, violation of these invariants must never compromise the memory safety of an implementation.

An implementation must not allow these invariants to be circumvented in any manner such as by providing alternative interfaces that implement the functionality of the essential internal methods without enforcing their invariants.

Definitions:

●   The target of an internal method is the object upon which the internal method is called.

●   A target is non-extensible if it has been observed to return false from its [[IsExtensible]] internal method, or true from its [[PreventExtensions]] internal method.

●   A non-existent property is a property that does not exist as an own property on a non-extensible target.

●   All references to SameValue are according to the definition of SameValue algorithm specified in 7.2.9.

[[GetPrototypeOf]] ( )

●   The Type of the return value must be either Object or Null.

●   If target is non-extensible, and [[GetPrototypeOf]] returns a value v, then any future calls to [[GetPrototypeOf]] should return the SameValue as v.

NOTE 1 An object’s prototype chain should have finite length (that is, starting from any object, recursively applying the [[GetPrototypeOf]] internal method to its result should eventually lead to the value null). However, this requirement is not enforceable as an object level invariant if the prototype chain includes any exotic objects that do not use the ordinary object definition of [[GetPrototypeOf]]. Such a circular prototype chain may result in infinite loops when accessing object properties.

[[SetPrototypeOf]] (V)

●   The Type of the return value must be Boolean.

●   If target is non-extensible, [[SetPrototypeOf]] must return false, unless V is the SameValue as the target’s observed [[GetPrototypeOf]] value.

[[PreventExtensions]] ( )

●   The Type of the return value must be Boolean.

●   If [[PreventExtensions]] returns true, all future calls to [[IsExtensible]] on the target must return false and the target is now considered non-extensible.

[[GetOwnProperty]] (P)

●   The Type of the return value must be either Property Descriptor or Undefined.

●   If the Type of the return value is Property Descriptor, the return value must be a complete property descriptor (see 6.2.4.6).

●   If a property P is described as a data property with Desc.[[Value]] equal to v and Desc.[[Writable]] and Desc.[[Configurable]] are both false, then the SameValue must be returned for the Desc.[[Value]] attribute of the property on all future calls to [[GetOwnProperty]] ( P ).

●   If P’s attributes other than [[Writable]] may change over time or if the property might disappear, then P’s [[Configurable]] attribute must be true.

●   If the [[Writable]] attribute may change from false to true, then the [[Configurable]] attribute must be true.

●   If the target is non-extensible and P is non-existent, then all future calls to [[GetOwnProperty]] (P) on the target must describe P as non-existent (i.e. [[GetOwnProperty]] (P) must return undefined).

NOTE 2 As a consequence of the third invariant, if a property is described as a data property and it may return different values over time, then either or both of the Desc.[[Writable]] and Desc.[[Configurable]] attributes must be true even if no mechanism to change the value is exposed via the other internal methods.

[[DefineOwnProperty]] (P, Desc)

●   The Type of the return value must be Boolean.

●   [[DefineOwnProperty]] must return false if P has previously been observed as a non-configurable own property of the target, unless either:

1. P is a non-configurable writable own data property. A non-configurable writable data property can be changed into a non-configurable non-writable data property.

2. All attributes in Desc are the SameValue as P’s attributes.

●   [[DefineOwnProperty]] (P, Desc) must return false if target is non-extensible and P is a non-existent own property. That is, a non-extensible target object cannot be extended with new properties.

[[HasProperty]] ( P )

●   The Type of the return value must be Boolean.

●   If P was previously observed as a non-configurable data or accessor own property of the target, [[HasProperty]] must return true.

[[Get]] (P, Receiver)

●   If P was previously observed as a non-configurable, non-writable own data property of the target with value v, then [[Get]] must return the SameValue.

●   If P was previously observed as a non-configurable own accessor property of the target whose [[Get]] attribute is undefined, the [[Get]] operation must return undefined.

[[Set]] ( P, V, Receiver)

●   The Type of the return value must be Boolean.

●   If P was previously observed as a non-configurable, non-writable own data property of the target, then [[Set]] must return false unless V is the SameValue as P’s [[Value]] attribute.

●   If P was previously observed as a non-configurable own accessor property of the target whose [[Set]] attribute is undefined, the [[Set]] operation must return false.

[[Delete]] ( P )

●   The Type of the return value must be Boolean.

●   If P was previously observed to be a non-configurable own data or accessor property of the target, [[Delete]] must return false.

[[Enumerate]] ( )

●   The Type of the return value must be Object.

[[OwnPropertyKeys]] ( )

●   The return value must be a List.

●   The Type of each element of the returned List is either String or Symbol.

●   The returned List must contain at least the keys of all non-configurable own properties that have previously been observed.

●   If the object is non-extensible, the returned List must contain only the keys of all own properties of the object that are observable using [[GetOwnProperty]].

[[Construct]] ( )

●   The Type of the return value must be Object.

6.1.7.4 Well-Known Intrinsic Objects

Well-known intrinsics are built-in objects that are explicitly referenced by the algorithms of this specification and which usually have Realm specific identities. Unless otherwise specified each intrinsic object actually corresponds to a set of similar objects, one per Realm.

Within this specification a reference such as %name% means the intrinsic object, associated with the current Realm, corresponding to the name. Determination of the current Realm and its intrinsics is described in 8.3. The well-known intrinsics are listed in Table 7.

Table 7 — Well-known Intrinsic Objects
Intrinsic Name Global Name ECMAScript Language Association
%Array% Array The Array constructor (22.1.1)
%ArrayBuffer% ArrayBuffer The ArrayBuffer constructor (24.1.2)
%ArrayBufferPrototype% ArrayBuffer.prototype The initial value of the prototype data property of %ArrayBuffer%.
%ArrayIteratorPrototype% The prototype of Array iterator objects (22.1.5)
%ArrayPrototype% Array.prototype The initial value of the prototype data property of %Array% (22.1.3)
%ArrayProto_values% Array.prototype.values The initial value of the values data property of %ArrayPrototype% (22.1.3.29)
%Boolean% Boolean The Boolean constructor (19.3.1)
%BooleanPrototype% Boolean.prototype The initial value of the prototype data property of %Boolean% (19.3.3)
%DataView% DataView The DataView constructor (24.2.2)
%DataViewPrototype% DataView.prototype The initial value of the prototype data property of %DataView%
%Date% Date The Date constructor (20.3.2)
%DatePrototype% Date.prototype The initial value of the prototype data property of %Date%.
%decodeURI% decodeURI The decodeURI function (18.2.6.2)
%decodeURIComponent% decodeURIComponent The decodeURIComponent function (18.2.6.3)
%encodeURI% encodeURI The encodeURI function (18.2.6.4)
%encodeURIComponent% encodeURIComponent The encodeURIComponent function (18.2.6.5)
%Error% Error The Error constructor (19.5.1)
%ErrorPrototype% Error.prototype The initial value of the prototype data property of %Error%
%eval% eval The eval function (18.2.1)
%EvalError% EvalError The EvalError constructor (19.5.5.1)
%EvalErrorPrototype% EvalError.prototype The initial value of the prototype property of %EvalError%
%Float32Array% Float32Array The Float32Array constructor (22.2)
%Float32ArrayPrototype% Float32Array.prototype The initial value of the prototype data property of %Float32Array%.
%Float64Array% Float64Array The Float64Array constructor (22.2)
%Float64ArrayPrototype% Float64Array.prototype The initial value of the prototype data property of %Float64Array%
%Function% Function The Function constructor (19.2.1)
%FunctionPrototype% Function.prototype The initial value of the prototype data property of %Function%
%Generator% The initial value of the prototype property of %GeneratorFunction%
%GeneratorFunction% The constructor of generator objects (25.2.1)
%GeneratorPrototype% The initial value of the prototype property of %Generator%
%Int8Array% Int8Array The Int8Array constructor (22.2)
%Int8ArrayPrototype% Int8Array.prototype The initial value of the prototype data property of %Int8Array%
%Int16Array% Int16Array The Int16Array constructor (22.2)
%Int16ArrayPrototype% Int16Array.prototype The initial value of the prototype data property of %Int16Array%
%Int32Array% Int32Array The Int32Array constructor (22.2)
%Int32ArrayPrototype% Int32Array.prototype The initial value of the prototype data property of %Int32Array%
%isFinite% isFinite The isFinite function (18.2.2)
%isNaN% isNaN The isNaN function (18.2.3)
%IteratorPrototype% An object that all standard built-in iterator objects indirectly inherit from
%JSON% JSON The JSON object (24.3)
%Map% Map The Map constructor (23.1.1)
%MapIteratorPrototype% The prototype of Map iterator objects (23.1.5)
%MapPrototype% Map.prototype The initial value of the prototype data property of %Map%
%Math% Math The Math object (20.2)
%Number% Number The Number constructor (20.1.1)
%NumberPrototype% Number.prototype The initial value of the prototype property of %Number%
%Object% Object The Object constructor (19.1.1)
%ObjectPrototype% Object.prototype The initial value of the prototype data property of %Object%. (19.1.3)
%ObjProto_toString% Object.prototype.
toString
The initial value of the toString data property of %ObjectPrototype% (19.1.3.6)
%parseFloat% parseFloat The parseFloat function (18.2.4)
%parseInt% parseInt The parseInt function (18.2.5)
%Promise% Promise The Promise constructor (25.4.3)
%PromisePrototype% Promise.prototype The initial value of the prototype data property of %Promise%
%Proxy% Proxy The Proxy constructor (26.2.1)
%RangeError% RangeError The RangeError constructor (19.5.5.2)
%RangeErrorPrototype% RangeError.prototype The initial value of the prototype property of %RangeError%
%ReferenceError% ReferenceError The ReferenceError constructor (19.5.5.3)
%ReferenceErrorPrototype% ReferenceError.
prototype
The initial value of the prototype property of %ReferenceError%
%Reflect% Reflect The Reflect object (26.1)
%RegExp% RegExp The RegExp constructor (21.2.3)
%RegExpPrototype% RegExp.prototype The initial value of the prototype data property of %RegExp%
%Set% Set The Set constructor (23.2.1)
%SetIteratorPrototype% The prototype of Set iterator objects (23.2.5)
%SetPrototype% Set.prototype The initial value of the prototype data property of %Set%
%String% String The String constructor (21.1.1)
%StringIteratorPrototype% The prototype of String iterator objects (21.1.5)
%StringPrototype% String.prototype The initial value of the prototype data property of %String%
%Symbol% Symbol The Symbol constructor (19.4.1)
%SymbolPrototype% Symbol.prototype The initial value of the prototype data property of %Symbol%. (19.4.3)
%SyntaxError% SyntaxError The SyntaxError constructor (19.5.5.4)
%SyntaxErrorPrototype% SyntaxError.prototype The initial value of the prototype property of %SyntaxError%
%ThrowTypeError% A function object that unconditionally throws a new instance of %TypeError%
%TypedArray% The super class of all typed Array constructors (22.2.1)
%TypedArrayPrototype% The initial value of the prototype property of %TypedArray%
%TypeError% TypeError The TypeError constructor (19.5.5.5)
%TypeErrorPrototype% TypeError.prototype The initial value of the prototype property of %TypeError%
%Uint8Array% Uint8Array The Uint8Array constructor (22.2)
%Uint8ArrayPrototype% Uint8Array.prototype The initial value of the prototype data property of %Uint8Array%
%Uint8ClampedArray% Uint8ClampedArray The Uint8ClampedArray constructor (22.2)
%Uint8ClampedArrayPrototype% Uint8ClampedArray.
prototype
The initial value of the prototype data property of %Uint8ClampedArray%
%Uint16Array% Uint16Array The Uint16Array constructor (22.2)
%Uint16ArrayPrototype% Uint16Array.prototype The initial value of the prototype data property of %Uint16Array%
%Uint32Array% Uint32Array The Uint32Array constructor (22.2)
%Uint32ArrayPrototype% Uint32Array.prototype The initial value of the prototype data property of %Uint32Array%
%URIError% URIError The URIError constructor (19.5.5.6)
%URIErrorPrototype% URIError.prototype The initial value of the prototype property of %URIError%
%WeakMap% WeakMap The WeakMap constructor (23.3.1)
%WeakMapPrototype% WeakMap.prototype The initial value of the prototype data property of %WeakMap%
%WeakSet% WeakSet The WeakSet constructor (23.4.1)
%WeakSetPrototype% WeakSet.prototype The initial value of the prototype data property of %WeakSet%

6.2 ECMAScript Specification Types

A specification type corresponds to meta-values that are used within algorithms to describe the semantics of ECMAScript language constructs and ECMAScript language types. The specification types are Reference, List, Completion, Property Descriptor, Lexical Environment, Environment Record, and Data Block. Specification type values are specification artefacts that do not necessarily correspond to any specific entity within an ECMAScript implementation. Specification type values may be used to describe intermediate results of ECMAScript expression evaluation but such values cannot be stored as properties of objects or values of ECMAScript language variables.

6.2.1 The List and Record Specification Type

The List type is used to explain the evaluation of argument lists (see 12.3.6) in new expressions, in function calls, and in other algorithms where a simple ordered list of values is needed. Values of the List type are simply ordered sequences of list elements containing the individual values. These sequences may be of any length. The elements of a list may be randomly accessed using 0-origin indices. For notational convenience an array-like syntax can be used to access List elements. For example, arguments[2] is shorthand for saying the 3rd element of the List arguments.

For notational convenience within this specification, a literal syntax can be used to express a new List value. For example, «1, 2» defines a List value that has two elements each of which is initialized to a specific value. A new empty List can be expressed as «».

The Record type is used to describe data aggregations within the algorithms of this specification. A Record type value consists of one or more named fields. The value of each field is either an ECMAScript value or an abstract value represented by a name associated with the Record type. Field names are always enclosed in double brackets, for example [[value]].

For notational convenience within this specification, an object literal-like syntax can be used to express a Record value. For example, {[[field1]]: 42, [[field2]]: false, [[field3]]: empty} defines a Record value that has three fields, each of which is initialized to a specific value. Field name order is not significant. Any fields that are not explicitly listed are considered to be absent.

In specification text and algorithms, dot notation may be used to refer to a specific field of a Record value. For example, if R is the record shown in the previous paragraph then R.[[field2]] is shorthand for “the field of R named [[field2]]”.

Schema for commonly used Record field combinations may be named, and that name may be used as a prefix to a literal Record value to identify the specific kind of aggregations that is being described. For example: PropertyDescriptor{[[Value]]: 42, [[Writable]]: false, [[Configurable]]: true}.

6.2.2 The Completion Record Specification Type

The Completion type is a Record used to explain the runtime propagation of values and control flow such as the behaviour of statements (break, continue, return and throw) that perform nonlocal transfers of control.

Values of the Completion type are Record values whose fields are defined as by Table 8.

Table 8 — Completion Record Fields
Field Value Meaning
[[type]] One of normal, break, continue, return, or throw The type of completion that occurred.
[[value]] any ECMAScript language value or empty The value that was produced.
[[target]] any ECMAScript string or empty The target label for directed control transfers.

The term “abrupt completion” refers to any completion with a [[type]] value other than normal.

6.2.2.1 NormalCompletion

The abstract operation NormalCompletion with a single argument, such as:

  1. Return NormalCompletion(argument).

Is a shorthand that is defined as follows:

  1. Return Completion{[[type]]: normal, [[value]]: argument, [[target]]:empty}.

6.2.2.2 Implicit Completion Values

The algorithms of this specification often implicitly return Completion Records whose [[type]] is normal. Unless it is otherwise obvious from the context, an algorithm statement that returns a value that is not a Completion Record, such as:

  1. Return "Infinity".

means the same thing as:

  1. Return NormalCompletion("Infinity").

However, if the value expression of a “return” statement is a Completion Record construction literal, the resulting Completion Record is returned. If the value expression is a call to an abstract operation, the “return” statement simply returns the Completion Record produced by the abstract operation.

The abstract operation Completion(completionRecord) is used to emphasize that a previously computed Completion Record is being returned. The Completion abstract operation takes a single argument, completionRecord, and performs the following steps:

  1. Assert: completionRecord is a Completion Record.
  2. Return completionRecord as the Completion Record of this abstract operation.

A “return” statement without a value in an algorithm step means the same thing as:

  1. Return NormalCompletion(undefined).

Any reference to a Completion Record value that is in a context that does not explicitly require a complete Completion Record value is equivalent to an explicit reference to the [[value]] field of the Completion Record value unless the Completion Record is an abrupt completion.

6.2.2.3 Throw an Exception

Algorithms steps that say to throw an exception, such as

  1. Throw a TypeError exception.

mean the same things as:

  1. Return Completion{[[type]]: throw, [[value]]: a newly created TypeError object, [[target]]:empty}.

6.2.2.4 ReturnIfAbrupt

Algorithms steps that say

  1. ReturnIfAbrupt(argument).

mean the same thing as:

  1. If argument is an abrupt completion, return argument.
  2. Else if argument is a Completion Record, let argument be argument.[[value]].

6.2.2.5 UpdateEmpty ( completionRecord, value)

The abstract operation UpdateEmpty with arguments completionRecord and value performs the following steps:

  1. Assert: if completionRecord.[[type]] is throw then completionRecord.[[value]] is not empty.
  2. If completionRecord.[[type]] is throw, return Completion(completionRecord).
  3. If completionRecord.[[value]] is not empty, return Completion(completionRecord).
  4. Return Completion{[[type]]: completionRecord.[[type]], [[value]]: value, [[target]]: completionRecord.[[target]] }.

6.2.3 The Reference Specification Type

NOTE The Reference type is used to explain the behaviour of such operators as delete, typeof, the assignment operators, the super keyword and other language features. For example, the left-hand operand of an assignment is expected to produce a reference.

A Reference is a resolved name or property binding. A Reference consists of three components, the base value, the referenced name and the Boolean valued strict reference flag. The base value is either undefined, an Object, a Boolean, a String, a Symbol, a Number, or an Environment Record (8.1.1). A base value of undefined indicates that the Reference could not be resolved to a binding. The referenced name is a String or Symbol value.

A Super Reference is a Reference that is used to represents a name binding that was expressed using the super keyword. A Super Reference has an additional thisValue component and its base value will never be an Environment Record.

The following abstract operations are used in this specification to access the components of references:

  • GetBase(V). Returns the base value component of the reference V.

  • GetReferencedName(V). Returns the referenced name component of the reference V.

  • IsStrictReference(V). Returns the strict reference flag component of the reference V.

  • HasPrimitiveBase(V). Returns true if Type(base) is Boolean, String, Symbol, or Number.

  • IsPropertyReference(V). Returns true if either the base value is an object or HasPrimitiveBase(V) is true; otherwise returns false.

  • IsUnresolvableReference(V). Returns true if the base value is undefined and false otherwise.

  • IsSuperReference(V). Returns true if this reference has a thisValue component.

The following abstract operations are used in this specification to operate on references:

6.2.3.1 GetValue (V)

  1. ReturnIfAbrupt(V).
  2. If Type(V) is not Reference, return V.
  3. Let base be GetBase(V).
  4. If IsUnresolvableReference(V), throw a ReferenceError exception.
  5. If IsPropertyReference(V), then
    1. If HasPrimitiveBase(V) is true, then
      1. Assert: In this case, base will never be null or undefined.
      2. Let base be ToObject(base).
    2. Return base.[[Get]](GetReferencedName(V), GetThisValue(V)).
  6. Else base must be an Environment Record,
    1. Return base.GetBindingValue(GetReferencedName(V), IsStrictReference(V)) (see 8.1.1).

NOTE The object that may be created in step 5.a.ii is not accessible outside of the above abstract operation and the ordinary object [[Get]] internal method. An implementation might choose to avoid the actual creation of the object.

6.2.3.2 PutValue (V, W)

  1. ReturnIfAbrupt(V).
  2. ReturnIfAbrupt(W).
  3. If Type(V) is not Reference, throw a ReferenceError exception.
  4. Let base be GetBase(V).
  5. If IsUnresolvableReference(V), then
    1. If IsStrictReference(V) is true, then
      1. Throw ReferenceError exception.
    2. Let globalObj be GetGlobalObject().
    3. Return Set(globalObj,GetReferencedName(V), W, false).
  6. Else if IsPropertyReference(V), then
    1. If HasPrimitiveBase(V) is true, then
      1. Assert: In this case, base will never be null or undefined.
      2. Set base to ToObject(base).
    2. Let succeeded be base.[[Set]](GetReferencedName(V), W, GetThisValue(V)).
    3. ReturnIfAbrupt(succeeded).
    4. If succeeded is false and IsStrictReference(V) is true, throw a TypeError exception.
    5. Return.
  7. Else base must be an Environment Record.
    1. Return base.SetMutableBinding(GetReferencedName(V), W, IsStrictReference(V)) (see 8.1.1).

NOTE The object that may be created in step 6.a.ii is not accessible outside of the above algorithm and the ordinary object [[Set]] internal method. An implementation might choose to avoid the actual creation of that object.

6.2.3.3 GetThisValue (V)

  1. Assert: IsPropertyReference(V) is true.
  2. If IsSuperReference(V), then
    1. Return the value of the thisValue component of the reference V.
  3. Return GetBase(V).

6.2.3.4 InitializeReferencedBinding (V, W)

  1. ReturnIfAbrupt(V).
  2. ReturnIfAbrupt(W).
  3. Assert: Type(V) is Reference.
  4. Assert: IsUnresolvableReference(V) is false.
  5. Let base be GetBase(V).
  6. Assert: base is an Environment Record.
  7. Return base.InitializeBinding(GetReferencedName(V), W).

6.2.4 The Property Descriptor Specification Type

The Property Descriptor type is used to explain the manipulation and reification of Object property attributes. Values of the Property Descriptor type are Records. Each field’s name is an attribute name and its value is a corresponding attribute value as specified in 6.1.7.1. In addition, any field may be present or absent. The schema name used within this specification to tag literal descriptions of Property Descriptor records is “PropertyDescriptor”.

Property Descriptor values may be further classified as data Property Descriptors and accessor Property Descriptors based upon the existence or use of certain fields. A data Property Descriptor is one that includes any fields named either [[Value]] or [[Writable]]. An accessor Property Descriptor is one that includes any fields named either [[Get]] or [[Set]]. Any Property Descriptor may have fields named [[Enumerable]] and [[Configurable]]. A Property Descriptor value may not be both a data Property Descriptor and an accessor Property Descriptor; however, it may be neither. A generic Property Descriptor is a Property Descriptor value that is neither a data Property Descriptor nor an accessor Property Descriptor. A fully populated Property Descriptor is one that is either an accessor Property Descriptor or a data Property Descriptor and that has all of the fields that correspond to the property attributes defined in either Table 2 or Table 3.

The following abstract operations are used in this specification to operate upon Property Descriptor values:

6.2.4.1 IsAccessorDescriptor ( Desc )

When the abstract operation IsAccessorDescriptor is called with Property Descriptor Desc, the following steps are taken:

  1. If Desc is undefined, return false.
  2. If both Desc.[[Get]] and Desc.[[Set]] are absent, return false.
  3. Return true.

6.2.4.2 IsDataDescriptor ( Desc )

When the abstract operation IsDataDescriptor is called with Property Descriptor Desc, the following steps are taken:

  1. If Desc is undefined, return false.
  2. If both Desc.[[Value]] and Desc.[[Writable]] are absent, return false.
  3. Return true.

6.2.4.3 IsGenericDescriptor ( Desc )

When the abstract operation IsGenericDescriptor is called with Property Descriptor Desc, the following steps are taken:

  1. If Desc is undefined, return false.
  2. If IsAccessorDescriptor(Desc) and IsDataDescriptor(Desc) are both false, return true.
  3. Return false.

6.2.4.4 FromPropertyDescriptor ( Desc )

When the abstract operation FromPropertyDescriptor is called with Property Descriptor Desc, the following steps are taken:

  1. If Desc is undefined, return undefined.
  2. Let obj be ObjectCreate(%ObjectPrototype%).
  3. Assert: obj is an extensible ordinary object with no own properties.
  4. If Desc has a [[Value]] field, then
    1. Perform CreateDataProperty(obj, "value", Desc.[[Value]]).
  5. If Desc has a [[Writable]] field, then
    1. Perform CreateDataProperty(obj, "writable", Desc.[[Writable]]).
  6. If Desc has a [[Get]] field, then
    1. Perform CreateDataProperty(obj, "get", Desc.[[Get]]).
  7. If Desc has a [[Set]] field, then
    1. Perform CreateDataProperty(obj, "set", Desc.[[Set]])
  8. If Desc has an [[Enumerable]] field, then
    1. Perform CreateDataProperty(obj, "enumerable", Desc.[[Enumerable]]).
  9. If Desc has a [[Configurable]] field, then
    1. Perform CreateDataProperty(obj , "configurable", Desc.[[Configurable]]).
  10. Assert: all of the above CreateDataProperty operations return true.
  11. Return obj.

6.2.4.5 ToPropertyDescriptor ( Obj )

When the abstract operation ToPropertyDescriptor is called with object Obj, the following steps are taken:

  1. ReturnIfAbrupt(Obj).
  2. If Type(Obj) is not Object, throw a TypeError exception.
  3. Let desc be a new Property Descriptor that initially has no fields.
  4. Let hasEnumerable be HasProperty(Obj, "enumerable").
  5. ReturnIfAbrupt(hasEnumerable).
  6. If hasEnumerable is true, then
    1. Let enum be ToBoolean(Get(Obj, "enumerable")).
    2. ReturnIfAbrupt(enum).
    3. Set the [[Enumerable]] field of desc to enum.
  7. Let hasConfigurable be HasProperty(Obj, "configurable").
  8. ReturnIfAbrupt(hasConfigurable).
  9. If hasConfigurable is true, then
    1. Let conf be ToBoolean(Get(Obj, "configurable")).
    2. ReturnIfAbrupt(conf).
    3. Set the [[Configurable]] field of desc to conf.
  10. Let hasValue be HasProperty(Obj, "value").
  11. ReturnIfAbrupt(hasValue).
  12. If hasValue is true, then
    1. Let value be Get(Obj, "value").
    2. ReturnIfAbrupt(value).
    3. Set the [[Value]] field of desc to value.
  13. Let hasWritable be HasProperty(Obj, "writable").
  14. ReturnIfAbrupt(hasWritable).
  15. If hasWritable is true, then
    1. Let writable be ToBoolean(Get(Obj, "writable")).
    2. ReturnIfAbrupt(writable).
    3. Set the [[Writable]] field of desc to writable.
  16. Let hasGet be HasProperty(Obj, "get").
  17. ReturnIfAbrupt(hasGet).
  18. If hasGet is true, then
    1. Let getter be Get(Obj, "get").
    2. ReturnIfAbrupt(getter).
    3. If IsCallable(getter) is false and getter is not undefined, throw a TypeError exception.
    4. Set the [[Get]] field of desc to getter.
  19. Let hasSet be HasProperty(Obj, "set").
  20. ReturnIfAbrupt(hasSet).
  21. If hasSet is true, then
    1. Let setter be Get(Obj, "set").
    2. ReturnIfAbrupt(setter).
    3. If IsCallable(setter) is false and setter is not undefined, throw a TypeError exception.
    4. Set the [[Set]] field of desc to setter.
  22. If either desc.[[Get]] or desc.[[Set]] is present, then
    1. If either desc.[[Value]] or desc.[[Writable]] is present, throw a TypeError exception.
  23. Return desc.

6.2.4.6 CompletePropertyDescriptor ( Desc )

When the abstract operation CompletePropertyDescriptor is called with Property Descriptor Desc the following steps are taken:

  1. ReturnIfAbrupt(Desc).
  2. Assert: Desc is a Property Descriptor
  3. Let like be Record{[[Value]]: undefined, [[Writable]]: false, [[Get]]: undefined, [[Set]]: undefined, [[Enumerable]]: false, [[Configurable]]: false}.
  4. If either IsGenericDescriptor(Desc) or IsDataDescriptor(Desc) is true, then
    1. If Desc does not have a [[Value]] field, set Desc.[[Value]] to like.[[Value]].
    2. If Desc does not have a [[Writable]] field, set Desc.[[Writable]] to like.[[Writable]].
  5. Else,
    1. If Desc does not have a [[Get]] field, set Desc.[[Get]] to like.[[Get]].
    2. If Desc does not have a [[Set]] field, set Desc.[[Set]] to like.[[Set]].
  6. If Desc does not have an [[Enumerable]] field, set Desc.[[Enumerable]] to like.[[Enumerable]].
  7. If Desc does not have a [[Configurable]] field, set Desc.[[Configurable]] to like.[[Configurable]].
  8. Return Desc.

6.2.5 The Lexical Environment and Environment Record Specification Types

The Lexical Environment and Environment Record types are used to explain the behaviour of name resolution in nested functions and blocks. These types and the operations upon them are defined in 8.1.

6.2.6 Data Blocks

The Data Block specification type is used to describe a distinct and mutable sequence of byte-sized (8 bit) numeric values. A Data Block value is created with a fixed number of bytes that each have the initial value 0.

For notational convenience within this specification, an array-like syntax can be used to access the individual bytes of a Data Block value. This notation presents a Data Block value as a 0-origined integer indexed sequence of bytes. For example, if db is a 5 byte Data Block value then db[2] can be used to access its 3rd byte.

The following abstract operations are used in this specification to operate upon Data Block values:

6.2.6.1 CreateByteDataBlock(size)

When the abstract operation CreateByteDataBlock is called with integer argument size, the following steps are taken:

  1. Assert: size≥0.
  2. Let db be a new Data Block value consisting of size bytes. If it is impossible to create such a Data Block, throw a RangeError exception.
  3. Set all of the bytes of db to 0.
  4. Return db.

6.2.6.2 CopyDataBlockBytes(toBlock, toIndex, fromBlock, fromIndex, count)

When the abstract operation CopyDataBlockBytes is called the following steps are taken:

  1. Assert: fromBlock and toBlock are distinct Data Block values.
  2. Assert: fromIndex, toIndex, and count are positive integer values.
  3. Let fromSize be the number of bytes in fromBlock.
  4. Assert: fromIndex+countfromSize.
  5. Let toSize be the number of bytes in toBlock.
  6. Assert: toIndex+counttoSize.
  7. Repeat, while count>0
    1. Set toBlock[toIndex] to the value of fromBlock[fromIndex].
    2. Increment toIndex and fromIndex each by 1.
    3. Decrement count by 1.
  8. Return NormalCompletion(empty)