ECMA-262 (12th Edition) ECMAScript 2021 Language Specification - page 13

 

  Главная      Manuals     ECMA-262 (12th Edition) ECMAScript 2021 Language Specification

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     11      12      13      14     ..

 

 

 

ECMA-262 (12th Edition) ECMAScript 2021 Language Specification - page 13

 

 

a key value with the attributes listed in 

Table 3

.

Table 3: 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 

14.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 4

.

Table 4: 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 7

) 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 7

) 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 

14.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 5

 is used.

90

Table 5: Default Attribute Values

Attribute Name Default Value

[[Value]]

undefined

[[Get]]

undefined

[[Set]]

undefined

[[Writable]]

false

[[Enumerable]]

false

[[Configurable]]

false

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 6

 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.

An 

ordinary object

 is an object that satisfies all of the following criteria:

For the internal methods listed in 

Table 6

, the object uses those defined in 

10.1

.

If the object has a [[Call]] internal method, it uses the one defined in 

10.2.1

.

If the object has a [[Construct]] internal method, it uses the one defined in 

10.2.2

.

An 

exotic object

 is an object that is not an 

ordinary object

.

This specification recognizes different kinds of exotic objects by those objects' internal methods. An object that is

6.1.7.2  Object Internal Methods and Internal Slots

91

behaviourally equivalent to a particular kind of 

exotic object

 (such as an 

Array exotic object

 or a 

bound function exotic

object

), but does not have the same collection of internal methods specified for that kind, is not recognized as that

kind of 

exotic object

.

The “Signature” column of 

Table 6

 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

.

In addition to its parameters, an internal method always has access to the object that is the target of the method
invocation.

An internal method implicitly returns a 

Completion Record

, either a normal completion that wraps a value of the

return type shown in its invocation pattern, or a throw completion.

92

Table 6: Essential Internal Methods

Internal Method

Signature

Description

[[GetPrototypeOf]]

( ) 

 Object |

Null

Determine the object that provides inherited properties for this object.

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.

[[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.

[[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.

[[OwnPropertyKeys]]

( ) 

 

List

 of

propertyKey

Return a 

List

 whose elements are all of the own property keys for the

object.

Table 7

 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 method. A 

constructor

 is an object that

supports the [[Construct]] internal method. Every object that supports [[Construct]] must support [[Call]]; that is,

93

every 

constructor

 must be a 

function object

. Therefore, a 

constructor

 may also be referred to as a 

constructor

 function

 or

constructor

 

function object

.

Table 7: 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

 whose elements are 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

new

 operator or a 

super

super

 call. The first argument to

the internal method is a 

List

 whose elements are the arguments of the 

constructor

invocation or the 

super

super

 call. The second argument is the object to which the 

new

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

10

. 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.

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.

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.

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 the 

SameValue

 algorithm.

The value returned by any internal method must be a 

Completion Record

 with either:

6.1.7.3  Invariants of the Essential Internal Methods

Definitions:

Return value:

94

[[Type]] = 

normal

, [[Target]] = 

empty

, and [[Value]] = a value of the "normal return type" shown below for that

internal method, or
[[Type]] = 

throw

, [[Target]] = 

empty

, and [[Value]] = any 

ECMAScript language value

.

NOTE 1

The normal return type is 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 2

The normal return type is Boolean.
If target is non-extensible, [[SetPrototypeOf]] must return 

false

, unless 

V

 is the 

SameValue

 as the target's

observed [[GetPrototypeOf]] value.

The normal return type is Boolean.
If [[IsExtensible]] returns 

false

, all future calls to [[IsExtensible]] on the target must return 

false

.

The normal return type is Boolean.
If [[PreventExtensions]] returns 

true

, all future calls to [[IsExtensible]] on the target must return 

false

 and the

target is now considered non-extensible.

The normal return type is either 

Property Descriptor

 or Undefined.

If the Type of the return value is 

Property Descriptor

, the return value must be a fully populated 

Property

Descriptor

.

If 

P

 is described as a non-configurable, non-writable own 

data property

, all future calls to [[GetOwnProperty]]

P

 ) must return 

Property Descriptor

 whose [[Value]] is 

SameValue

 as 

P

's [[Value]] attribute.

If 

P

's attributes other than [[Writable]] may change over time or if the property might be deleted, 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

).

An internal method must not return a completion with [[Type]] = 

continue

break

, or 

return

.

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.

[[GetPrototypeOf]] ( )

[[SetPrototypeOf]] ( 

V

 )

[[IsExtensible]] ( )

[[PreventExtensions]] ( )

[[GetOwnProperty]] ( 

P

 )

95

NOTE 3

The normal return type is 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 writable 

data property

. A non-configurable writable 

data property

 can be changed into a non-

configurable non-writable 

data property

.

2.  All attributes of 

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.

The normal return type is Boolean.
If 

P

 was previously observed as a non-configurable own data or 

accessor property

 of the target,

[[HasProperty]] must return 

true

.

The normal return type is any 

ECMAScript language type

.

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

 as 

V

.

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

.

The normal return type is 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

.

The normal return type is Boolean.
If 

P

 was previously observed as a non-configurable own data or 

accessor property

 of the target, [[Delete]] must

return 

false

.

The normal return type is 

List

.

The returned 

List

 must not contain any duplicate entries.

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.

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 [[Writable]] and [[Configurable]]
attributes must be 

true

 even if no mechanism to change the value is exposed via the other

essential internal methods.

[[DefineOwnProperty]] ( 

P

Desc

 )

[[HasProperty]] ( 

P

 )

[[Get]] ( 

P

Receiver

 )

[[Set]] ( 

P

V

Receiver

 )

[[Delete]] ( 

P

 )

[[OwnPropertyKeys]] ( )

96

If the target is non-extensible, the returned 

List

 must contain only the keys of all own properties of the target

that are observable using [[GetOwnProperty]].

The normal return type is any 

ECMAScript language type

.

The normal return type is Object.
The target must also have a [[Call]] internal method.

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. A reference such as %name.a.b% means, as if the "b" property of the "a" property of the
intrinsic object %name% was accessed prior to any ECMAScript code being evaluated. Determination of the current

realm

 and its intrinsics is described in 

9.3

. The well-known intrinsics are listed in 

Table 8

.

Table 8: Well-Known Intrinsic Objects

Intrinsic Name

Global Name

ECMAScript Language Association

%AggregateError%

AggregateError

AggregateError

The 

AggregateError

AggregateError

 

constructor

(

20.5.7.1

)

%Array%

Array

Array

The Array 

constructor

 (

23.1.1

)

%ArrayBuffer%

ArrayBuffer

ArrayBuffer

The ArrayBuffer 

constructor

 (

25.1.3

)

%ArrayIteratorPrototype%

The prototype of Array iterator objects
(

23.1.5

)

%AsyncFromSyncIteratorPrototype%

The prototype of async-from-sync iterator
objects (

27.1.4

)

%AsyncFunction%

The 

constructor

 of async function objects

(

27.7.1

)

%AsyncGeneratorFunction%

The 

constructor

 of async iterator objects

(

27.4.1

)

%AsyncIteratorPrototype%

An object that all standard built-in async
iterator objects indirectly inherit from

%Atomics%

Atomics

Atomics

The 

Atomics

Atomics

 object (

25.4

)

%BigInt%

BigInt

BigInt

The BigInt 

constructor

 (

21.2.1

)

%BigInt64Array%

BigInt64Array

BigInt64Array

The BigInt64Array 

constructor

 (

23.2

)

[[Call]] ( )

[[Construct]] ( )

6.1.7.4  Well-Known Intrinsic Objects

97

%BigUint64Array%

BigUint64Array

BigUint64Array

The BigUint64Array 

constructor

 (

23.2

)

%Boolean%

Boolean

Boolean

The Boolean 

constructor

 (

20.3.1

)

%DataView%

DataView

DataView

The DataView 

constructor

 (

25.3.2

)

%Date%

Date

Date

The Date 

constructor

 (

21.4.2

)

%decodeURI%

decodeURI

decodeURI

The 

decodeURI

decodeURI

 function (

19.2.6.2

)

%decodeURIComponent%

decodeURIComponent

decodeURIComponent

The 

decodeURIComponent

decodeURIComponent

 function

(

19.2.6.3

)

%encodeURI%

encodeURI

encodeURI

The 

encodeURI

encodeURI

 function (

19.2.6.4

)

%encodeURIComponent%

encodeURIComponent

encodeURIComponent

The 

encodeURIComponent

encodeURIComponent

 function

(

19.2.6.5

)

%Error%

Error

Error

The Error 

constructor

 (

20.5.1

)

%eval%

eval

eval

The 

eval

eval

 function (

19.2.1

)

%EvalError%

EvalError

EvalError

The EvalError 

constructor

 (

20.5.5.1

)

%FinalizationRegistry%

FinalizationRegistry

FinalizationRegistry

The 

FinalizationRegistry

 

constructor

(

26.2.1

)

%Float32Array%

Float32Array

Float32Array

The Float32Array 

constructor

 (

23.2

)

%Float64Array%

Float64Array

Float64Array

The Float64Array 

constructor

 (

23.2

)

%ForInIteratorPrototype%

The prototype of For-In iterator objects
(

14.7.5.10

)

%Function%

Function

Function

The Function 

constructor

 (

20.2.1

)

%GeneratorFunction%

The 

constructor

 of generator objects (

27.3.1

)

%Int8Array%

Int8Array

Int8Array

The Int8Array 

constructor

 (

23.2

)

%Int16Array%

Int16Array

Int16Array

The Int16Array 

constructor

 (

23.2

)

%Int32Array%

Int32Array

Int32Array

The Int32Array 

constructor

 (

23.2

)

%isFinite%

isFinite

isFinite

The 

isFinite

isFinite

 function (

19.2.2

)

%isNaN%

isNaN

isNaN

The 

isNaN

isNaN

 function (

19.2.3

)

%IteratorPrototype%

An object that all standard built-in iterator
objects indirectly inherit from

%JSON%

JSON

JSON

The 

JSON

JSON

 object (

25.5

)

%Map%

Map

Map

The Map 

constructor

 (

24.1.1

)

%MapIteratorPrototype%

The prototype of Map iterator objects
(

24.1.5

)

98

%Math%

Math

Math

The 

Math

Math

 object (

21.3

)

%Number%

Number

Number

The Number 

constructor

 (

21.1.1

)

%Object%

Object

Object

The Object 

constructor

 (

20.1.1

)

%parseFloat%

parseFloat

parseFloat

The 

parseFloat

parseFloat

 function (

19.2.4

)

%parseInt%

parseInt

parseInt

The 

parseInt

parseInt

 function (

19.2.5

)

%Promise%

Promise

Promise

The Promise 

constructor

 (

27.2.3

)

%Proxy%

Proxy

Proxy

The Proxy 

constructor

 (

28.2.1

)

%RangeError%

RangeError

RangeError

The RangeError 

constructor

 (

20.5.5.2

)

%ReferenceError%

ReferenceError

ReferenceError

The ReferenceError 

constructor

 (

20.5.5.3

)

%Reflect%

Reflect

Reflect

The 

Reflect

Reflect

 object (

28.1

)

%RegExp%

RegExp

RegExp

The RegExp 

constructor

 (

22.2.3

)

%RegExpStringIteratorPrototype%

The prototype of RegExp String Iterator
objects (

22.2.7

)

%Set%

Set

Set

The Set 

constructor

 (

24.2.1

)

%SetIteratorPrototype%

The prototype of Set iterator objects (

24.2.5

)

%SharedArrayBuffer%

SharedArrayBuffer

SharedArrayBuffer

The SharedArrayBuffer 

constructor

 (

25.2.2

)

%String%

String

String

The String 

constructor

 (

22.1.1

)

%StringIteratorPrototype%

The prototype of String iterator objects
(

22.1.5

)

%Symbol%

Symbol

Symbol

The Symbol 

constructor

 (

20.4.1

)

%SyntaxError%

SyntaxError

SyntaxError

The SyntaxError 

constructor

 (

20.5.5.4

)

%ThrowTypeError%

function object

 that unconditionally

throws a new instance of 

%TypeError%

%TypedArray%

The super class of all typed Array
constructors (

23.2.1

)

%TypeError%

TypeError

TypeError

The TypeError 

constructor

 (

20.5.5.5

)

%Uint8Array%

Uint8Array

Uint8Array

The Uint8Array 

constructor

 (

23.2

)

%Uint8ClampedArray%

Uint8ClampedArray

Uint8ClampedArray

The Uint8ClampedArray 

constructor

 (

23.2

)

%Uint16Array%

Uint16Array

Uint16Array

The Uint16Array 

constructor

 (

23.2

)

%Uint32Array%

Uint32Array

Uint32Array

The Uint32Array 

constructor

 (

23.2

)

%URIError%

URIError

URIError

The URIError 

constructor

 (

20.5.5.6

)

99

%WeakMap%

WeakMap

WeakMap

The WeakMap 

constructor

 (

24.3.1

)

%WeakRef%

WeakRef

WeakRef

The 

WeakRef

 

constructor

 (

26.1.1

)

%WeakSet%

WeakSet

WeakSet

The WeakSet 

constructor

 (

24.4.1

)

NOTE

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 include Reference, 

List

,

Completion

Property Descriptor

Environment Record

Abstract Closure

, 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.

The 

List

 type is used to explain the evaluation of argument lists (see 

13.3.8

) in 

new

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 3

rd

 element of the List 

arguments

.

When an algorithm iterates over the elements of a List without specifying an order, the order used is the order of the
elements in the List.

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

Additional entries in 

Table 82

.

6.2  ECMAScript Specification Types

6.2.1  The List and Record Specification Types

100

literal Record value to identify the specific kind of aggregations that is being described. For example:
PropertyDescriptor { [[Value]]: 42, [[Writable]]: 

false

, [[Configurable]]: 

true

 }.

The 

Set

 type is used to explain a collection of unordered elements for use in the 

memory model

. Values of the Set type

are simple collections of elements, where no element appears more than once. Elements may be added to and
removed from Sets. Sets may be unioned, intersected, or subtracted from each other.

The 

Relation

 type is used to explain constraints on Sets. Values of the Relation type are Sets of ordered pairs of values

from its value domain. For example, a Relation on events is a set of ordered pairs of events. For a Relation 

R

 and two

values 

a

 and 

b

 in the value domain of 

R

a

 

R

 

b

 is shorthand for saying the ordered pair (

a

b

) is a member of 

R

. A

Relation is least with respect to some conditions when it is the smallest Relation that satisfies those conditions.

strict partial order

 is a Relation value 

R

 that satisfies the following.

For all 

a

b

, and 

c

 in 

R

's domain:

It is not the case that 

a

 

R

 

a

, and

If 

a

 

R

 

b

 and 

b

 

R

 

c

, then 

a

 

R

 

c

.

NOTE 1

strict total order

 is a Relation value 

R

 that satisfies the following.

For all 

a

b

, and 

c

 in 

R

's domain:

a

 is identical to 

b

 or 

a

 

R

 

b

 or 

b

 

R

 

a

, and

It is not the case that 

a

 

R

 

a

, and

If 

a

 

R

 

b

 and 

b

 

R

 

c

, then 

a

 

R

 

c

.

NOTE 2

The Completion type is a 

Record

 used to explain the runtime propagation of values and control flow such as the

behaviour of statements (

break

break

continue

continue

return

return

 and 

throw

throw

) that perform nonlocal transfers of control.

Values of the Completion type ar

Record

 values whose fields are defined by 

Table 9

. Such values are referred to as

Completion Record

s.

Table 9: 

Completion Record

 Fields

Field Name

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 two properties above are called irreflexivity and transitivity, respectively.

The three properties above are called totality, irreflexivity, and transitivity, respectively.

6.2.2  The Set and Relation Specification Types

6.2.3  The Completion Record Specification Type

101

The term “

abrupt completion

” refers to any completion with a [[Type]] value other than 

normal

.

Algorithm steps that say

1.  Let 

completion

 be 

Await

(

value

).

mean the same thing as:

1.  Let 

asyncContext

 be the 

running execution context

.

2.  Let 

promise

 be ? 

PromiseResolve

(

%Promise%

value

).

3.  Let 

stepsFulfilled

 be the algorithm steps defined in 

Await Fulfilled Functions

.

4.  Let 

lengthFulfilled

 be the number of non-optional parameters of the function definition in 

Await Fulfilled

Functions

.

5.  Let 

onFulfilled

 be ! 

CreateBuiltinFunction

(

stepsFulfilled

lengthFulfilled

""

, « [[AsyncContext]] »).

6.  Set 

onFulfilled

.[[AsyncContext]] to 

asyncContext

.

7.  Let 

stepsRejected

 be the algorithm steps defined in 

Await Rejected Functions

.

8.  Let 

lengthRejected

 be the number of non-optional parameters of the function definition in 

Await Rejected

Functions

.

9.  Let 

onRejected

 be ! 

CreateBuiltinFunction

(

stepsRejected

lengthRejected

""

, « [[AsyncContext]] »).

10.  Set 

onRejected

.[[AsyncContext]] to 

asyncContext

.

11.  Perform ! 

PerformPromiseThen

(

promise

onFulfilled

onRejected

).

12.  Remove 

asyncContext

 from the 

execution context stack

 and restore the 

execution context

 that is at the top of the

execution context stack

 as the 

running execution context

.

13.  Set the code evaluation state of 

asyncContext

 such that when evaluation is resumed with a 

Completion

completion

, the following steps of the algorithm that invoked 

Await

 will be performed, with 

completion

available.

14.  Return.
15.  NOTE: This returns to the evaluation of the operation that had most previously resumed evaluation of

asyncContext

.

where all aliases in the above steps, with the exception of 

completion

, are ephemeral and visible only in the steps

pertaining to Await.

NOTE

An 

Await

 fulfilled function is an anonymous built-in function that is used as part of the 

Await

 specification device to

deliver the promise fulfillment value to the caller as a normal completion. Each 

Await

 fulfilled function has an

[[AsyncContext]] internal slot.

Await can be combined with the 

??

 and 

!!

 prefixes, so that for example

1.  Let 

result

 be ? 

Await

(

value

).

means the same thing as:

1.  Let 

result

 be 

Await

(

value

).

2. 

ReturnIfAbrupt

(

result

).

6.2.3.1  Await

6.2.3.1.1  Await Fulfilled Functions

102

When an 

Await

 fulfilled function is called with argument 

value

, the following steps are taken:

1.  Let 

F

 be the 

active function object

.

2.  Let 

asyncContext

 be 

F

.[[AsyncContext]].

3.  Let 

prevContext

 be the 

running execution context

.

4.  Suspend 

prevContext

.

5.  Push 

asyncContext

 onto the 

execution context stack

asyncContext

 is now the 

running execution context

.

6.  Resume the suspended evaluation of 

asyncContext

 using 

NormalCompletion

(

value

) as the result of the

operation that suspended it.

7. 

Assert

: When we reach this step, 

asyncContext

 has already been removed from the 

execution context stack

 and

prevContext

 is the currently 

running execution context

.

8.  Return 

undefined

.

The 

"length"

 property of an 

Await

 fulfilled function is 

1

𝔽

.

An 

Await

 rejected function is an anonymous built-in function that is used as part of the 

Await

 specification device to

deliver the promise rejection reason to the caller as an abrupt throw completion. Each 

Await

 rejected function has an

[[AsyncContext]] internal slot.

When an 

Await

 rejected function is called with argument 

reason

, the following steps are taken:

1.  Let 

F

 be the 

active function object

.

2.  Let 

asyncContext

 be 

F

.[[AsyncContext]].

3.  Let 

prevContext

 be the 

running execution context

.

4.  Suspend 

prevContext

.

5.  Push 

asyncContext

 onto the 

execution context stack

asyncContext

 is now the 

running execution context

.

6.  Resume the suspended evaluation of 

asyncContext

 using 

ThrowCompletion

(

reason

) as the result of the

operation that suspended it.

7. 

Assert

: When we reach this step, 

asyncContext

 has already been removed from the 

execution context stack

 and

prevContext

 is the currently 

running execution context

.

8.  Return 

undefined

.

The 

"length"

 property of an 

Await

 rejected function is 

1

𝔽

.

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

 }.

The abstract operation ThrowCompletion with a single 

argument

, such as:

1.  Return 

ThrowCompletion

(

argument

).

6.2.3.1.2  Await Rejected Functions

6.2.3.2  NormalCompletion

6.2.3.3  ThrowCompletion

103

Is a shorthand that is defined as follows:

1.  Return 

Completion

 { [[Type]]: 

throw

, [[Value]]: 

argument

, [[Target]]: 

empty

 }.

The abstract operation UpdateEmpty takes arguments 

completionRecord

 and 

value

. It performs the following steps

when called:

1. 

Assert

: If 

completionRecord

.[[Type]] is either 

return

 or 

throw

, then 

completionRecord

.[[Value]] is not 

empty

.

2.  If 

completionRecord

.[[Value]] is not 

empty

, return 

Completion

(

completionRecord

).

3.  Return 

Completion

 { [[Type]]: 

completionRecord

.[[Type]], [[Value]]: 

value

, [[Target]]: 

completionRecord

.[[Target]] }.

The 

Reference Record

 type is used to explain the behaviour of such operators as 

delete

delete

typeof

typeof

, the assignment

operators, the 

super

super

 

keyword

 and other language features. For example, the left-hand operand of an assignment is

expected to produce a Reference Record.

A Reference Record is a resolved name or property binding; its fields are defined by 

Table 10

.

Table 10: 

Reference Record

 Fields

Field Name

Value

Meaning

[[Base]]

One of:

any

ECMAScript
language
value

 except

undefined

 or

null

,

an

Environment
Record

, or

unresolvable

.

The value or 

Environment Record

 which holds the binding. A [[Base]]

of 

unresolvable

 indicates that the binding could not be resolved.

[[ReferencedName]] String or Symbol

The name of the binding. Always a String if [[Base]] value is an

Environment Record

.

[[Strict]]

Boolean

true

 if the 

Reference Record

 originated in 

strict mode code

false

otherwise.

[[ThisValue]]

any 

ECMAScript

language value

 or

empty

If not 

empty

, the 

Reference Record

 represents a property binding that

was expressed using the 

super

super

 

keyword

; it is called a 

Super Reference

Record

 and its [[Base]] value will never be an 

Environment Record

. In

that case, the [[ThisValue]] field holds the 

this

 value at the time the

Reference Record

 was created.

6.2.3.4  UpdateEmpty ( 

completionRecord

value

 )

6.2.4  The Reference Record Specification Type

104

The following 

abstract operations

 are used in this specification to operate upon References:

The abstract operation IsPropertyReference takes argument 

V

. It performs the following steps when called:

1. 

Assert

V

 is a 

Reference Record

.

2.  If 

V

.[[Base]] is 

unresolvable

, return 

false

.

3.  If 

Type

(

V

.[[Base]]) is Boolean, String, Symbol, BigInt, Number, or Object, return 

true

; otherwise return 

false

.

The abstract operation IsUnresolvableReference takes argument 

V

. It performs the following steps when called:

1. 

Assert

V

 is a 

Reference Record

.

2.  If 

V

.[[Base]] is 

unresolvable

, return 

true

; otherwise return 

false

.

The abstract operation IsSuperReference takes argument 

V

. It performs the following steps when called:

1. 

Assert

V

 is a 

Reference Record

.

2.  If 

V

.[[ThisValue]] is not 

empty

, return 

true

; otherwise return 

false

.

The abstract operation GetValue takes argument 

V

. It performs the following steps when called:

1. 

ReturnIfAbrupt

(

V

).

2.  If 

V

 is not a 

Reference Record

, return 

V

.

3.  If 

IsUnresolvableReference

(

V

) is 

true

, throw a 

ReferenceError

 exception.

4.  If 

IsPropertyReference

(

V

) is 

true

, then

a.  Let 

baseObj

 be ! 

ToObject

(

V

.[[Base]]).

b.  Return ? 

baseObj

.[[Get]](

V

.[[ReferencedName]], 

GetThisValue

(

V

)).

5.  Else,

a.  Let 

base

 be 

V

.[[Base]].

b. 

Assert

base

 is an 

Environment Record

.

c.  Return ? 

base

.GetBindingValue(

V

.[[ReferencedName]], 

V

.[[Strict]]) (see 

9.1

).

NOTE

The abstract operation PutValue takes arguments 

V

 and 

W

. It performs the following steps when called:

1. 

ReturnIfAbrupt

(

V

).

2. 

ReturnIfAbrupt

(

W

).

The object that may be created in step 

4.a

 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.4.1  IsPropertyReference ( 

V

 )

6.2.4.2  IsUnresolvableReference ( 

V

 )

6.2.4.3  IsSuperReference ( 

V

 )

6.2.4.4  GetValue ( 

V

 )

6.2.4.5  PutValue ( 

V

W

 )

105

 

 

 

 

 

 

 

Content      ..     11      12      13      14     ..