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

 

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

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     3      4      5      6     ..

 

 

 

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

 

 

24.2.3.12 Set.prototype [ @@toStringTag ]

24.2.4 Properties of Set Instances
24.2.5 Set Iterator Objects

24.2.5.1 CreateSetIterator ( 

set

kind

 )

24.2.5.2 The %SetIteratorPrototype% Object

24.2.5.2.1 %SetIteratorPrototype%.next ( )
24.2.5.2.2 %SetIteratorPrototype% [ @@toStringTag ]

24.3 WeakMap Objects

24.3.1 The WeakMap Constructor

24.3.1.1 WeakMap ( [ 

iterable

 ] )

24.3.2 Properties of the WeakMap Constructor

24.3.2.1 WeakMap.prototype

24.3.3 Properties of the WeakMap Prototype Object

24.3.3.1 WeakMap.prototype.constructor
24.3.3.2 WeakMap.prototype.delete ( 

key

 )

24.3.3.3 WeakMap.prototype.get ( 

key

 )

24.3.3.4 WeakMap.prototype.has ( 

key

 )

24.3.3.5 WeakMap.prototype.set ( 

key

value

 )

24.3.3.6 WeakMap.prototype [ @@toStringTag ]

24.3.4 Properties of WeakMap Instances

24.4 WeakSet Objects

24.4.1 The WeakSet Constructor

24.4.1.1 WeakSet ( [ 

iterable

 ] )

24.4.2 Properties of the WeakSet Constructor

24.4.2.1 WeakSet.prototype

24.4.3 Properties of the WeakSet Prototype Object

24.4.3.1 WeakSet.prototype.add ( 

value

 )

24.4.3.2 WeakSet.prototype.constructor
24.4.3.3 WeakSet.prototype.delete ( 

value

 )

24.4.3.4 WeakSet.prototype.has ( 

value

 )

24.4.3.5 WeakSet.prototype [ @@toStringTag ]

24.4.4 Properties of WeakSet Instances

25 Structured Data

25.1 ArrayBuffer Objects

25.1.1 Notation
25.1.2 Abstract Operations For ArrayBuffer Objects

25.1.2.1 AllocateArrayBuffer ( 

constructor

byteLength

 )

25.1.2.2 IsDetachedBuffer ( 

arrayBuffer

 )

25.1.2.3 DetachArrayBuffer ( 

arrayBuffer

 [ , 

key

 ] )

25.1.2.4 CloneArrayBuffer ( 

srcBuffer

srcByteOffset

srcLength

cloneConstructor

 )

25.1.2.5 IsUnsignedElementType ( 

type

 )

25.1.2.6 IsUnclampedIntegerElementType ( 

type

 )

25.1.2.7 IsBigIntElementType ( 

type

 )

25.1.2.8 IsNoTearConfiguration ( 

type

order

 )

25.1.2.9 RawBytesToNumeric ( 

type

rawBytes

isLittleEndian

 )

25.1.2.10 GetValueFromBuffer ( 

arrayBuffer

byteIndex

type

isTypedArray

order

 [ , 

isLittleEndian

 ] )

25.1.2.11 NumericToRawBytes ( 

type

value

isLittleEndian

 )

25.1.2.12 SetValueInBuffer ( 

arrayBuffer

byteIndex

type

value

isTypedArray

order

 [ , 

isLittleEndian

 ] )

34

25.1.2.13 GetModifySetValueInBuffer ( 

arrayBuffer

byteIndex

type

value

op

 [ , 

isLittleEndian

 ] )

25.1.3 The ArrayBuffer Constructor

25.1.3.1 ArrayBuffer ( 

length

 )

25.1.4 Properties of the ArrayBuffer Constructor

25.1.4.1 ArrayBuffer.isView ( 

arg

 )

25.1.4.2 ArrayBuffer.prototype
25.1.4.3 get ArrayBuffer [ @@species ]

25.1.5 Properties of the ArrayBuffer Prototype Object

25.1.5.1 get ArrayBuffer.prototype.byteLength
25.1.5.2 ArrayBuffer.prototype.constructor
25.1.5.3 ArrayBuffer.prototype.slice ( 

start

end

 )

25.1.5.4 ArrayBuffer.prototype [ @@toStringTag ]

25.1.6 Properties of ArrayBuffer Instances

25.2 SharedArrayBuffer Objects

25.2.1 Abstract Operations for SharedArrayBuffer Objects

25.2.1.1 AllocateSharedArrayBuffer ( 

constructor

byteLength

 )

25.2.1.2 IsSharedArrayBuffer ( 

obj

 )

25.2.2 The SharedArrayBuffer Constructor

25.2.2.1 SharedArrayBuffer ( [ 

length

 ] )

25.2.3 Properties of the SharedArrayBuffer Constructor

25.2.3.1 SharedArrayBuffer.prototype
25.2.3.2 get SharedArrayBuffer [ @@species ]

25.2.4 Properties of the SharedArrayBuffer Prototype Object

25.2.4.1 get SharedArrayBuffer.prototype.byteLength
25.2.4.2 SharedArrayBuffer.prototype.constructor
25.2.4.3 SharedArrayBuffer.prototype.slice ( 

start

end

 )

25.2.4.4 SharedArrayBuffer.prototype [ @@toStringTag ]

25.2.5 Properties of SharedArrayBuffer Instances

25.3 DataView Objects

25.3.1 Abstract Operations For DataView Objects

25.3.1.1 GetViewValue ( 

view

requestIndex

isLittleEndian

type

 )

25.3.1.2 SetViewValue ( 

view

requestIndex

isLittleEndian

type

value

 )

25.3.2 The DataView Constructor

25.3.2.1 DataView ( 

buffer

 [ , 

byteOffset

 [ , 

byteLength

 ] ] )

25.3.3 Properties of the DataView Constructor

25.3.3.1 DataView.prototype

25.3.4 Properties of the DataView Prototype Object

25.3.4.1 get DataView.prototype.buffer
25.3.4.2 get DataView.prototype.byteLength
25.3.4.3 get DataView.prototype.byteOffset
25.3.4.4 DataView.prototype.constructor
25.3.4.5 DataView.prototype.getBigInt64 ( 

byteOffset

 [ , 

littleEndian

 ] )

25.3.4.6 DataView.prototype.getBigUint64 ( 

byteOffset

 [ , 

littleEndian

 ] )

25.3.4.7 DataView.prototype.getFloat32 ( 

byteOffset

 [ , 

littleEndian

 ] )

25.3.4.8 DataView.prototype.getFloat64 ( 

byteOffset

 [ , 

littleEndian

 ] )

25.3.4.9 DataView.prototype.getInt8 ( 

byteOffset

 )

25.3.4.10 DataView.prototype.getInt16 ( 

byteOffset

 [ , 

littleEndian

 ] )

25.3.4.11 DataView.prototype.getInt32 ( 

byteOffset

 [ , 

littleEndian

 ] )

35

25.3.4.12 DataView.prototype.getUint8 ( 

byteOffset

 )

25.3.4.13 DataView.prototype.getUint16 ( 

byteOffset

 [ , 

littleEndian

 ] )

25.3.4.14 DataView.prototype.getUint32 ( 

byteOffset

 [ , 

littleEndian

 ] )

25.3.4.15 DataView.prototype.setBigInt64 ( 

byteOffset

value

 [ , 

littleEndian

 ] )

25.3.4.16 DataView.prototype.setBigUint64 ( 

byteOffset

value

 [ , 

littleEndian

 ] )

25.3.4.17 DataView.prototype.setFloat32 ( 

byteOffset

value

 [ , 

littleEndian

 ] )

25.3.4.18 DataView.prototype.setFloat64 ( 

byteOffset

value

 [ , 

littleEndian

 ] )

25.3.4.19 DataView.prototype.setInt8 ( 

byteOffset

value

 )

25.3.4.20 DataView.prototype.setInt16 ( 

byteOffset

value

 [ , 

littleEndian

 ] )

25.3.4.21 DataView.prototype.setInt32 ( 

byteOffset

value

 [ , 

littleEndian

 ] )

25.3.4.22 DataView.prototype.setUint8 ( 

byteOffset

value

 )

25.3.4.23 DataView.prototype.setUint16 ( 

byteOffset

value

 [ , 

littleEndian

 ] )

25.3.4.24 DataView.prototype.setUint32 ( 

byteOffset

value

 [ , 

littleEndian

 ] )

25.3.4.25 DataView.prototype [ @@toStringTag ]

25.3.5 Properties of DataView Instances

25.4 The Atomics Object

25.4.1 Abstract Operations for Atomics

25.4.1.1 ValidateIntegerTypedArray ( 

typedArray

 [ , 

waitable

 ] )

25.4.1.2 ValidateAtomicAccess ( 

typedArray

requestIndex

 )

25.4.1.3 GetWaiterList ( 

block

i

 )

25.4.1.4 EnterCriticalSection ( 

WL

 )

25.4.1.5 LeaveCriticalSection ( 

WL

 )

25.4.1.6 AddWaiter ( 

WL

W

 )

25.4.1.7 RemoveWaiter ( 

WL

W

 )

25.4.1.8 RemoveWaiters ( 

WL

c

 )

25.4.1.9 SuspendAgent ( 

WL

W

timeout

 )

25.4.1.10 NotifyWaiter ( 

WL

W

 )

25.4.1.11 AtomicReadModifyWrite ( 

typedArray

index

value

op

 )

25.4.1.12 ByteListBitwiseOp ( 

op

xBytes

yBytes

 )

25.4.1.13 ByteListEqual ( 

xBytes

yBytes

 )

25.4.2 Atomics.add ( 

typedArray

index

value

 )

25.4.3 Atomics.and ( 

typedArray

index

value

 )

25.4.4 Atomics.compareExchange ( 

typedArray

index

expectedValue

replacementValue

 )

25.4.5 Atomics.exchange ( 

typedArray

index

value

 )

25.4.6 Atomics.isLockFree ( 

size

 )

25.4.7 Atomics.load ( 

typedArray

index

 )

25.4.8 Atomics.or ( 

typedArray

index

value

 )

25.4.9 Atomics.store ( 

typedArray

index

value

 )

25.4.10 Atomics.sub ( 

typedArray

index

value

 )

25.4.11 Atomics.wait ( 

typedArray

index

value

timeout

 )

25.4.12 Atomics.notify ( 

typedArray

index

count

 )

25.4.13 Atomics.xor ( 

typedArray

index

value

 )

25.4.14 Atomics [ @@toStringTag ]

25.5 The JSON Object

25.5.1 JSON.parse ( 

text

 [ , 

reviver

 ] )

25.5.1.1 InternalizeJSONProperty ( 

holder

name

reviver

 )

25.5.2 JSON.stringify ( 

value

 [ , 

replacer

 [ , 

space

 ] ] )

25.5.2.1 SerializeJSONProperty ( 

state

key

holder

 )

36

25.5.2.2 QuoteJSONString ( 

value

 )

25.5.2.3 UnicodeEscape ( 

C

 )

25.5.2.4 SerializeJSONObject ( 

state

value

 )

25.5.2.5 SerializeJSONArray ( 

state

value

 )

25.5.3 JSON [ @@toStringTag ]

26 Managing Memory

26.1 WeakRef Objects

26.1.1 The WeakRef Constructor

26.1.1.1 WeakRef ( 

target

 )

26.1.2 Properties of the WeakRef Constructor

26.1.2.1 WeakRef.prototype

26.1.3 Properties of the WeakRef Prototype Object

26.1.3.1 WeakRef.prototype.constructor
26.1.3.2 WeakRef.prototype.deref ( )
26.1.3.3 WeakRef.prototype [ @@toStringTag ]

26.1.4 WeakRef Abstract Operations

26.1.4.1 WeakRefDeref ( 

weakRef

 )

26.1.5 Properties of WeakRef Instances

26.2 FinalizationRegistry Objects

26.2.1 The FinalizationRegistry Constructor

26.2.1.1 FinalizationRegistry ( 

cleanupCallback

 )

26.2.2 Properties of the FinalizationRegistry Constructor

26.2.2.1 FinalizationRegistry.prototype

26.2.3 Properties of the FinalizationRegistry Prototype Object

26.2.3.1 FinalizationRegistry.prototype.constructor
26.2.3.2 FinalizationRegistry.prototype.register ( 

target

heldValue

 [ , 

unregisterToken

 ] )

26.2.3.3 FinalizationRegistry.prototype.unregister ( 

unregisterToken

 )

26.2.3.4 FinalizationRegistry.prototype [ @@toStringTag ]

26.2.4 Properties of FinalizationRegistry Instances

27 Control Abstraction Objects

27.1 Iteration

27.1.1 Common Iteration Interfaces

27.1.1.1 The 

Iterable

 Interface

27.1.1.2 The 

Iterator

 Interface

27.1.1.3 The 

AsyncIterable

 Interface

27.1.1.4 The 

AsyncIterator

 Interface

27.1.1.5 The 

IteratorResult

 Interface

27.1.2 The %IteratorPrototype% Object

27.1.2.1 %IteratorPrototype% [ @@iterator ] ( )

27.1.3 The %AsyncIteratorPrototype% Object

27.1.3.1 %AsyncIteratorPrototype% [ @@asyncIterator ] ( )

27.1.4 Async-from-Sync Iterator Objects

27.1.4.1 CreateAsyncFromSyncIterator ( 

syncIteratorRecord

 )

27.1.4.2 The %AsyncFromSyncIteratorPrototype% Object

27.1.4.2.1 %AsyncFromSyncIteratorPrototype%.next ( [ 

value

 ] )

27.1.4.2.2 %AsyncFromSyncIteratorPrototype%.return ( [ 

value

 ] )

27.1.4.2.3 %AsyncFromSyncIteratorPrototype%.throw ( [ 

value

 ] )

27.1.4.2.4 Async-from-Sync Iterator Value Unwrap Functions

37

2. 

ReturnIfAbrupt

(

propKey

).

3.  Let 

scope

 be the 

running execution context

's LexicalEnvironment.

4.  Let 

sourceText

 be the source text matched by 

GeneratorMethod

.

5.  Let 

closure

 be 

OrdinaryFunctionCreate

(

%GeneratorFunction.prototype%

sourceText

UniqueFormalParameters

GeneratorBody

non-lexical-this

scope

).

6.  Perform 

MakeMethod

(

closure

object

).

7.  Perform 

SetFunctionName

(

closure

propKey

).

8.  Let 

prototype

 be ! 

OrdinaryObjectCreate

(

%GeneratorFunction.prototype.prototype%

).

9.  Perform 

DefinePropertyOrThrow

(

closure

"prototype"

, PropertyDescriptor { [[Value]]: 

prototype

, [[Writable]]:

true

, [[Enumerable]]: 

false

, [[Configurable]]: 

false

 }).

10.  Let 

desc

 be the PropertyDescriptor { [[Value]]: 

closure

, [[Writable]]: 

true

, [[Enumerable]]: 

enumerable

,

[[Configurable]]: 

true

 }.

11.  Return ? 

DefinePropertyOrThrow

(

object

propKey

desc

).

AsyncGeneratorMethod

 

:

 

async

 

*

 

PropertyName

 

(

 

UniqueFormalParameters

 

)

 

{

 

AsyncGeneratorBody

 

}

1.  Let 

propKey

 be the result of evaluating 

PropertyName

.

2. 

ReturnIfAbrupt

(

propKey

).

3.  Let 

scope

 be the 

running execution context

's LexicalEnvironment.

4.  Let 

sourceText

 be the source text matched by 

AsyncGeneratorMethod

.

5.  Let 

closure

 be ! 

OrdinaryFunctionCreate

(

%AsyncGeneratorFunction.prototype%

sourceText

UniqueFormalParameters

AsyncGeneratorBody

non-lexical-this

scope

).

6.  Perform ! 

MakeMethod

(

closure

object

).

7.  Perform ! 

SetFunctionName

(

closure

propKey

).

8.  Let 

prototype

 be ! 

OrdinaryObjectCreate

(

%AsyncGeneratorFunction.prototype.prototype%

).

9.  Perform ! 

DefinePropertyOrThrow

(

closure

"prototype"

, PropertyDescriptor { [[Value]]: 

prototype

, [[Writable]]:

true

, [[Enumerable]]: 

false

, [[Configurable]]: 

false

 }).

10.  Let 

desc

 be PropertyDescriptor { [[Value]]: 

closure

, [[Writable]]: 

true

, [[Enumerable]]: 

enumerable

,

[[Configurable]]: 

true

 }.

11.  Return ? 

DefinePropertyOrThrow

(

object

propKey

desc

).

AsyncMethod

 

:

 

async

 

PropertyName

 

(

 

UniqueFormalParameters

 

)

 

{

 

AsyncFunctionBody

 

}

1.  Let 

propKey

 be the result of evaluating 

PropertyName

.

2. 

ReturnIfAbrupt

(

propKey

).

3.  Let 

scope

 be the LexicalEnvironment of the 

running execution context

.

4.  Let 

sourceText

 be the source text matched by 

AsyncMethod

.

5.  Let 

closure

 be ! 

OrdinaryFunctionCreate

(

%AsyncFunction.prototype%

sourceText

UniqueFormalParameters

AsyncFunctionBody

non-lexical-this

scope

).

6.  Perform ! 

MakeMethod

(

closure

object

).

7.  Perform ! 

SetFunctionName

(

closure

propKey

).

8.  Let 

desc

 be the PropertyDescriptor { [[Value]]: 

closure

, [[Writable]]: 

true

, [[Enumerable]]: 

enumerable

,

[[Configurable]]: 

true

 }.

9.  Return ? 

DefinePropertyOrThrow

(

object

propKey

desc

).

15.5  Generator Function Definitions

Syntax

403

GeneratorMethod

[Yield, Await]

 

:

*

 

PropertyName

[?Yield, ?Await]

 

(

 

UniqueFormalParameters

[+Yield, ~Await]

 

)

 

{

 

GeneratorBody

 

}

GeneratorDeclaration

[Yield, Await, Default]

 

:

function

 

*

 

BindingIdentifier

[?Yield, ?Await]

 

(

 

FormalParameters

[+Yield, ~Await]

 

)

 

{

 

GeneratorBody

 

}

[+Default]

 

function

 

*

 

(

 

FormalParameters

[+Yield, ~Await]

 

)

 

{

 

GeneratorBody

 

}

GeneratorExpression

 

:

function

 

*

 

BindingIdentifier

[+Yield, ~Await]

opt

 

(

 

FormalParameters

[+Yield, ~Await]

 

)

 

{

 

GeneratorBody

}

GeneratorBody

 

:

FunctionBody

[+Yield, ~Await]

YieldExpression

[In, Await]

 

:

yield

yield

 [no 

LineTerminator

 here]  

AssignmentExpression

[?In, +Yield, ?Await]

yield

 [no 

LineTerminator

 here]  

*

 

AssignmentExpression

[?In, +Yield, ?Await]

NOTE 1

NOTE 2

NOTE 3

GeneratorMethod

 

:

 

*

 

PropertyName

 

(

 

UniqueFormalParameters

 

)

 

{

 

GeneratorBody

 

}

It is a Syntax Error if 

HasDirectSuper

 of 

GeneratorMethod

 is 

true

.

It is a Syntax Error if 

UniqueFormalParameters

 

Contains

 

YieldExpression

 is 

true

.

It is a Syntax Error if 

FunctionBodyContainsUseStrict

 of 

GeneratorBody

 is 

true

 and 

IsSimpleParameterList

 of 

UniqueFormalParameters

 is 

false

.

It is a Syntax Error if any element of the 

BoundNames

 of 

UniqueFormalParameters

 also occurs in the

LexicallyDeclaredNames

 of 

GeneratorBody

.

GeneratorDeclaration

 

:

function

 

*

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

function

 

*

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

GeneratorExpression

 

:

function

 

*

 

BindingIdentifier

opt

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

If the source code matching 

FormalParameters

 is 

strict mode code

, the Early Error rules for

The syntactic context immediately following 

yield

yield

 requires use of the 

InputElementRegExpOrTemplateTail

 lexical goal.

YieldExpression

 cannot be used within the 

FormalParameters

 of a generator function because any

expressions that are part of 

FormalParameters

 are evaluated before the resulting generator object is

in a resumable state.

Abstract operations

 relating to generator objects are defined in 

27.5.3

.

15.5.1  Static Semantics: Early Errors

404

UniqueFormalParameters

 

:

 

FormalParameters

 are applied.

If 

BindingIdentifier

 is present and the source code matching 

BindingIdentifier

 is 

strict mode code

, it is a Syntax

Error if the 

StringValue

 of 

BindingIdentifier

 is 

"eval"

 or 

"arguments"

.

It is a Syntax Error if 

FunctionBodyContainsUseStrict

 of 

GeneratorBody

 is 

true

 and 

IsSimpleParameterList

 of 

FormalParameters

 is 

false

.

It is a Syntax Error if any element of the 

BoundNames

 of 

FormalParameters

 also occurs in the

LexicallyDeclaredNames

 of 

GeneratorBody

.

It is a Syntax Error if 

FormalParameters

 

Contains

 

YieldExpression

 is 

true

.

It is a Syntax Error if 

FormalParameters

 

Contains

 

SuperProperty

 is 

true

.

It is a Syntax Error if 

GeneratorBody

 

Contains

 

SuperProperty

 is 

true

.

It is a Syntax Error if 

FormalParameters

 

Contains

 

SuperCall

 is 

true

.

It is a Syntax Error if 

GeneratorBody

 

Contains

 

SuperCall

 is 

true

.

With parameters 

functionObject

 and 

argumentsList

 (a 

List

).

GeneratorBody

 

:

 

FunctionBody

1.  Perform ? 

FunctionDeclarationInstantiation

(

functionObject

argumentsList

).

2.  Let 

G

 be ? 

OrdinaryCreateFromConstructor

(

functionObject

"%GeneratorFunction.prototype.prototype%"

, «

[[GeneratorState]], [[GeneratorContext]], [[GeneratorBrand]] »).

3.  Set 

G

.[[GeneratorBrand]] to 

empty

.

4.  Perform 

GeneratorStart

(

G

FunctionBody

).

5.  Return 

Completion

 { [[Type]]: 

return

, [[Value]]: 

G

, [[Target]]: 

empty

 }.

With parameter 

scope

.

GeneratorDeclaration

 

:

 

function

 

*

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

1.  Let 

name

 be 

StringValue

 of 

BindingIdentifier

.

2.  Let 

sourceText

 be the source text matched by 

GeneratorDeclaration

.

3.  Let 

F

 be 

OrdinaryFunctionCreate

(

%GeneratorFunction.prototype%

sourceText

FormalParameters

GeneratorBody

non-lexical-this

scope

).

4.  Perform 

SetFunctionName

(

F

name

).

5.  Let 

prototype

 be ! 

OrdinaryObjectCreate

(

%GeneratorFunction.prototype.prototype%

).

6.  Perform 

DefinePropertyOrThrow

(

F

"prototype"

, PropertyDescriptor { [[Value]]: 

prototype

, [[Writable]]: 

true

,

[[Enumerable]]: 

false

, [[Configurable]]: 

false

 }).

7.  Return 

F

.

GeneratorDeclaration

 

:

 

function

 

*

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

1.  Let 

sourceText

 be the source text matched by 

GeneratorDeclaration

.

2.  Let 

F

 be 

OrdinaryFunctionCreate

(

%GeneratorFunction.prototype%

sourceText

FormalParameters

GeneratorBody

non-lexical-this

scope

).

3.  Perform 

SetFunctionName

(

F

"default"

).

4.  Let 

prototype

 be ! 

OrdinaryObjectCreate

(

%GeneratorFunction.prototype.prototype%

).

15.5.2  Runtime Semantics: EvaluateGeneratorBody

15.5.3  Runtime Semantics: InstantiateGeneratorFunctionObject

405

 

 

 

 

 

 

 

Content      ..     3      4      5      6     ..