13.2 Primary Expression
Syntax
Supplemental Syntax
When processing an instance of the production
the interpretation of
13.2.1 The this
Keyword
13.2.1.1 Runtime Semantics: Evaluation
- Return ?
ResolveThisBinding ().
13.2.2 Identifier Reference
See
13.2.3 Literals
Syntax
13.2.3.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.9.3 .
- Return the
SV ofStringLiteral as defined in12.9.4.2 .
13.2.4 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.4.1 Runtime Semantics: ArrayAccumulation
The
- Return ?
ArrayAccumulation ofElision with arguments array and (nextIndex + 1).
- If
Elision is present, then- Set nextIndex to ?
ArrayAccumulation ofElision with arguments array and nextIndex.
- Set nextIndex to ?
- Let initResult be ?
Evaluation ofAssignmentExpression . - Let initValue be ?
GetValue (initResult). - Perform !
CreateDataPropertyOrThrow (array, !ToString (𝔽 (nextIndex)), initValue). - Return nextIndex + 1.
- If
Elision is present, then- Set nextIndex to ?
ArrayAccumulation ofElision with arguments array and nextIndex.
- Set nextIndex to ?
- Return ?
ArrayAccumulation ofSpreadElement with arguments array and nextIndex.
- Set nextIndex to ?
ArrayAccumulation ofElementList with arguments array and nextIndex. - If
Elision is present, then- Set nextIndex to ?
ArrayAccumulation ofElision with arguments array and nextIndex.
- Set nextIndex to ?
- Let initResult be ?
Evaluation ofAssignmentExpression . - Let initValue be ?
GetValue (initResult). - Perform !
CreateDataPropertyOrThrow (array, !ToString (𝔽 (nextIndex)), initValue). - Return nextIndex + 1.
- Set nextIndex to ?
ArrayAccumulation ofElementList with arguments array and nextIndex. - If
Elision is present, then- Set nextIndex to ?
ArrayAccumulation ofElision with arguments array and nextIndex.
- Set nextIndex to ?
- Return ?
ArrayAccumulation ofSpreadElement with arguments array and nextIndex.
- Let spreadRef be ?
Evaluation ofAssignmentExpression . - Let spreadObj be ?
GetValue (spreadRef). - Let iteratorRecord be ?
GetIterator (spreadObj,sync ). - Repeat,
- Let next be ?
IteratorStepValue (iteratorRecord). - If next is
done , return nextIndex. - Perform !
CreateDataPropertyOrThrow (array, !ToString (𝔽 (nextIndex)), next). - Set nextIndex to nextIndex + 1.
- Let next be ?
13.2.4.2 Runtime Semantics: Evaluation
- Let array be !
ArrayCreate (0). - If
Elision is present, then- Perform ?
ArrayAccumulation ofElision with arguments array and 0.
- Perform ?
- Return array.
- Let array be !
ArrayCreate (0). - Perform ?
ArrayAccumulation ofElementList with arguments array and 0. - Return array.
- Let array be !
ArrayCreate (0). - Let nextIndex be ?
ArrayAccumulation ofElementList with arguments array and 0. - If
Elision is present, then- Perform ?
ArrayAccumulation ofElision with arguments array and nextIndex.
- Perform ?
- Return array.
13.2.5 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
Syntax
In certain contexts,
13.2.5.1 Static Semantics: Early Errors
-
It is a Syntax Error if
HasDirectSuper ofMethodDefinition istrue . -
It is a Syntax Error if
PrivateBoundIdentifiers ofMethodDefinition is not empty.
In addition to describing an actual object initializer the
- It is a Syntax Error if any source text is matched by this production.
This production exists so that
-
It is a Syntax Error if
PropertyNameList ofPropertyDefinitionList contains any duplicate entries for"__proto__" and at least two of those entries were obtained from productions of the form . This rule is not applied if thisPropertyDefinition : PropertyName : AssignmentExpression ObjectLiteral is contained within aScript that is being parsed for JSON.parse (see step4 ofJSON.parse ).
The
13.2.5.2 Static Semantics: IsComputedPropertyKey
The
- Return
false .
- Return
true .
13.2.5.3 Static Semantics: PropertyNameList
The
- Let propName be
PropName ofPropertyDefinition . - If propName is
empty , return a new emptyList . - Return « propName ».
- Let list be
PropertyNameList ofPropertyDefinitionList . - Let propName be
PropName ofPropertyDefinition . - If propName is
empty , return list. - Return the
list-concatenation of list and « propName ».
13.2.5.4 Runtime Semantics: Evaluation
- Return
OrdinaryObjectCreate (%Object.prototype% ).
- Let obj be
OrdinaryObjectCreate (%Object.prototype% ). - Perform ?
PropertyDefinitionEvaluation ofPropertyDefinitionList with argument obj. - Return obj.
- Return
StringValue ofIdentifierName .
- Return the
SV ofStringLiteral .
- Let nbr be the
NumericValue ofNumericLiteral . - Return !
ToString (nbr).
- Let exprValue be ?
Evaluation ofAssignmentExpression . - Let propName be ?
GetValue (exprValue). - Return ?
ToPropertyKey (propName).
13.2.5.5 Runtime Semantics: PropertyDefinitionEvaluation
The
- Perform ?
PropertyDefinitionEvaluation ofPropertyDefinitionList with argument object. - Perform ?
PropertyDefinitionEvaluation ofPropertyDefinition with argument object. - Return
unused .
- Let exprValue be ?
Evaluation ofAssignmentExpression . - Let fromValue be ?
GetValue (exprValue). - Let excludedNames be a new empty
List . - Perform ?
CopyDataProperties (object, fromValue, excludedNames). - Return
unused .
- Let propName be
StringValue ofIdentifierReference . - Let exprValue be ?
Evaluation ofIdentifierReference . - Let propValue be ?
GetValue (exprValue). Assert : object is an ordinary, extensible object with no non-configurable properties.- Perform !
CreateDataPropertyOrThrow (object, propName, propValue). - Return
unused .
- Let propKey be ?
Evaluation ofPropertyName . - If this
PropertyDefinition is contained within aScript that is being evaluated for JSON.parse (see step7 ofJSON.parse ), then- Let isProtoSetter be
false .
- Let isProtoSetter be
- Else if propKey is
"__proto__" andIsComputedPropertyKey ofPropertyName isfalse , then- Let isProtoSetter be
true .
- Let isProtoSetter be
- Else,
- Let isProtoSetter be
false .
- Let isProtoSetter be
- If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue and isProtoSetter isfalse , then- Let propValue be ?
NamedEvaluation ofAssignmentExpression with argument propKey.
- Let propValue be ?
- Else,
- Let exprValueRef be ?
Evaluation ofAssignmentExpression . - Let propValue be ?
GetValue (exprValueRef).
- Let exprValueRef be ?
- If isProtoSetter is
true , then- If propValue
is an Object or propValue isnull , then- Perform ! object.[[SetPrototypeOf]](propValue).
- Return
unused .
- If propValue
Assert : object is an ordinary, extensible object with no non-configurable properties.- Perform !
CreateDataPropertyOrThrow (object, propKey, propValue). - Return
unused .
- Perform ?
MethodDefinitionEvaluation ofMethodDefinition with arguments object andtrue . - Return
unused .
13.2.6 Function Defining Expressions
See
See
See
See
See
13.2.7 Regular Expression Literals
Syntax
See
13.2.7.1 Static Semantics: Early Errors
-
It is a Syntax Error if
IsValidRegularExpressionLiteral (RegularExpressionLiteral ) isfalse .
13.2.7.2 Static Semantics: IsValidRegularExpressionLiteral ( literal )
The abstract operation IsValidRegularExpressionLiteral takes argument literal (a
- Let flags be
FlagText of literal. - If flags contains any code points other than
d
,g
,i
,m
,s
,u
,v
, ory
, or if flags contains any code point more than once, returnfalse . - If flags contains
u
, let u betrue ; else let u befalse . - If flags contains
v
, let v betrue ; else let v befalse . - Let patternText be
BodyText of literal. - If u is
false and v isfalse , 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, v). - If parseResult is a
Parse Node , returntrue ; else returnfalse .
13.2.7.3 Runtime Semantics: Evaluation
- Let pattern be
CodePointsToString (BodyText ofRegularExpressionLiteral ). - Let flags be
CodePointsToString (FlagText ofRegularExpressionLiteral ). - Return !
RegExpCreate (pattern, flags).
13.2.8 Template Literals
Syntax
13.2.8.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 or equal to 232.
-
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.8.2 Static Semantics: TemplateStrings
The
- Return «
TemplateString (NoSubstitutionTemplate , raw) ».
- Let head be «
TemplateString (TemplateHead , raw) ». - Let tail be
TemplateStrings ofTemplateSpans with argument raw. - Return the
list-concatenation of head and tail.
- Return «
TemplateString (TemplateTail , raw) ».
- Let middle be
TemplateStrings ofTemplateMiddleList with argument raw. - Let tail be «
TemplateString (TemplateTail , raw) ». - Return the
list-concatenation of middle and tail.
- Return «
TemplateString (TemplateMiddle , raw) ».
- Let front be
TemplateStrings ofTemplateMiddleList with argument raw. - Let last be «
TemplateString (TemplateMiddle , raw) ». - Return the
list-concatenation of front and last.
13.2.8.3 Static Semantics: TemplateString ( templateToken, raw )
The abstract operation TemplateString takes arguments templateToken (a
This operation returns
13.2.8.4 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 . Assert : rawStrings is aList of Strings.- 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 realm.[[TemplateMap]]. - 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.8.5 Runtime Semantics: SubstitutionEvaluation
The
- Return a new empty
List .
- Return ?
SubstitutionEvaluation ofTemplateMiddleList .
- Let subRef be ?
Evaluation ofExpression . - Let sub be ?
GetValue (subRef). - Return « sub ».
- Let preceding be ?
SubstitutionEvaluation ofTemplateMiddleList . - Let nextRef be ?
Evaluation ofExpression . - Let next be ?
GetValue (nextRef). - Return the
list-concatenation of preceding and « next ».
13.2.8.6 Runtime Semantics: Evaluation
- Return the
TV ofNoSubstitutionTemplate as defined in12.9.6 .
- Let head be the
TV ofTemplateHead as defined in12.9.6 . - Let subRef be ?
Evaluation ofExpression . - Let sub be ?
GetValue (subRef). - Let middle be ?
ToString (sub). - Let tail be ?
Evaluation ofTemplateSpans . - 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 ofTemplateTail as defined in12.9.6 .
- Let head be ?
Evaluation ofTemplateMiddleList . - Let tail be the
TV ofTemplateTail as defined in12.9.6 . - Return the
string-concatenation of head and tail.
- Let head be the
TV ofTemplateMiddle as defined in12.9.6 . - Let subRef be ?
Evaluation ofExpression . - 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 ?
Evaluation ofTemplateMiddleList . - Let middle be the
TV ofTemplateMiddle as defined in12.9.6 . - Let subRef be ?
Evaluation ofExpression . - 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.9 The Grouping Operator
13.2.9.1 Static Semantics: Early Errors
13.2.9.2 Runtime Semantics: Evaluation
- Let expr be the
ParenthesizedExpression that iscovered byCoverParenthesizedExpressionAndArrowParameterList . - Return ?
Evaluation of expr.
- Return ?
Evaluation ofExpression . This may be of type Reference.
This algorithm does not apply delete
and typeof
may be applied to parenthesized expressions.