8.5 Miscellaneous
These operations are used in multiple places throughout the specification.
8.5.1 Runtime Semantics: InstantiateFunctionObject
With parameter scope.
- Return ?
InstantiateOrdinaryFunctionObject ofFunctionDeclaration with argument scope.
- Return ?
InstantiateGeneratorFunctionObject ofGeneratorDeclaration with argument scope.
- Return ?
InstantiateAsyncGeneratorFunctionObject ofAsyncGeneratorDeclaration with argument scope.
- Return ?
InstantiateAsyncFunctionObject ofAsyncFunctionDeclaration with argument scope.
8.5.2 Runtime Semantics: BindingInitialization
With parameters value and environment.
var
statements and formal parameter lists of some non-strict functions (See
- Let name be
StringValue ofIdentifier . - Return ?
InitializeBoundName (name, value, environment).
- Return ?
InitializeBoundName ("yield" , value, environment).
- Return ?
InitializeBoundName ("await" , value, environment).
- Perform ?
RequireObjectCoercible (value). - Return the result of performing
BindingInitialization forObjectBindingPattern using value and environment as arguments.
- Let iteratorRecord be ?
GetIterator (value). - Let result be
IteratorBindingInitialization ofArrayBindingPattern with arguments iteratorRecord and environment. - If iteratorRecord.[[Done]] is
false , return ?IteratorClose (iteratorRecord, result). - Return result.
- Return
NormalCompletion (empty ).
- Perform ?
PropertyBindingInitialization forBindingPropertyList using value and environment as the arguments. - Return
NormalCompletion (empty ).
- Let excludedNames be a new empty
List . - Return the result of performing
RestBindingInitialization ofBindingRestProperty with value, environment, and excludedNames as the arguments.
- Let excludedNames be ?
PropertyBindingInitialization ofBindingPropertyList with arguments value and environment. - Return the result of performing
RestBindingInitialization ofBindingRestProperty with arguments value, environment, and excludedNames.
8.5.2.1 InitializeBoundName ( name, value, environment )
The abstract operation InitializeBoundName takes arguments name, value, and environment. It performs the following steps when called:
Assert :Type (name) is String.- If environment is not
undefined , then- Perform environment.InitializeBinding(name, value).
- Return
NormalCompletion (undefined ).
- Else,
- Let lhs be
ResolveBinding (name). - Return ?
PutValue (lhs, value).
- Let lhs be
8.5.3 Runtime Semantics: IteratorBindingInitialization
With parameters iteratorRecord and environment.
When
- Return
NormalCompletion (empty ).
- Return the result of performing
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.
- If
Elision is present, then- Perform ?
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.
- Perform ?
- Return the result of performing
IteratorBindingInitialization forBindingRestElement with iteratorRecord and environment as arguments.
- Perform ?
IteratorBindingInitialization forBindingElementList with iteratorRecord and environment as arguments. - Return the result of performing
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.
- Perform ?
IteratorBindingInitialization forBindingElementList with iteratorRecord and environment as arguments. - If
Elision is present, then- Perform ?
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.
- Perform ?
- Return the result of performing
IteratorBindingInitialization forBindingRestElement with iteratorRecord and environment as arguments.
- Perform ?
IteratorBindingInitialization forBindingElementList with iteratorRecord and environment as arguments. - Return the result of performing
IteratorBindingInitialization forBindingElisionElement using iteratorRecord and environment as arguments.
- Perform ?
IteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument. - Return the result of performing
IteratorBindingInitialization ofBindingElement with iteratorRecord and environment as the arguments.
- Let bindingId be
StringValue ofBindingIdentifier . - Let lhs be ?
ResolveBinding (bindingId, environment). - If iteratorRecord.[[Done]] is
false , then- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue . - Else,
- Let v be
IteratorValue (next). - If v is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (v).
- Let v be
- Let next be
- If iteratorRecord.[[Done]] is
true , let v beundefined . - If
Initializer is present and v isundefined , then- If
IsAnonymousFunctionDefinition (Initializer ) istrue , then- Set v to the result of performing
NamedEvaluation forInitializer with argument bindingId.
- Set v to the result of performing
- Else,
- Let defaultValue be the result of evaluating
Initializer . - Set v to ?
GetValue (defaultValue).
- Let defaultValue be the result of evaluating
- If
- If environment is
undefined , return ?PutValue (lhs, v). - Return
InitializeReferencedBinding (lhs, v).
- If iteratorRecord.[[Done]] is
false , then- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue . - Else,
- Let v be
IteratorValue (next). - If v is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (v).
- Let v be
- Let next be
- If iteratorRecord.[[Done]] is
true , let v beundefined . - If
Initializer is present and v isundefined , then- Let defaultValue be the result of evaluating
Initializer . - Set v to ?
GetValue (defaultValue).
- Let defaultValue be the result of evaluating
- Return the result of performing
BindingInitialization ofBindingPattern with v and environment as the arguments.
- Let lhs be ?
ResolveBinding (StringValue ofBindingIdentifier , environment). - Let A be !
ArrayCreate (0). - Let n be 0.
- Repeat,
- If iteratorRecord.[[Done]] is
false , then- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue .
- Let next be
- If iteratorRecord.[[Done]] is
true , then- If environment is
undefined , return ?PutValue (lhs, A). - Return
InitializeReferencedBinding (lhs, A).
- If environment is
- Let nextValue be
IteratorValue (next). - If nextValue is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (nextValue).- Perform !
CreateDataPropertyOrThrow (A, !ToString (𝔽 (n)), nextValue). - Set n to n + 1.
- If iteratorRecord.[[Done]] is
- Let A be !
ArrayCreate (0). - Let n be 0.
- Repeat,
- If iteratorRecord.[[Done]] is
false , then- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue .
- Let next be
- If iteratorRecord.[[Done]] is
true , then- Return the result of performing
BindingInitialization ofBindingPattern with A and environment as the arguments.
- Return the result of performing
- Let nextValue be
IteratorValue (next). - If nextValue is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (nextValue).- Perform !
CreateDataPropertyOrThrow (A, !ToString (𝔽 (n)), nextValue). - Set n to n + 1.
- If iteratorRecord.[[Done]] is
- Return
NormalCompletion (empty ).
- Perform ?
IteratorBindingInitialization forFormalParameterList using iteratorRecord and environment as the arguments. - Return the result of performing
IteratorBindingInitialization forFunctionRestParameter using iteratorRecord and environment as the arguments.
- Perform ?
IteratorBindingInitialization forFormalParameterList using iteratorRecord and environment as the arguments. - Return the result of performing
IteratorBindingInitialization forFormalParameter using iteratorRecord and environment as the arguments.
Assert : iteratorRecord.[[Done]] isfalse .- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue . - Else,
- Let v be
IteratorValue (next). - If v is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (v).
- Let v be
- If iteratorRecord.[[Done]] is
true , let v beundefined . - Return the result of performing
BindingInitialization forBindingIdentifier using v and environment as the arguments.
- Let formals be
CoveredFormalsList ofCoverParenthesizedExpressionAndArrowParameterList . - Return
IteratorBindingInitialization of formals with arguments iteratorRecord and environment.
Assert : iteratorRecord.[[Done]] isfalse .- Let next be
IteratorStep (iteratorRecord). - If next is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (next).- If next is
false , set iteratorRecord.[[Done]] totrue . - Else,
- Let v be
IteratorValue (next). - If v is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (v).
- Let v be
- If iteratorRecord.[[Done]] is
true , let v beundefined . - Return the result of performing
BindingInitialization forBindingIdentifier using v and environment as the arguments.
8.5.4 Static Semantics: AssignmentTargetType
- If this
IdentifierReference is contained instrict mode code andStringValue ofIdentifier is"eval" or"arguments" , returninvalid . - Return
simple .
- Return
simple .
- Let expr be
CoveredParenthesizedExpression ofCoverParenthesizedExpressionAndArrowParameterList . - Return
AssignmentTargetType of expr.
- Return
invalid .
8.5.5 Static Semantics: PropName
- Return
StringValue ofIdentifierReference .
- Return
empty .
- Return
PropName ofPropertyName .
- Return
StringValue ofIdentifierName .
- Return the
SV ofStringLiteral .
- Let nbr be the
NumericValue ofNumericLiteral . - Return !
ToString (nbr).
- Return
empty .
- Return
PropName ofPropertyName .
- Return
PropName ofPropertyName .
- Return
PropName ofPropertyName .
- Return
empty .
- Return
PropName ofPropertyName .