13 ECMAScript 언어: 표현식

13.1 식별자

구문

IdentifierReference[Yield, Await] : Identifier [~Yield] yield [~Await] await BindingIdentifier[Yield, Await] : Identifier yield await LabelIdentifier[Yield, Await] : Identifier [~Yield] yield [~Await] await Identifier : IdentifierName but not ReservedWord Note

yieldawait는 문법상 BindingIdentifier로 허용되고, 아래의 정적 의미론에서 금지되는데, 이는 다음과 같은 경우에 자동 세미콜론 삽입을 막기 위함이다

let
await 0;

13.1.1 Static Semantics: Early Errors

BindingIdentifier : Identifier IdentifierReference : yield BindingIdentifier : yield LabelIdentifier : yield
  • IsStrict(this production)가 true이면 Syntax Error이다.
IdentifierReference : await BindingIdentifier : await LabelIdentifier : await
  • 구문 문법의 goal symbol이 Module이면 Syntax Error이다.
BindingIdentifier[Yield, Await] : yield
  • 이 production이 [Yield] 매개변수를 가지면 Syntax Error이다.
BindingIdentifier[Yield, Await] : await
  • 이 production이 [Await] 매개변수를 가지면 Syntax Error이다.
IdentifierReference[Yield, Await] : Identifier BindingIdentifier[Yield, Await] : Identifier LabelIdentifier[Yield, Await] : Identifier
  • 이 production이 [Yield] 매개변수를 가지고 IdentifierStringValue"yield"이면 Syntax Error이다.
  • 이 production이 [Await] 매개변수를 가지고 IdentifierStringValue"await"이면 Syntax Error이다.
Identifier : IdentifierName but not ReservedWord Note

IdentifierNameStringValueIdentifierName 안의 모든 유니코드 이스케이프 시퀀스를 정규화하므로, 그런 이스케이프를 사용해서 코드 포인트 시퀀스가 ReservedWord와 같은 Identifier를 작성할 수는 없다.

13.1.2 Static Semantics: StringValue

The syntax-directed operation StringValue takes no arguments and returns a String. It is defined piecewise over the following productions:

IdentifierName :: IdentifierStart IdentifierName IdentifierPart
  1. idTextUnescapedIdentifierNameIdentifierCodePoints라고 하자.
  2. CodePointsToString(idTextUnescaped)를 반환한다.
IdentifierReference : yield BindingIdentifier : yield LabelIdentifier : yield
  1. "yield"를 반환한다.
IdentifierReference : await BindingIdentifier : await LabelIdentifier : await
  1. "await"를 반환한다.
Identifier : IdentifierName but not ReservedWord
  1. IdentifierNameStringValue를 반환한다.
PrivateIdentifier :: # IdentifierName
  1. 0x0023 (NUMBER SIGN)와 IdentifierNameStringValue의 문자열 연결을 반환한다.
ModuleExportName : StringLiteral
  1. StringLiteralSV를 반환한다.

13.1.3 Runtime Semantics: Evaluation

IdentifierReference : Identifier
  1. ResolveBinding(StringValue of Identifier)를 반환한다.
IdentifierReference : yield
  1. ResolveBinding("yield")를 반환한다.
IdentifierReference : await
  1. ResolveBinding("await")를 반환한다.
Note 1

IdentifierReference를 평가한 결과는 언제나 Reference 타입의 값이다.

Note 2

non-strict 코드에서는 키워드 yield를 식별자로 사용할 수 있다. IdentifierReference를 평가하면 마치 그것이 Identifier인 것처럼 yield의 바인딩을 해석한다. Early Error 제한은 이런 평가가 오직 non-strict 코드에서만 일어날 수 있도록 보장한다.

13.2 기본 표현식

구문

PrimaryExpression[Yield, Await] : this IdentifierReference[?Yield, ?Await] Literal ArrayLiteral[?Yield, ?Await] ObjectLiteral[?Yield, ?Await] FunctionExpression ClassExpression[?Yield, ?Await] GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral[?Yield, ?Await, ~Tagged] CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] CoverParenthesizedExpressionAndArrowParameterList[Yield, Await] : ( Expression[+In, ?Yield, ?Await] ) ( Expression[+In, ?Yield, ?Await] , ) ( ) ( ... BindingIdentifier[?Yield, ?Await] ) ( ... BindingPattern[?Yield, ?Await] ) ( Expression[+In, ?Yield, ?Await] , ... BindingIdentifier[?Yield, ?Await] ) ( Expression[+In, ?Yield, ?Await] , ... BindingPattern[?Yield, ?Await] )

보충 구문

production의 인스턴스를 처리할 때
PrimaryExpression[Yield, Await] : CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList의 해석은 다음 문법을 사용하여 정제된다:

ParenthesizedExpression[Yield, Await] : ( Expression[+In, ?Yield, ?Await] )

13.2.1 this 키워드

13.2.1.1 Runtime Semantics: Evaluation

PrimaryExpression : this
  1. ResolveThisBinding()을 반환한다.

13.2.2 식별자 참조

IdentifierReference에 대해서는 13.1를 보라.

13.2.3 리터럴

구문

Literal : NullLiteral BooleanLiteral NumericLiteral StringLiteral

13.2.3.1 Runtime Semantics: Evaluation

Literal : NullLiteral
  1. null을 반환한다.
Literal : BooleanLiteral
  1. BooleanLiteral이 토큰 false이면, false를 반환한다.
  2. BooleanLiteral이 토큰 true이면, true를 반환한다.
Literal : NumericLiteral
  1. 12.9.3에 정의된 NumericLiteralNumericValue를 반환한다.
Literal : StringLiteral
  1. 12.9.4.2에 정의된 StringLiteralSV를 반환한다.

13.2.4 배열 초기자

Note

ArrayLiteral은 대괄호로 둘러싸인, 0개 이상의 표현식 목록을 사용하여 Array의 초기화를 기술하는 표현식이며, 각 표현식은 배열 요소를 나타낸다. 요소는 리터럴일 필요가 없으며; 배열 초기자가 평가될 때마다 각각 평가된다.

배열 요소는 요소 목록의 처음, 중간, 또는 끝에서 생략될 수 있다. 요소 목록에서 콤마 앞에 AssignmentExpression이 없을 때마다(즉, 처음의 콤마이거나 다른 콤마 뒤의 콤마인 경우), 빠진 배열 요소는 Array의 길이에 기여하고 이후 요소들의 인덱스를 증가시킨다. 생략된 배열 요소는 정의되지 않는다. 배열 끝에서 요소가 생략되면, 그 요소는 Array의 길이에 기여하지 않는다.

구문

ArrayLiteral[Yield, Await] : [ Elisionopt ] [ ElementList[?Yield, ?Await] ] [ ElementList[?Yield, ?Await] , Elisionopt ] ElementList[Yield, Await] : Elisionopt AssignmentExpression[+In, ?Yield, ?Await] Elisionopt SpreadElement[?Yield, ?Await] ElementList[?Yield, ?Await] , Elisionopt AssignmentExpression[+In, ?Yield, ?Await] ElementList[?Yield, ?Await] , Elisionopt SpreadElement[?Yield, ?Await] Elision : , Elision , SpreadElement[Yield, Await] : ... AssignmentExpression[+In, ?Yield, ?Await]

13.2.4.1 Runtime Semantics: ArrayAccumulation

The syntax-directed operation ArrayAccumulation takes arguments array (an Array) and nextIndex (an integer) and returns either a normal completion containing an integer or an abrupt completion. It is defined piecewise over the following productions:

Elision : ,
  1. lennextIndex + 1이라고 하자.
  2. Set(array, "length", 𝔽(len), true)를 수행한다.
  3. NOTE: 위 단계는 len이 232 - 1을 초과하면 예외를 던진다.
  4. len을 반환한다.
Elision : Elision ,
  1. 인수 array와 (nextIndex + 1)을 사용한 ElisionArrayAccumulation을 ? 반환한다.
ElementList : Elisionopt AssignmentExpression
  1. Elision이 존재하면,
    1. nextIndex를 인수 arraynextIndex를 사용한 ElisionArrayAccumulation 결과 ?로 설정한다.
  2. initResultAssignmentExpressionEvaluation 결과 ?라고 하자.
  3. initValue를 ? GetValue(initResult)라고 하자.
  4. CreateDataPropertyOrThrow(array, ! ToString(𝔽(nextIndex)), initValue)를 수행한다.
  5. nextIndex + 1을 반환한다.
ElementList : Elisionopt SpreadElement
  1. Elision이 존재하면,
    1. nextIndex를 인수 arraynextIndex를 사용한 ElisionArrayAccumulation 결과 ?로 설정한다.
  2. 인수 arraynextIndex를 사용한 SpreadElementArrayAccumulation을 ? 반환한다.
ElementList : ElementList , Elisionopt AssignmentExpression
  1. nextIndex를 인수 arraynextIndex를 사용한 도출된 ElementListArrayAccumulation 결과 ?로 설정한다.
  2. Elision이 존재하면,
    1. nextIndex를 인수 arraynextIndex를 사용한 ElisionArrayAccumulation 결과 ?로 설정한다.
  3. initResultAssignmentExpressionEvaluation 결과 ?라고 하자.
  4. initValue를 ? GetValue(initResult)라고 하자.
  5. CreateDataPropertyOrThrow(array, ! ToString(𝔽(nextIndex)), initValue)를 수행한다.
  6. nextIndex + 1을 반환한다.
ElementList : ElementList , Elisionopt SpreadElement
  1. nextIndex를 인수 arraynextIndex를 사용한 도출된 ElementListArrayAccumulation 결과 ?로 설정한다.
  2. Elision이 존재하면,
    1. nextIndex를 인수 arraynextIndex를 사용한 ElisionArrayAccumulation 결과 ?로 설정한다.
  3. 인수 arraynextIndex를 사용한 SpreadElementArrayAccumulation을 ? 반환한다.
SpreadElement : ... AssignmentExpression
  1. spreadRefAssignmentExpressionEvaluation 결과 ?라고 하자.
  2. spreadObj를 ? GetValue(spreadRef)라고 하자.
  3. iteratorRecord를 ? GetIterator(spreadObj, sync)라고 하자.
  4. 반복한다,
    1. next를 ? IteratorStepValue(iteratorRecord)라고 하자.
    2. nextdone이면, nextIndex를 반환한다.
    3. CreateDataPropertyOrThrow(array, ! ToString(𝔽(nextIndex)), next)를 수행한다.
    4. nextIndexnextIndex + 1로 설정한다.
Note

CreateDataPropertyOrThrow는 표준 내장 Array 프로토타입 객체[[Set]]을 사용한 새로운 자체 프로퍼티 생성이 불가능하도록 수정된 경우에도 배열에 자체 프로퍼티가 정의되도록 보장하기 위해 사용된다.

13.2.4.2 Runtime Semantics: Evaluation

ArrayLiteral : [ Elisionopt ]
  1. array를 ! ArrayCreate(0)라고 하자.
  2. Elision이 존재하면,
    1. 인수 array와 0을 사용한 ElisionArrayAccumulation을 ? 수행한다.
  3. array를 반환한다.
ArrayLiteral : [ ElementList ]
  1. array를 ! ArrayCreate(0)라고 하자.
  2. 인수 array와 0을 사용한 ElementListArrayAccumulation을 ? 수행한다.
  3. array를 반환한다.
ArrayLiteral : [ ElementList , Elisionopt ]
  1. array를 ! ArrayCreate(0)라고 하자.
  2. nextIndex를 인수 array와 0을 사용한 ElementListArrayAccumulation 결과 ?라고 하자.
  3. Elision이 존재하면,
    1. 인수 arraynextIndex를 사용한 ElisionArrayAccumulation을 ? 수행한다.
  4. array를 반환한다.

13.2.5 객체 초기자

Note 1

객체 초기자는 리터럴과 유사한 형태로 작성된, Object의 초기화를 기술하는 표현식이다. 이것은 중괄호로 둘러싸인, 0개 이상의 프로퍼티 키와 연관된 값의 쌍 목록이다. 값은 리터럴일 필요가 없으며; 객체 초기자가 평가될 때마다 각각 평가된다.

구문

ObjectLiteral[Yield, Await] : { } { PropertyDefinitionList[?Yield, ?Await] } { PropertyDefinitionList[?Yield, ?Await] , } PropertyDefinitionList[Yield, Await] : PropertyDefinition[?Yield, ?Await] PropertyDefinitionList[?Yield, ?Await] , PropertyDefinition[?Yield, ?Await] PropertyDefinition[Yield, Await] : IdentifierReference[?Yield, ?Await] CoverInitializedName[?Yield, ?Await] PropertyName[?Yield, ?Await] : AssignmentExpression[+In, ?Yield, ?Await] MethodDefinition[?Yield, ?Await] ... AssignmentExpression[+In, ?Yield, ?Await] PropertyName[Yield, Await] : LiteralPropertyName ComputedPropertyName[?Yield, ?Await] LiteralPropertyName : IdentifierName StringLiteral NumericLiteral ComputedPropertyName[Yield, Await] : [ AssignmentExpression[+In, ?Yield, ?Await] ] CoverInitializedName[Yield, Await] : IdentifierReference[?Yield, ?Await] Initializer[+In, ?Yield, ?Await] Initializer[In, Yield, Await] : = AssignmentExpression[?In, ?Yield, ?Await] Note 2

MethodDefinition15.4에 정의되어 있다.

Note 3

특정 문맥에서 ObjectLiteral은 더 제한적인 2차 문법을 위한 커버 문법으로 사용된다. CoverInitializedName production은 이 2차 문법들을 완전히 덮기 위해 필요하다. 그러나 이 production을 사용하면 실제 ObjectLiteral이 기대되는 일반 문맥에서는 이른 Syntax Error가 발생한다.

13.2.5.1 Static Semantics: Early Errors

PropertyDefinition : MethodDefinition

실제 객체 초기자를 기술하는 것 외에도 ObjectLiteral production은 ObjectAssignmentPattern을 위한 커버 문법으로도 사용되며 CoverParenthesizedExpressionAndArrowParameterList의 일부로 인식될 수 있다. ObjectLiteralObjectAssignmentPattern이 필요한 문맥에 나타날 때는 다음 Early Error 규칙이 적용되지 않는다. 또한 CoverParenthesizedExpressionAndArrowParameterList 또는 CoverCallExpressionAndAsyncArrowHead를 처음 파싱할 때에도 적용되지 않는다.

PropertyDefinition : CoverInitializedName
  • 이 production에 의해 어떤 소스 텍스트라도 매치되면 Syntax Error이다.
Note 1

이 production은 ObjectLiteralObjectAssignmentPattern의 커버 문법 역할을 할 수 있도록 존재한다. 실제 객체 초기자에서는 나타날 수 없다.

ObjectLiteral : { PropertyDefinitionList } { PropertyDefinitionList , } Note 2

PropertyNameList가 반환하는 ListComputedPropertyName을 사용해 정의된 프로퍼티 이름을 포함하지 않는다.

13.2.5.2 Static Semantics: IsComputedPropertyKey

The syntax-directed operation IsComputedPropertyKey takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

PropertyName : LiteralPropertyName
  1. false를 반환한다.
PropertyName : ComputedPropertyName
  1. true를 반환한다.

13.2.5.3 Static Semantics: PropertyDefinitionNodes

The syntax-directed operation PropertyDefinitionNodes takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

ObjectLiteral : { }
  1. 새로운 빈 List를 반환한다.
PropertyDefinitionList : PropertyDefinition
  1. « PropertyDefinition »를 반환한다.
PropertyDefinitionList : PropertyDefinitionList , PropertyDefinition
  1. head를 도출된 PropertyDefinitionListPropertyDefinitionNodes라고 하자.
  2. head와 « PropertyDefinition »의 list-concatenation을 반환한다.

13.2.5.4 Static Semantics: PropertyNameList

The syntax-directed operation PropertyNameList takes no arguments and returns a List of Strings. It is defined piecewise over the following productions:

PropertyDefinitionList : PropertyDefinition
  1. propNamePropertyDefinitionPropName이라고 하자.
  2. propNameempty이면, 새로운 빈 List를 반환한다.
  3. « propName »를 반환한다.
PropertyDefinitionList : PropertyDefinitionList , PropertyDefinition
  1. listPropertyDefinitionListPropertyNameList라고 하자.
  2. propNamePropertyDefinitionPropName이라고 하자.
  3. propNameempty이면, list를 반환한다.
  4. list와 « propName »의 list-concatenation을 반환한다.

13.2.5.5 Runtime Semantics: Evaluation

ObjectLiteral : { }
  1. OrdinaryObjectCreate(%Object.prototype%)를 반환한다.
ObjectLiteral : { PropertyDefinitionList } { PropertyDefinitionList , }
  1. objOrdinaryObjectCreate(%Object.prototype%)라고 하자.
  2. 인수 obj를 사용한 PropertyDefinitionListPropertyDefinitionEvaluation을 ? 수행한다.
  3. obj를 반환한다.
LiteralPropertyName : IdentifierName
  1. IdentifierNameStringValue를 반환한다.
LiteralPropertyName : StringLiteral
  1. StringLiteralSV를 반환한다.
LiteralPropertyName : NumericLiteral
  1. nbrNumericLiteralNumericValue라고 하자.
  2. ToString(nbr)를 반환한다.
ComputedPropertyName : [ AssignmentExpression ]
  1. exprValueAssignmentExpressionEvaluation 결과 ?라고 하자.
  2. propName을 ? GetValue(exprValue)라고 하자.
  3. ToPropertyKey(propName)를 반환한다.

13.2.5.6 Runtime Semantics: PropertyDefinitionEvaluation

The syntax-directed operation PropertyDefinitionEvaluation takes argument object (an Object) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

PropertyDefinitionList : PropertyDefinitionList , PropertyDefinition
  1. 인수 object를 사용한 PropertyDefinitionListPropertyDefinitionEvaluation을 ? 수행한다.
  2. 인수 object를 사용한 PropertyDefinitionPropertyDefinitionEvaluation을 ? 수행한다.
  3. unused를 반환한다.
PropertyDefinition : ... AssignmentExpression
  1. exprValueAssignmentExpressionEvaluation 결과 ?라고 하자.
  2. fromValue를 ? GetValue(exprValue)라고 하자.
  3. excludedNames를 새로운 빈 List라고 하자.
  4. CopyDataProperties(object, fromValue, excludedNames)를 수행한다.
  5. unused를 반환한다.
PropertyDefinition : IdentifierReference
  1. propNameIdentifierReferenceStringValue라고 하자.
  2. exprValueIdentifierReferenceEvaluation 결과 ?라고 하자.
  3. propValue를 ? GetValue(exprValue)라고 하자.
  4. Assert: object는 non-configurable 프로퍼티가 없는 일반적이고 확장 가능한 객체이다.
  5. CreateDataPropertyOrThrow(object, propName, propValue)를 수행한다.
  6. unused를 반환한다.
PropertyDefinition : PropertyName : AssignmentExpression
  1. propertyKeyPropertyNameEvaluation 결과 ?라고 하자.
  2. PropertyDefinitionParseJSON의 평가를 위해 평가되는 Script 안에 포함된 경우라면(참조: ParseJSON의 단계 6),
    1. isProtoSetterfalse라고 하자.
  3. 그렇지 않고 propertyKey"__proto__"이며 PropertyNameIsComputedPropertyKeyfalse이면,
    1. isProtoSettertrue라고 하자.
  4. 그렇지 않으면,
    1. isProtoSetterfalse라고 하자.
  5. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 isProtoSetterfalse이면,
    1. propValue를 인수 propertyKey를 사용한 AssignmentExpressionNamedEvaluation 결과 ?라고 하자.
  6. 그렇지 않으면,
    1. exprValueRefAssignmentExpressionEvaluation 결과 ?라고 하자.
    2. propValue를 ? GetValue(exprValueRef)라고 하자.
  7. isProtoSettertrue이면,
    1. propValue가 Object이거나 propValuenull이면,
      1. object.[[SetPrototypeOf]](propValue)를 수행한다.
    2. unused를 반환한다.
  8. Assert: object는 non-configurable 프로퍼티가 없는 일반적이고 확장 가능한 객체이다.
  9. CreateDataPropertyOrThrow(object, propertyKey, propValue)를 수행한다.
  10. unused를 반환한다.
PropertyDefinition : MethodDefinition
  1. 인수 objecttrue를 사용한 MethodDefinitionMethodDefinitionEvaluation을 ? 수행한다.
  2. unused를 반환한다.

13.2.6 함수 정의 표현식

PrimaryExpression : FunctionExpression 에 대해서는 15.2를 보라.

PrimaryExpression : GeneratorExpression 에 대해서는 15.5를 보라.

PrimaryExpression : ClassExpression 에 대해서는 15.7를 보라.

PrimaryExpression : AsyncFunctionExpression 에 대해서는 15.8를 보라.

PrimaryExpression : AsyncGeneratorExpression 에 대해서는 15.6를 보라.

13.2.7 정규식 리터럴

구문

12.9.5를 보라.

13.2.7.1 Static Semantics: Early Errors

PrimaryExpression : RegularExpressionLiteral

13.2.7.2 Static Semantics: IsValidRegularExpressionLiteral ( literal )

The abstract operation IsValidRegularExpressionLiteral takes argument literal (a RegularExpressionLiteral Parse Node) and returns a Boolean. 이것은 인수가 유효한 정규식 리터럴인지 결정한다. It performs the following steps when called:

  1. flagsliteralFlagText라고 하자.
  2. flagsd, g, i, m, s, u, v, y 이외의 코드 포인트를 하나라도 포함하면 false를 반환한다.
  3. flags가 어떤 코드 포인트든 두 번 이상 포함하면 false를 반환한다.
  4. flagsu를 포함하면 utrue로 하자; 그렇지 않으면 ufalse로 하자.
  5. flagsv를 포함하면 vtrue로 하자; 그렇지 않으면 vfalse로 하자.
  6. patternTextliteralBodyText라고 하자.
  7. ufalse이고 vfalse이면,
    1. stringValueCodePointsToString(patternText)라고 하자.
    2. patternTextstringValue의 각 16비트 요소를 유니코드 BMP 코드 포인트로 해석한 결과의 코드 포인트 시퀀스로 설정한다. 요소들에는 UTF-16 디코딩이 적용되지 않는다.
  8. parseResultParsePattern(patternText, u, v)라고 하자.
  9. parseResult가 Parse Node이면 true를 반환한다.
  10. false를 반환한다.

13.2.7.3 Runtime Semantics: Evaluation

PrimaryExpression : RegularExpressionLiteral
  1. patternCodePointsToString(BodyText of RegularExpressionLiteral)라고 하자.
  2. flagsCodePointsToString(FlagText of RegularExpressionLiteral)라고 하자.
  3. RegExpCreate(pattern, flags)를 반환한다.

13.2.8 템플릿 리터럴

구문

TemplateLiteral[Yield, Await, Tagged] : NoSubstitutionTemplate SubstitutionTemplate[?Yield, ?Await, ?Tagged] SubstitutionTemplate[Yield, Await, Tagged] : TemplateHead Expression[+In, ?Yield, ?Await] TemplateSpans[?Yield, ?Await, ?Tagged] TemplateSpans[Yield, Await, Tagged] : TemplateTail TemplateMiddleList[?Yield, ?Await, ?Tagged] TemplateTail TemplateMiddleList[Yield, Await, Tagged] : TemplateMiddle Expression[+In, ?Yield, ?Await] TemplateMiddleList[?Yield, ?Await, ?Tagged] TemplateMiddle Expression[+In, ?Yield, ?Await]

13.2.8.1 Static Semantics: Early Errors

TemplateLiteral[Yield, Await, Tagged] : NoSubstitutionTemplate TemplateLiteral[Yield, Await, Tagged] : SubstitutionTemplate[?Yield, ?Await, ?Tagged] SubstitutionTemplate[Yield, Await, Tagged] : TemplateHead Expression[+In, ?Yield, ?Await] TemplateSpans[?Yield, ?Await, ?Tagged] TemplateSpans[Yield, Await, Tagged] : TemplateTail TemplateMiddleList[Yield, Await, Tagged] : TemplateMiddle Expression[+In, ?Yield, ?Await] TemplateMiddleList[?Yield, ?Await, ?Tagged] TemplateMiddle Expression[+In, ?Yield, ?Await]

13.2.8.2 Static Semantics: TemplateStrings

The syntax-directed operation TemplateStrings takes argument raw (a Boolean) and returns a List of either Strings or undefined. It is defined piecewise over the following productions:

TemplateLiteral : NoSubstitutionTemplate
  1. « TemplateString(NoSubstitutionTemplate, raw) »를 반환한다.
SubstitutionTemplate : TemplateHead Expression TemplateSpans
  1. head를 « TemplateString(TemplateHead, raw) »라고 하자.
  2. tail을 인수 raw를 사용한 TemplateSpansTemplateStrings라고 하자.
  3. headtaillist-concatenation을 반환한다.
TemplateSpans : TemplateTail
  1. « TemplateString(TemplateTail, raw) »를 반환한다.
TemplateSpans : TemplateMiddleList TemplateTail
  1. middle을 인수 raw를 사용한 TemplateMiddleListTemplateStrings라고 하자.
  2. tail을 « TemplateString(TemplateTail, raw) »라고 하자.
  3. middletaillist-concatenation을 반환한다.
TemplateMiddleList : TemplateMiddle Expression
  1. « TemplateString(TemplateMiddle, raw) »를 반환한다.
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
  1. front를 인수 raw를 사용한 TemplateMiddleListTemplateStrings라고 하자.
  2. last를 « TemplateString(TemplateMiddle, raw) »라고 하자.
  3. frontlastlist-concatenation을 반환한다.

13.2.8.3 Static Semantics: TemplateString ( templateToken, raw )

The abstract operation TemplateString takes arguments templateToken (a NoSubstitutionTemplate Parse Node, a TemplateHead Parse Node, a TemplateMiddle Parse Node, or a TemplateTail Parse Node) and raw (a Boolean) and returns a String or undefined. It performs the following steps when called:

  1. rawtrue이면,
    1. stringtemplateTokenTRV라고 하자.
  2. 그렇지 않으면,
    1. stringtemplateTokenTV라고 하자.
  3. string을 반환한다.
Note

이 연산은 rawfalse이고 templateTokenNotEscapeSequence를 포함하면 undefined를 반환한다. 그 외 모든 경우에는 String을 반환한다.

13.2.8.4 GetTemplateObject ( templateLiteral )

The abstract operation GetTemplateObject takes argument templateLiteral (a Parse Node) and returns an Array. It performs the following steps when called:

  1. realm을 현재 Realm Record라고 하자.
  2. templateRegistryrealm.[[TemplateMap]]라고 하자.
  3. templateRegistry의 각 요소 e에 대해, 다음을 수행한다
    1. e.[[Site]]templateLiteral과 같은 Parse Node이면,
      1. e.[[Array]]를 반환한다.
  4. rawStrings를 인수 true를 사용한 templateLiteralTemplateStrings라고 하자.
  5. Assert: rawStrings는 Strings의 List이다.
  6. cookedStrings를 인수 false를 사용한 templateLiteralTemplateStrings라고 하자.
  7. countList cookedStrings의 요소 개수라고 하자.
  8. Assert: count ≤ 232 - 1.
  9. template를 ! ArrayCreate(count)라고 하자.
  10. rawObj를 ! ArrayCreate(count)라고 하자.
  11. index를 0이라고 하자.
  12. index < count인 동안, 다음을 반복한다
    1. propertyKey를 ! ToString(𝔽(index))라고 하자.
    2. cookedValuecookedStrings[index]라고 하자.
    3. DefinePropertyOrThrow(template, propertyKey, PropertyDescriptor { [[Value]]: cookedValue, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false })를 수행한다.
    4. rawValue를 String 값 rawStrings[index]라고 하자.
    5. DefinePropertyOrThrow(rawObj, propertyKey, PropertyDescriptor { [[Value]]: rawValue, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false })를 수행한다.
    6. indexindex + 1로 설정한다.
  13. SetIntegrityLevel(rawObj, frozen)를 수행한다.
  14. DefinePropertyOrThrow(template, "raw", PropertyDescriptor { [[Value]]: rawObj, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
  15. SetIntegrityLevel(template, frozen)를 수행한다.
  16. Record { [[Site]]: templateLiteral, [[Array]]: template }를 realm.[[TemplateMap]]에 추가한다.
  17. template를 반환한다.
Note 1

템플릿 객체의 생성은 abrupt completion을 발생시킬 수 없다.

Note 2

realm의 프로그램 코드 안의 각 TemplateLiteral은 태그된 Template의 평가(13.2.8.6)에 사용되는 고유한 템플릿 객체와 연관된다. 템플릿 객체는 동결되며, 특정 태그된 Template가 평가될 때마다 같은 템플릿 객체가 사용된다. 템플릿 객체가 TemplateLiteral의 첫 평가 시점에 지연 생성되는지, 또는 첫 평가 전에 미리 생성되는지는 ECMAScript 코드에서 관찰할 수 없는 구현 선택이다.

Note 3

이 명세의 미래 판은 템플릿 객체의 추가적인 non-enumerable 프로퍼티를 정의할 수 있다.

13.2.8.5 Runtime Semantics: SubstitutionEvaluation

The syntax-directed operation SubstitutionEvaluation takes no arguments and returns either a normal completion containing a List of ECMAScript language values or an abrupt completion. It is defined piecewise over the following productions:

TemplateSpans : TemplateTail
  1. 새로운 빈 List를 반환한다.
TemplateSpans : TemplateMiddleList TemplateTail
  1. TemplateMiddleListSubstitutionEvaluation을 ? 반환한다.
TemplateMiddleList : TemplateMiddle Expression
  1. subRefExpressionEvaluation 결과 ?라고 하자.
  2. sub를 ? GetValue(subRef)라고 하자.
  3. « sub »를 반환한다.
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
  1. precedingTemplateMiddleListSubstitutionEvaluation 결과 ?라고 하자.
  2. nextRefExpressionEvaluation 결과 ?라고 하자.
  3. next를 ? GetValue(nextRef)라고 하자.
  4. preceding과 « next »의 list-concatenation을 반환한다.

13.2.8.6 Runtime Semantics: Evaluation

TemplateLiteral : NoSubstitutionTemplate
  1. 12.9.6에 정의된 NoSubstitutionTemplateTV를 반환한다.
SubstitutionTemplate : TemplateHead Expression TemplateSpans
  1. head12.9.6에 정의된 TemplateHeadTV라고 하자.
  2. subRefExpressionEvaluation 결과 ?라고 하자.
  3. sub를 ? GetValue(subRef)라고 하자.
  4. middle을 ? ToString(sub)라고 하자.
  5. tailTemplateSpansEvaluation 결과 ?라고 하자.
  6. head, middle, tail의 문자열 연결을 반환한다.
Note 1

Expression 값에 적용되는 문자열 변환 의미론은 + 연산자라기보다 String.prototype.concat과 같다.

TemplateSpans : TemplateTail
  1. 12.9.6에 정의된 TemplateTailTV를 반환한다.
TemplateSpans : TemplateMiddleList TemplateTail
  1. headTemplateMiddleListEvaluation 결과 ?라고 하자.
  2. tail12.9.6에 정의된 TemplateTailTV라고 하자.
  3. headtail의 문자열 연결을 반환한다.
TemplateMiddleList : TemplateMiddle Expression
  1. head12.9.6에 정의된 TemplateMiddleTV라고 하자.
  2. subRefExpressionEvaluation 결과 ?라고 하자.
  3. sub를 ? GetValue(subRef)라고 하자.
  4. middle을 ? ToString(sub)라고 하자.
  5. headmiddle의 문자열 연결을 반환한다.
Note 2

Expression 값에 적용되는 문자열 변환 의미론은 + 연산자라기보다 String.prototype.concat과 같다.

TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
  1. restTemplateMiddleListEvaluation 결과 ?라고 하자.
  2. middle12.9.6에 정의된 TemplateMiddleTV라고 하자.
  3. subRefExpressionEvaluation 결과 ?라고 하자.
  4. sub를 ? GetValue(subRef)라고 하자.
  5. last를 ? ToString(sub)라고 하자.
  6. rest, middle, last의 문자열 연결을 반환한다.
Note 3

Expression 값에 적용되는 문자열 변환 의미론은 + 연산자라기보다 String.prototype.concat과 같다.

13.2.9 그룹화 연산자

13.2.9.1 Static Semantics: Early Errors

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList

13.2.9.2 Runtime Semantics: Evaluation

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. exprCoverParenthesizedExpressionAndArrowParameterList이 커버하는 ParenthesizedExpression이라고 하자.
  2. exprEvaluation을 ? 반환한다.
ParenthesizedExpression : ( Expression )
  1. ExpressionEvaluation을 ? 반환한다. 이것은 Reference 타입일 수 있다.
Note

이 알고리즘은 ExpressionEvaluationGetValue를 적용하지 않는다. 그 주된 동기는 deletetypeof 같은 연산자가 괄호로 둘러싸인 표현식에 적용될 수 있도록 하기 위해서이다.

13.3 좌변 표현식

구문

MemberExpression[Yield, Await] : PrimaryExpression[?Yield, ?Await] MemberExpression[?Yield, ?Await] [ Expression[+In, ?Yield, ?Await] ] MemberExpression[?Yield, ?Await] . IdentifierName MemberExpression[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged] SuperProperty[?Yield, ?Await] MetaProperty new MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] MemberExpression[?Yield, ?Await] . PrivateIdentifier SuperProperty[Yield, Await] : super [ Expression[+In, ?Yield, ?Await] ] super . IdentifierName MetaProperty : NewTarget ImportMeta NewTarget : new . target ImportMeta : import . meta NewExpression[Yield, Await] : MemberExpression[?Yield, ?Await] new NewExpression[?Yield, ?Await] CallExpression[Yield, Await] : CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await] SuperCall[?Yield, ?Await] ImportCall[?Yield, ?Await] CallExpression[?Yield, ?Await] Arguments[?Yield, ?Await] CallExpression[?Yield, ?Await] [ Expression[+In, ?Yield, ?Await] ] CallExpression[?Yield, ?Await] . IdentifierName CallExpression[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged] CallExpression[?Yield, ?Await] . PrivateIdentifier SuperCall[Yield, Await] : super Arguments[?Yield, ?Await] ImportCall[Yield, Await] : import ( AssignmentExpression[+In, ?Yield, ?Await] ,opt ) import ( AssignmentExpression[+In, ?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ,opt ) Arguments[Yield, Await] : ( ) ( ArgumentList[?Yield, ?Await] ) ( ArgumentList[?Yield, ?Await] , ) ArgumentList[Yield, Await] : AssignmentExpression[+In, ?Yield, ?Await] ... AssignmentExpression[+In, ?Yield, ?Await] ArgumentList[?Yield, ?Await] , AssignmentExpression[+In, ?Yield, ?Await] ArgumentList[?Yield, ?Await] , ... AssignmentExpression[+In, ?Yield, ?Await] OptionalExpression[Yield, Await] : MemberExpression[?Yield, ?Await] OptionalChain[?Yield, ?Await] CallExpression[?Yield, ?Await] OptionalChain[?Yield, ?Await] OptionalExpression[?Yield, ?Await] OptionalChain[?Yield, ?Await] OptionalChain[Yield, Await] : ?. Arguments[?Yield, ?Await] ?. [ Expression[+In, ?Yield, ?Await] ] ?. IdentifierName ?. TemplateLiteral[?Yield, ?Await, +Tagged] ?. PrivateIdentifier OptionalChain[?Yield, ?Await] Arguments[?Yield, ?Await] OptionalChain[?Yield, ?Await] [ Expression[+In, ?Yield, ?Await] ] OptionalChain[?Yield, ?Await] . IdentifierName OptionalChain[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged] OptionalChain[?Yield, ?Await] . PrivateIdentifier LeftHandSideExpression[Yield, Await] : NewExpression[?Yield, ?Await] CallExpression[?Yield, ?Await] OptionalExpression[?Yield, ?Await]

보충 구문

production의 인스턴스를 처리할 때
CallExpression : CoverCallExpressionAndAsyncArrowHead
CoverCallExpressionAndAsyncArrowHead의 해석은 다음 문법을 사용하여 정제된다:

CallMemberExpression[Yield, Await] : MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]

13.3.1 Static Semantics

13.3.1.1 Static Semantics: Early Errors

OptionalChain : ?. TemplateLiteral OptionalChain TemplateLiteral
  • 이 production에 의해 어떤 소스 텍스트라도 매치되면 Syntax Error이다.
Note

이 production은 자동 세미콜론 삽입 규칙(12.10)이 다음 코드에 적용되는 것을 막기 위해 존재한다:

a?.b
`c`

그 결과 이것이 두 개의 유효한 문장으로 해석되지 않도록 하기 위함이다. 목적은 optional chaining이 없는 유사한 코드와의 일관성을 유지하는 것이다:

a.b
`c`

이것은 유효한 문장이며 자동 세미콜론 삽입이 적용되지 않는다.

ImportMeta : import . meta
  • 구문 goal symbol이 Module이 아니면 Syntax Error이다.

13.3.2 프로퍼티 접근자

Note

프로퍼티는 이름으로 접근되며, 점 표기법을 사용하거나:

또는 대괄호 표기법을 사용한다:

점 표기법은 다음 구문 변환으로 설명된다:

은 동작상 다음과 동일하다

MemberExpression [ <identifier-name-string> ]

그리고 마찬가지로

은 동작상 다음과 동일하다

CallExpression [ <identifier-name-string> ]

여기서 <identifier-name-string>는 IdentifierNameStringValue이다.

13.3.2.1 Runtime Semantics: Evaluation

MemberExpression : MemberExpression [ Expression ]
  1. baseReferenceMemberExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. strict를 this MemberExpressionIsStrict라고 하자.
  4. 인수 baseValue, Expression, strict를 사용하여 ? EvaluatePropertyAccessWithExpressionKey를 반환한다.
MemberExpression : MemberExpression . IdentifierName
  1. baseReferenceMemberExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. strict를 this MemberExpressionIsStrict라고 하자.
  4. EvaluatePropertyAccessWithIdentifierKey(baseValue, IdentifierName, strict)를 반환한다.
MemberExpression : MemberExpression . PrivateIdentifier
  1. baseReferenceMemberExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. fieldNameStringPrivateIdentifierStringValue라고 하자.
  4. MakePrivateReference(baseValue, fieldNameString)를 반환한다.
CallExpression : CallExpression [ Expression ]
  1. baseReferenceCallExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. strict를 this CallExpressionIsStrict라고 하자.
  4. 인수 baseValue, Expression, strict를 사용하여 ? EvaluatePropertyAccessWithExpressionKey를 반환한다.
CallExpression : CallExpression . IdentifierName
  1. baseReferenceCallExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. strict를 this CallExpressionIsStrict라고 하자.
  4. EvaluatePropertyAccessWithIdentifierKey(baseValue, IdentifierName, strict)를 반환한다.
CallExpression : CallExpression . PrivateIdentifier
  1. baseReferenceCallExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. fieldNameStringPrivateIdentifierStringValue라고 하자.
  4. MakePrivateReference(baseValue, fieldNameString)를 반환한다.

13.3.3 EvaluatePropertyAccessWithExpressionKey ( baseValue, expression, strict )

The abstract operation EvaluatePropertyAccessWithExpressionKey takes arguments baseValue (an ECMAScript language value), expression (an Expression Parse Node), and strict (a Boolean) and returns either a normal completion containing a Reference Record or an abrupt completion. It performs the following steps when called:

  1. propertyNameReferenceexpressionEvaluation 결과 ?라고 하자.
  2. propertyNameValue를 ? GetValue(propertyNameReference)라고 하자.
  3. NOTE: 대부분의 경우, 이 단계 직후 propertyNameValueToPropertyKey가 수행된다. 그러나 a[b] = c의 경우에는 c의 평가 이후까지 수행되지 않는다.
  4. Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyNameValue, [[Strict]]: strict, [[ThisValue]]: empty }를 반환한다.

13.3.4 EvaluatePropertyAccessWithIdentifierKey ( baseValue, identifierName, strict )

The abstract operation EvaluatePropertyAccessWithIdentifierKey takes arguments baseValue (an ECMAScript language value), identifierName (an IdentifierName Parse Node), and strict (a Boolean) and returns a Reference Record. It performs the following steps when called:

  1. propertyNameStringidentifierNameStringValue라고 하자.
  2. Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyNameString, [[Strict]]: strict, [[ThisValue]]: empty }를 반환한다.

13.3.5 new 연산자

13.3.5.1 Runtime Semantics: Evaluation

NewExpression : new NewExpression
  1. EvaluateNew(NewExpression, empty)를 반환한다.
MemberExpression : new MemberExpression Arguments
  1. EvaluateNew(MemberExpression, Arguments)를 반환한다.

13.3.5.1.1 EvaluateNew ( constructExpr, arguments )

The abstract operation EvaluateNew takes arguments constructExpr (a NewExpression Parse Node or a MemberExpression Parse Node) and arguments (empty or an Arguments Parse Node) and returns either a normal completion containing an Object or an abrupt completion. It performs the following steps when called:

  1. refconstructExprEvaluation 결과 ?라고 하자.
  2. constructor를 ? GetValue(ref)라고 하자.
  3. argumentsempty이면,
    1. argList를 새로운 빈 List라고 하자.
  4. 그렇지 않으면,
    1. argListArgumentsArgumentListEvaluation 결과 ?라고 하자.
  5. IsConstructor(constructor)가 false이면, TypeError 예외를 던진다.
  6. Construct(constructor, argList)를 반환한다.

13.3.6 함수 호출

13.3.6.1 Runtime Semantics: Evaluation

CallExpression : CoverCallExpressionAndAsyncArrowHead
  1. exprCoverCallExpressionAndAsyncArrowHead가 커버하는 CallMemberExpression이라고 하자.
  2. memberExprexprMemberExpression이라고 하자.
  3. argumentsexprArguments라고 하자.
  4. refmemberExprEvaluation 결과 ?라고 하자.
  5. func를 ? GetValue(ref)라고 하자.
  6. refReference Record이고, IsPropertyReference(ref)가 false이며, ref.[[ReferencedName]]"eval"이면,
    1. SameValue(func, %eval%)가 true이면,
      1. argListArgumentsArgumentListEvaluation 결과 ?라고 하자.
      2. argList에 요소가 없으면 undefined를 반환한다.
      3. evalArgargList의 첫 번째 요소라고 하자.
      4. IsStrict(this CallExpression)가 true이면 strictCallertrue로 하자; 그렇지 않으면 strictCallerfalse로 하자.
      5. PerformEval(evalArg, strictCaller, true)를 반환한다.
  7. thisCall을 this CallExpression이라고 하자.
  8. tailCallIsInTailPosition(thisCall)이라고 하자.
  9. EvaluateCall(func, ref, arguments, tailCall)을 반환한다.

단계 6.a.v를 실행하는 CallExpression 평가는 직접 eval이다.

CallExpression : CallExpression Arguments
  1. refCallExpressionEvaluation 결과 ?라고 하자.
  2. func를 ? GetValue(ref)라고 하자.
  3. thisCall을 this CallExpression이라고 하자.
  4. tailCallIsInTailPosition(thisCall)이라고 하자.
  5. EvaluateCall(func, ref, Arguments, tailCall)을 반환한다.

13.3.6.2 EvaluateCall ( func, ref, arguments, tailPosition )

The abstract operation EvaluateCall takes arguments func (an ECMAScript language value), ref (an ECMAScript language value or a Reference Record), arguments (a Parse Node), and tailPosition (a Boolean) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It performs the following steps when called:

  1. refReference Record이면,
    1. IsPropertyReference(ref)가 true이면,
      1. thisValueGetThisValue(ref)라고 하자.
    2. 그렇지 않으면,
      1. refEnvref.[[Base]]라고 하자.
      2. Assert: refEnvEnvironment Record이다.
      3. thisValuerefEnv.WithBaseObject()라고 하자.
  2. 그렇지 않으면,
    1. thisValueundefined라고 하자.
  3. argList를 |_arguments_|의 ArgumentListEvaluation 결과 ?라고 하자.
  4. func가 Object가 아니면, TypeError 예외를 던진다.
  5. IsCallable(func)가 false이면, TypeError 예외를 던진다.
  6. tailPositiontrue이면, PrepareForTailCall()을 수행한다.
  7. Call(func, thisValue, argList)를 반환한다.

13.3.7 super 키워드

13.3.7.1 Runtime Semantics: Evaluation

SuperProperty : super [ Expression ]
  1. envGetThisEnvironment()라고 하자.
  2. actualThis를 ? env.GetThisBinding()이라고 하자.
  3. propertyNameReferenceExpressionEvaluation 결과 ?라고 하자.
  4. propertyNameValue를 ? GetValue(propertyNameReference)라고 하자.
  5. strict를 this SuperPropertyIsStrict라고 하자.
  6. NOTE: 대부분의 경우, 이 단계 직후 propertyNameValueToPropertyKey가 수행된다. 그러나 super[b] = c의 경우에는 c의 평가 이후까지 수행되지 않는다.
  7. MakeSuperPropertyReference(actualThis, propertyNameValue, strict)를 반환한다.
SuperProperty : super . IdentifierName
  1. envGetThisEnvironment()라고 하자.
  2. actualThis를 ? env.GetThisBinding()이라고 하자.
  3. propertyKeyIdentifierNameStringValue라고 하자.
  4. strict를 this SuperPropertyIsStrict라고 하자.
  5. MakeSuperPropertyReference(actualThis, propertyKey, strict)를 반환한다.
SuperCall : super Arguments
  1. newTargetGetNewTarget()이라고 하자.
  2. Assert: newTargetconstructor이다.
  3. superConstructorGetSuperConstructor()라고 하자.
  4. argListArgumentsArgumentListEvaluation 결과 ?라고 하자.
  5. IsConstructor(superConstructor)가 false이면, TypeError 예외를 던진다.
  6. result를 ? Construct(superConstructor, argList, newTarget)라고 하자.
  7. thisERGetThisEnvironment()라고 하자.
  8. Assert: thisERFunction Environment Record이다.
  9. BindThisValue(thisER, result)를 수행한다.
  10. funcObjthisER.[[FunctionObject]]라고 하자.
  11. Assert: funcObj는 ECMAScript 함수 객체이다.
  12. InitializeInstanceElements(result, funcObj)를 수행한다.
  13. result를 반환한다.

13.3.7.2 GetSuperConstructor ( )

The abstract operation GetSuperConstructor takes no arguments and returns an Object or null. It performs the following steps when called:

  1. envRecGetThisEnvironment()라고 하자.
  2. Assert: envRecFunction Environment Record이다.
  3. activeFunctionenvRec.[[FunctionObject]]라고 하자.
  4. Assert: activeFunction은 ECMAScript 함수 객체이다.
  5. superConstructor를 ! activeFunction.[[GetPrototypeOf]]()라고 하자.
  6. superConstructor를 반환한다.

13.3.7.3 MakeSuperPropertyReference ( actualThis, propertyKey, strict )

The abstract operation MakeSuperPropertyReference takes arguments actualThis (an ECMAScript language value), propertyKey (an ECMAScript language value), and strict (a Boolean) and returns a Super Reference Record. It performs the following steps when called:

  1. envGetThisEnvironment()라고 하자.
  2. Assert: env.HasSuperBinding()은 true이다.
  3. Assert: envFunction Environment Record이다.
  4. baseValueGetSuperBase(env)라고 하자.
  5. Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: actualThis }를 반환한다.

13.3.8 인수 목록

Note

인수 목록의 평가는 값들의 List를 생성한다.

13.3.8.1 Runtime Semantics: ArgumentListEvaluation

The syntax-directed operation ArgumentListEvaluation takes no arguments and returns either a normal completion containing a List of ECMAScript language values or an abrupt completion. It is defined piecewise over the following productions:

Arguments : ( )
  1. 새로운 빈 List를 반환한다.
ArgumentList : AssignmentExpression
  1. refAssignmentExpressionEvaluation 결과 ?라고 하자.
  2. arg를 ? GetValue(ref)라고 하자.
  3. « arg »를 반환한다.
ArgumentList : ... AssignmentExpression
  1. list를 새로운 빈 List라고 하자.
  2. spreadRefAssignmentExpressionEvaluation 결과 ?라고 하자.
  3. spreadObj를 ? GetValue(spreadRef)라고 하자.
  4. iteratorRecord를 ? GetIterator(spreadObj, sync)라고 하자.
  5. 반복한다,
    1. next를 ? IteratorStepValue(iteratorRecord)라고 하자.
    2. nextdone이면, list를 반환한다.
    3. nextlist에 추가한다.
ArgumentList : ArgumentList , AssignmentExpression
  1. precedingArgsArgumentListArgumentListEvaluation 결과 ?라고 하자.
  2. refAssignmentExpressionEvaluation 결과 ?라고 하자.
  3. arg를 ? GetValue(ref)라고 하자.
  4. precedingArgs와 « arg »의 list-concatenation을 반환한다.
ArgumentList : ArgumentList , ... AssignmentExpression
  1. precedingArgsArgumentListArgumentListEvaluation 결과 ?라고 하자.
  2. spreadRefAssignmentExpressionEvaluation 결과 ?라고 하자.
  3. iteratorRecord를 ? GetIterator(? GetValue(spreadRef), sync)라고 하자.
  4. 반복한다,
    1. next를 ? IteratorStepValue(iteratorRecord)라고 하자.
    2. nextdone이면, precedingArgs를 반환한다.
    3. nextprecedingArgs에 추가한다.
TemplateLiteral : NoSubstitutionTemplate
  1. templateLiteral을 this TemplateLiteral이라고 하자.
  2. siteObjGetTemplateObject(templateLiteral)라고 하자.
  3. « siteObj »를 반환한다.
TemplateLiteral : SubstitutionTemplate
  1. templateLiteral을 this TemplateLiteral이라고 하자.
  2. siteObjGetTemplateObject(templateLiteral)라고 하자.
  3. remainingSubstitutionTemplateArgumentListEvaluation 결과 ?라고 하자.
  4. « siteObj »와 remaininglist-concatenation을 반환한다.
SubstitutionTemplate : TemplateHead Expression TemplateSpans
  1. firstSubRefExpressionEvaluation 결과 ?라고 하자.
  2. firstSub를 ? GetValue(firstSubRef)라고 하자.
  3. restSubTemplateSpansSubstitutionEvaluation 결과 ?라고 하자.
  4. Assert: restSub는 비어 있을 수도 있는 List이다.
  5. « firstSub »와 restSublist-concatenation을 반환한다.

13.3.9 선택적 체인

Note
선택적 체인은 하나 이상의 프로퍼티 접근과 함수 호출로 이루어진 체인이며, 그 첫 번째는 토큰 ?.로 시작한다.

13.3.9.1 Runtime Semantics: Evaluation

OptionalExpression : MemberExpression OptionalChain
  1. baseReferenceMemberExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. baseValueundefined 또는 null 중 하나이면,
    1. undefined를 반환한다.
  4. 인수 baseValuebaseReference를 사용하여 OptionalChainChainEvaluation을 ? 반환한다.
OptionalExpression : CallExpression OptionalChain
  1. baseReferenceCallExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. baseValueundefined 또는 null 중 하나이면,
    1. undefined를 반환한다.
  4. 인수 baseValuebaseReference를 사용하여 OptionalChainChainEvaluation을 ? 반환한다.
OptionalExpression : OptionalExpression OptionalChain
  1. baseReferenceOptionalExpressionEvaluation 결과 ?라고 하자.
  2. baseValue를 ? GetValue(baseReference)라고 하자.
  3. baseValueundefined 또는 null 중 하나이면,
    1. undefined를 반환한다.
  4. 인수 baseValuebaseReference를 사용하여 OptionalChainChainEvaluation을 ? 반환한다.

13.3.9.2 Runtime Semantics: ChainEvaluation

The syntax-directed operation ChainEvaluation takes arguments baseValue (an ECMAScript language value) and baseReference (an ECMAScript language value or a Reference Record) and returns either a normal completion containing either an ECMAScript language value or a Reference Record, or an abrupt completion. It is defined piecewise over the following productions:

OptionalChain : ?. Arguments
  1. thisChain을 this OptionalChain이라고 하자.
  2. tailCallIsInTailPosition(thisChain)이라고 하자.
  3. EvaluateCall(baseValue, baseReference, Arguments, tailCall)을 반환한다.
OptionalChain : ?. [ Expression ]
  1. strict를 this OptionalChainIsStrict라고 하자.
  2. 인수 baseValue, Expression, strict를 사용하여 ? EvaluatePropertyAccessWithExpressionKey를 반환한다.
OptionalChain : ?. IdentifierName
  1. strict를 this OptionalChainIsStrict라고 하자.
  2. EvaluatePropertyAccessWithIdentifierKey(baseValue, IdentifierName, strict)를 반환한다.
OptionalChain : ?. PrivateIdentifier
  1. fieldNameStringPrivateIdentifierStringValue라고 하자.
  2. MakePrivateReference(baseValue, fieldNameString)를 반환한다.
OptionalChain : OptionalChain Arguments
  1. optionalChainOptionalChain이라고 하자.
  2. newReference를 인수 baseValuebaseReference를 사용한 optionalChainChainEvaluation 결과 ?라고 하자.
  3. newValue를 ? GetValue(newReference)라고 하자.
  4. thisChain을 this OptionalChain이라고 하자.
  5. tailCallIsInTailPosition(thisChain)이라고 하자.
  6. EvaluateCall(newValue, newReference, Arguments, tailCall)을 반환한다.
OptionalChain : OptionalChain [ Expression ]
  1. optionalChainOptionalChain이라고 하자.
  2. newReference를 인수 baseValuebaseReference를 사용한 optionalChainChainEvaluation 결과 ?라고 하자.
  3. newValue를 ? GetValue(newReference)라고 하자.
  4. strict를 this OptionalChainIsStrict라고 하자.
  5. 인수 newValue, Expression, strict를 사용하여 ? EvaluatePropertyAccessWithExpressionKey를 반환한다.
OptionalChain : OptionalChain . IdentifierName
  1. optionalChainOptionalChain이라고 하자.
  2. newReference를 인수 baseValuebaseReference를 사용한 optionalChainChainEvaluation 결과 ?라고 하자.
  3. newValue를 ? GetValue(newReference)라고 하자.
  4. strict를 this OptionalChainIsStrict라고 하자.
  5. EvaluatePropertyAccessWithIdentifierKey(newValue, IdentifierName, strict)를 반환한다.
OptionalChain : OptionalChain . PrivateIdentifier
  1. optionalChainOptionalChain이라고 하자.
  2. newReference를 인수 baseValuebaseReference를 사용한 optionalChainChainEvaluation 결과 ?라고 하자.
  3. newValue를 ? GetValue(newReference)라고 하자.
  4. fieldNameStringPrivateIdentifierStringValue라고 하자.
  5. MakePrivateReference(newValue, fieldNameString)를 반환한다.

13.3.10 Import 호출

13.3.10.1 Runtime Semantics: Evaluation

ImportCall : import ( AssignmentExpression ,opt )
  1. EvaluateImportCall(AssignmentExpression)을 반환한다.
ImportCall : import ( AssignmentExpression , AssignmentExpression ,opt )
  1. EvaluateImportCall(the first AssignmentExpression, the second AssignmentExpression)을 반환한다.

13.3.10.2 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )

The abstract operation EvaluateImportCall takes argument specifierExpression (a Parse Node) and optional argument optionsExpression (a Parse Node) and returns either a normal completion containing a Promise or an abrupt completion. It performs the following steps when called:

  1. referrerGetActiveScriptOrModule()이라고 하자.
  2. referrernull이면, referrer를 현재 Realm Record로 설정한다.
  3. specifierRefspecifierExpressionEvaluation 결과 ?라고 하자.
  4. specifier를 ? GetValue(specifierRef)라고 하자.
  5. optionsExpression이 존재하면,
    1. optionsRefoptionsExpressionEvaluation 결과 ?라고 하자.
    2. options를 ? GetValue(optionsRef)라고 하자.
  6. 그렇지 않으면,
    1. optionsundefined라고 하자.
  7. promiseCapability를 ! NewPromiseCapability(%Promise%)라고 하자.
  8. specifierStringCompletion(ToString(specifier))이라고 하자.
  9. IfAbruptRejectPromise(specifierString, promiseCapability).
  10. attributes를 새로운 빈 List라고 하자.
  11. optionsundefined가 아니면,
    1. options가 Object가 아니면,
      1. Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »)를 수행한다.
      2. promiseCapability.[[Promise]]를 반환한다.
    2. attributesObjCompletion(Get(options, "with"))라고 하자.
    3. IfAbruptRejectPromise(attributesObj, promiseCapability).
    4. attributesObjundefined가 아니면,
      1. attributesObj가 Object가 아니면,
        1. Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »)를 수행한다.
        2. promiseCapability.[[Promise]]를 반환한다.
      2. entriesCompletion(EnumerableOwnProperties(attributesObj, key+value))라고 하자.
      3. IfAbruptRejectPromise(entries, promiseCapability).
      4. entries의 각 요소 entry에 대해, 다음을 수행한다
        1. key를 ! Get(entry, "0")라고 하자.
        2. value를 ! Get(entry, "1")라고 하자.
        3. key가 String이면,
          1. value가 String이 아니면,
            1. Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »)를 수행한다.
            2. promiseCapability.[[Promise]]를 반환한다.
          2. ImportAttribute Record { [[Key]]: key, [[Value]]: value }를 attributes에 추가한다.
    5. AllImportAttributesSupported(attributes)가 false이면,
      1. Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »)를 수행한다.
      2. promiseCapability.[[Promise]]를 반환한다.
    6. attributes[[Key]] 필드 값들을 UTF-16 코드 단위 값 시퀀스로 취급하여 그 사전식 순서에 따라 attributes를 정렬한다. NOTE: 이 정렬은 호스트가 속성이 열거된 순서에 따라 동작을 바꾸는 것이 금지된다는 점에서만 관찰 가능하다.
  12. moduleRequest를 새로운 ModuleRequest Record { [[Specifier]]: specifierString, [[Attributes]]: attributes }라고 하자.
  13. HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability)를 수행한다.
  14. promiseCapability.[[Promise]]를 반환한다.

13.3.10.3 ContinueDynamicImport ( promiseCapability, moduleCompletion )

The abstract operation ContinueDynamicImport takes arguments promiseCapability (a PromiseCapability Record) and moduleCompletion (either a normal completion containing a Module Record or a throw completion) and returns unused. 이것은 원래 import() 호출로 시작된 동적 import 과정을 완료하며, 필요에 따라 그 호출이 반환한 promise를 resolve 또는 reject한다. It performs the following steps when called:

  1. moduleCompletionabrupt completion이면,
    1. Call(promiseCapability.[[Reject]], undefined, « moduleCompletion.[[Value]] »)를 수행한다.
    2. unused를 반환한다.
  2. modulemoduleCompletion.[[Value]]라고 하자.
  3. loadPromisemodule.LoadRequestedModules()라고 하자.
  4. promiseCapability를 캡처하고, 호출될 때 다음 단계를 수행하는 매개변수 (reason)를 가진 새로운 Abstract ClosurerejectedClosure라고 하자:
    1. Call(promiseCapability.[[Reject]], undefined, « reason »)를 수행한다.
    2. NormalCompletion(undefined)를 반환한다.
  5. onRejectedCreateBuiltinFunction(rejectedClosure, 1, "", « »)라고 하자.
  6. module, promiseCapability, onRejected를 캡처하고, 호출될 때 다음 단계를 수행하는 매개변수 없는 새로운 Abstract ClosurelinkAndEvaluateClosure라고 하자:
    1. linkCompletion(module.Link())라고 하자.
    2. linkabrupt completion이면,
      1. Call(promiseCapability.[[Reject]], undefined, « link.[[Value]] »)를 수행한다.
      2. NormalCompletion(undefined)를 반환한다.
    3. evaluatePromisemodule.Evaluate()라고 하자.
    4. modulepromiseCapability를 캡처하고, 호출될 때 다음 단계를 수행하는 매개변수 없는 새로운 Abstract ClosurefulfilledClosure라고 하자:
      1. namespaceGetModuleNamespace(module)라고 하자.
      2. Call(promiseCapability.[[Resolve]], undefined, « namespace »)를 수행한다.
      3. NormalCompletion(undefined)를 반환한다.
    5. onFulfilledCreateBuiltinFunction(fulfilledClosure, 0, "", « »)라고 하자.
    6. PerformPromiseThen(evaluatePromise, onFulfilled, onRejected)를 수행한다.
    7. unused를 반환한다.
  7. linkAndEvaluateCreateBuiltinFunction(linkAndEvaluateClosure, 0, "", « »)라고 하자.
  8. PerformPromiseThen(loadPromise, linkAndEvaluate, onRejected)를 수행한다.
  9. unused를 반환한다.

13.3.11 태그된 템플릿

Note

태그된 템플릿은 호출 인수가 TemplateLiteral(13.2.8)로부터 파생되는 함수 호출이다. 실제 인수에는 템플릿 객체(13.2.8.4)와 TemplateLiteral 안에 포함된 표현식들을 평가해서 생성된 값들이 포함된다.

13.3.11.1 Runtime Semantics: Evaluation

MemberExpression : MemberExpression TemplateLiteral
  1. tagRefMemberExpressionEvaluation 결과 ?라고 하자.
  2. tagFunc를 ? GetValue(tagRef)라고 하자.
  3. thisCall을 this MemberExpression이라고 하자.
  4. tailCallIsInTailPosition(thisCall)이라고 하자.
  5. EvaluateCall(tagFunc, tagRef, TemplateLiteral, tailCall)을 반환한다.
CallExpression : CallExpression TemplateLiteral
  1. tagRefCallExpressionEvaluation 결과 ?라고 하자.
  2. tagFunc를 ? GetValue(tagRef)라고 하자.
  3. thisCall을 this CallExpression이라고 하자.
  4. tailCallIsInTailPosition(thisCall)이라고 하자.
  5. EvaluateCall(tagFunc, tagRef, TemplateLiteral, tailCall)을 반환한다.

13.3.12 메타 프로퍼티

13.3.12.1 Runtime Semantics: Evaluation

NewTarget : new . target
  1. GetNewTarget()을 반환한다.
ImportMeta : import . meta
  1. moduleGetActiveScriptOrModule()이라고 하자.
  2. Assert: moduleSource Text Module Record이다.
  3. importMetamodule.[[ImportMeta]]라고 하자.
  4. importMetaempty이면,
    1. importMetaOrdinaryObjectCreate(null)로 설정한다.
    2. importMetaValuesHostGetImportMetaProperties(module)라고 하자.
    3. importMetaValues의 각 Record { [[Key]], [[Value]] } p에 대해, 다음을 수행한다
      1. CreateDataPropertyOrThrow(importMeta, p.[[Key]], p.[[Value]])를 수행한다.
    4. HostFinalizeImportMeta(importMeta, module)를 수행한다.
    5. module.[[ImportMeta]]importMeta로 설정한다.
    6. importMeta를 반환한다.
  5. Assert: importMeta는 Object이다.
  6. importMeta를 반환한다.

13.3.12.1.1 HostGetImportMetaProperties ( moduleRecord )

The host-defined abstract operation HostGetImportMetaProperties takes argument moduleRecord (a Module Record) and returns a List of Records with fields [[Key]] (a property key) and [[Value]] (an ECMAScript language value). 이것은 호스트import.meta로부터 반환되는 객체에 대한 프로퍼티 키와 값을 제공할 수 있게 한다.

HostGetImportMetaProperties의 기본 구현은 새로운 빈 List를 반환하는 것이다.

13.3.12.1.2 HostFinalizeImportMeta ( importMeta, moduleRecord )

The host-defined abstract operation HostFinalizeImportMeta takes arguments importMeta (an Object) and moduleRecord (a Module Record) and returns unused. 이것은 호스트import.meta에서 반환되는 객체를 준비하기 위해 특별한 연산을 수행할 수 있게 한다.

대부분의 호스트는 단순히 HostGetImportMetaProperties를 정의하고, HostFinalizeImportMeta는 기본 동작 그대로 둘 수 있다. 그러나 HostFinalizeImportMeta는 객체가 ECMAScript 코드에 노출되기 전에 호스트가 직접 조작해야 하는 경우를 위한 "탈출구"를 제공한다.

HostFinalizeImportMeta의 기본 구현은 unused를 반환하는 것이다.

13.4 업데이트 표현식

구문

UpdateExpression[Yield, Await] : LeftHandSideExpression[?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await] [no LineTerminator here] ++ LeftHandSideExpression[?Yield, ?Await] [no LineTerminator here] -- ++ UnaryExpression[?Yield, ?Await] -- UnaryExpression[?Yield, ?Await]

13.4.1 Static Semantics: Early Errors

UpdateExpression : LeftHandSideExpression ++ LeftHandSideExpression -- UpdateExpression : ++ UnaryExpression -- UnaryExpression

13.4.2 후위 증가 연산자

13.4.2.1 Runtime Semantics: Evaluation

UpdateExpression : LeftHandSideExpression ++
  1. lhsLeftHandSideExpressionEvaluation 결과 ?라고 하자.
  2. LeftHandSideExpressionAssignmentTargetTypeweb-compat이면, ReferenceError 예외를 던진다.
  3. oldValue를 ? ToNumeric(? GetValue(lhs))라고 하자.
  4. oldValue가 Number이면,
    1. newValueNumber::add(oldValue, 1𝔽)라고 하자.
  5. 그렇지 않으면,
    1. Assert: oldValue는 BigInt이다.
    2. newValueBigInt::add(oldValue, 1)라고 하자.
  6. PutValue(lhs, newValue)를 수행한다.
  7. oldValue를 반환한다.

13.4.3 후위 감소 연산자

13.4.3.1 Runtime Semantics: Evaluation

UpdateExpression : LeftHandSideExpression --
  1. lhsLeftHandSideExpressionEvaluation 결과 ?라고 하자.
  2. LeftHandSideExpressionAssignmentTargetTypeweb-compat이면, ReferenceError 예외를 던진다.
  3. oldValue를 ? ToNumeric(? GetValue(lhs))라고 하자.
  4. oldValue가 Number이면,
    1. newValueNumber::subtract(oldValue, 1𝔽)라고 하자.
  5. 그렇지 않으면,
    1. Assert: oldValue는 BigInt이다.
    2. newValueBigInt::subtract(oldValue, 1)라고 하자.
  6. PutValue(lhs, newValue)를 수행한다.
  7. oldValue를 반환한다.

13.4.4 전위 증가 연산자

13.4.4.1 Runtime Semantics: Evaluation

UpdateExpression : ++ UnaryExpression
  1. exprUnaryExpressionEvaluation 결과 ?라고 하자.
  2. UnaryExpressionAssignmentTargetTypeweb-compat이면, ReferenceError 예외를 던진다.
  3. oldValue를 ? ToNumeric(? GetValue(expr))라고 하자.
  4. oldValue가 Number이면,
    1. newValueNumber::add(oldValue, 1𝔽)라고 하자.
  5. 그렇지 않으면,
    1. Assert: oldValue는 BigInt이다.
    2. newValueBigInt::add(oldValue, 1)라고 하자.
  6. PutValue(expr, newValue)를 수행한다.
  7. newValue를 반환한다.

13.4.5 전위 감소 연산자

13.4.5.1 Runtime Semantics: Evaluation

UpdateExpression : -- UnaryExpression
  1. exprUnaryExpressionEvaluation 결과 ?라고 하자.
  2. UnaryExpressionAssignmentTargetTypeweb-compat이면, ReferenceError 예외를 던진다.
  3. oldValue를 ? ToNumeric(? GetValue(expr))라고 하자.
  4. oldValue가 Number이면,
    1. newValueNumber::subtract(oldValue, 1𝔽)라고 하자.
  5. 그렇지 않으면,
    1. Assert: oldValue는 BigInt이다.
    2. newValueBigInt::subtract(oldValue, 1)라고 하자.
  6. PutValue(expr, newValue)를 수행한다.
  7. newValue를 반환한다.

13.5 단항 연산자

구문

UnaryExpression[Yield, Await] : UpdateExpression[?Yield, ?Await] delete UnaryExpression[?Yield, ?Await] void UnaryExpression[?Yield, ?Await] typeof UnaryExpression[?Yield, ?Await] + UnaryExpression[?Yield, ?Await] - UnaryExpression[?Yield, ?Await] ~ UnaryExpression[?Yield, ?Await] ! UnaryExpression[?Yield, ?Await] [+Await] AwaitExpression[?Yield]

13.5.1 delete 연산자

13.5.1.1 Static Semantics: Early Errors

UnaryExpression : delete UnaryExpression Note

마지막 규칙은 delete (((foo))) 같은 표현식이 첫 번째 규칙의 재귀적 적용으로 인해 early error를 발생시킨다는 뜻이다.

13.5.1.2 Runtime Semantics: Evaluation

UnaryExpression : delete UnaryExpression
  1. refUnaryExpressionEvaluation 결과 ?라고 하자.
  2. refReference Record가 아니면, true를 반환한다.
  3. IsUnresolvableReference(ref)가 true이면,
    1. Assert: ref.[[Strict]]false이다.
    2. true를 반환한다.
  4. IsPropertyReference(ref)가 true이면,
    1. Assert: IsPrivateReference(ref)는 false이다.
    2. IsSuperReference(ref)가 true이면, ReferenceError 예외를 던진다.
    3. baseObj를 ? ToObject(ref.[[Base]])라고 하자.
    4. ref.[[ReferencedName]]이 프로퍼티 키가 아니면,
      1. ref.[[ReferencedName]]를 ? ToPropertyKey(ref.[[ReferencedName]])로 설정한다.
    5. deleteStatus를 ? baseObj.[[Delete]](ref.[[ReferencedName]])라고 하자.
    6. deleteStatusfalse이고 ref.[[Strict]]true이면, TypeError 예외를 던진다.
    7. deleteStatus를 반환한다.
  5. baseref.[[Base]]라고 하자.
  6. Assert: baseEnvironment Record이다.
  7. base.DeleteBinding(ref.[[ReferencedName]])를 반환한다.
Note 1

delete 연산자가 strict mode 코드 안에 나타나면, 그 UnaryExpression이 변수, 함수 인수, 또는 함수 이름에 대한 직접 참조일 경우 SyntaxError 예외가 던져진다. 또한 delete 연산자가 strict mode 코드 안에 나타나고 삭제하려는 프로퍼티가 { [[Configurable]]: false } 속성을 가지는 경우(또는 다른 이유로 삭제할 수 없는 경우), TypeError 예외가 던져진다.

Note 2

단계 4.c에서 생성될 수 있는 객체는 위 추상 연산과 일반 객체 [[Delete]] 내부 메서드 밖에서는 접근할 수 없다. 구현은 그 객체를 실제로 만들지 않도록 선택할 수 있다.

13.5.2 void 연산자

13.5.2.1 Runtime Semantics: Evaluation

UnaryExpression : void UnaryExpression
  1. exprUnaryExpressionEvaluation 결과 ?라고 하자.
  2. GetValue(expr)를 수행한다.
  3. undefined를 반환한다.
Note

GetValue의 값은 사용되지 않더라도 관찰 가능한 부작용이 있을 수 있으므로 반드시 호출해야 한다.

13.5.3 typeof 연산자

13.5.3.1 Runtime Semantics: Evaluation

UnaryExpression : typeof UnaryExpression
  1. valUnaryExpressionEvaluation 결과 ?라고 하자.
  2. valReference Record이면,
    1. IsUnresolvableReference(val)가 true이면 "undefined"를 반환한다.
  3. val을 ? GetValue(val)로 설정한다.
  4. valundefined이면 "undefined"를 반환한다.
  5. valnull이면 "object"를 반환한다.
  6. val이 String이면 "string"을 반환한다.
  7. val이 Symbol이면 "symbol"을 반환한다.
  8. val이 Boolean이면 "boolean"을 반환한다.
  9. val이 Number이면 "number"를 반환한다.
  10. val이 BigInt이면 "bigint"를 반환한다.
  11. Assert: val은 Object이다.
  12. Normative Optional
    호스트가 웹 브라우저이거나 또는 [[IsHTMLDDA]] 내부 슬롯를 지원하면,
    1. val[[IsHTMLDDA]] 내부 슬롯을 가지면 "undefined"를 반환한다.
  13. val[[Call]] 내부 메서드를 가지면 "function"을 반환한다.
  14. "object"를 반환한다.

13.5.4 단항 + 연산자

Note

단항 + 연산자는 피연산자를 Number 타입으로 변환한다.

13.5.4.1 Runtime Semantics: Evaluation

UnaryExpression : + UnaryExpression
  1. exprUnaryExpressionEvaluation 결과 ?라고 하자.
  2. ToNumber(? GetValue(expr))를 반환한다.

13.5.5 단항 - 연산자

Note

단항 - 연산자는 피연산자를 수치 값으로 변환한 뒤 부호를 반전시킨다. +0𝔽를 부정하면 -0𝔽가 되고, -0𝔽를 부정하면 +0𝔽가 된다.

13.5.5.1 Runtime Semantics: Evaluation

UnaryExpression : - UnaryExpression
  1. exprUnaryExpressionEvaluation 결과 ?라고 하자.
  2. oldValue를 ? ToNumeric(? GetValue(expr))라고 하자.
  3. oldValue가 Number이면 Number::unaryMinus(oldValue)를 반환한다.
  4. Assert: oldValue는 BigInt이다.
  5. BigInt::unaryMinus(oldValue)를 반환한다.

13.5.6 비트 NOT 연산자 ( ~ )

13.5.6.1 Runtime Semantics: Evaluation

UnaryExpression : ~ UnaryExpression
  1. exprUnaryExpressionEvaluation 결과 ?라고 하자.
  2. oldValue를 ? ToNumeric(? GetValue(expr))라고 하자.
  3. oldValue가 Number이면 Number::bitwiseNOT(oldValue)를 반환한다.
  4. Assert: oldValue는 BigInt이다.
  5. BigInt::bitwiseNOT(oldValue)를 반환한다.

13.5.7 논리 NOT 연산자 ( ! )

13.5.7.1 Runtime Semantics: Evaluation

UnaryExpression : ! UnaryExpression
  1. exprUnaryExpressionEvaluation 결과 ?라고 하자.
  2. oldValueToBoolean(? GetValue(expr))라고 하자.
  3. oldValuetrue이면 false를 반환한다.
  4. true를 반환한다.

13.6 거듭제곱 연산자

구문

ExponentiationExpression[Yield, Await] : UnaryExpression[?Yield, ?Await] UpdateExpression[?Yield, ?Await] ** ExponentiationExpression[?Yield, ?Await]

13.6.1 Runtime Semantics: Evaluation

ExponentiationExpression : UpdateExpression ** ExponentiationExpression
  1. EvaluateStringOrNumericBinaryExpression(UpdateExpression, **, ExponentiationExpression)을 반환한다.

13.7 곱셈 연산자

구문

MultiplicativeExpression[Yield, Await] : ExponentiationExpression[?Yield, ?Await] MultiplicativeExpression[?Yield, ?Await] MultiplicativeOperator ExponentiationExpression[?Yield, ?Await] MultiplicativeOperator : one of * / % Note
  • * 연산자는 곱셈을 수행하여 피연산자의 곱을 생성한다.
  • / 연산자는 나눗셈을 수행하여 피연산자의 몫을 생성한다.
  • % 연산자는 암묵적인 나눗셈에서 피연산자의 나머지를 산출한다.

13.7.1 Runtime Semantics: Evaluation

MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression
  1. opTextMultiplicativeOperator에 매치된 소스 텍스트라고 하자.
  2. EvaluateStringOrNumericBinaryExpression(MultiplicativeExpression, opText, ExponentiationExpression)을 반환한다.

13.8 덧셈 연산자

구문

AdditiveExpression[Yield, Await] : MultiplicativeExpression[?Yield, ?Await] AdditiveExpression[?Yield, ?Await] + MultiplicativeExpression[?Yield, ?Await] AdditiveExpression[?Yield, ?Await] - MultiplicativeExpression[?Yield, ?Await]

13.8.1 덧셈 연산자 ( + )

Note

덧셈 연산자는 문자열 연결 또는 수치 덧셈을 수행한다.

13.8.1.1 Runtime Semantics: Evaluation

AdditiveExpression : AdditiveExpression + MultiplicativeExpression
  1. EvaluateStringOrNumericBinaryExpression(AdditiveExpression, +, MultiplicativeExpression)을 반환한다.

13.8.2 뺄셈 연산자 ( - )

Note

- 연산자는 뺄셈을 수행하여 피연산자의 차를 생성한다.

13.8.2.1 Runtime Semantics: Evaluation

AdditiveExpression : AdditiveExpression - MultiplicativeExpression
  1. EvaluateStringOrNumericBinaryExpression(AdditiveExpression, -, MultiplicativeExpression)을 반환한다.

13.9 비트 시프트 연산자

구문

ShiftExpression[Yield, Await] : AdditiveExpression[?Yield, ?Await] ShiftExpression[?Yield, ?Await] << AdditiveExpression[?Yield, ?Await] ShiftExpression[?Yield, ?Await] >> AdditiveExpression[?Yield, ?Await] ShiftExpression[?Yield, ?Await] >>> AdditiveExpression[?Yield, ?Await]

13.9.1 좌측 시프트 연산자 ( << )

Note

왼쪽 피연산자에 대해 오른쪽 피연산자가 지정한 양만큼 비트 단위 왼쪽 시프트 연산을 수행한다.

13.9.1.1 Runtime Semantics: Evaluation

ShiftExpression : ShiftExpression << AdditiveExpression
  1. EvaluateStringOrNumericBinaryExpression(ShiftExpression, <<, AdditiveExpression)을 반환한다.

13.9.2 부호 있는 우측 시프트 연산자 ( >> )

Note

왼쪽 피연산자에 대해 오른쪽 피연산자가 지정한 양만큼 부호 확장 비트 단위 오른쪽 시프트 연산을 수행한다.

13.9.2.1 Runtime Semantics: Evaluation

ShiftExpression : ShiftExpression >> AdditiveExpression
  1. EvaluateStringOrNumericBinaryExpression(ShiftExpression, >>, AdditiveExpression)을 반환한다.

13.9.3 부호 없는 우측 시프트 연산자 ( >>> )

Note

왼쪽 피연산자에 대해 오른쪽 피연산자가 지정한 양만큼 0 확장 비트 단위 오른쪽 시프트 연산을 수행한다.

13.9.3.1 Runtime Semantics: Evaluation

ShiftExpression : ShiftExpression >>> AdditiveExpression
  1. EvaluateStringOrNumericBinaryExpression(ShiftExpression, >>>, AdditiveExpression)을 반환한다.

13.10 관계 연산자

Note 1

관계 연산자를 평가한 결과는 언제나 Boolean 타입이며, 연산자가 이름 붙인 관계가 두 피연산자 사이에 성립하는지를 반영한다.

구문

RelationalExpression[In, Yield, Await] : ShiftExpression[?Yield, ?Await] RelationalExpression[?In, ?Yield, ?Await] < ShiftExpression[?Yield, ?Await] RelationalExpression[?In, ?Yield, ?Await] > ShiftExpression[?Yield, ?Await] RelationalExpression[?In, ?Yield, ?Await] <= ShiftExpression[?Yield, ?Await] RelationalExpression[?In, ?Yield, ?Await] >= ShiftExpression[?Yield, ?Await] RelationalExpression[?In, ?Yield, ?Await] instanceof ShiftExpression[?Yield, ?Await] [+In] RelationalExpression[+In, ?Yield, ?Await] in ShiftExpression[?Yield, ?Await] [+In] PrivateIdentifier in ShiftExpression[?Yield, ?Await] Note 2

[In] 문법 매개변수는 관계 표현식의 in 연산자와 for 문 안의 in 연산자를 혼동하지 않도록 하기 위해 필요하다.

13.10.1 Runtime Semantics: Evaluation

RelationalExpression : RelationalExpression < ShiftExpression
  1. lRefRelationalExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefShiftExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. result를 ? IsLessThan(lVal, rVal, true)라고 하자.
  6. resultundefined이면 false를 반환한다.
  7. result를 반환한다.
RelationalExpression : RelationalExpression > ShiftExpression
  1. lRefRelationalExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefShiftExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. result를 ? IsLessThan(rVal, lVal, false)라고 하자.
  6. resultundefined이면 false를 반환한다.
  7. result를 반환한다.
RelationalExpression : RelationalExpression <= ShiftExpression
  1. lRefRelationalExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefShiftExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. result를 ? IsLessThan(rVal, lVal, false)라고 하자.
  6. resulttrue 또는 undefined 중 하나이면 false를 반환한다.
  7. true를 반환한다.
RelationalExpression : RelationalExpression >= ShiftExpression
  1. lRefRelationalExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefShiftExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. result를 ? IsLessThan(lVal, rVal, true)라고 하자.
  6. resulttrue 또는 undefined 중 하나이면 false를 반환한다.
  7. true를 반환한다.
RelationalExpression : RelationalExpression instanceof ShiftExpression
  1. lRefRelationalExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefShiftExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. InstanceofOperator(lVal, rVal)를 반환한다.
RelationalExpression : RelationalExpression in ShiftExpression
  1. lRefRelationalExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefShiftExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. rVal가 Object가 아니면 TypeError 예외를 던진다.
  6. HasProperty(rVal, ? ToPropertyKey(lVal))를 반환한다.
RelationalExpression : PrivateIdentifier in ShiftExpression
  1. privateIdentifierPrivateIdentifierStringValue라고 하자.
  2. rRefShiftExpressionEvaluation 결과 ?라고 하자.
  3. rVal를 ? GetValue(rRef)라고 하자.
  4. rVal가 Object가 아니면 TypeError 예외를 던진다.
  5. privateEnv를 현재 실행 중인 execution context의 PrivateEnvironment라고 하자.
  6. Assert: privateEnvnull이 아니다.
  7. privateNameResolvePrivateIdentifier(privateEnv, privateIdentifier)라고 하자.
  8. PrivateElementFind(rVal, privateName)가 empty이면 false를 반환한다.
  9. true를 반환한다.

13.10.2 InstanceofOperator ( value, target )

The abstract operation InstanceofOperator takes arguments value (an ECMAScript language value) and target (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. 이것은 valuetarget의 인스턴스인지 결정하는 일반 알고리즘을 구현하는데, target%Symbol.hasInstance% 메서드를 조회하거나, 그것이 없으면 target"prototype" 프로퍼티 값이 value의 프로토타입 체인 안에 존재하는지를 결정한다. It performs the following steps when called:

  1. target이 Object가 아니면 TypeError 예외를 던진다.
  2. instOfHandler를 ? GetMethod(target, %Symbol.hasInstance%)라고 하자.
  3. instOfHandlerundefined가 아니면,
    1. ToBoolean(? Call(instOfHandler, target, « value »))를 반환한다.
  4. IsCallable(target)가 false이면 TypeError 예외를 던진다.
  5. OrdinaryHasInstance(target, value)를 반환한다.
Note

단계 45instanceof 연산자 의미론을 정의하기 위해 %Symbol.hasInstance% 메서드를 사용하지 않았던 이전 ECMAScript 판과의 호환성을 제공한다. 객체가 %Symbol.hasInstance%를 정의하거나 상속하지 않으면 기본 instanceof 의미론을 사용한다.

13.11 동등 연산자

Note

동등 연산자를 평가한 결과는 언제나 Boolean 타입이며, 연산자가 이름 붙인 관계가 두 피연산자 사이에 성립하는지를 반영한다.

구문

EqualityExpression[In, Yield, Await] : RelationalExpression[?In, ?Yield, ?Await] EqualityExpression[?In, ?Yield, ?Await] == RelationalExpression[?In, ?Yield, ?Await] EqualityExpression[?In, ?Yield, ?Await] != RelationalExpression[?In, ?Yield, ?Await] EqualityExpression[?In, ?Yield, ?Await] === RelationalExpression[?In, ?Yield, ?Await] EqualityExpression[?In, ?Yield, ?Await] !== RelationalExpression[?In, ?Yield, ?Await]

13.11.1 Runtime Semantics: Evaluation

EqualityExpression : EqualityExpression == RelationalExpression
  1. lRefEqualityExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefRelationalExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. IsLooselyEqual(rVal, lVal)를 반환한다.
EqualityExpression : EqualityExpression != RelationalExpression
  1. lRefEqualityExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefRelationalExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. r를 ? IsLooselyEqual(rVal, lVal)라고 하자.
  6. rtrue이면 false를 반환한다.
  7. true를 반환한다.
EqualityExpression : EqualityExpression === RelationalExpression
  1. lRefEqualityExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefRelationalExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. IsStrictlyEqual(rVal, lVal)를 반환한다.
EqualityExpression : EqualityExpression !== RelationalExpression
  1. lRefEqualityExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefRelationalExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. rIsStrictlyEqual(rVal, lVal)라고 하자.
  6. rtrue이면 false를 반환한다.
  7. true를 반환한다.
Note 1

동등 연산자는 다음 불변식을 유지한다:

  • A != B!(A == B)와 동등하다.
  • A == BAB의 평가 순서를 제외하면 B == A와 동등하다.
Note 2

동등 연산자는 항상 추이적이지는 않다. 예를 들어, 같은 String 값을 나타내는 서로 다른 두 String 객체가 있을 수 있다; 각 String 객체는 == 연산자에 의해 그 String 값과는 같다고 간주되지만, 두 String 객체는 서로 같지 않다. 예를 들어:

  • new String("a") == "a""a" == new String("a")는 둘 다 true이다.
  • new String("a") == new String("a")false이다.
Note 3

String 비교는 코드 단위 값 시퀀스에 대한 단순한 동등성 테스트를 사용한다. Unicode 명세에 정의된 보다 복잡하고 의미 지향적인 문자 또는 문자열 동등성 및 정렬 순서 정의를 사용하려는 시도는 없다. 따라서 Unicode Standard에 따라 canonical equal한 String 값들이 서로 같지 않게 테스트될 수 있다. 실제로 이 알고리즘은 두 String이 이미 정규화된 형태라고 가정한다.

13.12 이항 비트 연산자

구문

BitwiseANDExpression[In, Yield, Await] : EqualityExpression[?In, ?Yield, ?Await] BitwiseANDExpression[?In, ?Yield, ?Await] & EqualityExpression[?In, ?Yield, ?Await] BitwiseXORExpression[In, Yield, Await] : BitwiseANDExpression[?In, ?Yield, ?Await] BitwiseXORExpression[?In, ?Yield, ?Await] ^ BitwiseANDExpression[?In, ?Yield, ?Await] BitwiseORExpression[In, Yield, Await] : BitwiseXORExpression[?In, ?Yield, ?Await] BitwiseORExpression[?In, ?Yield, ?Await] | BitwiseXORExpression[?In, ?Yield, ?Await]

13.12.1 Runtime Semantics: Evaluation

BitwiseANDExpression : BitwiseANDExpression & EqualityExpression
  1. EvaluateStringOrNumericBinaryExpression(BitwiseANDExpression, &, EqualityExpression)을 반환한다.
BitwiseXORExpression : BitwiseXORExpression ^ BitwiseANDExpression
  1. EvaluateStringOrNumericBinaryExpression(BitwiseXORExpression, ^, BitwiseANDExpression)을 반환한다.
BitwiseORExpression : BitwiseORExpression | BitwiseXORExpression
  1. EvaluateStringOrNumericBinaryExpression(BitwiseORExpression, |, BitwiseXORExpression)을 반환한다.

13.13 이항 논리 연산자

구문

LogicalANDExpression[In, Yield, Await] : BitwiseORExpression[?In, ?Yield, ?Await] LogicalANDExpression[?In, ?Yield, ?Await] && BitwiseORExpression[?In, ?Yield, ?Await] LogicalORExpression[In, Yield, Await] : LogicalANDExpression[?In, ?Yield, ?Await] LogicalORExpression[?In, ?Yield, ?Await] || LogicalANDExpression[?In, ?Yield, ?Await] CoalesceExpression[In, Yield, Await] : CoalesceExpressionHead[?In, ?Yield, ?Await] ?? BitwiseORExpression[?In, ?Yield, ?Await] CoalesceExpressionHead[In, Yield, Await] : CoalesceExpression[?In, ?Yield, ?Await] BitwiseORExpression[?In, ?Yield, ?Await] ShortCircuitExpression[In, Yield, Await] : LogicalORExpression[?In, ?Yield, ?Await] CoalesceExpression[?In, ?Yield, ?Await] Note

&& 또는 || 연산자가 생성하는 값은 반드시 Boolean 타입일 필요는 없다. 생성되는 값은 언제나 두 피연산자 표현식 중 하나의 값이다.

13.13.1 Runtime Semantics: Evaluation

LogicalANDExpression : LogicalANDExpression && BitwiseORExpression
  1. lRefLogicalANDExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. ToBoolean(lVal)가 false이면, lVal를 반환한다.
  4. rRefBitwiseORExpressionEvaluation 결과 ?라고 하자.
  5. GetValue(rRef)를 반환한다.
LogicalORExpression : LogicalORExpression || LogicalANDExpression
  1. lRefLogicalORExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. ToBoolean(lVal)가 true이면, lVal를 반환한다.
  4. rRefLogicalANDExpressionEvaluation 결과 ?라고 하자.
  5. GetValue(rRef)를 반환한다.
CoalesceExpression : CoalesceExpressionHead ?? BitwiseORExpression
  1. lRefCoalesceExpressionHeadEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. lValundefined도 아니고 null도 아니면, lVal를 반환한다.
  4. rRefBitwiseORExpressionEvaluation 결과 ?라고 하자.
  5. GetValue(rRef)를 반환한다.

13.14 조건 연산자 ( ? : )

구문

ConditionalExpression[In, Yield, Await] : ShortCircuitExpression[?In, ?Yield, ?Await] ShortCircuitExpression[?In, ?Yield, ?Await] ? AssignmentExpression[+In, ?Yield, ?Await] : AssignmentExpression[?In, ?Yield, ?Await] Note

ECMAScript의 ConditionalExpression 문법은 C와 Java의 그것과 약간 다르며, 이 둘은 각각 두 번째 하위 표현식으로 Expression을 허용하지만 세 번째 표현식은 ConditionalExpression으로 제한한다. ECMAScript에서 이 차이의 동기는 조건식의 어느 쪽 가지에도 대입 표현식이 오도록 허용하고, 가운데 표현식이 콤마 표현식인 혼란스럽고 거의 쓸모없는 경우를 제거하기 위함이다.

13.14.1 Runtime Semantics: Evaluation

ConditionalExpression : ShortCircuitExpression ? AssignmentExpression : AssignmentExpression
  1. lRefShortCircuitExpressionEvaluation 결과 ?라고 하자.
  2. lValToBoolean(? GetValue(lRef))라고 하자.
  3. lValtrue이면,
    1. trueRef를 첫 번째 AssignmentExpressionEvaluation 결과 ?라고 하자.
    2. GetValue(trueRef)를 반환한다.
  4. falseRef를 두 번째 AssignmentExpressionEvaluation 결과 ?라고 하자.
  5. GetValue(falseRef)를 반환한다.

13.15 대입 연산자

구문

AssignmentExpression[In, Yield, Await] : ConditionalExpression[?In, ?Yield, ?Await] [+Yield] YieldExpression[?In, ?Await] ArrowFunction[?In, ?Yield, ?Await] AsyncArrowFunction[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await] = AssignmentExpression[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await] AssignmentOperator AssignmentExpression[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await] &&= AssignmentExpression[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await] ||= AssignmentExpression[?In, ?Yield, ?Await] LeftHandSideExpression[?Yield, ?Await] ??= AssignmentExpression[?In, ?Yield, ?Await] AssignmentOperator : one of *= /= %= += -= <<= >>= >>>= &= ^= |= **=

13.15.1 Static Semantics: Early Errors

AssignmentExpression : LeftHandSideExpression = AssignmentExpression AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression LeftHandSideExpression ||= AssignmentExpression LeftHandSideExpression ??= AssignmentExpression

13.15.2 Runtime Semantics: Evaluation

AssignmentExpression : LeftHandSideExpression = AssignmentExpression
  1. LeftHandSideExpressionObjectLiteralArrayLiteral도 아니면,
    1. lRefLeftHandSideExpressionEvaluation 결과 ?라고 하자.
    2. LeftHandSideExpressionAssignmentTargetTypeweb-compat이면, ReferenceError 예외를 던진다.
    3. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 IsIdentifierRef of LeftHandSideExpressiontrue이면,
      1. lhsLeftHandSideExpressionStringValue라고 하자.
      2. rVal를 인수 lhs를 사용한 AssignmentExpressionNamedEvaluation 결과 ?라고 하자.
    4. 그렇지 않으면,
      1. rRefAssignmentExpressionEvaluation 결과 ?라고 하자.
      2. rVal를 ? GetValue(rRef)라고 하자.
    5. PutValue(lRef, rVal)를 수행한다.
    6. rVal를 반환한다.
  2. assignmentPatternLeftHandSideExpression이 커버하는 AssignmentPattern이라고 하자.
  3. rRefAssignmentExpressionEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. 인수 rVal를 사용한 assignmentPatternDestructuringAssignmentEvaluation을 ? 수행한다.
  6. rVal를 반환한다.
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
  1. lRefLeftHandSideExpressionEvaluation 결과 ?라고 하자.
  2. LeftHandSideExpressionAssignmentTargetTypeweb-compat이면, ReferenceError 예외를 던진다.
  3. lVal를 ? GetValue(lRef)라고 하자.
  4. rRefAssignmentExpressionEvaluation 결과 ?라고 하자.
  5. rVal를 ? GetValue(rRef)라고 하자.
  6. assignmentOpTextAssignmentOperator에 매치된 소스 텍스트라고 하자.
  7. opText를 다음 표에서 assignmentOpText와 연관된 유니코드 코드 포인트 시퀀스라고 하자:
    assignmentOpText opText
    **= **
    *= *
    /= /
    %= %
    += +
    -= -
    <<= <<
    >>= >>
    >>>= >>>
    &= &
    ^= ^
    |= |
  8. r를 ? ApplyStringOrNumericBinaryOperator(lVal, opText, rVal)라고 하자.
  9. PutValue(lRef, r)를 수행한다.
  10. r를 반환한다.
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
  1. lRefLeftHandSideExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. ToBoolean(lVal)가 false이면, lVal를 반환한다.
  4. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 IsIdentifierRef of LeftHandSideExpressiontrue이면,
    1. lhsLeftHandSideExpressionStringValue라고 하자.
    2. rVal를 인수 lhs를 사용한 AssignmentExpressionNamedEvaluation 결과 ?라고 하자.
  5. 그렇지 않으면,
    1. rRefAssignmentExpressionEvaluation 결과 ?라고 하자.
    2. rVal를 ? GetValue(rRef)라고 하자.
  6. PutValue(lRef, rVal)를 수행한다.
  7. rVal를 반환한다.
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
  1. lRefLeftHandSideExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. ToBoolean(lVal)가 true이면, lVal를 반환한다.
  4. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 IsIdentifierRef of LeftHandSideExpressiontrue이면,
    1. lhsLeftHandSideExpressionStringValue라고 하자.
    2. rVal를 인수 lhs를 사용한 AssignmentExpressionNamedEvaluation 결과 ?라고 하자.
  5. 그렇지 않으면,
    1. rRefAssignmentExpressionEvaluation 결과 ?라고 하자.
    2. rVal를 ? GetValue(rRef)라고 하자.
  6. PutValue(lRef, rVal)를 수행한다.
  7. rVal를 반환한다.
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
  1. lRefLeftHandSideExpressionEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. lValundefined도 아니고 null도 아니면, lVal를 반환한다.
  4. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 IsIdentifierRef of LeftHandSideExpressiontrue이면,
    1. lhsLeftHandSideExpressionStringValue라고 하자.
    2. rVal를 인수 lhs를 사용한 AssignmentExpressionNamedEvaluation 결과 ?라고 하자.
  5. 그렇지 않으면,
    1. rRefAssignmentExpressionEvaluation 결과 ?라고 하자.
    2. rVal를 ? GetValue(rRef)라고 하자.
  6. PutValue(lRef, rVal)를 수행한다.
  7. rVal를 반환한다.
Note

이 표현식이 strict mode 코드 안에 나타날 때, 단계 1.e, 3, 2, 2, 2에서의 lRef가 해석 불가능한 참조이면 런타임 오류이다. 그런 경우 ReferenceError 예외가 던져진다. 또한 단계 9, 6, 6, 6에서의 lRef가 { [[Writable]]: false } 속성 값을 가진 데이터 프로퍼티, { [[Set]]: undefined } 속성 값을 가진 접근자 프로퍼티, 또는 IsExtensible 판정이 false를 반환하는 객체의 존재하지 않는 프로퍼티에 대한 참조이면 런타임 오류이다. 이 경우 TypeError 예외가 던져진다.

13.15.3 ApplyStringOrNumericBinaryOperator ( lVal, opText, rVal )

The abstract operation ApplyStringOrNumericBinaryOperator takes arguments lVal (an ECMAScript language value), opText (**, *, /, %, +, -, <<, >>, >>>, &, ^, or |), and rVal (an ECMAScript language value) and returns either a normal completion containing either a String, a BigInt, or a Number, or a throw completion. It performs the following steps when called:

  1. opText+이면,
    1. lPrim을 ? ToPrimitive(lVal)라고 하자.
    2. rPrim을 ? ToPrimitive(rVal)라고 하자.
    3. lPrim이 String이거나 rPrim이 String이면,
      1. lStr를 ? ToString(lPrim)라고 하자.
      2. rStr를 ? ToString(rPrim)라고 하자.
      3. lStrrStr의 문자열 연결을 반환한다.
    4. lVallPrim으로 설정한다.
    5. rValrPrim으로 설정한다.
  2. NOTE: 이 시점부터는 수치 연산이어야 한다.
  3. lNum을 ? ToNumeric(lVal)라고 하자.
  4. rNum을 ? ToNumeric(rVal)라고 하자.
  5. SameType(lNum, rNum)이 false이면 TypeError 예외를 던진다.
  6. lNum이 BigInt이면,
    1. opText**이면, ? BigInt::exponentiate(lNum, rNum)를 반환한다.
    2. opText/이면, ? BigInt::divide(lNum, rNum)를 반환한다.
    3. opText%이면, ? BigInt::remainder(lNum, rNum)를 반환한다.
    4. opText>>>이면, ? BigInt::unsignedRightShift(lNum, rNum)를 반환한다.
    5. operation을 다음 표에서 opText와 연관된 추상 연산이라고 하자:
      opText operation
      * BigInt::multiply
      + BigInt::add
      - BigInt::subtract
      << BigInt::leftShift
      >> BigInt::signedRightShift
      & BigInt::bitwiseAND
      ^ BigInt::bitwiseXOR
      | BigInt::bitwiseOR
  7. 그렇지 않으면,
    1. Assert: lNum은 Number이다.
    2. operation을 다음 표에서 opText와 연관된 추상 연산이라고 하자:
      opText operation
      ** Number::exponentiate
      * Number::multiply
      / Number::divide
      % Number::remainder
      + Number::add
      - Number::subtract
      << Number::leftShift
      >> Number::signedRightShift
      >>> Number::unsignedRightShift
      & Number::bitwiseAND
      ^ Number::bitwiseXOR
      | Number::bitwiseOR
  8. operation(lNum, rNum)를 반환한다.
Note 1

단계 1.a1.b에서 ToPrimitive 호출에는 힌트가 제공되지 않는다. Date를 제외한 모든 표준 객체는 힌트가 없는 경우 number가 주어진 것처럼 처리한다; Date는 힌트가 없는 경우 string이 주어진 것처럼 처리한다. 이색 객체는 힌트의 부재를 다른 방식으로 처리할 수 있다.

Note 2

단계 1.c는 논리곱 대신 논리합 연산을 사용한다는 점에서 IsLessThan 알고리즘의 단계 3와 다르다.

13.15.4 EvaluateStringOrNumericBinaryExpression ( leftOperand, opText, rightOperand )

The abstract operation EvaluateStringOrNumericBinaryExpression takes arguments leftOperand (a Parse Node), opText (**, *, /, %, +, -, <<, >>, >>>, &, ^, or |), and rightOperand (a Parse Node) and returns either a normal completion containing either a String, a BigInt, or a Number, or an abrupt completion. It performs the following steps when called:

  1. lRefleftOperandEvaluation 결과 ?라고 하자.
  2. lVal를 ? GetValue(lRef)라고 하자.
  3. rRefrightOperandEvaluation 결과 ?라고 하자.
  4. rVal를 ? GetValue(rRef)라고 하자.
  5. ApplyStringOrNumericBinaryOperator(lVal, opText, rVal)를 반환한다.

13.15.5 구조 분해 대입

보충 구문

특정 상황에서 production의 인스턴스를 처리할 때
AssignmentExpression : LeftHandSideExpression = AssignmentExpression
LeftHandSideExpression의 해석은 다음 문법을 사용하여 정제된다:

AssignmentPattern[Yield, Await] : ObjectAssignmentPattern[?Yield, ?Await] ArrayAssignmentPattern[?Yield, ?Await] ObjectAssignmentPattern[Yield, Await] : { } { AssignmentRestProperty[?Yield, ?Await] } { AssignmentPropertyList[?Yield, ?Await] } { AssignmentPropertyList[?Yield, ?Await] , AssignmentRestProperty[?Yield, ?Await]opt } ArrayAssignmentPattern[Yield, Await] : [ Elisionopt AssignmentRestElement[?Yield, ?Await]opt ] [ AssignmentElementList[?Yield, ?Await] ] [ AssignmentElementList[?Yield, ?Await] , Elisionopt AssignmentRestElement[?Yield, ?Await]opt ] AssignmentRestProperty[Yield, Await] : ... DestructuringAssignmentTarget[?Yield, ?Await] AssignmentPropertyList[Yield, Await] : AssignmentProperty[?Yield, ?Await] AssignmentPropertyList[?Yield, ?Await] , AssignmentProperty[?Yield, ?Await] AssignmentElementList[Yield, Await] : AssignmentElisionElement[?Yield, ?Await] AssignmentElementList[?Yield, ?Await] , AssignmentElisionElement[?Yield, ?Await] AssignmentElisionElement[Yield, Await] : Elisionopt AssignmentElement[?Yield, ?Await] AssignmentProperty[Yield, Await] : IdentifierReference[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt PropertyName[?Yield, ?Await] : AssignmentElement[?Yield, ?Await] AssignmentElement[Yield, Await] : DestructuringAssignmentTarget[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt AssignmentRestElement[Yield, Await] : ... DestructuringAssignmentTarget[?Yield, ?Await] DestructuringAssignmentTarget[Yield, Await] : LeftHandSideExpression[?Yield, ?Await]

13.15.5.1 Static Semantics: Early Errors

AssignmentProperty : IdentifierReference Initializeropt AssignmentRestProperty : ... DestructuringAssignmentTarget DestructuringAssignmentTarget : LeftHandSideExpression

13.15.5.2 Runtime Semantics: DestructuringAssignmentEvaluation

The syntax-directed operation DestructuringAssignmentEvaluation takes argument value (an ECMAScript language value) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

ObjectAssignmentPattern : { }
  1. RequireObjectCoercible(value)를 수행한다.
  2. unused를 반환한다.
ObjectAssignmentPattern : { AssignmentPropertyList } { AssignmentPropertyList , }
  1. RequireObjectCoercible(value)를 수행한다.
  2. 인수 value를 사용한 AssignmentPropertyListPropertyDestructuringAssignmentEvaluation을 ? 수행한다.
  3. unused를 반환한다.
ObjectAssignmentPattern : { AssignmentRestProperty }
  1. RequireObjectCoercible(value)를 수행한다.
  2. excludedNames를 새로운 빈 List라고 하자.
  3. 인수 valueexcludedNames를 사용한 AssignmentRestPropertyRestDestructuringAssignmentEvaluation을 ? 반환한다.
ObjectAssignmentPattern : { AssignmentPropertyList , AssignmentRestProperty }
  1. RequireObjectCoercible(value)를 수행한다.
  2. excludedNames를 인수 value를 사용한 AssignmentPropertyListPropertyDestructuringAssignmentEvaluation 결과 ?라고 하자.
  3. 인수 valueexcludedNames를 사용한 AssignmentRestPropertyRestDestructuringAssignmentEvaluation을 ? 반환한다.
ArrayAssignmentPattern : [ ]
  1. iteratorRecord를 ? GetIterator(value, sync)라고 하자.
  2. IteratorClose(iteratorRecord, NormalCompletion(unused))를 반환한다.
ArrayAssignmentPattern : [ Elision ]
  1. iteratorRecord를 ? GetIterator(value, sync)라고 하자.
  2. result를 인수 iteratorRecord를 사용한 ElisionIteratorDestructuringAssignmentEvaluationCompletion이라고 하자.
  3. iteratorRecord.[[Done]]false이면, ? IteratorClose(iteratorRecord, result)를 반환한다.
  4. result를 반환한다.
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
  1. iteratorRecord를 ? GetIterator(value, sync)라고 하자.
  2. Elision이 존재하면,
    1. status를 인수 iteratorRecord를 사용한 ElisionIteratorDestructuringAssignmentEvaluationCompletion이라고 하자.
    2. statusabrupt completion이면,
      1. Assert: iteratorRecord.[[Done]]true이다.
      2. status를 반환한다.
  3. result를 인수 iteratorRecord를 사용한 AssignmentRestElementIteratorDestructuringAssignmentEvaluationCompletion이라고 하자.
  4. iteratorRecord.[[Done]]false이면, ? IteratorClose(iteratorRecord, result)를 반환한다.
  5. result를 반환한다.
ArrayAssignmentPattern : [ AssignmentElementList ]
  1. iteratorRecord를 ? GetIterator(value, sync)라고 하자.
  2. result를 인수 iteratorRecord를 사용한 AssignmentElementListIteratorDestructuringAssignmentEvaluationCompletion이라고 하자.
  3. iteratorRecord.[[Done]]false이면, ? IteratorClose(iteratorRecord, result)를 반환한다.
  4. result를 반환한다.
ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
  1. iteratorRecord를 ? GetIterator(value, sync)라고 하자.
  2. status를 인수 iteratorRecord를 사용한 AssignmentElementListIteratorDestructuringAssignmentEvaluationCompletion이라고 하자.
  3. statusabrupt completion이면,
    1. iteratorRecord.[[Done]]false이면, ? IteratorClose(iteratorRecord, status)를 반환한다.
    2. status를 반환한다.
  4. Elision이 존재하면,
    1. status를 인수 iteratorRecord를 사용한 ElisionIteratorDestructuringAssignmentEvaluationCompletion으로 설정한다.
    2. statusabrupt completion이면,
      1. Assert: iteratorRecord.[[Done]]true이다.
      2. status를 반환한다.
  5. AssignmentRestElement이 존재하면,
    1. status를 인수 iteratorRecord를 사용한 AssignmentRestElementIteratorDestructuringAssignmentEvaluationCompletion으로 설정한다.
  6. iteratorRecord.[[Done]]false이면, ? IteratorClose(iteratorRecord, status)를 반환한다.
  7. status를 반환한다.

13.15.5.3 Runtime Semantics: PropertyDestructuringAssignmentEvaluation

The syntax-directed operation PropertyDestructuringAssignmentEvaluation takes argument value (an ECMAScript language value) and returns either a normal completion containing a List of property keys or an abrupt completion. 이것은 구조 분해된 모든 프로퍼티 키의 리스트를 수집한다. It is defined piecewise over the following productions:

AssignmentPropertyList : AssignmentPropertyList , AssignmentProperty
  1. propertyNames를 인수 value를 사용한 AssignmentPropertyListPropertyDestructuringAssignmentEvaluation 결과 ?라고 하자.
  2. nextNames를 인수 value를 사용한 AssignmentPropertyPropertyDestructuringAssignmentEvaluation 결과 ?라고 하자.
  3. propertyNamesnextNameslist-concatenation을 반환한다.
AssignmentProperty : IdentifierReference Initializeropt
  1. propertyNameIdentifierReferenceStringValue라고 하자.
  2. lRef를 ? ResolveBinding(propertyName)이라고 하자.
  3. v를 ? GetV(value, propertyName)라고 하자.
  4. Initializer가 존재하고 vundefined이면,
    1. IsAnonymousFunctionDefinition(Initializer)이 true이면,
      1. v를 인수 propertyName을 사용한 InitializerNamedEvaluation 결과 ?로 설정한다.
    2. 그렇지 않으면,
      1. defaultValueInitializerEvaluation 결과 ?라고 하자.
      2. v를 ? GetValue(defaultValue)로 설정한다.
  5. PutValue(lRef, v)를 수행한다.
  6. « propertyName »를 반환한다.
AssignmentProperty : PropertyName : AssignmentElement
  1. namePropertyNameEvaluation 결과 ?라고 하자.
  2. 인수 valuename을 사용한 AssignmentElementKeyedDestructuringAssignmentEvaluation을 ? 수행한다.
  3. « name »를 반환한다.

13.15.5.4 Runtime Semantics: RestDestructuringAssignmentEvaluation

The syntax-directed operation RestDestructuringAssignmentEvaluation takes arguments value (an ECMAScript language value) and excludedNames (a List of property keys) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

AssignmentRestProperty : ... DestructuringAssignmentTarget
  1. lRefDestructuringAssignmentTargetEvaluation 결과 ?라고 하자.
  2. restObjOrdinaryObjectCreate(%Object.prototype%)라고 하자.
  3. CopyDataProperties(restObj, value, excludedNames)를 수행한다.
  4. PutValue(lRef, restObj)를 반환한다.

13.15.5.5 Runtime Semantics: IteratorDestructuringAssignmentEvaluation

The syntax-directed operation IteratorDestructuringAssignmentEvaluation takes argument iteratorRecord (an Iterator Record) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

AssignmentElementList : AssignmentElisionElement
  1. 인수 iteratorRecord를 사용한 AssignmentElisionElementIteratorDestructuringAssignmentEvaluation을 ? 반환한다.
AssignmentElementList : AssignmentElementList , AssignmentElisionElement
  1. 인수 iteratorRecord를 사용한 AssignmentElementListIteratorDestructuringAssignmentEvaluation을 ? 수행한다.
  2. 인수 iteratorRecord를 사용한 AssignmentElisionElementIteratorDestructuringAssignmentEvaluation을 ? 반환한다.
AssignmentElisionElement : AssignmentElement
  1. 인수 iteratorRecord를 사용한 AssignmentElementIteratorDestructuringAssignmentEvaluation을 ? 반환한다.
AssignmentElisionElement : Elision AssignmentElement
  1. 인수 iteratorRecord를 사용한 ElisionIteratorDestructuringAssignmentEvaluation을 ? 수행한다.
  2. 인수 iteratorRecord를 사용한 AssignmentElementIteratorDestructuringAssignmentEvaluation을 ? 반환한다.
Elision : ,
  1. iteratorRecord.[[Done]]false이면,
    1. IteratorStep(iteratorRecord)를 수행한다.
  2. unused를 반환한다.
Elision : Elision ,
  1. 인수 iteratorRecord를 사용한 ElisionIteratorDestructuringAssignmentEvaluation을 ? 수행한다.
  2. iteratorRecord.[[Done]]false이면,
    1. IteratorStep(iteratorRecord)를 수행한다.
  3. unused를 반환한다.
AssignmentElement : DestructuringAssignmentTarget Initializeropt
  1. DestructuringAssignmentTargetObjectLiteral도 아니고 ArrayLiteral도 아니면,
    1. lRefDestructuringAssignmentTargetEvaluation 결과 ?라고 하자.
  2. valueundefined라고 하자.
  3. iteratorRecord.[[Done]]false이면,
    1. next를 ? IteratorStepValue(iteratorRecord)라고 하자.
    2. nextdone가 아니면,
      1. valuenext로 설정한다.
  4. Initializer가 존재하고 valueundefined이면,
    1. IsAnonymousFunctionDefinition(Initializer)이 true이고 IsIdentifierRef of DestructuringAssignmentTargettrue이면,
      1. targetDestructuringAssignmentTargetStringValue라고 하자.
      2. v를 인수 target을 사용한 InitializerNamedEvaluation 결과 ?라고 하자.
    2. 그렇지 않으면,
      1. defaultValueInitializerEvaluation 결과 ?라고 하자.
      2. v를 ? GetValue(defaultValue)라고 하자.
  5. 그렇지 않으면,
    1. vvalue라고 하자.
  6. DestructuringAssignmentTargetObjectLiteral 또는 ArrayLiteral 중 하나이면,
    1. nestedAssignmentPatternDestructuringAssignmentTarget이 커버하는 AssignmentPattern이라고 하자.
    2. 인수 v를 사용한 nestedAssignmentPatternDestructuringAssignmentEvaluation을 ? 반환한다.
  7. PutValue(lRef, v)를 반환한다.
Note

좌에서 우로의 평가 순서는, 구조 분해 패턴이 아닌 DestructuringAssignmentTarget을 이터레이터 접근이나 Initializer 평가보다 먼저 평가함으로써 유지된다.

AssignmentRestElement : ... DestructuringAssignmentTarget
  1. DestructuringAssignmentTargetObjectLiteral도 아니고 ArrayLiteral도 아니면,
    1. lRefDestructuringAssignmentTargetEvaluation 결과 ?라고 하자.
  2. array를 ! ArrayCreate(0)라고 하자.
  3. n을 0이라고 하자.
  4. iteratorRecord.[[Done]]false인 동안, 다음을 반복한다
    1. next를 ? IteratorStepValue(iteratorRecord)라고 하자.
    2. nextdone가 아니면,
      1. CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), next)를 수행한다.
      2. nn + 1로 설정한다.
  5. DestructuringAssignmentTargetObjectLiteral도 아니고 ArrayLiteral도 아니면,
    1. PutValue(lRef, array)를 반환한다.
  6. nestedAssignmentPatternDestructuringAssignmentTarget이 커버하는 AssignmentPattern이라고 하자.
  7. 인수 array를 사용한 nestedAssignmentPatternDestructuringAssignmentEvaluation을 ? 반환한다.

13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation

The syntax-directed operation KeyedDestructuringAssignmentEvaluation takes arguments value (an ECMAScript language value) and propertyName (a property key) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

AssignmentElement : DestructuringAssignmentTarget Initializeropt
  1. DestructuringAssignmentTargetObjectLiteral도 아니고 ArrayLiteral도 아니면,
    1. lRefDestructuringAssignmentTargetEvaluation 결과 ?라고 하자.
  2. v를 ? GetV(value, propertyName)라고 하자.
  3. Initializer가 존재하고 vundefined이면,
    1. IsAnonymousFunctionDefinition(Initializer)이 true이고 IsIdentifierRef of DestructuringAssignmentTargettrue이면,
      1. targetDestructuringAssignmentTargetStringValue라고 하자.
      2. rhsValue를 인수 target을 사용한 InitializerNamedEvaluation 결과 ?라고 하자.
    2. 그렇지 않으면,
      1. defaultValueInitializerEvaluation 결과 ?라고 하자.
      2. rhsValue를 ? GetValue(defaultValue)라고 하자.
  4. 그렇지 않으면,
    1. rhsValuev라고 하자.
  5. DestructuringAssignmentTargetObjectLiteral 또는 ArrayLiteral 중 하나이면,
    1. assignmentPatternDestructuringAssignmentTarget이 커버하는 AssignmentPattern이라고 하자.
    2. 인수 rhsValue를 사용한 assignmentPatternDestructuringAssignmentEvaluation을 ? 반환한다.
  6. PutValue(lRef, rhsValue)를 반환한다.

13.16 콤마 연산자 ( , )

구문

Expression[In, Yield, Await] : AssignmentExpression[?In, ?Yield, ?Await] Expression[?In, ?Yield, ?Await] , AssignmentExpression[?In, ?Yield, ?Await]

13.16.1 Runtime Semantics: Evaluation

Expression : Expression , AssignmentExpression
  1. lRefExpressionEvaluation 결과 ?라고 하자.
  2. GetValue(lRef)를 수행한다.
  3. rRefAssignmentExpressionEvaluation 결과 ?라고 하자.
  4. GetValue(rRef)를 반환한다.
Note

GetValue의 값은 사용되지 않더라도 관찰 가능한 부작용이 있을 수 있으므로 반드시 호출해야 한다.