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

 

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

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..      1      2      3      ..

 

 

 

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

 

 

7.1.20 ToLength ( 

argument

 )

7.1.21 CanonicalNumericIndexString ( 

argument

 )

7.1.22 ToIndex ( 

value

 )

7.2 Testing and Comparison Operations

7.2.1 RequireObjectCoercible ( 

argument

 )

7.2.2 IsArray ( 

argument

 )

7.2.3 IsCallable ( 

argument

 )

7.2.4 IsConstructor ( 

argument

 )

7.2.5 IsExtensible ( 

O

 )

7.2.6 IsIntegralNumber ( 

argument

 )

7.2.7 IsPropertyKey ( 

argument

 )

7.2.8 IsRegExp ( 

argument

 )

7.2.9 IsStringPrefix ( 

p

q

 )

7.2.10 SameValue ( 

x

y

 )

7.2.11 SameValueZero ( 

x

y

 )

7.2.12 SameValueNonNumeric ( 

x

y

 )

7.2.13 Abstract Relational Comparison
7.2.14 Abstract Equality Comparison
7.2.15 Strict Equality Comparison

7.3 Operations on Objects

7.3.1 MakeBasicObject ( 

internalSlotsList

 )

7.3.2 Get ( 

O

P

 )

7.3.3 GetV ( 

V

P

 )

7.3.4 Set ( 

O

P

V

Throw

 )

7.3.5 CreateDataProperty ( 

O

P

V

 )

7.3.6 CreateMethodProperty ( 

O

P

V

 )

7.3.7 CreateDataPropertyOrThrow ( 

O

P

V

 )

7.3.8 DefinePropertyOrThrow ( 

O

P

desc

 )

7.3.9 DeletePropertyOrThrow ( 

O

P

 )

7.3.10 GetMethod ( 

V

P

 )

7.3.11 HasProperty ( 

O

P

 )

7.3.12 HasOwnProperty ( 

O

P

 )

7.3.13 Call ( 

F

V

 [ , 

argumentsList

 ] )

7.3.14 Construct ( 

F

 [ , 

argumentsList

 [ , 

newTarget

 ] ] )

7.3.15 SetIntegrityLevel ( 

O

level

 )

7.3.16 TestIntegrityLevel ( 

O

level

 )

7.3.17 CreateArrayFromList ( 

elements

 )

7.3.18 LengthOfArrayLike ( 

obj

 )

7.3.19 CreateListFromArrayLike ( 

obj

 [ , 

elementTypes

 ] )

7.3.20 Invoke ( 

V

P

 [ , 

argumentsList

 ] )

7.3.21 OrdinaryHasInstance ( 

C

O

 )

7.3.22 SpeciesConstructor ( 

O

defaultConstructor

 )

7.3.23 EnumerableOwnPropertyNames ( 

O

kind

 )

7.3.24 GetFunctionRealm ( 

obj

 )

7.3.25 CopyDataProperties ( 

target

source

excludedItems

 )

7.4 Operations on Iterator Objects

7.4.1 GetIterator ( 

obj

 [ , 

hint

 [ , 

method

 ] ] )

7.4.2 IteratorNext ( 

iteratorRecord

 [ , 

value

 ] )

6

7.4.3 IteratorComplete ( 

iterResult

 )

7.4.4 IteratorValue ( 

iterResult

 )

7.4.5 IteratorStep ( 

iteratorRecord

 )

7.4.6 IteratorClose ( 

iteratorRecord

completion

 )

7.4.7 AsyncIteratorClose ( 

iteratorRecord

completion

 )

7.4.8 CreateIterResultObject ( 

value

done

 )

7.4.9 CreateListIteratorRecord ( 

list

 )

7.4.10 IterableToList ( 

items

 [ , 

method

 ] )

8 Syntax-Directed Operations

8.1 Scope Analysis

8.1.1 SS: BoundNames
8.1.2 SS: DeclarationPart
8.1.3 SS: IsConstantDeclaration
8.1.4 SS: LexicallyDeclaredNames
8.1.5 SS: LexicallyScopedDeclarations
8.1.6 SS: VarDeclaredNames
8.1.7 SS: VarScopedDeclarations
8.1.8 SS: TopLevelLexicallyDeclaredNames
8.1.9 SS: TopLevelLexicallyScopedDeclarations
8.1.10 SS: TopLevelVarDeclaredNames
8.1.11 SS: TopLevelVarScopedDeclarations

8.2 Labels

8.2.1 SS: ContainsDuplicateLabels
8.2.2 SS: ContainsUndefinedBreakTarget
8.2.3 SS: ContainsUndefinedContinueTarget

8.3 Function Name Inference

8.3.1 SS: HasName
8.3.2 SS: IsFunctionDefinition
8.3.3 SS: IsAnonymousFunctionDefinition ( 

expr

 )

8.3.4 SS: IsIdentifierRef
8.3.5 RS: NamedEvaluation

8.4 Contains

8.4.1 SS: Contains
8.4.2 SS: ComputedPropertyContains

8.5 Miscellaneous

8.5.1 RS: InstantiateFunctionObject
8.5.2 RS: BindingInitialization

8.5.2.1 InitializeBoundName ( 

name

value

environment

 )

8.5.3 RS: IteratorBindingInitialization
8.5.4 SS: AssignmentTargetType
8.5.5 SS: PropName

9 Executable Code and Execution Contexts

9.1 Environment Records

9.1.1 The Environment Record Type Hierarchy

9.1.1.1 Declarative Environment Records

9.1.1.1.1 HasBinding ( 

N

 )

9.1.1.1.2 CreateMutableBinding ( 

N

D

 )

9.1.1.1.3 CreateImmutableBinding ( 

N

S

 )

7

9.1.1.1.4 InitializeBinding ( 

N

V

 )

9.1.1.1.5 SetMutableBinding ( 

N

V

S

 )

9.1.1.1.6 GetBindingValue ( 

N

S

 )

9.1.1.1.7 DeleteBinding ( 

N

 )

9.1.1.1.8 HasThisBinding ( )
9.1.1.1.9 HasSuperBinding ( )
9.1.1.1.10 WithBaseObject ( )

9.1.1.2 Object Environment Records

9.1.1.2.1 HasBinding ( 

N

 )

9.1.1.2.2 CreateMutableBinding ( 

N

D

 )

9.1.1.2.3 CreateImmutableBinding ( 

N

S

 )

9.1.1.2.4 InitializeBinding ( 

N

V

 )

9.1.1.2.5 SetMutableBinding ( 

N

V

S

 )

9.1.1.2.6 GetBindingValue ( 

N

S

 )

9.1.1.2.7 DeleteBinding ( 

N

 )

9.1.1.2.8 HasThisBinding ( )
9.1.1.2.9 HasSuperBinding ( )
9.1.1.2.10 WithBaseObject ( )

9.1.1.3 Function Environment Records

9.1.1.3.1 BindThisValue ( 

V

 )

9.1.1.3.2 HasThisBinding ( )
9.1.1.3.3 HasSuperBinding ( )
9.1.1.3.4 GetThisBinding ( )
9.1.1.3.5 GetSuperBase ( )

9.1.1.4 Global Environment Records

9.1.1.4.1 HasBinding ( 

N

 )

9.1.1.4.2 CreateMutableBinding ( 

N

D

 )

9.1.1.4.3 CreateImmutableBinding ( 

N

S

 )

9.1.1.4.4 InitializeBinding ( 

N

V

 )

9.1.1.4.5 SetMutableBinding ( 

N

V

S

 )

9.1.1.4.6 GetBindingValue ( 

N

S

 )

9.1.1.4.7 DeleteBinding ( 

N

 )

9.1.1.4.8 HasThisBinding ( )
9.1.1.4.9 HasSuperBinding ( )
9.1.1.4.10 WithBaseObject ( )
9.1.1.4.11 GetThisBinding ( )
9.1.1.4.12 HasVarDeclaration ( 

N

 )

9.1.1.4.13 HasLexicalDeclaration ( 

N

 )

9.1.1.4.14 HasRestrictedGlobalProperty ( 

N

 )

9.1.1.4.15 CanDeclareGlobalVar ( 

N

 )

9.1.1.4.16 CanDeclareGlobalFunction ( 

N

 )

9.1.1.4.17 CreateGlobalVarBinding ( 

N

D

 )

9.1.1.4.18 CreateGlobalFunctionBinding ( 

N

V

D

 )

9.1.1.5 Module Environment Records

9.1.1.5.1 GetBindingValue ( 

N

S

 )

9.1.1.5.2 DeleteBinding ( 

N

 )

9.1.1.5.3 HasThisBinding ( )
9.1.1.5.4 GetThisBinding ( )

8

9.1.1.5.5 CreateImportBinding ( 

N

M

N2

 )

9.1.2 Environment Record Operations

9.1.2.1 GetIdentifierReference ( 

env

name

strict

 )

9.1.2.2 NewDeclarativeEnvironment ( 

E

 )

9.1.2.3 NewObjectEnvironment ( 

O

E

 )

9.1.2.4 NewFunctionEnvironment ( 

F

newTarget

 )

9.1.2.5 NewGlobalEnvironment ( 

G

thisValue

 )

9.1.2.6 NewModuleEnvironment ( 

E

 )

9.2 Realms

9.2.1 CreateRealm ( )
9.2.2 CreateIntrinsics ( 

realmRec

 )

9.2.3 SetRealmGlobalObject ( 

realmRec

globalObj

thisValue

 )

9.2.4 SetDefaultGlobalBindings ( 

realmRec

 )

9.3 Execution Contexts

9.3.1 GetActiveScriptOrModule ( )
9.3.2 ResolveBinding ( 

name

 [ , 

env

 ] )

9.3.3 GetThisEnvironment ( )
9.3.4 ResolveThisBinding ( )
9.3.5 GetNewTarget ( )
9.3.6 GetGlobalObject ( )

9.4 Jobs and Host Operations to Enqueue Jobs

9.4.1 JobCallback Records
9.4.2 HostMakeJobCallback ( 

callback

 )

9.4.3 HostCallJobCallback ( 

jobCallback

V

argumentsList

 )

9.4.4 HostEnqueuePromiseJob ( 

job

realm

 )

9.5 InitializeHostDefinedRealm ( )
9.6 Agents

9.6.1 AgentSignifier ( )
9.6.2 AgentCanSuspend ( )

9.7 Agent Clusters
9.8 Forward Progress
9.9 Processing Model of WeakRef and FinalizationRegistry Objects

9.9.1 Objectives
9.9.2 Liveness
9.9.3 Execution
9.9.4 Host Hooks

9.9.4.1 HostEnqueueFinalizationRegistryCleanupJob ( 

finalizationRegistry

 )

9.10 ClearKeptObjects ( )
9.11 AddToKeptObjects ( 

object

 )

9.12 CleanupFinalizationRegistry ( 

finalizationRegistry

 )

10 Ordinary and Exotic Objects Behaviours

10.1 Ordinary Object Internal Methods and Internal Slots

10.1.1 [[GetPrototypeOf]] ( )

10.1.1.1 OrdinaryGetPrototypeOf ( 

O

 )

10.1.2 [[SetPrototypeOf]] ( 

V

 )

10.1.2.1 OrdinarySetPrototypeOf ( 

O

V

 )

10.1.3 [[IsExtensible]] ( )

10.1.3.1 OrdinaryIsExtensible ( 

O

 )

9

2.  Set 

env

.[[OuterEnv]] to 

E

.

3.  Return 

env

.

Before it is evaluated, all ECMAScript code must be associated with a 

realm

. Conceptually, a 

realm

 consists of a set of

intrinsic objects, an ECMAScript global environment, all of the ECMAScript code that is loaded within the scope of
that global environment, and other associated state and resources.

realm

 is represented in this specification as a 

Realm Record

 with the fields specified in 

Table 23

:

Table 23: 

Realm Record

 Fields

Field Name

Value

Meaning

[[Intrinsics]]

Record

 whose field

names are intrinsic
keys and whose
values are objects

The intrinsic values used by code associated with this 

realm

[[GlobalObject]]

Object

The 

global object

 for this 

realm

[[GlobalEnv]]

global Environment
Record

The global environment for this 

realm

[[TemplateMap]] 

List

 of 

Record

 {

[[Site]]: 

Parse Node

,

[[Array]]: Object }.

Template objects are canonicalized separately for each 

realm

 using its

Realm Record

's [[TemplateMap]]. Each [[Site]] value is a 

Parse Node

 that is

TemplateLiteral

. The associated [[Array]] value is the corresponding

template object that is passed to a tag function.

NOTE

[[HostDefined]]

Any, default value
is 

undefined

.

Field reserved for use by hosts that need to associate additional
information with a 

Realm Record

.

The abstract operation CreateRealm takes no arguments. It performs the following steps when called:

1.  Let 

realmRec

 be a new 

Realm Record

.

2.  Perform 

CreateIntrinsics

(

realmRec

).

3.  Set 

realmRec

.[[GlobalObject]] to 

undefined

.

4.  Set 

realmRec

.[[GlobalEnv]] to 

undefined

.

5.  Set 

realmRec

.[[TemplateMap]] to a new empty 

List

.

6.  Return 

realmRec

.

Once a 

Parse Node

 becomes unreachable, the

corresponding [[Array]] is also unreachable, and it
would be unobservable if an implementation
removed the pair from the [[TemplateMap]] list.

9.2  Realms

9.2.1  CreateRealm ( )

206

The abstract operation CreateIntrinsics takes argument 

realmRec

. It performs the following steps when called:

1.  Let 

intrinsics

 be a new 

Record

.

2.  Set 

realmRec

.[[Intrinsics]] to 

intrinsics

.

3.  Set fields of 

intrinsics

 with the values listed in 

Table 8

. The field names are the names listed in column one of

the table. The value of each field is a new object value fully and recursively populated with property values as
defined by the specification of each object in clauses 

19

 through 

28

. All object property values are newly created

object values. All values that are built-in function objects are created by performing

CreateBuiltinFunction

(

steps

length

name

slots

realmRec

prototype

) where 

steps

 is the definition of that function

provided by this specification, 

name

 is the initial value of the function's 

name

name

 property, 

length

 is the initial

value of the function's 

length

length

 property, 

slots

 is a list of the names, if any, of the function's specified internal

slots, and 

prototype

 is the specified value of the function's [[Prototype]] internal slot. The creation of the

intrinsics and their properties must be ordered to avoid any dependencies upon objects that have not yet been
created.

4.  Perform 

AddRestrictedFunctionProperties

(

intrinsics

.[[

%Function.prototype%

]], 

realmRec

).

5.  Return 

intrinsics

.

The abstract operation SetRealmGlobalObject takes arguments 

realmRec

globalObj

, and 

thisValue

. It performs the

following steps when called:

1.  If 

globalObj

 is 

undefined

, then

a.  Let 

intrinsics

 be 

realmRec

.[[Intrinsics]].

b.  Set 

globalObj

 to ! 

OrdinaryObjectCreate

(

intrinsics

.[[

%Object.prototype%

]]).

2. 

Assert

Type

(

globalObj

) is Object.

3.  If 

thisValue

 is 

undefined

, set 

thisValue

 to 

globalObj

.

4.  Set 

realmRec

.[[GlobalObject]] to 

globalObj

.

5.  Let 

newGlobalEnv

 be 

NewGlobalEnvironment

(

globalObj

thisValue

).

6.  Set 

realmRec

.[[GlobalEnv]] to 

newGlobalEnv

.

7.  Return 

realmRec

.

The abstract operation SetDefaultGlobalBindings takes argument 

realmRec

. It performs the following steps when

called:

1.  Let 

global

 be 

realmRec

.[[GlobalObject]].

2.  For each property of the Global Object specified in clause 

19

, do

a.  Let 

name

 be the String value of the 

property name

.

b.  Let 

desc

 be the fully populated data 

Property Descriptor

 for the property, containing the specified

attributes for the property. For properties listed in 

19.2

19.3

, or 

19.4

 the value of the [[Value]] attribute is

the corresponding intrinsic object from 

realmRec

.

c.  Perform ? 

DefinePropertyOrThrow

(

global

name

desc

).

3.  Return 

global

.

9.2.2  CreateIntrinsics ( 

realmRec

 )

9.2.3  SetRealmGlobalObject ( 

realmRec

globalObj

thisValue

 )

9.2.4  SetDefaultGlobalBindings ( 

realmRec

 )

207

An 

execution context

 is a specification device that is used to track the runtime evaluation of code by an ECMAScript

implementation. At any point in time, there is at most one execution context per 

agent

 that is actually executing code.

This is known as the 

agent

's 

running execution context

. All references to the 

running execution context

 in this

specification denote the 

running execution context

 of the 

surrounding agent

.

The 

execution context stack

 is used to track execution contexts. The 

running execution context

 is always the top element

of this stack. A new execution context is created whenever control is transferred from the executable code associated
with the currently 

running execution context

 to executable code that is not associated with that execution context. The

newly created execution context is pushed onto the stack and becomes the 

running execution context

.

An execution context contains whatever implementation specific state is necessary to track the execution progress of
its associated code. Each execution context has at least the state components listed in 

Table 24

.

Table 24: State Components for All Execution Contexts

Component

Purpose

code evaluation
state

Any state needed to perform, suspend, and resume evaluation of the code associated with this

execution context

.

Function

If this 

execution context

 is evaluating the code of a 

function object

, then the value of this

component is that 

function object

. If the context is evaluating the code of a 

Script

 or 

Module

, the

value is 

null

.

Realm

The 

Realm Record

 from which associated code accesses ECMAScript resources.

ScriptOrModule The 

Module Record

 or 

Script Record

 from which associated code originates. If there is no

originating script or module, as is the case for the original 

execution context

 created in

InitializeHostDefinedRealm

, the value is 

null

.

Evaluation of code by the 

running execution context

 may be suspended at various points defined within this

specification. Once the 

running execution context

 has been suspended a different execution context may become the

running execution context

 and commence evaluating its code. At some later time a suspended execution context may

again become the 

running execution context

 and continue evaluating its code at the point where it had previously

been suspended. Transition of the 

running execution context

 status among execution contexts usually occurs in stack-

like last-in/first-out manner. However, some ECMAScript features require non-LIFO transitions of the 

running

execution context

.

The value of the 

Realm

 component of the 

running execution context

 is also called 

the current Realm Record

. The value

of the Function component of the 

running execution context

 is also called the 

active function object

.

Execution contexts for ECMAScript code have the additional state components listed in 

Table 25

.

9.3  Execution Contexts

208

 

 

 

 

 

 

 

Content      ..      1      2      3      ..