13 ECMAScript Language: Expressions
13.1 Identifiers
Syntax
yield and await are permitted as
let
await 0;
13.1.1 Static Semantics: Early Errors
-
It is a Syntax Error if the code matched by this production is contained in
strict mode code and theStringValue ofIdentifier is"arguments" or"eval" .
-
It is a Syntax Error if the code matched by this production is contained in
strict mode code .
-
It is a Syntax Error if the
goal symbol of the syntactic grammar isModule .
- It is a Syntax Error if this production has a [Yield] parameter.
- It is a Syntax Error if this production has an [Await] parameter.
-
It is a Syntax Error if this production has a [Yield] parameter and
StringValue ofIdentifier is"yield" . -
It is a Syntax Error if this production has an [Await] parameter and
StringValue ofIdentifier is"await" .
-
It is a Syntax Error if this phrase is contained in
strict mode code and theStringValue ofIdentifierName is:"implements" ,"interface" ,"let" ,"package" ,"private" ,"protected" ,"public" ,"static" , or"yield" . -
It is a Syntax Error if the
goal symbol of the syntactic grammar isModule and theStringValue ofIdentifierName is"await" . -
It is a Syntax Error if
StringValue ofIdentifierName is the same String value as theStringValue of anyReservedWord except foryieldorawait.
13.1.2 Static Semantics: StringValue
- Let idText be the
source text matched by IdentifierName . - Let idTextUnescaped be the result of replacing any occurrences of
\UnicodeEscapeSequence in idText with the code point represented by theUnicodeEscapeSequence . - Return !
CodePointsToString (idTextUnescaped).
- Return
"yield" .
- Return
"await" .
- Return the StringValue of
IdentifierName .
13.1.3 Runtime Semantics: Evaluation
- Return ?
ResolveBinding (StringValue ofIdentifier ).
- Return ?
ResolveBinding ("yield" ).
- Return ?
ResolveBinding ("await" ).
The result of evaluating an
In yield may be used as an identifier. Evaluating the yield as if it was an
13.2 Primary Expression
Syntax
Supplemental Syntax
When processing an instance of the production
the interpretation of
13.2.1 Semantics
13.2.1.1 Static Semantics: CoveredParenthesizedExpression
13.2.2 The this Keyword
13.2.2.1 Runtime Semantics: Evaluation
- Return ?
ResolveThisBinding ().
13.2.3 Identifier Reference
See
13.2.4 Literals
13.2.4.1 Runtime Semantics: Evaluation
- Return
null .
- If
BooleanLiteral is the tokenfalse, returnfalse . - If
BooleanLiteral is the tokentrue, returntrue .
- Return the
NumericValue ofNumericLiteral as defined in12.8.3 .
- Return the
SV ofStringLiteral as defined in12.8.4.1 .
13.2.5 Array Initializer
An
Array elements may be elided at the beginning, middle or end of the element list. Whenever a comma in the element list is not preceded by an
Syntax
13.2.5.1 Runtime Semantics: ArrayAccumulation
With parameters array and nextIndex.
- Return the result of performing ArrayAccumulation for
Elision with arguments array and nextIndex + 1.
- If
Elision is present, thenSet nextIndex to the result of performing ArrayAccumulation forElision with arguments array and nextIndex.ReturnIfAbrupt (nextIndex).
- Let initResult be the result of evaluating
AssignmentExpression . - Let initValue be ?
GetValue (initResult). - Let created be !
CreateDataPropertyOrThrow (array, !ToString (𝔽(nextIndex)), initValue). - Return nextIndex + 1.
- If
Elision is present, thenSet nextIndex to the result of performing ArrayAccumulation forElision with arguments array and nextIndex.ReturnIfAbrupt (nextIndex).
- Return the result of performing ArrayAccumulation for
SpreadElement with arguments array and nextIndex.
Set nextIndex to the result of performing ArrayAccumulation forElementList with arguments array and nextIndex.ReturnIfAbrupt (nextIndex).- If
Elision is present, thenSet nextIndex to the result of performing ArrayAccumulation forElision with arguments array and nextIndex.ReturnIfAbrupt (nextIndex).
- Let initResult be the result of evaluating
AssignmentExpression . - Let initValue be ?
GetValue (initResult). - Let created be !
CreateDataPropertyOrThrow (array, !ToString (𝔽(nextIndex)), initValue). - Return nextIndex + 1.
Set nextIndex to the result of performing ArrayAccumulation forElementList with arguments array and nextIndex.ReturnIfAbrupt (nextIndex).- If
Elision is present, thenSet nextIndex to the result of performing ArrayAccumulation forElision with arguments array and nextIndex.ReturnIfAbrupt (nextIndex).
- Return the result of performing ArrayAccumulation for
SpreadElement with arguments array and nextIndex.
- Let spreadRef be the result of evaluating
AssignmentExpression . - Let spreadObj be ?
GetValue (spreadRef). - Let iteratorRecord be ?
GetIterator (spreadObj). - Repeat,
- Let next be ?
IteratorStep (iteratorRecord). - If next is
false , return nextIndex. - Let nextValue be ?
IteratorValue (next). - Perform !
CreateDataPropertyOrThrow (array, !ToString (𝔽(nextIndex)), nextValue). Set nextIndex to nextIndex + 1.
- Let next be ?
13.2.5.2 Runtime Semantics: Evaluation
- Let array be !
ArrayCreate (0). - If
Elision is present, then- Let len be the result of performing
ArrayAccumulation forElision with arguments array and 0. ReturnIfAbrupt (len).
- Let len be the result of performing
- Return array.
- Let array be !
ArrayCreate (0). - Let len be the result of performing
ArrayAccumulation forElementList with arguments array and 0. ReturnIfAbrupt (len).- Return array.
- Let array be !
ArrayCreate (0). - Let nextIndex be the result of performing
ArrayAccumulation forElementList with arguments array and 0. ReturnIfAbrupt (nextIndex).- If
Elision is present, then- Let len be the result of performing
ArrayAccumulation forElision with arguments array and nextIndex. ReturnIfAbrupt (len).
- Let len be the result of performing
- Return array.
13.2.6 Object Initializer
An object initializer is an expression describing the initialization of an Object, written in a form resembling a literal. It is a list of zero or more pairs of property keys and associated values, enclosed in curly brackets. The values need not be literals; they are evaluated each time the object initializer is evaluated.
Syntax
In certain contexts,
13.2.6.1 Static Semantics: Early Errors
-
It is a Syntax Error if
HasDirectSuper ofMethodDefinition istrue .
In addition to describing an actual object initializer the
- Always throw a Syntax Error if code matches this production.
This production exists so that
13.2.6.2 Static Semantics: IsComputedPropertyKey
13.2.6.3 Static Semantics: PropertyNameList
- If
PropName ofPropertyDefinition isempty , return a new emptyList . - Return a
List whose sole element isPropName ofPropertyDefinition .
- Let list be PropertyNameList of
PropertyDefinitionList . - If
PropName ofPropertyDefinition isempty , return list. - Append
PropName ofPropertyDefinition to the end of list. - Return list.
13.2.6.4 Runtime Semantics: Evaluation
- Return !
OrdinaryObjectCreate (%Object.prototype% ).
- Let obj be !
OrdinaryObjectCreate (%Object.prototype% ). - Perform ?
PropertyDefinitionEvaluation ofPropertyDefinitionList with arguments obj andtrue . - Return obj.
- Return
StringValue ofIdentifierName .
- Return the
SV ofStringLiteral .
- Let nbr be the
NumericValue ofNumericLiteral . - Return !
ToString (nbr).
- Let exprValue be the result of evaluating
AssignmentExpression . - Let propName be ?
GetValue (exprValue). - Return ?
ToPropertyKey (propName).
13.2.6.5 Runtime Semantics: PropertyDefinitionEvaluation
With parameters object and enumerable.
- Perform ? PropertyDefinitionEvaluation of
PropertyDefinitionList with arguments object and enumerable. - Return the result of performing PropertyDefinitionEvaluation of
PropertyDefinition with arguments object and enumerable.
- Let exprValue be the result of evaluating
AssignmentExpression . - Let fromValue be ?
GetValue (exprValue). - Let excludedNames be a new empty
List . - Return ?
CopyDataProperties (object, fromValue, excludedNames).
- Let propName be
StringValue ofIdentifierReference . - Let exprValue be the result of evaluating
IdentifierReference . - Let propValue be ?
GetValue (exprValue). Assert : enumerable istrue .Assert : object is an ordinary, extensible object with no non-configurable properties.- Return !
CreateDataPropertyOrThrow (object, propName, propValue).
- Let propKey be the result of evaluating
PropertyName . ReturnIfAbrupt (propKey).- If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue , then- Let propValue be ?
NamedEvaluation ofAssignmentExpression with argument propKey.
- Let propValue be ?
- Else,
- Let exprValueRef be the result of evaluating
AssignmentExpression . - Let propValue be ?
GetValue (exprValueRef).
- Let exprValueRef be the result of evaluating
Assert : enumerable istrue .Assert : object is an ordinary, extensible object with no non-configurable properties.- Return !
CreateDataPropertyOrThrow (object, propKey, propValue).
An alternative semantics for this production is given in
- Return ?
MethodDefinitionEvaluation ofMethodDefinition with arguments object and enumerable.
- Return ?
MethodDefinitionEvaluation ofGeneratorMethod with arguments object and enumerable.
- Return ?
MethodDefinitionEvaluation ofAsyncGeneratorMethod with arguments object and enumerable.
- Return ?
MethodDefinitionEvaluation ofAsyncMethod with arguments object and enumerable.
13.2.7 Function Defining Expressions
See
See
See
See
See
13.2.8 Regular Expression Literals
Syntax
See
13.2.8.1 Static Semantics: Early Errors
-
It is a Syntax Error if
IsValidRegularExpressionLiteral (RegularExpressionLiteral ) isfalse .
13.2.8.2 Static Semantics: IsValidRegularExpressionLiteral ( literal )
The abstract operation IsValidRegularExpressionLiteral takes argument literal. It determines if its argument is a valid regular expression literal. It performs the following steps when called:
Assert : literal is aRegularExpressionLiteral .- If
FlagText of literal contains any code points other thang,i,m,s,u, ory, or if it contains the same code point more than once, returnfalse . - Let patternText be
BodyText of literal. - If
FlagText of literal containsu, let u betrue ; else let u befalse . - If u is
false , then- Let stringValue be
CodePointsToString (patternText). Set patternText to the sequence of code points resulting from interpreting each of the 16-bit elements of stringValue as a Unicode BMP code point. UTF-16 decoding is not applied to the elements.
- Let stringValue be
- Let parseResult be
ParsePattern (patternText, u). - If parseResult is a
Parse Node , returntrue ; else returnfalse .
13.2.8.3 Runtime Semantics: Evaluation
- Let pattern be !
CodePointsToString (BodyText ofRegularExpressionLiteral ). - Let flags be !
CodePointsToString (FlagText ofRegularExpressionLiteral ). - Return
RegExpCreate (pattern, flags).
13.2.9 Template Literals
Syntax
13.2.9.1 Static Semantics: Early Errors
-
It is a Syntax Error if the [Tagged] parameter was not set and
NoSubstitutionTemplate Contains NotEscapeSequence .
-
It is a Syntax Error if the number of elements in the result of
TemplateStrings ofTemplateLiteral with argumentfalse is greater than 232 - 1.
-
It is a Syntax Error if the [Tagged] parameter was not set and
TemplateHead Contains NotEscapeSequence .
-
It is a Syntax Error if the [Tagged] parameter was not set and
TemplateTail Contains NotEscapeSequence .
-
It is a Syntax Error if the [Tagged] parameter was not set and
TemplateMiddle Contains NotEscapeSequence .
13.2.9.2 Static Semantics: TemplateStrings
With parameter raw.
- If raw is
false , then- Let string be the TV of
NoSubstitutionTemplate .
- Let string be the TV of
- Else,
- Let string be the TRV of
NoSubstitutionTemplate .
- Let string be the TRV of
- Return a
List whose sole element is string.
- If raw is
false , then- Let head be the TV of
TemplateHead .
- Let head be the TV of
- Else,
- Let head be the TRV of
TemplateHead .
- Let head be the TRV of
- Let tail be TemplateStrings of
TemplateSpans with argument raw. - Return a
List whose elements are head followed by the elements of tail.
- If raw is
false , then- Let tail be the TV of
TemplateTail .
- Let tail be the TV of
- Else,
- Let tail be the TRV of
TemplateTail .
- Let tail be the TRV of
- Return a
List whose sole element is tail.
- Let middle be TemplateStrings of
TemplateMiddleList with argument raw. - If raw is
false , then- Let tail be the TV of
TemplateTail .
- Let tail be the TV of
- Else,
- Let tail be the TRV of
TemplateTail .
- Let tail be the TRV of
- Return a
List whose elements are the elements of middle followed by tail.
- If raw is
false , then- Let string be the TV of
TemplateMiddle .
- Let string be the TV of
- Else,
- Let string be the TRV of
TemplateMiddle .
- Let string be the TRV of
- Return a
List whose sole element is string.
- Let front be TemplateStrings of
TemplateMiddleList with argument raw. - If raw is
false , then- Let last be the TV of
TemplateMiddle .
- Let last be the TV of
- Else,
- Let last be the TRV of
TemplateMiddle .
- Let last be the TRV of
- Append last as the last element of the
List front. - Return front.
13.2.9.3 GetTemplateObject ( templateLiteral )
The abstract operation GetTemplateObject takes argument templateLiteral (a
- Let realm be
the current Realm Record . - Let templateRegistry be realm.[[TemplateMap]].
- For each element e of templateRegistry, do
- If e.[[Site]] is
the same Parse Node as templateLiteral, then- Return e.[[Array]].
- If e.[[Site]] is
- Let rawStrings be
TemplateStrings of templateLiteral with argumenttrue . - Let cookedStrings be
TemplateStrings of templateLiteral with argumentfalse . - Let count be the number of elements in the
List cookedStrings. Assert : count ≤ 232 - 1.- Let template be !
ArrayCreate (count). - Let rawObj be !
ArrayCreate (count). - Let index be 0.
- Repeat, while index < count,
- Let prop be !
ToString (𝔽(index)). - Let cookedValue be cookedStrings[index].
- Perform !
DefinePropertyOrThrow (template, prop, PropertyDescriptor { [[Value]]: cookedValue, [[Writable]]:false , [[Enumerable]]:true , [[Configurable]]:false }). - Let rawValue be the String value rawStrings[index].
- Perform !
DefinePropertyOrThrow (rawObj, prop, PropertyDescriptor { [[Value]]: rawValue, [[Writable]]:false , [[Enumerable]]:true , [[Configurable]]:false }). Set index to index + 1.
- Let prop be !
- Perform !
SetIntegrityLevel (rawObj,frozen ). - Perform !
DefinePropertyOrThrow (template,"raw" , PropertyDescriptor { [[Value]]: rawObj, [[Writable]]:false , [[Enumerable]]:false , [[Configurable]]:false }). - Perform !
SetIntegrityLevel (template,frozen ). - Append the
Record { [[Site]]: templateLiteral, [[Array]]: template } to templateRegistry. - Return template.
The creation of a template object cannot result in an
Each
Future editions of this specification may define additional non-enumerable properties of template objects.
13.2.9.4 Runtime Semantics: SubstitutionEvaluation
- Return a new empty
List .
- Return the result of SubstitutionEvaluation of
TemplateMiddleList .
- Let subRef be the result of evaluating
Expression . - Let sub be ?
GetValue (subRef). - Return a
List whose sole element is sub.
- Let preceding be ? SubstitutionEvaluation of
TemplateMiddleList . - Let nextRef be the result of evaluating
Expression . - Let next be ?
GetValue (nextRef). - Append next as the last element of the
List preceding. - Return preceding.
13.2.9.5 Runtime Semantics: Evaluation
- Return the TV of
NoSubstitutionTemplate as defined in12.8.6 .
- Let head be the TV of
TemplateHead as defined in12.8.6 . - Let subRef be the result of evaluating
Expression . - Let sub be ?
GetValue (subRef). - Let middle be ?
ToString (sub). - Let tail be the result of evaluating
TemplateSpans . ReturnIfAbrupt (tail).- Return the
string-concatenation of head, middle, and tail.
The string conversion semantics applied to the String.prototype.concat rather than the + operator.
- Return the TV of
TemplateTail as defined in12.8.6 .
- Let head be the result of evaluating
TemplateMiddleList . ReturnIfAbrupt (head).- Let tail be the TV of
TemplateTail as defined in12.8.6 . - Return the
string-concatenation of head and tail.
- Let head be the TV of
TemplateMiddle as defined in12.8.6 . - Let subRef be the result of evaluating
Expression . - Let sub be ?
GetValue (subRef). - Let middle be ?
ToString (sub). - Return the
string-concatenation of head and middle.
The string conversion semantics applied to the String.prototype.concat rather than the + operator.
- Let rest be the result of evaluating
TemplateMiddleList . ReturnIfAbrupt (rest).- Let middle be the TV of
TemplateMiddle as defined in12.8.6 . - Let subRef be the result of evaluating
Expression . - Let sub be ?
GetValue (subRef). - Let last be ?
ToString (sub). - Return the
string-concatenation of rest, middle, and last.
The string conversion semantics applied to the String.prototype.concat rather than the + operator.
13.2.10 The Grouping Operator
13.2.10.1 Static Semantics: Early Errors
-
It is a Syntax Error if
CoverParenthesizedExpressionAndArrowParameterList is notcovering aParenthesizedExpression . -
All Early Error rules for
ParenthesizedExpression and its derived productions also apply toCoveredParenthesizedExpression ofCoverParenthesizedExpressionAndArrowParameterList .
13.2.10.2 Runtime Semantics: Evaluation
- Let expr be
CoveredParenthesizedExpression ofCoverParenthesizedExpressionAndArrowParameterList . - Return the result of evaluating expr.
- Return the result of evaluating
Expression . This may be oftype Reference.
This algorithm does not apply delete and typeof may be applied to parenthesized expressions.
13.3 Left-Hand-Side Expressions
Syntax
Supplemental Syntax
When processing an instance of the production
the interpretation of
13.3.1 Static Semantics
13.3.1.1 Static Semantics: Early Errors
- It is a Syntax Error if any code matches this production.
This production exists in order to prevent automatic semicolon insertion rules (
a?.b
`c`
so that it would be interpreted as two valid statements. The purpose is to maintain consistency with similar code without optional chaining:
a.b
`c`
which is a valid statement and where automatic semicolon insertion does not apply.
-
It is a Syntax Error if the syntactic
goal symbol is notModule .
13.3.1.2 Static Semantics: CoveredCallExpression
13.3.2 Property Accessors
Properties are accessed by name, using either the dot notation:
or the bracket notation:
The dot notation is explained by the following syntactic conversion:
is identical in its behaviour to
and similarly
is identical in its behaviour to
where <identifier-name-string> is the result of evaluating
13.3.2.1 Runtime Semantics: Evaluation
- Let baseReference be the result of evaluating
MemberExpression . - Let baseValue be ?
GetValue (baseReference). - If the code matched by this
MemberExpression isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
EvaluatePropertyAccessWithExpressionKey (baseValue,Expression , strict).
- Let baseReference be the result of evaluating
MemberExpression . - Let baseValue be ?
GetValue (baseReference). - If the code matched by this
MemberExpression isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
EvaluatePropertyAccessWithIdentifierKey (baseValue,IdentifierName , strict).
- Let baseReference be the result of evaluating
CallExpression . - Let baseValue be ?
GetValue (baseReference). - If the code matched by this
CallExpression isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
EvaluatePropertyAccessWithExpressionKey (baseValue,Expression , strict).
- Let baseReference be the result of evaluating
CallExpression . - Let baseValue be ?
GetValue (baseReference). - If the code matched by this
CallExpression isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
EvaluatePropertyAccessWithIdentifierKey (baseValue,IdentifierName , strict).
13.3.3 EvaluatePropertyAccessWithExpressionKey ( baseValue, expression, strict )
The abstract operation EvaluatePropertyAccessWithExpressionKey takes arguments baseValue (an
- Let propertyNameReference be the result of evaluating expression.
- Let propertyNameValue be ?
GetValue (propertyNameReference). - Let bv be ?
RequireObjectCoercible (baseValue). - Let propertyKey be ?
ToPropertyKey (propertyNameValue). - Return the
Reference Record { [[Base]]: bv, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]:empty }.
13.3.4 EvaluatePropertyAccessWithIdentifierKey ( baseValue, identifierName, strict )
The abstract operation EvaluatePropertyAccessWithIdentifierKey takes arguments baseValue (an
Assert : identifierName is anIdentifierName .- Let bv be ?
RequireObjectCoercible (baseValue). - Let propertyNameString be
StringValue of identifierName. - Return the
Reference Record { [[Base]]: bv, [[ReferencedName]]: propertyNameString, [[Strict]]: strict, [[ThisValue]]:empty }.
13.3.5 The new Operator
13.3.5.1 Runtime Semantics: Evaluation
- Return ?
EvaluateNew (NewExpression ,empty ).
- Return ?
EvaluateNew (MemberExpression ,Arguments ).
13.3.5.1.1 EvaluateNew ( constructExpr, arguments )
The abstract operation EvaluateNew takes arguments constructExpr and arguments. It performs the following steps when called:
Assert : constructExpr is either aNewExpression or aMemberExpression .Assert : arguments is eitherempty or anArguments .- Let ref be the result of evaluating constructExpr.
- Let constructor be ?
GetValue (ref). - If arguments is
empty , let argList be a new emptyList . - Else,
- Let argList be ?
ArgumentListEvaluation of arguments.
- Let argList be ?
- If
IsConstructor (constructor) isfalse , throw aTypeError exception. - Return ?
Construct (constructor, argList).
13.3.6 Function Calls
13.3.6.1 Runtime Semantics: Evaluation
- Let expr be
CoveredCallExpression ofCoverCallExpressionAndAsyncArrowHead . - Let memberExpr be the
MemberExpression of expr. - Let arguments be the
Arguments of expr. - Let ref be the result of evaluating memberExpr.
- Let func be ?
GetValue (ref). - If ref is a
Reference Record ,IsPropertyReference (ref) isfalse , and ref.[[ReferencedName]] is"eval" , then- If
SameValue (func,%eval% ) istrue , then- Let argList be ?
ArgumentListEvaluation of arguments. - If argList has no elements, return
undefined . - Let evalArg be the first element of argList.
- If the source code matching this
CallExpression isstrict mode code , let strictCaller betrue . Otherwise let strictCaller befalse . - Let evalRealm be
the current Realm Record . - Return ?
PerformEval (evalArg, evalRealm, strictCaller,true ).
- Let argList be ?
- If
- Let thisCall be this
CallExpression . - Let tailCall be
IsInTailPosition (thisCall). - Return ?
EvaluateCall (func, ref, arguments, tailCall).
A
- Let ref be the result of evaluating
CallExpression . - Let func be ?
GetValue (ref). - Let thisCall be this
CallExpression . - Let tailCall be
IsInTailPosition (thisCall). - Return ?
EvaluateCall (func, ref,Arguments , tailCall).
13.3.6.2 EvaluateCall ( func, ref, arguments, tailPosition )
The abstract operation EvaluateCall takes arguments func (an
- If ref is a
Reference Record , then- If
IsPropertyReference (ref) istrue , then- Let thisValue be
GetThisValue (ref).
- Let thisValue be
- Else,
- Let refEnv be ref.[[Base]].
Assert : refEnv is anEnvironment Record .- Let thisValue be refEnv.WithBaseObject().
- If
- Else,
- Let thisValue be
undefined .
- Let thisValue be
- Let argList be ?
ArgumentListEvaluation of arguments. - If
Type (func) is not Object, throw aTypeError exception. - If
IsCallable (func) isfalse , throw aTypeError exception. - If tailPosition is
true , performPrepareForTailCall (). - Let result be
Call (func, thisValue, argList). Assert : If tailPosition istrue , the above call will not return here, but instead evaluation will continue as if the following return has already occurred.Assert : If result is not anabrupt completion , thenType (result) is anECMAScript language type .- Return result.
13.3.7 The super Keyword
13.3.7.1 Runtime Semantics: Evaluation
- Let env be
GetThisEnvironment (). - Let actualThis be ? env.GetThisBinding().
- Let propertyNameReference be the result of evaluating
Expression . - Let propertyNameValue be ?
GetValue (propertyNameReference). - Let propertyKey be ?
ToPropertyKey (propertyNameValue). - If the code matched by this
SuperProperty isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
MakeSuperPropertyReference (actualThis, propertyKey, strict).
- Let env be
GetThisEnvironment (). - Let actualThis be ? env.GetThisBinding().
- Let propertyKey be
StringValue ofIdentifierName . - If the code matched by this
SuperProperty isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
MakeSuperPropertyReference (actualThis, propertyKey, strict).
- Let newTarget be
GetNewTarget (). Assert :Type (newTarget) is Object.- Let func be !
GetSuperConstructor (). - Let argList be ?
ArgumentListEvaluation ofArguments . - If
IsConstructor (func) isfalse , throw aTypeError exception. - Let result be ?
Construct (func, argList, newTarget). - Let thisER be
GetThisEnvironment (). - Return ? thisER.BindThisValue(result).
13.3.7.2 GetSuperConstructor ( )
The abstract operation GetSuperConstructor takes no arguments. It performs the following steps when called:
- Let envRec be
GetThisEnvironment (). Assert : envRec is afunction Environment Record .- Let activeFunction be envRec.[[FunctionObject]].
Assert : activeFunction is an ECMAScriptfunction object .- Let superConstructor be ! activeFunction.[[GetPrototypeOf]]().
- Return superConstructor.
13.3.7.3 MakeSuperPropertyReference ( actualThis, propertyKey, strict )
The abstract operation MakeSuperPropertyReference takes arguments actualThis, propertyKey, and strict. It performs the following steps when called:
- Let env be
GetThisEnvironment (). Assert : env.HasSuperBinding() istrue .- Let baseValue be ? env.GetSuperBase().
- Let bv be ?
RequireObjectCoercible (baseValue). - Return the
Reference Record { [[Base]]: bv, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: actualThis }. - NOTE: This returns a
Super Reference Record .
13.3.8 Argument Lists
The evaluation of an argument list produces a
13.3.8.1 Runtime Semantics: ArgumentListEvaluation
- Return a new empty
List .
- Let ref be the result of evaluating
AssignmentExpression . - Let arg be ?
GetValue (ref). - Return a
List whose sole element is arg.
- Let list be a new empty
List . - Let spreadRef be the result of evaluating
AssignmentExpression . - Let spreadObj be ?
GetValue (spreadRef). - Let iteratorRecord be ?
GetIterator (spreadObj). - Repeat,
- Let next be ?
IteratorStep (iteratorRecord). - If next is
false , return list. - Let nextArg be ?
IteratorValue (next). - Append nextArg as the last element of list.
- Let next be ?
- Let precedingArgs be ? ArgumentListEvaluation of
ArgumentList . - Let ref be the result of evaluating
AssignmentExpression . - Let arg be ?
GetValue (ref). - Append arg to the end of precedingArgs.
- Return precedingArgs.
- Let precedingArgs be ? ArgumentListEvaluation of
ArgumentList . - Let spreadRef be the result of evaluating
AssignmentExpression . - Let iteratorRecord be ?
GetIterator (?GetValue (spreadRef)). - Repeat,
- Let next be ?
IteratorStep (iteratorRecord). - If next is
false , return precedingArgs. - Let nextArg be ?
IteratorValue (next). - Append nextArg as the last element of precedingArgs.
- Let next be ?
- Let templateLiteral be this
TemplateLiteral . - Let siteObj be
GetTemplateObject (templateLiteral). - Return a
List whose sole element is siteObj.
- Let templateLiteral be this
TemplateLiteral . - Let siteObj be
GetTemplateObject (templateLiteral). - Let remaining be ? ArgumentListEvaluation of
SubstitutionTemplate . - Return a
List whose first element is siteObj and whose subsequent elements are the elements of remaining.
- Let firstSubRef be the result of evaluating
Expression . - Let firstSub be ?
GetValue (firstSubRef). - Let restSub be ?
SubstitutionEvaluation ofTemplateSpans . Assert : restSub is aList .- Return a
List whose first element is firstSub and whose subsequent elements are the elements of restSub. restSub may contain no elements.
13.3.9 Optional Chains
?..13.3.9.1 Runtime Semantics: Evaluation
- Let baseReference be the result of evaluating
MemberExpression . - Let baseValue be ?
GetValue (baseReference). - If baseValue is
undefined ornull , then- Return
undefined .
- Return
- Return the result of performing
ChainEvaluation ofOptionalChain with arguments baseValue and baseReference.
- Let baseReference be the result of evaluating
CallExpression . - Let baseValue be ?
GetValue (baseReference). - If baseValue is
undefined ornull , then- Return
undefined .
- Return
- Return the result of performing
ChainEvaluation ofOptionalChain with arguments baseValue and baseReference.
- Let baseReference be the result of evaluating
OptionalExpression . - Let baseValue be ?
GetValue (baseReference). - If baseValue is
undefined ornull , then- Return
undefined .
- Return
- Return the result of performing
ChainEvaluation ofOptionalChain with arguments baseValue and baseReference.
13.3.9.2 Runtime Semantics: ChainEvaluation
With parameters baseValue and baseReference.
- Let thisChain be this
OptionalChain . - Let tailCall be
IsInTailPosition (thisChain). - Return ?
EvaluateCall (baseValue, baseReference,Arguments , tailCall).
- If the code matched by this
OptionalChain isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
EvaluatePropertyAccessWithExpressionKey (baseValue,Expression , strict).
- If the code matched by this
OptionalChain isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
EvaluatePropertyAccessWithIdentifierKey (baseValue,IdentifierName , strict).
- Let optionalChain be
OptionalChain . - Let newReference be ? ChainEvaluation of optionalChain with arguments baseValue and baseReference.
- Let newValue be ?
GetValue (newReference). - Let thisChain be this
OptionalChain . - Let tailCall be
IsInTailPosition (thisChain). - Return ?
EvaluateCall (newValue, newReference,Arguments , tailCall).
- Let optionalChain be
OptionalChain . - Let newReference be ? ChainEvaluation of optionalChain with arguments baseValue and baseReference.
- Let newValue be ?
GetValue (newReference). - If the code matched by this
OptionalChain isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
EvaluatePropertyAccessWithExpressionKey (newValue,Expression , strict).
- Let optionalChain be
OptionalChain . - Let newReference be ? ChainEvaluation of optionalChain with arguments baseValue and baseReference.
- Let newValue be ?
GetValue (newReference). - If the code matched by this
OptionalChain isstrict mode code , let strict betrue ; else let strict befalse . - Return ?
EvaluatePropertyAccessWithIdentifierKey (newValue,IdentifierName , strict).
13.3.10 Import Calls
13.3.10.1 Runtime Semantics: Evaluation
- Let referencingScriptOrModule be !
GetActiveScriptOrModule (). - Let argRef be the result of evaluating
AssignmentExpression . - Let specifier be ?
GetValue (argRef). - Let promiseCapability be !
NewPromiseCapability (%Promise% ). - Let specifierString be
ToString (specifier). IfAbruptRejectPromise (specifierString, promiseCapability).- Perform !
HostImportModuleDynamically (referencingScriptOrModule, specifierString, promiseCapability). - Return promiseCapability.[[Promise]].
13.3.11 Tagged Templates
A tagged template is a function call where the arguments of the call are derived from a
13.3.11.1 Runtime Semantics: Evaluation
- Let tagRef be the result of evaluating
MemberExpression . - Let tagFunc be ?
GetValue (tagRef). - Let thisCall be this
MemberExpression . - Let tailCall be
IsInTailPosition (thisCall). - Return ?
EvaluateCall (tagFunc, tagRef,TemplateLiteral , tailCall).
- Let tagRef be the result of evaluating
CallExpression . - Let tagFunc be ?
GetValue (tagRef). - Let thisCall be this
CallExpression . - Let tailCall be
IsInTailPosition (thisCall). - Return ?
EvaluateCall (tagFunc, tagRef,TemplateLiteral , tailCall).
13.3.12 Meta Properties
13.3.12.1 Runtime Semantics: Evaluation
- Return
GetNewTarget ().
- Let module be !
GetActiveScriptOrModule (). Assert : module is aSource Text Module Record .- Let importMeta be module.[[ImportMeta]].
- If importMeta is
empty , thenSet importMeta to !OrdinaryObjectCreate (null ).- Let importMetaValues be !
HostGetImportMetaProperties (module). - For each
Record { [[Key]], [[Value]] } p of importMetaValues, do- Perform !
CreateDataPropertyOrThrow (importMeta, p.[[Key]], p.[[Value]]).
- Perform !
- Perform !
HostFinalizeImportMeta (importMeta, module). Set module.[[ImportMeta]] to importMeta.- Return importMeta.
- Else,
13.3.12.1.1 HostGetImportMetaProperties ( moduleRecord )
The import.meta.
The implementation of HostGetImportMetaProperties must conform to the following requirements:
- It must return a
List , whose values are all Records with two fields, [[Key]] and [[Value]]. - Each such
Record 's [[Key]] field must be a property key, i.e.,IsPropertyKey must returntrue when applied to it. - Each such
Record 's [[Value]] field must be an ECMAScript value. - It must always complete normally (i.e., not return an
abrupt completion ).
The default implementation of HostGetImportMetaProperties is to return a new empty
13.3.12.1.2 HostFinalizeImportMeta ( importMeta, moduleRecord )
The import.meta.
Most hosts will be able to simply define
The implementation of HostFinalizeImportMeta must conform to the following requirements:
- It must always complete normally (i.e., not return an
abrupt completion ).
The default implementation of HostFinalizeImportMeta is to return
13.4 Update Expressions
Syntax
13.4.1 Static Semantics: Early Errors
-
It is an early Syntax Error if
AssignmentTargetType ofLeftHandSideExpression is notsimple .
-
It is an early Syntax Error if
AssignmentTargetType ofUnaryExpression is notsimple .
13.4.2 Postfix Increment Operator
13.4.2.1 Runtime Semantics: Evaluation
13.4.3 Postfix Decrement Operator
13.4.3.1 Runtime Semantics: Evaluation
13.4.4 Prefix Increment Operator
13.4.4.1 Runtime Semantics: Evaluation
13.4.5 Prefix Decrement Operator
13.4.5.1 Runtime Semantics: Evaluation
13.5 Unary Operators
Syntax
13.5.1 The delete Operator
13.5.1.1 Static Semantics: Early Errors
-
It is a Syntax Error if the
UnaryExpression is contained instrict mode code and the derivedUnaryExpression is .PrimaryExpression : IdentifierReference -
It is a Syntax Error if the derived
UnaryExpression is
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
andCoverParenthesizedExpressionAndArrowParameterList ultimately derives a phrase that, if used in place ofUnaryExpression , would produce a Syntax Error according to these rules. This rule is recursively applied.
The last rule means that expressions such as delete (((foo))) produce early errors because of recursive application of the first rule.
13.5.1.2 Runtime Semantics: Evaluation
- Let ref be the result of evaluating
UnaryExpression . ReturnIfAbrupt (ref).- If ref is not a
Reference Record , returntrue . - If
IsUnresolvableReference (ref) istrue , thenAssert : ref.[[Strict]] isfalse .- Return
true .
- If
IsPropertyReference (ref) istrue , then- If
IsSuperReference (ref) istrue , throw aReferenceError exception. - Let baseObj be !
ToObject (ref.[[Base]]). - Let deleteStatus be ? baseObj.[[Delete]](ref.[[ReferencedName]]).
- If deleteStatus is
false and ref.[[Strict]] istrue , throw aTypeError exception. - Return deleteStatus.
- If
- Else,
- Let base be ref.[[Base]].
Assert : base is anEnvironment Record .- Return ? base.DeleteBinding(ref.[[ReferencedName]]).
When a delete operator occurs within delete operator occurs within
The object that may be created in step
13.5.2 The void Operator
13.5.2.1 Runtime Semantics: Evaluation
- Let expr be the result of evaluating
UnaryExpression . - Perform ?
GetValue (expr). - Return
undefined .
13.5.3 The typeof Operator
13.5.3.1 Runtime Semantics: Evaluation
- Let val be the result of evaluating
UnaryExpression . - If val is a
Reference Record , then- If
IsUnresolvableReference (val) istrue , return"undefined" .
- If
Set val to ?GetValue (val).- Return a String according to
Table 37 .
|
|
Result |
|---|---|
| Undefined |
|
| Null |
|
| Boolean |
|
| Number |
|
| String |
|
| Symbol |
|
| BigInt |
|
| Object (does not implement [[Call]]) |
|
| Object (implements [[Call]]) |
|
An additional entry related to [[IsHTMLDDA]] Internal Slot can be found in
13.5.4 Unary + Operator
The unary + operator converts its operand to Number
13.5.4.1 Runtime Semantics: Evaluation
- Let expr be the result of evaluating
UnaryExpression . - Return ?
ToNumber (?GetValue (expr)).
13.5.5 Unary - Operator
The unary - operator converts its operand to Number
13.5.5.1 Runtime Semantics: Evaluation
- Let expr be the result of evaluating
UnaryExpression . - Let oldValue be ?
ToNumeric (?GetValue (expr)). - Let T be
Type (oldValue). - Return ! T::unaryMinus(oldValue).
13.5.6 Bitwise NOT Operator ( ~ )
13.5.6.1 Runtime Semantics: Evaluation
- Let expr be the result of evaluating
UnaryExpression . - Let oldValue be ?
ToNumeric (?GetValue (expr)). - Let T be
Type (oldValue). - Return ! T::bitwiseNOT(oldValue).
13.5.7 Logical NOT Operator ( ! )
13.5.7.1 Runtime Semantics: Evaluation
- Let expr be the result of evaluating
UnaryExpression . - Let oldValue be !
ToBoolean (?GetValue (expr)). - If oldValue is
true , returnfalse . - Return
true .
13.6 Exponentiation Operator
Syntax
13.6.1 Runtime Semantics: Evaluation
13.7 Multiplicative Operators
Syntax
- The
*operator performs multiplication, producing the product of its operands. - The
/operator performs division, producing the quotient of its operands. - The
%operator yields the remainder of its operands from an implied division.
13.7.1 Runtime Semantics: Evaluation
13.8 Additive Operators
Syntax
13.8.1 The Addition Operator ( + )
The addition operator either performs string concatenation or numeric addition.
13.8.1.1 Runtime Semantics: Evaluation
13.8.2 The Subtraction Operator ( - )
The - operator performs subtraction, producing the difference of its operands.
13.8.2.1 Runtime Semantics: Evaluation
13.9 Bitwise Shift Operators
Syntax
13.9.1 The Left Shift Operator ( << )
Performs a bitwise left shift operation on the left operand by the amount specified by the right operand.
13.9.1.1 Runtime Semantics: Evaluation
13.9.2 The Signed Right Shift Operator ( >> )
Performs a sign-filling bitwise right shift operation on the left operand by the amount specified by the right operand.
13.9.2.1 Runtime Semantics: Evaluation
13.9.3 The Unsigned Right Shift Operator ( >>> )
Performs a zero-filling bitwise right shift operation on the left operand by the amount specified by the right operand.
13.9.3.1 Runtime Semantics: Evaluation
13.10 Relational Operators
The result of evaluating a relational operator is always of
Syntax
The [In] grammar parameter is needed to avoid confusing the in operator in a relational expression with the in operator in a for statement.
13.10.1 Runtime Semantics: Evaluation
- Let lref be the result of evaluating
RelationalExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
ShiftExpression . - Let rval be ?
GetValue (rref). - Let r be the result of performing
Abstract Relational Comparison lval < rval. ReturnIfAbrupt (r).- If r is
undefined , returnfalse . Otherwise, return r.
- Let lref be the result of evaluating
RelationalExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
ShiftExpression . - Let rval be ?
GetValue (rref). - Let r be the result of performing
Abstract Relational Comparison rval < lval with LeftFirst equal tofalse . ReturnIfAbrupt (r).- If r is
undefined , returnfalse . Otherwise, return r.
- Let lref be the result of evaluating
RelationalExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
ShiftExpression . - Let rval be ?
GetValue (rref). - Let r be the result of performing
Abstract Relational Comparison rval < lval with LeftFirst equal tofalse . ReturnIfAbrupt (r).- If r is
true orundefined , returnfalse . Otherwise, returntrue .
- Let lref be the result of evaluating
RelationalExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
ShiftExpression . - Let rval be ?
GetValue (rref). - Let r be the result of performing
Abstract Relational Comparison lval < rval. ReturnIfAbrupt (r).- If r is
true orundefined , returnfalse . Otherwise, returntrue .
- Let lref be the result of evaluating
RelationalExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
ShiftExpression . - Let rval be ?
GetValue (rref). - Return ?
InstanceofOperator (lval, rval).
- Let lref be the result of evaluating
RelationalExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
ShiftExpression . - Let rval be ?
GetValue (rref). - If
Type (rval) is not Object, throw aTypeError exception. - Return ?
HasProperty (rval, ?ToPropertyKey (lval)).
13.10.2 InstanceofOperator ( V, target )
The abstract operation InstanceofOperator takes arguments V (an
- If
Type (target) is not Object, throw aTypeError exception. - Let instOfHandler be ?
GetMethod (target, @@hasInstance). - If instOfHandler is not
undefined , then - If
IsCallable (target) isfalse , throw aTypeError exception. - Return ?
OrdinaryHasInstance (target, V).
13.11 Equality Operators
The result of evaluating an equality operator is always of
Syntax
13.11.1 Runtime Semantics: Evaluation
- Let lref be the result of evaluating
EqualityExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
RelationalExpression . - Let rval be ?
GetValue (rref). - Return the result of performing
Abstract Equality Comparison rval == lval.
- Let lref be the result of evaluating
EqualityExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
RelationalExpression . - Let rval be ?
GetValue (rref). - Let r be the result of performing
Abstract Equality Comparison rval == lval. ReturnIfAbrupt (r).- If r is
true , returnfalse . Otherwise, returntrue .
- Let lref be the result of evaluating
EqualityExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
RelationalExpression . - Let rval be ?
GetValue (rref). - Return the result of performing
Strict Equality Comparison rval === lval.
- Let lref be the result of evaluating
EqualityExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
RelationalExpression . - Let rval be ?
GetValue (rref). - Let r be the result of performing
Strict Equality Comparison rval === lval. Assert : r is a normal completion.- If r.[[Value]] is
true , returnfalse . Otherwise, returntrue .
Given the above definition of equality:
-
String comparison can be forced by:
\${a}\== \${b}\``. -
Numeric comparison can be forced by:
+a == +b. -
Boolean comparison can be forced by:
!a == !b.
The equality operators maintain the following invariants:
-
A != Bis equivalent to!(A == B). -
A == Bis equivalent toB == A, except in the order of evaluation ofAandB.
The equality operator is not always transitive. For example, there might be two distinct String objects, each representing the same String value; each String object would be considered equal to the String value by the == operator, but the two String objects would not be equal to each other. For example:
-
new String("a") == "a"and"a" == new String("a")are bothtrue . -
new String("a") == new String("a")isfalse .
Comparison of Strings uses a simple equality test on sequences of code unit values. There is no attempt to use the more complex, semantically oriented definitions of character or string equality and collating order defined in the Unicode specification. Therefore Strings values that are canonically equal according to the Unicode standard could test as unequal. In effect this algorithm assumes that both Strings are already in normalized form.
13.12 Binary Bitwise Operators
Syntax
13.12.1 Runtime Semantics: Evaluation
13.13 Binary Logical Operators
Syntax
The value produced by a && or || operator is not necessarily of
13.13.1 Runtime Semantics: Evaluation
- Let lref be the result of evaluating
LogicalANDExpression . - Let lval be ?
GetValue (lref). - Let lbool be !
ToBoolean (lval). - If lbool is
false , return lval. - Let rref be the result of evaluating
BitwiseORExpression . - Return ?
GetValue (rref).
- Let lref be the result of evaluating
LogicalORExpression . - Let lval be ?
GetValue (lref). - Let lbool be !
ToBoolean (lval). - If lbool is
true , return lval. - Let rref be the result of evaluating
LogicalANDExpression . - Return ?
GetValue (rref).
- Let lref be the result of evaluating
CoalesceExpressionHead . - Let lval be ?
GetValue (lref). - If lval is
undefined ornull , then- Let rref be the result of evaluating
BitwiseORExpression . - Return ?
GetValue (rref).
- Let rref be the result of evaluating
- Otherwise, return lval.
13.14 Conditional Operator ( ? : )
Syntax
The grammar for a
13.14.1 Runtime Semantics: Evaluation
- Let lref be the result of evaluating
ShortCircuitExpression . - Let lval be !
ToBoolean (?GetValue (lref)). - If lval is
true , then- Let trueRef be the result of evaluating the first
AssignmentExpression . - Return ?
GetValue (trueRef).
- Let trueRef be the result of evaluating the first
- Else,
- Let falseRef be the result of evaluating the second
AssignmentExpression . - Return ?
GetValue (falseRef).
- Let falseRef be the result of evaluating the second
13.15 Assignment Operators
Syntax
13.15.1 Static Semantics: Early Errors
If
-
It is a Syntax Error if
LeftHandSideExpression is notcovering anAssignmentPattern . -
All Early Error rules for
AssignmentPattern and its derived productions also apply to theAssignmentPattern that iscovered byLeftHandSideExpression .
If
-
It is a Syntax Error if
AssignmentTargetType ofLeftHandSideExpression is notsimple .
-
It is a Syntax Error if
AssignmentTargetType ofLeftHandSideExpression is notsimple .
13.15.2 Runtime Semantics: Evaluation
- If
LeftHandSideExpression is neither anObjectLiteral nor anArrayLiteral , then- Let lref be the result of evaluating
LeftHandSideExpression . ReturnIfAbrupt (lref).- If
IsAnonymousFunctionDefinition (AssignmentExpression ) andIsIdentifierRef ofLeftHandSideExpression are bothtrue , then- Let rval be
NamedEvaluation ofAssignmentExpression with argument lref.[[ReferencedName]].
- Let rval be
- Else,
- Let rref be the result of evaluating
AssignmentExpression . - Let rval be ?
GetValue (rref).
- Let rref be the result of evaluating
- Perform ?
PutValue (lref, rval). - Return rval.
- Let lref be the result of evaluating
- Let assignmentPattern be the
AssignmentPattern that iscovered byLeftHandSideExpression . - Let rref be the result of evaluating
AssignmentExpression . - Let rval be ?
GetValue (rref). - Perform ?
DestructuringAssignmentEvaluation of assignmentPattern using rval as the argument. - Return rval.
- Let lref be the result of evaluating
LeftHandSideExpression . - Let lval be ?
GetValue (lref). - Let rref be the result of evaluating
AssignmentExpression . - Let rval be ?
GetValue (rref). - Let assignmentOpText be the
source text matched by AssignmentOperator . - Let opText be the sequence of Unicode code points associated with assignmentOpText in the following table:
assignmentOpText opText **=***=*/=/%=%+=+-=-<<=<<>>=>>>>>=>>>&=&^=^|=| - Let r be
ApplyStringOrNumericBinaryOperator (lval, opText, rval). - Perform ?
PutValue (lref, r). - Return r.
- Let lref be the result of evaluating
LeftHandSideExpression . - Let lval be ?
GetValue (lref). - Let lbool be !
ToBoolean (lval). - If lbool is
false , return lval. - If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue andIsIdentifierRef ofLeftHandSideExpression istrue , then- Let rval be
NamedEvaluation ofAssignmentExpression with argument lref.[[ReferencedName]].
- Let rval be
- Else,
- Let rref be the result of evaluating
AssignmentExpression . - Let rval be ?
GetValue (rref).
- Let rref be the result of evaluating
- Perform ?
PutValue (lref, rval). - Return rval.
- Let lref be the result of evaluating
LeftHandSideExpression . - Let lval be ?
GetValue (lref). - Let lbool be !
ToBoolean (lval). - If lbool is
true , return lval. - If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue andIsIdentifierRef ofLeftHandSideExpression istrue , then- Let rval be
NamedEvaluation ofAssignmentExpression with argument lref.[[ReferencedName]].
- Let rval be
- Else,
- Let rref be the result of evaluating
AssignmentExpression . - Let rval be ?
GetValue (rref).
- Let rref be the result of evaluating
- Perform ?
PutValue (lref, rval). - Return rval.
- Let lref be the result of evaluating
LeftHandSideExpression . - Let lval be ?
GetValue (lref). - If lval is neither
undefined nornull , return lval. - If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue andIsIdentifierRef ofLeftHandSideExpression istrue , then- Let rval be
NamedEvaluation ofAssignmentExpression with argument lref.[[ReferencedName]].
- Let rval be
- Else,
- Let rref be the result of evaluating
AssignmentExpression . - Let rval be ?
GetValue (rref).
- Let rref be the result of evaluating
- Perform ?
PutValue (lref, rval). - Return rval.
When this expression occurs within
13.15.3 ApplyStringOrNumericBinaryOperator ( lval, opText, rval )
The abstract operation ApplyStringOrNumericBinaryOperator takes arguments lval (an
Assert : opText is present in the table in step8 .- If opText is
+, then- Let lprim be ?
ToPrimitive (lval). - Let rprim be ?
ToPrimitive (rval). - If
Type (lprim) is String orType (rprim) is String, then- Let lstr be ?
ToString (lprim). - Let rstr be ?
ToString (rprim). - Return the
string-concatenation of lstr and rstr.
- Let lstr be ?
Set lval to lprim.Set rval to rprim.
- Let lprim be ?
- NOTE: At this point, it must be a numeric operation.
- Let lnum be ?
ToNumeric (lval). - Let rnum be ?
ToNumeric (rval). - If
Type (lnum) is different fromType (rnum), throw aTypeError exception. - Let T be
Type (lnum). - Let operation be the abstract operation associated with opText in the following table:
opText operation **T::exponentiate *T::multiply /T::divide %T::remainder +T::add -T::subtract <<T::leftShift >>T::signedRightShift >>>T::unsignedRightShift &T::bitwiseAND ^T::bitwiseXOR |T::bitwiseOR - Return ? operation(lnum, rnum).
No hint is provided in the calls to
Step
13.15.4 EvaluateStringOrNumericBinaryExpression ( leftOperand, opText, rightOperand )
The abstract operation EvaluateStringOrNumericBinaryExpression takes arguments leftOperand (a
- Let lref be the result of evaluating leftOperand.
- Let lval be ?
GetValue (lref). - Let rref be the result of evaluating rightOperand.
- Let rval be ?
GetValue (rref). - Return ?
ApplyStringOrNumericBinaryOperator (lval, opText, rval).
13.15.5 Destructuring Assignment
Supplemental Syntax
In certain circumstances when processing an instance of the production
the interpretation of
13.15.5.1 Static Semantics: Early Errors
-
It is a Syntax Error if
AssignmentTargetType ofIdentifierReference is notsimple .
-
It is a Syntax Error if
DestructuringAssignmentTarget is anArrayLiteral or anObjectLiteral .
If
-
It is a Syntax Error if
LeftHandSideExpression is notcovering anAssignmentPattern . -
All Early Error rules for
AssignmentPattern and its derived productions also apply to theAssignmentPattern that iscovered byLeftHandSideExpression .
If
-
It is a Syntax Error if
AssignmentTargetType ofLeftHandSideExpression is notsimple .
13.15.5.2 Runtime Semantics: DestructuringAssignmentEvaluation
With parameter value.
- Perform ?
RequireObjectCoercible (value). - Return
NormalCompletion (empty ).
- Perform ?
RequireObjectCoercible (value). - Perform ?
PropertyDestructuringAssignmentEvaluation forAssignmentPropertyList using value as the argument. - Return
NormalCompletion (empty ).
- Let iteratorRecord be ?
GetIterator (value). - Return ?
IteratorClose (iteratorRecord,NormalCompletion (empty )).
- Let iteratorRecord be ?
GetIterator (value). - Let result be
IteratorDestructuringAssignmentEvaluation ofElision with argument iteratorRecord. - If iteratorRecord.[[Done]] is
false , return ?IteratorClose (iteratorRecord, result). - Return result.
- Let iteratorRecord be ?
GetIterator (value). - If
Elision is present, then- Let status be
IteratorDestructuringAssignmentEvaluation ofElision with argument iteratorRecord. - If status is an
abrupt completion , thenAssert : iteratorRecord.[[Done]] istrue .- Return
Completion (status).
- Let status be
- Let result be
IteratorDestructuringAssignmentEvaluation ofAssignmentRestElement with argument iteratorRecord. - If iteratorRecord.[[Done]] is
false , return ?IteratorClose (iteratorRecord, result). - Return result.
- Let iteratorRecord be ?
GetIterator (value). - Let result be
IteratorDestructuringAssignmentEvaluation ofAssignmentElementList with argument iteratorRecord. - If iteratorRecord.[[Done]] is
false , return ?IteratorClose (iteratorRecord, result). - Return result.
- Let iteratorRecord be ?
GetIterator (value). - Let status be
IteratorDestructuringAssignmentEvaluation ofAssignmentElementList with argument iteratorRecord. - If status is an
abrupt completion , then- If iteratorRecord.[[Done]] is
false , return ?IteratorClose (iteratorRecord, status). - Return
Completion (status).
- If iteratorRecord.[[Done]] is
- If
Elision is present, thenSet status to the result of performingIteratorDestructuringAssignmentEvaluation ofElision with iteratorRecord as the argument.- If status is an
abrupt completion , thenAssert : iteratorRecord.[[Done]] istrue .- Return
Completion (status).
- If
AssignmentRestElement is present, thenSet status to the result of performingIteratorDestructuringAssignmentEvaluation ofAssignmentRestElement with iteratorRecord as the argument.
- If iteratorRecord.[[Done]] is
false , return ?IteratorClose (iteratorRecord, status). - Return
Completion (status).
- Perform ?
RequireObjectCoercible (value). - Let excludedNames be a new empty
List . - Return the result of performing
RestDestructuringAssignmentEvaluation ofAssignmentRestProperty with value and excludedNames as the arguments.
- Perform ?
RequireObjectCoercible (value). - Let excludedNames be ?
PropertyDestructuringAssignmentEvaluation ofAssignmentPropertyList with argument value. - Return the result of performing
RestDestructuringAssignmentEvaluation ofAssignmentRestProperty with arguments value and excludedNames.
13.15.5.3 Runtime Semantics: PropertyDestructuringAssignmentEvaluation
With parameter value.
- Let propertyNames be ? PropertyDestructuringAssignmentEvaluation of
AssignmentPropertyList with argument value. - Let nextNames be ? PropertyDestructuringAssignmentEvaluation of
AssignmentProperty with argument value. - Append each item in nextNames to the end of propertyNames.
- Return propertyNames.
- Let P be
StringValue ofIdentifierReference . - Let lref be ?
ResolveBinding (P). - Let v be ?
GetV (value, P). - If
Initializer_opt is present and v isundefined , then- If
IsAnonymousFunctionDefinition (Initializer ) istrue , thenSet v to the result of performingNamedEvaluation forInitializer with argument P.
- Else,
- Let defaultValue be the result of evaluating
Initializer . Set v to ?GetValue (defaultValue).
- Let defaultValue be the result of evaluating
- If
- Perform ?
PutValue (lref, v). - Return a
List whose sole element is P.
- Let name be the result of evaluating
PropertyName . ReturnIfAbrupt (name).- Perform ?
KeyedDestructuringAssignmentEvaluation ofAssignmentElement with value and name as the arguments. - Return a
List whose sole element is name.
13.15.5.4 Runtime Semantics: RestDestructuringAssignmentEvaluation
With parameters value and excludedNames.
- Let lref be the result of evaluating
DestructuringAssignmentTarget . ReturnIfAbrupt (lref).- Let restObj be !
OrdinaryObjectCreate (%Object.prototype% ). - Perform ?
CopyDataProperties (restObj, value, excludedNames). - Return
PutValue (lref, restObj).
13.15.5.5 Runtime Semantics: IteratorDestructuringAssignmentEvaluation
With parameter iteratorRecord.
- Return the result of performing IteratorDestructuringAssignmentEvaluation of
AssignmentElisionElement using iteratorRecord as the argument.
- Perform ? IteratorDestructuringAssignmentEvaluation of
AssignmentElementList using iteratorRecord as the argument. - Return the result of performing IteratorDestructuringAssignmentEvaluation of
AssignmentElisionElement using iteratorRecord as the argument.
- Return the result of performing IteratorDestructuringAssignmentEvaluation of
AssignmentElement with iteratorRecord as the argument.
- Perform ? IteratorDestructuringAssignmentEvaluation of
Elision with iteratorRecord as the argument. - Return the result of performing IteratorDestructuringAssignmentEvaluation of
AssignmentElement with iteratorRecord as the argument.
- 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
- Return
NormalCompletion (empty ).
- Perform ? IteratorDestructuringAssignmentEvaluation of
Elision with iteratorRecord as the argument. - 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
- Return
NormalCompletion (empty ).
- If
DestructuringAssignmentTarget is neither anObjectLiteral nor anArrayLiteral , then- Let lref be the result of evaluating
DestructuringAssignmentTarget . ReturnIfAbrupt (lref).
- Let lref be the result of evaluating
- 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 value be
IteratorValue (next). - If value is an
abrupt completion , set iteratorRecord.[[Done]] totrue . ReturnIfAbrupt (value).
- Let value be
- Let next be
- If iteratorRecord.[[Done]] is
true , let value beundefined . - If
Initializer is present and value isundefined , then- If
IsAnonymousFunctionDefinition (Initializer ) istrue andIsIdentifierRef ofDestructuringAssignmentTarget istrue , then- Let v be ?
NamedEvaluation ofInitializer with argument lref.[[ReferencedName]].
- Let v be ?
- Else,
- Let defaultValue be the result of evaluating
Initializer . - Let v be ?
GetValue (defaultValue).
- Let defaultValue be the result of evaluating
- If
- Else, let v be value.
- If
DestructuringAssignmentTarget is anObjectLiteral or anArrayLiteral , then- Let nestedAssignmentPattern be the
AssignmentPattern that iscovered byDestructuringAssignmentTarget . - Return the result of performing
DestructuringAssignmentEvaluation of nestedAssignmentPattern with v as the argument.
- Let nestedAssignmentPattern be the
- Return ?
PutValue (lref, v).
Left to right evaluation order is maintained by evaluating a
- If
DestructuringAssignmentTarget is neither anObjectLiteral nor anArrayLiteral , then- Let lref be the result of evaluating
DestructuringAssignmentTarget . ReturnIfAbrupt (lref).
- Let lref be the result of evaluating
- Let A be !
ArrayCreate (0). - Let n be 0.
- Repeat, while iteratorRecord.[[Done]] is
false ,- 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 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.
- Let nextValue be
- Let next be
- If
DestructuringAssignmentTarget is neither anObjectLiteral nor anArrayLiteral , then- Return ?
PutValue (lref, A).
- Return ?
- Let nestedAssignmentPattern be the
AssignmentPattern that iscovered byDestructuringAssignmentTarget . - Return the result of performing
DestructuringAssignmentEvaluation of nestedAssignmentPattern with A as the argument.
13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation
With parameters value and propertyName.
- If
DestructuringAssignmentTarget is neither anObjectLiteral nor anArrayLiteral , then- Let lref be the result of evaluating
DestructuringAssignmentTarget . ReturnIfAbrupt (lref).
- Let lref be the result of evaluating
- Let v be ?
GetV (value, propertyName). - If
Initializer is present and v isundefined , then- If
IsAnonymousFunctionDefinition (Initializer ) andIsIdentifierRef ofDestructuringAssignmentTarget are bothtrue , then- Let rhsValue be ?
NamedEvaluation ofInitializer with argument lref.[[ReferencedName]].
- Let rhsValue be ?
- Else,
- Let defaultValue be the result of evaluating
Initializer . - Let rhsValue be ?
GetValue (defaultValue).
- Let defaultValue be the result of evaluating
- If
- Else, let rhsValue be v.
- If
DestructuringAssignmentTarget is anObjectLiteral or anArrayLiteral , then- Let assignmentPattern be the
AssignmentPattern that iscovered byDestructuringAssignmentTarget . - Return the result of performing
DestructuringAssignmentEvaluation of assignmentPattern with rhsValue as the argument.
- Let assignmentPattern be the
- Return ?
PutValue (lref, rhsValue).
13.16 Comma Operator ( , )
Syntax
13.16.1 Runtime Semantics: Evaluation
- Let lref be the result of evaluating
Expression . - Perform ?
GetValue (lref). - Let rref be the result of evaluating
AssignmentExpression . - Return ?
GetValue (rref).