페이지 표시 설정

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 참고

yield와 await는 다음과 같은 경우 자동 세미콜론 삽입을 금지하기 위해 문법에서는 BindingIdentifier로 허용되고 아래의 정적 의미론에서 금지됩니다.

let
await 0;

13.1.1 Static Semantics: 조기 오류

BindingIdentifier : Identifier IdentifierReference : yield BindingIdentifier : yield LabelIdentifier : yield
  • IsStrict(this production)이 true이면 Syntax Error입니다.
IdentifierReference : await BindingIdentifier : await LabelIdentifier : await BindingIdentifier[Yield, Await] : yield
  • 이 생성 규칙에 [Yield] 매개변수가 있으면 Syntax Error입니다.
BindingIdentifier[Yield, Await] : await
  • 이 생성 규칙에 [Await] 매개변수가 있으면 Syntax Error입니다.
IdentifierReference[Yield, Await] : Identifier BindingIdentifier[Yield, Await] : Identifier LabelIdentifier[Yield, Await] : Identifier
  • 이 생성 규칙에 [Yield] 매개변수가 있고 Identifier의 StringValue가 "yield"이면 Syntax Error입니다.
  • 이 생성 규칙에 [Await] 매개변수가 있고 Identifier의 StringValue가 "await"이면 Syntax Error입니다.
Identifier : IdentifierName but not ReservedWord 참고

IdentifierName의 StringValue는 IdentifierName 안의 모든 유니코드 이스케이프 시퀀스를 정규화하므로, 이러한 이스케이프를 사용하여 코드 포인트 시퀀스가 ReservedWord와 같은 Identifier를 작성할 수 없습니다.

13.1.2 Static Semantics: StringValue

구문 지향 연산 StringValue. 인수 없음. 반환값: String. 다음 생성 규칙별로 정의된다.

IdentifierName :: IdentifierStart IdentifierName IdentifierPart
  1. nameUnescaped를 IdentifierName의 IdentifierCodePoints로 둡니다.
  2. CodePointsToString(nameUnescaped)을 반환합니다.
IdentifierReference : yield BindingIdentifier : yield LabelIdentifier : yield
  1. "yield"를 반환합니다.
IdentifierReference : await BindingIdentifier : await LabelIdentifier : await
  1. "await"를 반환합니다.
Identifier : IdentifierName but not ReservedWord
  1. IdentifierName의 StringValue를 반환합니다.
PrivateIdentifier :: # IdentifierName
  1. 0x0023 (NUMBER SIGN)과 IdentifierName의 StringValue의 문자열 연결을 반환합니다.
ModuleExportName : StringLiteral
  1. StringLiteral의 SV를 반환합니다.

13.1.3 Runtime Semantics: 평가

IdentifierReference : Identifier
  1. ? ResolveBinding(Identifier의 StringValue)을 반환합니다.
IdentifierReference : yield
  1. ? ResolveBinding("yield")를 반환합니다.
IdentifierReference : await
  1. ? ResolveBinding("await")를 반환합니다.
참고 1

IdentifierReference를 평가한 결과는 항상 Reference 타입의 값입니다.

참고 2

비엄격 코드에서는 키워드 yield를 식별자로 사용할 수 있습니다. IdentifierReference를 평가하면 yield가 Identifier인 것처럼 그 바인딩을 해석합니다. 조기 오류 제한은 이러한 평가가 비엄격 코드에서만 발생할 수 있도록 보장합니다.

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] ,opt ) ( ... BindingIdentifier[?Yield, ?Await] ) ( ... BindingPattern[?Yield, ?Await] ) ( Expression[+In, ?Yield, ?Await] , ... BindingIdentifier[?Yield, ?Await] ) ( Expression[+In, ?Yield, ?Await] , ... BindingPattern[?Yield, ?Await] )

보충 구문

다음 생성 규칙의 인스턴스를 처리할 때
PrimaryExpression[Yield, Await] : CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await]
CoverParenthesizedExpressionAndArrowParameterList의 해석은 다음 문법을 사용하여 구체화됩니다:

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

13.2.1 this 키워드

13.2.1.1 Runtime Semantics: 평가

PrimaryExpression : this
  1. ? ResolveThisBinding()을 반환합니다.

13.2.2 식별자 참조

IdentifierReference에 대해서는 13.1를 참조하시기 바랍니다.

13.2.3 리터럴

구문

Literal : NullLiteral BooleanLiteral NumericLiteral StringLiteral

13.2.3.1 Runtime Semantics: 평가

Literal : NullLiteral
  1. null을 반환합니다.
Literal : BooleanLiteral
  1. BooleanLiteral이 토큰 false이면 false를 반환합니다.
  2. BooleanLiteral이 토큰 true이면 true를 반환합니다.
Literal : NumericLiteral
  1. 12.9.3에 정의된 NumericLiteral의 NumericValue를 반환합니다.
Literal : StringLiteral
  1. 12.9.4.2에 정의된 StringLiteral의 SV를 반환합니다.

13.2.4 Array 이니셜라이저

참고

ArrayLiteral은 대괄호 안에 배열 요소를 나타내는 0개 이상의 표현식 목록을 사용하여 Array의 초기화를 설명하는 표현식입니다. 요소가 반드시 리터럴일 필요는 없으며 배열 이니셜라이저가 평가될 때마다 평가됩니다.

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

구문 지향 연산 ArrayAccumulation. 인수 array (Array) 및 nextIndex (정수). 반환값: (정상 완료 (값: 정수) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

Elision : ,
  1. length를 nextIndex + 1로 둡니다.
  2. ? Set(array, "length", 𝔽(length), true)를 수행합니다.
  3. 참고: 위 단계는 length가 232 - 1을 초과하면 예외를 던집니다.
  4. length를 반환합니다.
Elision : Elision ,
  1. 인수 array 및 (nextIndex + 1)을 사용한 Elision의 ? ArrayAccumulation을 반환합니다.
ElementList : Elisionopt AssignmentExpression
  1. Elision이 존재하면, 다음을 수행합니다.
    1. nextIndex를 인수 array 및 nextIndex를 사용한 Elision의 ? ArrayAccumulation으로 설정합니다.
  2. initResult를 AssignmentExpression의 ? Evaluation으로 둡니다.
  3. initValue를 ? GetValue(initResult)로 둡니다.
  4. ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(nextIndex)), initValue)를 수행합니다.
  5. nextIndex + 1을 반환합니다.
ElementList : Elisionopt SpreadElement
  1. Elision이 존재하면, 다음을 수행합니다.
    1. nextIndex를 인수 array 및 nextIndex를 사용한 Elision의 ? ArrayAccumulation으로 설정합니다.
  2. 인수 array 및 nextIndex를 사용한 SpreadElement의 ? ArrayAccumulation을 반환합니다.
ElementList : ElementList , Elisionopt AssignmentExpression
  1. nextIndex를 인수 array 및 nextIndex를 사용한 파생된 ElementList의 ? ArrayAccumulation으로 설정합니다.
  2. Elision이 존재하면, 다음을 수행합니다.
    1. nextIndex를 인수 array 및 nextIndex를 사용한 Elision의 ? ArrayAccumulation으로 설정합니다.
  3. initResult를 AssignmentExpression의 ? Evaluation으로 둡니다.
  4. initValue를 ? GetValue(initResult)로 둡니다.
  5. ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(nextIndex)), initValue)를 수행합니다.
  6. nextIndex + 1을 반환합니다.
ElementList : ElementList , Elisionopt SpreadElement
  1. nextIndex를 인수 array 및 nextIndex를 사용한 파생된 ElementList의 ? ArrayAccumulation으로 설정합니다.
  2. Elision이 존재하면, 다음을 수행합니다.
    1. nextIndex를 인수 array 및 nextIndex를 사용한 Elision의 ? ArrayAccumulation으로 설정합니다.
  3. 인수 array 및 nextIndex를 사용한 SpreadElement의 ? ArrayAccumulation을 반환합니다.
SpreadElement : ... AssignmentExpression
  1. spreadRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
  2. spreadObj를 ? GetValue(spreadRef)로 둡니다.
  3. iteratorRecord를 ? GetIterator(spreadObj, sync)로 둡니다.
  4. 다음을 반복합니다.
    1. next를 ? IteratorStepValue(iteratorRecord)로 둡니다.
    2. next가 done이면 nextIndex를 반환합니다.
    3. ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(nextIndex)), next)를 수행합니다.
    4. nextIndex를 nextIndex + 1로 설정합니다.
참고

표준 내장 Array 프로토타입 객체가 [[Set]]을 사용한 새로운 자체 프로퍼티 생성을 방해하는 방식으로 수정되었더라도 배열에 자체 프로퍼티가 정의되도록 보장하기 위해 CreateDataPropertyOrThrow를 사용합니다.

13.2.4.2 Runtime Semantics: 평가

ArrayLiteral : [ Elisionopt ]
  1. array를 ! ArrayCreate(0)으로 둡니다.
  2. Elision이 존재하면, 다음을 수행합니다.
    1. 인수 array 및 0을 사용한 Elision의 ? ArrayAccumulation을 수행합니다.
  3. array를 반환합니다.
ArrayLiteral : [ ElementList ]
  1. array를 ! ArrayCreate(0)으로 둡니다.
  2. 인수 array 및 0을 사용한 ElementList의 ? ArrayAccumulation을 수행합니다.
  3. array를 반환합니다.
ArrayLiteral : [ ElementList , Elisionopt ]
  1. array를 ! ArrayCreate(0)으로 둡니다.
  2. nextIndex를 인수 array 및 0을 사용한 ElementList의 ? ArrayAccumulation으로 둡니다.
  3. Elision이 존재하면, 다음을 수행합니다.
    1. 인수 array 및 nextIndex를 사용한 Elision의 ? ArrayAccumulation을 수행합니다.
  4. array를 반환합니다.

13.2.5 Object 이니셜라이저

참고 1

객체 이니셜라이저는 리터럴과 유사한 형식으로 작성되어 Object의 초기화를 설명하는 표현식입니다. 중괄호 안에 프로퍼티 키와 연결된 값의 쌍을 0개 이상 나열합니다. 값은 반드시 리터럴일 필요가 없으며 객체 이니셜라이저가 평가될 때마다 평가됩니다.

구문

ObjectLiteral[Yield, Await] : { } { PropertyDefinitionList[?Yield, ?Await] ,opt } 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] 참고 2

MethodDefinition은 15.4에 정의되어 있습니다.

참고 3

CoverInitializedName의 의미는 다음 절을 참조하시기 바랍니다.

13.2.5.1 Static Semantics: 조기 오류

ObjectLiteral : { PropertyDefinitionList ,opt } 참고 1

PropertyNameList가 반환하는 List에는 ComputedPropertyName을 사용하여 정의된 프로퍼티 이름이 포함되지 않습니다.

PropertyDefinition : MethodDefinition PropertyDefinition : CoverInitializedName 참고 2

이 명세의 다른 위치에는 특정 상황에서 LeftHandSideExpression이 AssignmentPattern을 포괄해야 한다고 요구하는 조기 오류 규칙이 있습니다. 따라서 ObjectLiteral은 ObjectAssignmentPattern의 커버 문법 역할을 합니다. CoverInitializedName 생성 규칙은 AssignmentProperty를 완전히 포괄하는 데 필요하지만 실제 객체 이니셜라이저 안에서는 유효하지 않습니다.

구체적으로 실제 ObjectLiteral이 예상되는 문맥에서는 위 조기 오류 규칙이 CoverInitializedName 사용을 방지합니다. 그러나 ObjectLiteral이 커버 문법으로 사용되는 경우 “포괄해야 한다”의 의미론에 따라 ObjectLiteral 안의 Parse Node에는 조기 오류 규칙이 적용되지 않으므로 CoverInitializedName이 허용됩니다.

예를 들어 다음을 생각해 보시기 바랍니다:

let o = {f = 1};

{f = 1}은 CoverInitializedName을 갖는 ObjectLiteral로 파싱되며 이 조기 오류 규칙에 의해 Syntax Error가 발생합니다.

반대로 다음을 생각해 보시기 바랍니다:

({f = 1} = {f: 2});

여기에서도 {f = 1}은 처음에는 CoverInitializedName을 갖는 ObjectLiteral로 파싱되지만 AssignmentExpression의 LeftHandSideExpression이므로 AssignmentPattern을 포괄해야 합니다. 따라서 ObjectLiteral과 CoverInitializedName에는 조기 오류 규칙이 적용되지 않습니다. 대신 {f = 1}은 AssignmentProperty를 갖는 ObjectAssignmentPattern으로 다시 파싱되며 Syntax Error가 없습니다.

13.2.5.2 Static Semantics: IsComputedPropertyKey

구문 지향 연산 IsComputedPropertyKey. 인수 없음. 반환값: Boolean. 다음 생성 규칙별로 정의된다.

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

13.2.5.3 Static Semantics: PropertyDefinitionNodes

구문 지향 연산 PropertyDefinitionNodes. 인수 없음. 반환값: 리스트 (요소: 구문 분석 노드). 다음 생성 규칙별로 정의된다.

ObjectLiteral : { }
  1. 새로운 빈 List를 반환합니다.
PropertyDefinitionList : PropertyDefinition
  1. « PropertyDefinition »을 반환합니다.
PropertyDefinitionList : PropertyDefinitionList , PropertyDefinition
  1. head를 파생된 PropertyDefinitionList의 PropertyDefinitionNodes로 둡니다.
  2. head와 « PropertyDefinition »의 목록 연결을 반환합니다.

13.2.5.4 Static Semantics: PropertyNameList

구문 지향 연산 PropertyNameList. 인수 없음. 반환값: 리스트 (요소: String). 다음 생성 규칙별로 정의된다.

PropertyDefinitionList : PropertyDefinition
  1. propertyName을 PropertyDefinition의 PropName으로 둡니다.
  2. propertyName이 empty이면 새로운 빈 List를 반환합니다.
  3. « propertyName »을 반환합니다.
PropertyDefinitionList : PropertyDefinitionList , PropertyDefinition
  1. list를 PropertyDefinitionList의 PropertyNameList로 둡니다.
  2. propertyName을 PropertyDefinition의 PropName으로 둡니다.
  3. propertyName이 empty이면 list를 반환합니다.
  4. list와 « propertyName »의 목록 연결을 반환합니다.

13.2.5.5 Runtime Semantics: 평가

ObjectLiteral : { }
  1. OrdinaryObjectCreate(%Object.prototype%)를 반환합니다.
ObjectLiteral : { PropertyDefinitionList ,opt }
  1. obj를 OrdinaryObjectCreate(%Object.prototype%)로 둡니다.
  2. 인수 obj를 사용한 PropertyDefinitionList의 ? PropertyDefinitionEvaluation을 수행합니다.
  3. obj를 반환합니다.
LiteralPropertyName : IdentifierName
  1. IdentifierName의 StringValue를 반환합니다.
LiteralPropertyName : StringLiteral
  1. StringLiteral의 SV를 반환합니다.
LiteralPropertyName : NumericLiteral
  1. number를 NumericLiteral의 NumericValue로 둡니다.
  2. ! ToString(number)을 반환합니다.
ComputedPropertyName : [ AssignmentExpression ]
  1. exprValue를 AssignmentExpression의 ? Evaluation으로 둡니다.
  2. propertyName을 ? GetValue(exprValue)로 둡니다.
  3. ? ToPropertyKey(propertyName)를 반환합니다.

13.2.5.6 Runtime Semantics: PropertyDefinitionEvaluation

구문 지향 연산 PropertyDefinitionEvaluation. 인수 obj (Object). 반환값: (정상 완료 (값: unused) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

PropertyDefinitionList : PropertyDefinitionList , PropertyDefinition
  1. 인수 obj를 사용한 PropertyDefinitionList의 ? PropertyDefinitionEvaluation을 수행합니다.
  2. 인수 obj를 사용한 PropertyDefinition의 ? PropertyDefinitionEvaluation을 수행합니다.
  3. unused를 반환합니다.
PropertyDefinition : ... AssignmentExpression
  1. exprValue를 AssignmentExpression의 ? Evaluation으로 둡니다.
  2. fromValue를 ? GetValue(exprValue)로 둡니다.
  3. excludedNames를 새로운 빈 List로 둡니다.
  4. ? CopyDataProperties(obj, fromValue, excludedNames)를 수행합니다.
  5. unused를 반환합니다.
PropertyDefinition : IdentifierReference
  1. propertyName을 IdentifierReference의 StringValue로 둡니다.
  2. exprValue를 IdentifierReference의 ? Evaluation으로 둡니다.
  3. propertyValue를 ? GetValue(exprValue)로 둡니다.
  4. 단언: obj는 구성 불가능한 프로퍼티가 없는 일반 확장 가능 객체입니다.
  5. ! CreateDataPropertyOrThrow(obj, propertyName, propertyValue)를 수행합니다.
  6. unused를 반환합니다.
PropertyDefinition : PropertyName : AssignmentExpression
  1. propertyKey를 PropertyName의 ? Evaluation으로 둡니다.
  2. 이 PropertyDefinition이 ParseJSON을 위해 평가되는 Script 안에 포함되어 있으면(ParseJSON의 6 단계 참조), 다음을 수행합니다.
    1. isProtoSetter를 false로 둡니다.
  3. 그렇지 않고 propertyKey가 "__proto__"이며 PropertyName의 IsComputedPropertyKey가 false이면, 다음을 수행합니다.
    1. isProtoSetter를 true로 둡니다.
  4. 그렇지 않으면,
    1. isProtoSetter를 false로 둡니다.
  5. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 isProtoSetter가 false이면, 다음을 수행합니다.
    1. propertyValue를 인수 propertyKey를 사용한 AssignmentExpression의 ? NamedEvaluation으로 둡니다.
  6. 그렇지 않으면,
    1. exprValueRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
    2. propertyValue를 ? GetValue(exprValueRef)로 둡니다.
  7. isProtoSetter가 true이면, 다음을 수행합니다.
    1. propertyValue가 Object이거나 propertyValue가 null이면, 다음을 수행합니다.
      1. ! obj.[[SetPrototypeOf]](propertyValue)를 수행합니다.
    2. unused를 반환합니다.
  8. 단언: obj는 구성 불가능한 프로퍼티가 없는 일반 확장 가능 객체입니다.
  9. ! CreateDataPropertyOrThrow(obj, propertyKey, propertyValue)를 수행합니다.
  10. unused를 반환합니다.
PropertyDefinition : MethodDefinition
  1. result를 인수 obj 및 true를 사용한 MethodDefinition의 ? MethodDefinitionEvaluation으로 둡니다.
  2. 단언: result는 empty입니다.
  3. 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: 조기 오류

PrimaryExpression : RegularExpressionLiteral

13.2.7.2 Static Semantics: IsValidRegularExpressionLiteral ( literal )

추상 연산 IsValidRegularExpressionLiteral. 인수 literal (a RegularExpressionLiteral Parse Node). 반환값: Boolean. 인수가 유효한 정규 표현식 리터럴인지 결정합니다. 호출되면 다음 단계를 수행한다.

  1. flags를 literal의 FlagText로 둡니다.
  2. flags에 d, g, i, m, s, u, v, y 이외의 코드 포인트가 하나라도 포함되어 있으면 false를 반환합니다.
  3. flags에 같은 코드 포인트가 두 번 이상 포함되어 있으면 false를 반환합니다.
  4. flags에 u가 포함되어 있으면 u를 true로 둡니다. 그렇지 않으면 u를 false로 둡니다.
  5. flags에 v가 포함되어 있으면 v를 true로 둡니다. 그렇지 않으면 v를 false로 둡니다.
  6. patternText를 literal의 BodyText로 둡니다.
  7. u가 false이고 v가 false이면, 다음을 수행합니다.
    1. stringValue를 CodePointsToString(patternText)으로 둡니다.
    2. patternText를 stringValue의 각 16비트 요소를 유니코드 BMP 코드 포인트로 해석하여 얻은 코드 포인트 시퀀스로 설정합니다. 요소에는 UTF-16 디코딩을 적용하지 않습니다.
  8. parseResult를 ParsePattern(patternText, u, v)로 둡니다.
  9. parseResult가 Parse Node이면 true를 반환합니다.
  10. false를 반환합니다.

13.2.7.3 Runtime Semantics: 평가

PrimaryExpression : RegularExpressionLiteral
  1. pattern을 CodePointsToString(RegularExpressionLiteral의 BodyText)으로 둡니다.
  2. flags를 CodePointsToString(RegularExpressionLiteral의 FlagText)로 둡니다.
  3. ! RegExpCreate(pattern, flags)를 반환합니다.

13.2.8 템플릿 리터럴

구문

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

13.2.8.1 Static Semantics: 조기 오류

TemplateLiteral[Yield, Await, Tagged] : NoSubstitutionTemplate
  • [Tagged] 매개변수가 설정되지 않았고 인수 cooked를 사용한 TemplateLiteral의 TemplateStrings에 undefined가 포함되어 있으면 Syntax Error입니다.
TemplateLiteral[Yield, Await, Tagged] : SubstitutionTemplate[?Yield, ?Await]

13.2.8.2 Static Semantics: TemplateStrings

구문 지향 연산 TemplateStrings. 인수 escapes ((raw 또는 cooked)). 반환값: 리스트 (요소: (String 또는 undefined)). 다음 생성 규칙별로 정의된다.

TemplateLiteral : NoSubstitutionTemplate
  1. « TemplateString(NoSubstitutionTemplate, escapes) »를 반환합니다.
SubstitutionTemplate : TemplateHead Expression TemplateSpans
  1. head를 « TemplateString(TemplateHead, escapes) »로 둡니다.
  2. tail을 인수 escapes를 사용한 TemplateSpans의 TemplateStrings로 둡니다.
  3. head와 tail의 목록 연결을 반환합니다.
TemplateSpans : TemplateTail
  1. « TemplateString(TemplateTail, escapes) »를 반환합니다.
TemplateSpans : TemplateMiddleList TemplateTail
  1. middle을 인수 escapes를 사용한 TemplateMiddleList의 TemplateStrings로 둡니다.
  2. tail을 « TemplateString(TemplateTail, escapes) »로 둡니다.
  3. middle과 tail의 목록 연결을 반환합니다.
TemplateMiddleList : TemplateMiddle Expression
  1. « TemplateString(TemplateMiddle, escapes) »를 반환합니다.
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
  1. front를 인수 escapes를 사용한 TemplateMiddleList의 TemplateStrings로 둡니다.
  2. last를 « TemplateString(TemplateMiddle, escapes) »로 둡니다.
  3. front와 last의 목록 연결을 반환합니다.

13.2.8.3 Static Semantics: TemplateString ( templateToken, escapes )

추상 연산 TemplateString. 인수 templateToken ((a NoSubstitutionTemplate Parse Node, a TemplateHead Parse Node, a TemplateMiddle Parse Node 또는 a TemplateTail Parse Node)) 및 escapes ((raw 또는 cooked)). 반환값: (String 또는 undefined). 호출되면 다음 단계를 수행한다.

  1. escapes가 raw이면 templateToken의 TRV를 반환합니다.
  2. templateToken의 TV를 반환합니다.
참고

이 연산은 escapes가 raw이고 templateToken에 NotEscapeSequence가 포함되어 있으면 undefined를 반환합니다. 그 밖의 모든 경우에는 String을 반환합니다.

13.2.8.4 GetTemplateObject ( templateLiteral )

추상 연산 GetTemplateObject. 인수 templateLiteral (구문 분석 노드). 반환값: Array. 호출되면 다음 단계를 수행한다.

  1. realm을 현재 Realm Record로 둡니다.
  2. templateRegistry를 realm.[[TemplateMap]]으로 둡니다.
  3. templateRegistry의 각 요소 element에 대해 다음을 수행합니다.
    1. element.[[Site]]가 templateLiteral과 같은 Parse Node이면, 다음을 수행합니다.
      1. element.[[Array]]를 반환합니다.
  4. rawStrings를 인수 raw를 사용한 templateLiteral의 TemplateStrings로 둡니다.
  5. 단언: rawStrings는 String의 List입니다.
  6. cookedStrings를 인수 cooked를 사용한 templateLiteral의 TemplateStrings로 둡니다.
  7. count를 List cookedStrings의 요소 수로 둡니다.
  8. 단언: count ≤ 232 - 1입니다.
  9. template을 ! ArrayCreate(count)로 둡니다.
  10. rawObj를 ! ArrayCreate(count)로 둡니다.
  11. index를 0으로 둡니다.
  12. index < count인 동안 다음을 반복합니다.
    1. propertyKey를 ! ToString(𝔽(index))으로 둡니다.
    2. cookedValue를 cookedStrings[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. index를 index + 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을 반환합니다.
참고 1

템플릿 객체 생성은 비정상 완료를 발생시킬 수 없습니다.

참고 2

realm의 프로그램 코드에 있는 각 TemplateLiteral은 태그된 Template(13.2.8.6)을 평가할 때 사용하는 고유한 템플릿 객체와 연결됩니다. 템플릿 객체는 동결되며 특정 태그된 Template을 평가할 때마다 동일한 템플릿 객체를 사용합니다. 템플릿 객체를 TemplateLiteral을 처음 평가할 때 지연 생성할지 아니면 최초 평가 전에 미리 생성할지는 ECMAScript 코드에서 관찰할 수 없는 구현 선택입니다.

참고 3

이 명세의 향후 판에서는 템플릿 객체의 열거 불가능한 추가 프로퍼티를 정의할 수 있습니다.

13.2.8.5 Runtime Semantics: SubstitutionEvaluation

구문 지향 연산 SubstitutionEvaluation. 인수 없음. 반환값: (정상 완료 (값: 리스트 (요소: ECMAScript 언어 값)) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

TemplateSpans : TemplateTail
  1. 새로운 빈 List를 반환합니다.
TemplateSpans : TemplateMiddleList TemplateTail
  1. TemplateMiddleList의 ? SubstitutionEvaluation을 반환합니다.
TemplateMiddleList : TemplateMiddle Expression
  1. subRef를 Expression의 ? Evaluation으로 둡니다.
  2. sub를 ? GetValue(subRef)로 둡니다.
  3. « sub »를 반환합니다.
TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
  1. preceding을 TemplateMiddleList의 ? SubstitutionEvaluation으로 둡니다.
  2. nextRef를 Expression의 ? Evaluation으로 둡니다.
  3. next를 ? GetValue(nextRef)로 둡니다.
  4. preceding과 « next »의 목록 연결을 반환합니다.

13.2.8.6 Runtime Semantics: 평가

TemplateLiteral : NoSubstitutionTemplate
  1. 12.9.6에 정의된 NoSubstitutionTemplate의 TV를 반환합니다.
SubstitutionTemplate : TemplateHead Expression TemplateSpans
  1. head를 12.9.6에 정의된 TemplateHead의 TV로 둡니다.
  2. subRef를 Expression의 ? Evaluation으로 둡니다.
  3. sub를 ? GetValue(subRef)로 둡니다.
  4. middle을 ? ToString(sub)으로 둡니다.
  5. tail을 TemplateSpans의 ? Evaluation으로 둡니다.
  6. head, middle 및 tail의 문자열 연결을 반환합니다.
참고 1

Expression 값에 적용되는 문자열 변환 의미론은 + 연산자보다 String.prototype.concat과 유사합니다.

TemplateSpans : TemplateTail
  1. 12.9.6에 정의된 TemplateTail의 TV를 반환합니다.
TemplateSpans : TemplateMiddleList TemplateTail
  1. head를 TemplateMiddleList의 ? Evaluation으로 둡니다.
  2. tail을 12.9.6에 정의된 TemplateTail의 TV로 둡니다.
  3. head와 tail의 문자열 연결을 반환합니다.
TemplateMiddleList : TemplateMiddle Expression
  1. head를 12.9.6에 정의된 TemplateMiddle의 TV로 둡니다.
  2. subRef를 Expression의 ? Evaluation으로 둡니다.
  3. sub를 ? GetValue(subRef)로 둡니다.
  4. middle을 ? ToString(sub)으로 둡니다.
  5. head와 middle의 문자열 연결을 반환합니다.
참고 2

Expression 값에 적용되는 문자열 변환 의미론은 + 연산자보다 String.prototype.concat과 유사합니다.

TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression
  1. rest를 TemplateMiddleList의 ? Evaluation으로 둡니다.
  2. middle을 12.9.6에 정의된 TemplateMiddle의 TV로 둡니다.
  3. subRef를 Expression의 ? Evaluation으로 둡니다.
  4. sub를 ? GetValue(subRef)로 둡니다.
  5. last를 ? ToString(sub)으로 둡니다.
  6. rest, middle 및 last의 문자열 연결을 반환합니다.
참고 3

Expression 값에 적용되는 문자열 변환 의미론은 + 연산자보다 String.prototype.concat과 유사합니다.

13.2.9 그룹화 연산자

13.2.9.1 Static Semantics: 조기 오류

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList

13.2.9.2 Runtime Semantics: 평가

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. expr을 CoverParenthesizedExpressionAndArrowParameterList가 포괄하는 ParenthesizedExpression로 둡니다.
  2. expr의 ? Evaluation을 반환합니다.
ParenthesizedExpression : ( Expression )
  1. Expression의 ? Evaluation을 반환합니다. 이는 Reference 타입일 수 있습니다.
참고

이 알고리즘은 Expression의 Evaluation에 GetValue를 적용하지 않습니다. 주된 이유는 delete 및 typeof와 같은 연산자를 괄호로 둘러싸인 표현식에 적용할 수 있도록 하기 위해서입니다.

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] ,opt ) 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]

보충 구문

다음 생성 규칙의 인스턴스를 처리할 때
CallExpression : CoverCallExpressionAndAsyncArrowHead
CoverCallExpressionAndAsyncArrowHead의 해석은 다음 문법을 사용하여 구체화됩니다:

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

13.3.1 정적 의미론

13.3.1.1 Static Semantics: 조기 오류

OptionalChain : ?. TemplateLiteral OptionalChain TemplateLiteral 참고

이 생성 규칙은 자동 세미콜론 삽입 규칙(12.10)이 다음 코드에 적용되는 것을 방지하기 위해 존재합니다:

a?.b
`c`

즉, 이를 두 개의 유효한 문으로 해석하지 않도록 합니다. 목적은 선택적 체인이 없는 유사한 코드와 일관성을 유지하는 것입니다:

a.b
`c`

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

ImportMeta : import . meta

13.3.2 프로퍼티 접근자

참고

프로퍼티에는 다음과 같은 점 표기법을 사용하여 이름으로 접근할 수 있습니다:

또는 다음과 같은 대괄호 표기법을 사용합니다:

점 표기법은 다음 구문 변환으로 설명할 수 있습니다:

의 동작은 다음과 동일합니다.

MemberExpression [ <identifier-name-string> ]

마찬가지로

의 동작은 다음과 동일합니다.

CallExpression [ <identifier-name-string> ]

여기서 <identifier-name-string>은 IdentifierName의 StringValue입니다.

13.3.2.1 Runtime Semantics: 평가

MemberExpression : MemberExpression [ Expression ]
  1. baseRef를 MemberExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. strict를 IsStrict(this MemberExpression)로 둡니다.
  4. ? EvaluatePropertyAccessWithExpressionKey(baseValue, Expression, strict)를 반환합니다.
MemberExpression : MemberExpression . IdentifierName
  1. baseRef를 MemberExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. strict를 IsStrict(this MemberExpression)로 둡니다.
  4. EvaluatePropertyAccessWithIdentifierKey(baseValue, IdentifierName, strict)를 반환합니다.
MemberExpression : MemberExpression . PrivateIdentifier
  1. baseRef를 MemberExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. fieldNameString을 PrivateIdentifier의 StringValue로 둡니다.
  4. MakePrivateReference(baseValue, fieldNameString)를 반환합니다.
CallExpression : CallExpression [ Expression ]
  1. baseRef를 CallExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. strict를 IsStrict(this CallExpression)로 둡니다.
  4. ? EvaluatePropertyAccessWithExpressionKey(baseValue, Expression, strict)를 반환합니다.
CallExpression : CallExpression . IdentifierName
  1. baseRef를 CallExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. strict를 IsStrict(this CallExpression)로 둡니다.
  4. EvaluatePropertyAccessWithIdentifierKey(baseValue, IdentifierName, strict)를 반환합니다.
CallExpression : CallExpression . PrivateIdentifier
  1. baseRef를 CallExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. fieldNameString을 PrivateIdentifier의 StringValue로 둡니다.
  4. MakePrivateReference(baseValue, fieldNameString)를 반환합니다.

13.3.3 EvaluatePropertyAccessWithExpressionKey ( baseValue, expr, strict )

추상 연산 EvaluatePropertyAccessWithExpressionKey. 인수 baseValue (ECMAScript 언어 값), expr (an Expression Parse Node) 및 strict (Boolean). 반환값: (정상 완료 (값: Reference 레코드) 또는 중도 완료). 호출되면 다음 단계를 수행한다.

  1. propertyNameRef를 expr의 ? Evaluation으로 둡니다.
  2. propertyNameValue를 ? GetValue(propertyNameRef)로 둡니다.
  3. 참고: 대부분의 경우 이 단계 직후 propertyNameValue에 ToPropertyKey를 수행합니다. 그러나 a[b] = c의 경우에는 c를 평가한 후까지 수행하지 않습니다.
  4. Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyNameValue, [[Strict]]: strict, [[ThisValue]]: empty }를 반환합니다.

13.3.4 EvaluatePropertyAccessWithIdentifierKey ( baseValue, identifierName, strict )

추상 연산 EvaluatePropertyAccessWithIdentifierKey. 인수 baseValue (ECMAScript 언어 값), identifierName (an IdentifierName Parse Node) 및 strict (Boolean). 반환값: Reference 레코드. 호출되면 다음 단계를 수행한다.

  1. propertyNameString을 identifierName의 StringValue로 둡니다.
  2. Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyNameString, [[Strict]]: strict, [[ThisValue]]: empty }를 반환합니다.

13.3.5 new 연산자

13.3.5.1 Runtime Semantics: 평가

NewExpression : new NewExpression
  1. ? EvaluateNew(NewExpression, empty)을 반환합니다.
MemberExpression : new MemberExpression Arguments
  1. ? EvaluateNew(MemberExpression, Arguments)를 반환합니다.

13.3.5.1.1 EvaluateNew ( constructExpr, argumentsNode )

추상 연산 EvaluateNew. 인수 constructExpr ((a NewExpression Parse Node 또는 a MemberExpression Parse Node)) 및 argumentsNode ((empty 또는 an Arguments Parse Node)). 반환값: (정상 완료 (값: Object) 또는 중도 완료). 호출되면 다음 단계를 수행한다.

  1. ref를 constructExpr의 ? Evaluation으로 둡니다.
  2. ctor를 ? GetValue(ref)로 둡니다.
  3. argumentsNode가 empty이면, 다음을 수행합니다.
    1. argList를 새로운 빈 List로 둡니다.
  4. 그렇지 않으면,
    1. argList를 argumentsNode의 ? ArgumentListEvaluation으로 둡니다.
  5. IsConstructor(ctor)가 false이면 TypeError 예외를 던집니다.
  6. ? Construct(ctor, argList)를 반환합니다.

13.3.6 함수 호출

13.3.6.1 Runtime Semantics: 평가

CallExpression : CoverCallExpressionAndAsyncArrowHead
  1. expr을 CoverCallExpressionAndAsyncArrowHead가 포괄하는 CallMemberExpression로 둡니다.
  2. memberExpr을 expr의 MemberExpression로 둡니다.
  3. args를 expr의 Arguments로 둡니다.
  4. ref를 memberExpr의 ? Evaluation으로 둡니다.
  5. func를 ? GetValue(ref)로 둡니다.
  6. ref가 Reference Record이고 IsPropertyReference(ref)가 false이며 ref.[[ReferencedName]]이 "eval"이면, 다음을 수행합니다.
    1. SameValue(func, %eval%)가 true이면, 다음을 수행합니다.
      1. argList를 args의 ? ArgumentListEvaluation으로 둡니다.
      2. argList에 요소가 없으면 undefined를 반환합니다.
      3. evalArg를 argList의 첫 번째 요소로 둡니다.
      4. IsStrict(this CallExpression)가 true이면 strictCaller를 true로 둡니다. 그렇지 않으면 strictCaller를 false로 둡니다.
      5. ? PerformEval(evalArg, strictCaller, true)를 반환합니다.
  7. thisCall을 이 CallExpression로 둡니다.
  8. tailCall을 IsInTailPosition(thisCall)으로 둡니다.
  9. ? EvaluateCall(func, ref, args, tailCall)을 반환합니다.

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

CallExpression : CallExpression Arguments
  1. ref를 CallExpression의 ? Evaluation으로 둡니다.
  2. func를 ? GetValue(ref)로 둡니다.
  3. thisCall을 이 CallExpression로 둡니다.
  4. tailCall을 IsInTailPosition(thisCall)으로 둡니다.
  5. ? EvaluateCall(func, ref, Arguments, tailCall)을 반환합니다.

13.3.6.2 EvaluateCall ( func, thisValueRef, argumentListNode, tailPosition )

추상 연산 EvaluateCall. 인수 func (ECMAScript 언어 값), thisValueRef ((ECMAScript 언어 값 또는 Reference 레코드)), argumentListNode (구문 분석 노드) 및 tailPosition (Boolean). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 중도 완료). 호출되면 다음 단계를 수행한다.

  1. thisValueRef가 Reference Record이면, 다음을 수행합니다.
    1. IsPropertyReference(thisValueRef)가 true이면, 다음을 수행합니다.
      1. thisValue를 GetThisValue(thisValueRef)로 둡니다.
    2. 그렇지 않으면,
      1. refEnv를 thisValueRef.[[Base]]로 둡니다.
      2. 단언: refEnv는 Environment Record입니다.
      3. thisValue를 refEnv.WithBaseObject()로 둡니다.
  2. 그렇지 않으면,
    1. thisValue를 undefined로 둡니다.
  3. argList를 argumentListNode의 ? ArgumentListEvaluation으로 둡니다.
  4. func가 Object가 아니면 TypeError 예외를 던집니다.
  5. IsCallable(func)이 false이면 TypeError 예외를 던집니다.
  6. tailPosition이 true이면 PrepareForTailCall()을 수행합니다.
  7. ? Call(func, thisValue, argList)을 반환합니다.

13.3.7 super 키워드

13.3.7.1 Runtime Semantics: 평가

SuperProperty : super [ Expression ]
  1. envRecord를 GetThisEnvironment()로 둡니다.
  2. actualThis를 ? envRecord.GetThisBinding()으로 둡니다.
  3. propertyNameRef를 Expression의 ? Evaluation으로 둡니다.
  4. propertyNameValue를 ? GetValue(propertyNameRef)로 둡니다.
  5. strict를 IsStrict(this SuperProperty)로 둡니다.
  6. 참고: 대부분의 경우 이 단계 직후 propertyNameValue에 ToPropertyKey를 수행합니다. 그러나 super[b] = c의 경우에는 c를 평가한 후까지 수행하지 않습니다.
  7. MakeSuperPropertyReference(actualThis, propertyNameValue, strict)를 반환합니다.
SuperProperty : super . IdentifierName
  1. envRecord를 GetThisEnvironment()로 둡니다.
  2. actualThis를 ? envRecord.GetThisBinding()으로 둡니다.
  3. propertyKey를 IdentifierName의 StringValue로 둡니다.
  4. strict를 IsStrict(this SuperProperty)로 둡니다.
  5. MakeSuperPropertyReference(actualThis, propertyKey, strict)를 반환합니다.
SuperCall : super Arguments
  1. newTarget을 GetNewTarget()으로 둡니다.
  2. 단언: newTarget은 constructor입니다.
  3. superCtor를 GetSuperConstructor()로 둡니다.
  4. argList를 Arguments의 ? ArgumentListEvaluation으로 둡니다.
  5. IsConstructor(superCtor)가 false이면 TypeError 예외를 던집니다.
  6. result를 ? Construct(superCtor, argList, newTarget)로 둡니다.
  7. thisER을 GetThisEnvironment()로 둡니다.
  8. 단언: thisER은 Function Environment Record입니다.
  9. ? BindThisValue(thisER, result)를 수행합니다.
  10. funcObj를 thisER.[[FunctionObject]]로 둡니다.
  11. 단언: funcObj는 ECMAScript 함수 객체입니다.
  12. ? InitializeInstanceElements(result, funcObj)를 수행합니다.
  13. result를 반환합니다.

13.3.7.2 GetSuperConstructor ( )

추상 연산 GetSuperConstructor. 인수 없음. 반환값: (Object 또는 null). 호출되면 다음 단계를 수행한다.

  1. envRecord를 GetThisEnvironment()로 둡니다.
  2. 단언: envRecord는 Function Environment Record입니다.
  3. activeFunc를 envRecord.[[FunctionObject]]로 둡니다.
  4. 단언: activeFunc는 ECMAScript 함수 객체입니다.
  5. superCtor를 ! activeFunc.[[GetPrototypeOf]]()로 둡니다.
  6. superCtor를 반환합니다.

13.3.7.3 MakeSuperPropertyReference ( actualThis, propertyKey, strict )

추상 연산 MakeSuperPropertyReference. 인수 actualThis (ECMAScript 언어 값), propertyKey (ECMAScript 언어 값) 및 strict (Boolean). 반환값: Super Reference 레코드. 호출되면 다음 단계를 수행한다.

  1. envRecord를 GetThisEnvironment()로 둡니다.
  2. 단언: envRecord.HasSuperBinding()은 true입니다.
  3. 단언: envRecord는 Function Environment Record입니다.
  4. baseValue를 GetSuperBase(envRecord)로 둡니다.
  5. Reference Record { [[Base]]: baseValue, [[ReferencedName]]: propertyKey, [[Strict]]: strict, [[ThisValue]]: actualThis }를 반환합니다.

13.3.8 인수 목록

참고

인수 목록을 평가하면 값의 List가 생성됩니다.

13.3.8.1 Runtime Semantics: ArgumentListEvaluation

구문 지향 연산 ArgumentListEvaluation. 인수 없음. 반환값: (정상 완료 (값: 리스트 (요소: ECMAScript 언어 값)) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

Arguments : ( )
  1. 새로운 빈 List를 반환합니다.
ArgumentList : AssignmentExpression
  1. ref를 AssignmentExpression의 ? Evaluation으로 둡니다.
  2. arg를 ? GetValue(ref)로 둡니다.
  3. « arg »를 반환합니다.
ArgumentList : ... AssignmentExpression
  1. list를 새로운 빈 List로 둡니다.
  2. spreadRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
  3. spreadObj를 ? GetValue(spreadRef)로 둡니다.
  4. iteratorRecord를 ? GetIterator(spreadObj, sync)로 둡니다.
  5. 다음을 반복합니다.
    1. next를 ? IteratorStepValue(iteratorRecord)로 둡니다.
    2. next가 done이면 list를 반환합니다.
    3. next를 list에 추가합니다.
ArgumentList : ArgumentList , AssignmentExpression
  1. precedingArgs를 ArgumentList의 ? ArgumentListEvaluation으로 둡니다.
  2. ref를 AssignmentExpression의 ? Evaluation으로 둡니다.
  3. arg를 ? GetValue(ref)로 둡니다.
  4. precedingArgs와 « arg »의 목록 연결을 반환합니다.
ArgumentList : ArgumentList , ... AssignmentExpression
  1. precedingArgs를 ArgumentList의 ? ArgumentListEvaluation으로 둡니다.
  2. spreadRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
  3. iteratorRecord를 ? GetIterator(? GetValue(spreadRef), sync)로 둡니다.
  4. 다음을 반복합니다.
    1. next를 ? IteratorStepValue(iteratorRecord)로 둡니다.
    2. next가 done이면 precedingArgs를 반환합니다.
    3. next를 precedingArgs에 추가합니다.
TemplateLiteral : NoSubstitutionTemplate
  1. templateLiteral을 이 TemplateLiteral로 둡니다.
  2. siteObj를 GetTemplateObject(templateLiteral)로 둡니다.
  3. « siteObj »를 반환합니다.
TemplateLiteral : SubstitutionTemplate
  1. templateLiteral을 이 TemplateLiteral로 둡니다.
  2. siteObj를 GetTemplateObject(templateLiteral)로 둡니다.
  3. remaining을 SubstitutionTemplate의 ? ArgumentListEvaluation으로 둡니다.
  4. « siteObj »와 remaining의 목록 연결을 반환합니다.
SubstitutionTemplate : TemplateHead Expression TemplateSpans
  1. firstSubRef를 Expression의 ? Evaluation으로 둡니다.
  2. firstSub를 ? GetValue(firstSubRef)로 둡니다.
  3. restSub를 TemplateSpans의 ? SubstitutionEvaluation으로 둡니다.
  4. 단언: restSub는 비어 있을 수도 있는 List입니다.
  5. « firstSub »와 restSub의 목록 연결을 반환합니다.

13.3.9 선택적 체인

참고
선택적 체인은 하나 이상의 프로퍼티 접근 및 함수 호출로 구성된 체인이며, 그 첫 번째 항목은 토큰 ?.로 시작합니다.

13.3.9.1 Runtime Semantics: 평가

OptionalExpression : MemberExpression OptionalChain
  1. baseRef를 MemberExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. baseValue가 undefined 또는 null이면, 다음을 수행합니다.
    1. undefined를 반환합니다.
  4. 인수 baseValue 및 baseRef를 사용한 OptionalChain의 ? ChainEvaluation을 반환합니다.
OptionalExpression : CallExpression OptionalChain
  1. baseRef를 CallExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. baseValue가 undefined 또는 null이면, 다음을 수행합니다.
    1. undefined를 반환합니다.
  4. 인수 baseValue 및 baseRef를 사용한 OptionalChain의 ? ChainEvaluation을 반환합니다.
OptionalExpression : OptionalExpression OptionalChain
  1. baseRef를 OptionalExpression의 ? Evaluation으로 둡니다.
  2. baseValue를 ? GetValue(baseRef)로 둡니다.
  3. baseValue가 undefined 또는 null이면, 다음을 수행합니다.
    1. undefined를 반환합니다.
  4. 인수 baseValue 및 baseRef를 사용한 OptionalChain의 ? ChainEvaluation을 반환합니다.

13.3.9.2 Runtime Semantics: ChainEvaluation

구문 지향 연산 ChainEvaluation. 인수 baseValue (ECMAScript 언어 값) 및 baseRef ((ECMAScript 언어 값 또는 Reference 레코드)). 반환값: (정상 완료 (값: (ECMAScript 언어 값 또는 Reference 레코드)) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

OptionalChain : ?. Arguments
  1. thisChain을 이 OptionalChain로 둡니다.
  2. tailCall을 IsInTailPosition(thisChain)으로 둡니다.
  3. ? EvaluateCall(baseValue, baseRef, Arguments, tailCall)을 반환합니다.
OptionalChain : ?. [ Expression ]
  1. strict를 IsStrict(this OptionalChain)로 둡니다.
  2. ? EvaluatePropertyAccessWithExpressionKey(baseValue, Expression, strict)를 반환합니다.
OptionalChain : ?. IdentifierName
  1. strict를 IsStrict(this OptionalChain)로 둡니다.
  2. EvaluatePropertyAccessWithIdentifierKey(baseValue, IdentifierName, strict)를 반환합니다.
OptionalChain : ?. PrivateIdentifier
  1. fieldNameString을 PrivateIdentifier의 StringValue로 둡니다.
  2. MakePrivateReference(baseValue, fieldNameString)를 반환합니다.
OptionalChain : OptionalChain Arguments
  1. optionalChain을 OptionalChain로 둡니다.
  2. newRef를 인수 baseValue 및 baseRef를 사용한 optionalChain의 ? ChainEvaluation으로 둡니다.
  3. newValue를 ? GetValue(newRef)로 둡니다.
  4. thisChain을 이 OptionalChain로 둡니다.
  5. tailCall을 IsInTailPosition(thisChain)으로 둡니다.
  6. ? EvaluateCall(newValue, newRef, Arguments, tailCall)을 반환합니다.
OptionalChain : OptionalChain [ Expression ]
  1. optionalChain을 OptionalChain로 둡니다.
  2. newRef를 인수 baseValue 및 baseRef를 사용한 optionalChain의 ? ChainEvaluation으로 둡니다.
  3. newValue를 ? GetValue(newRef)로 둡니다.
  4. strict를 IsStrict(this OptionalChain)로 둡니다.
  5. ? EvaluatePropertyAccessWithExpressionKey(newValue, Expression, strict)를 반환합니다.
OptionalChain : OptionalChain . IdentifierName
  1. optionalChain을 OptionalChain로 둡니다.
  2. newRef를 인수 baseValue 및 baseRef를 사용한 optionalChain의 ? ChainEvaluation으로 둡니다.
  3. newValue를 ? GetValue(newRef)로 둡니다.
  4. strict를 IsStrict(this OptionalChain)로 둡니다.
  5. EvaluatePropertyAccessWithIdentifierKey(newValue, IdentifierName, strict)를 반환합니다.
OptionalChain : OptionalChain . PrivateIdentifier
  1. optionalChain을 OptionalChain로 둡니다.
  2. newRef를 인수 baseValue 및 baseRef를 사용한 optionalChain의 ? ChainEvaluation으로 둡니다.
  3. newValue를 ? GetValue(newRef)로 둡니다.
  4. fieldNameString을 PrivateIdentifier의 StringValue로 둡니다.
  5. MakePrivateReference(newValue, fieldNameString)를 반환합니다.

13.3.10 Import 호출

13.3.10.1 Runtime Semantics: 평가

ImportCall : import ( AssignmentExpression ,opt )
  1. ? EvaluateImportCall(AssignmentExpression)을 반환합니다.
ImportCall : import ( AssignmentExpression , AssignmentExpression ,opt )
  1. ? EvaluateImportCall(첫 번째 AssignmentExpression, 두 번째 AssignmentExpression)을 반환합니다.

13.3.10.2 EvaluateImportCall ( specifierExpr [ , optionsExpr ] )

추상 연산 EvaluateImportCall. 인수 specifierExpr (구문 분석 노드) 및 선택적 인수 optionsExpr (구문 분석 노드). 반환값: (정상 완료 (값: Promise) 또는 중도 완료). 호출되면 다음 단계를 수행한다.

  1. referrer를 GetActiveScriptOrModule()로 둡니다.
  2. referrer가 null이면 referrer를 현재 Realm Record로 설정합니다.
  3. specifierRef를 specifierExpr의 ? Evaluation으로 둡니다.
  4. specifier를 ? GetValue(specifierRef)로 둡니다.
  5. optionsExpr이 존재하면, 다음을 수행합니다.
    1. optionsRef를 optionsExpr의 ? Evaluation으로 둡니다.
    2. options를 ? GetValue(optionsRef)로 둡니다.
  6. 그렇지 않으면,
    1. options를 undefined로 둡니다.
  7. promiseCapability를 ! NewPromiseCapability(%Promise%)로 둡니다.
  8. specifierString을 Completion(ToString(specifier))으로 둡니다.
  9. IfAbruptRejectPromise(specifierString, promiseCapability).
  10. attrs를 새로운 빈 List로 둡니다.
  11. options가 undefined가 아니면, 다음을 수행합니다.
    1. options가 Object가 아니면, 다음을 수행합니다.
      1. ! Call(promiseCapability.[[Reject]], undefined, « 새로 생성된 TypeError 객체 »)를 수행합니다.
      2. promiseCapability.[[Promise]]를 반환합니다.
    2. attrsObj를 Completion(Get(options, "with"))로 둡니다.
    3. IfAbruptRejectPromise(attrsObj, promiseCapability).
    4. attrsObj가 undefined가 아니면, 다음을 수행합니다.
      1. attrsObj가 Object가 아니면, 다음을 수행합니다.
        1. ! Call(promiseCapability.[[Reject]], undefined, « 새로 생성된 TypeError 객체 »)를 수행합니다.
        2. promiseCapability.[[Promise]]를 반환합니다.
      2. entries를 Completion(EnumerableOwnProperties(attrsObj, 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, « 새로 생성된 TypeError 객체 »)를 수행합니다.
            2. promiseCapability.[[Promise]]를 반환합니다.
          2. ImportAttribute Record { [[Key]]: key, [[Value]]: value }를 attrs에 추가합니다.
    5. AllImportAttributesSupported(attrs)가 false이면, 다음을 수행합니다.
      1. ! Call(promiseCapability.[[Reject]], undefined, « 새로 생성된 TypeError 객체 »)를 수행합니다.
      2. promiseCapability.[[Promise]]를 반환합니다.
    6. 각 [[Key]] 필드의 값을 UTF-16 코드 단위 값의 시퀀스로 취급하여 해당 [[Key]] 필드의 사전식 순서에 따라 attrs를 정렬합니다. 참고: 호스트가 속성이 열거되는 순서를 기반으로 동작을 변경하는 것이 금지되어 있다는 점에서만 이 정렬을 관찰할 수 있습니다.
  12. moduleRequest를 새로운 ModuleRequest Record { [[Specifier]]: specifierString, [[Attributes]]: attrs }로 둡니다.
  13. HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability)을 수행합니다.
  14. promiseCapability.[[Promise]]를 반환합니다.

13.3.10.3 ContinueDynamicImport ( promiseCapability, moduleCompletion )

추상 연산 ContinueDynamicImport. 인수 promiseCapability (PromiseCapability 레코드) 및 moduleCompletion ((정상 완료 (값: Module 레코드) 또는 throw 완료)). 반환값: unused. import() 호출로 처음 시작된 동적 가져오기 과정을 완료하고, 해당 호출이 반환한 Promise를 적절히 이행하거나 거부합니다. 호출되면 다음 단계를 수행한다.

  1. moduleCompletion이 비정상 완료이면, 다음을 수행합니다.
    1. ! Call(promiseCapability.[[Reject]], undefined, « moduleCompletion.[[Value]] »)를 수행합니다.
    2. unused를 반환합니다.
  2. module을 moduleCompletion.[[Value]]로 둡니다.
  3. loadPromise를 module.LoadRequestedModules()로 둡니다.
  4. rejectedClosure를 매개변수 (reason)를 갖고 promiseCapability을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure로 둡니다:
    1. ! Call(promiseCapability.[[Reject]], undefined, « reason »)를 수행합니다.
    2. NormalCompletion(undefined)을 반환합니다.
  5. onRejected를 CreateBuiltinFunction(rejectedClosure, 1, "", « »)로 둡니다.
  6. linkAndEvaluateClosure를 매개변수가 없고 module, promiseCapability 및 onRejected를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure로 둡니다:
    1. link를 Completion(module.Link())으로 둡니다.
    2. link가 비정상 완료이면, 다음을 수행합니다.
      1. ! Call(promiseCapability.[[Reject]], undefined, « link.[[Value]] »)를 수행합니다.
      2. NormalCompletion(undefined)을 반환합니다.
    3. evaluatePromise를 module.Evaluate()로 둡니다.
    4. fulfilledClosure를 매개변수가 없고 module 및 promiseCapability을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure로 둡니다:
      1. namespace를 GetModuleNamespace(module)로 둡니다.
      2. ! Call(promiseCapability.[[Resolve]], undefined, « namespace »)를 수행합니다.
      3. NormalCompletion(undefined)을 반환합니다.
    5. onFulfilled를 CreateBuiltinFunction(fulfilledClosure, 0, "", « »)로 둡니다.
    6. PerformPromiseThen(evaluatePromise, onFulfilled, onRejected)을 수행합니다.
    7. unused를 반환합니다.
  7. linkAndEvaluate를 CreateBuiltinFunction(linkAndEvaluateClosure, 0, "", « »)로 둡니다.
  8. PerformPromiseThen(loadPromise, linkAndEvaluate, onRejected)을 수행합니다.
  9. unused를 반환합니다.

13.3.11 태그된 템플릿

참고

태그된 템플릿은 호출의 인수가 TemplateLiteral(13.2.8)에서 파생되는 함수 호출입니다. 실제 인수에는 템플릿 객체(13.2.8.4)와 TemplateLiteral 안에 삽입된 표현식을 평가하여 생성된 값이 포함됩니다.

13.3.11.1 Runtime Semantics: 평가

MemberExpression : MemberExpression TemplateLiteral
  1. tagRef를 MemberExpression의 ? Evaluation으로 둡니다.
  2. tagFunc를 ? GetValue(tagRef)로 둡니다.
  3. thisCall을 이 MemberExpression로 둡니다.
  4. tailCall을 IsInTailPosition(thisCall)으로 둡니다.
  5. ? EvaluateCall(tagFunc, tagRef, TemplateLiteral, tailCall)을 반환합니다.
CallExpression : CallExpression TemplateLiteral
  1. tagRef를 CallExpression의 ? Evaluation으로 둡니다.
  2. tagFunc를 ? GetValue(tagRef)로 둡니다.
  3. thisCall을 이 CallExpression로 둡니다.
  4. tailCall을 IsInTailPosition(thisCall)으로 둡니다.
  5. ? EvaluateCall(tagFunc, tagRef, TemplateLiteral, tailCall)을 반환합니다.

13.3.12 메타 프로퍼티

13.3.12.1 Runtime Semantics: 평가

NewTarget : new . target
  1. GetNewTarget()을 반환합니다.
ImportMeta : import . meta
  1. module을 GetActiveScriptOrModule()로 둡니다.
  2. 단언: module은 Source Text Module Record입니다.
  3. importMeta를 module.[[ImportMeta]]로 둡니다.
  4. importMeta가 empty이면, 다음을 수행합니다.
    1. importMeta를 OrdinaryObjectCreate(null)로 설정합니다.
    2. importMetaValues를 HostGetImportMetaProperties(module)로 둡니다.
    3. importMetaValues의 각 Record { [[Key]], [[Value]] } entry에 대해 다음을 수행합니다.
      1. ! CreateDataPropertyOrThrow(importMeta, entry.[[Key]], entry.[[Value]])를 수행합니다.
    4. HostFinalizeImportMeta(importMeta, module)를 수행합니다.
    5. module.[[ImportMeta]]를 importMeta로 설정합니다.
    6. importMeta를 반환합니다.
  5. 단언: importMeta는 Object입니다.
  6. importMeta를 반환합니다.

13.3.12.1.1 HostGetImportMetaProperties ( moduleRecord )

호스트 정의 추상 연산 HostGetImportMetaProperties. 인수 moduleRecord (Module 레코드). 반환값: 리스트 (요소: 레코드 (필드: [[Key]] (프로퍼티 키), [[Value]] (ECMAScript 언어 값))). 호스트가 import.meta에서 반환하는 객체에 사용할 프로퍼티 키와 값을 제공할 수 있도록 합니다.

HostGetImportMetaProperties의 기본 구현은 새로운 빈 List를 반환합니다.

13.3.12.1.2 HostFinalizeImportMeta ( importMeta, moduleRecord )

호스트 정의 추상 연산 HostFinalizeImportMeta. 인수 importMeta (Object) 및 moduleRecord (Module 레코드). 반환값: 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: 조기 오류

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

13.4.2 후위 증가 연산자

13.4.2.1 Runtime Semantics: 평가

UpdateExpression : LeftHandSideExpression ++
  1. lhs를 LeftHandSideExpression의 ? Evaluation으로 둡니다.
  2. LeftHandSideExpression의 AssignmentTargetType이 web-compat이면 ReferenceError 예외를 던집니다.
  3. oldValue를 ? ToNumeric(? GetValue(lhs))로 둡니다.
  4. oldValue가 Number이면, 다음을 수행합니다.
    1. newValue를 Number::add(oldValue, 1𝔽)로 둡니다.
  5. 그렇지 않으면,
    1. 단언: oldValue는 BigInt입니다.
    2. newValue를 BigInt::add(oldValue, 1ℤ)로 둡니다.
  6. ? PutValue(lhs, newValue)를 수행합니다.
  7. oldValue를 반환합니다.

13.4.3 후위 감소 연산자

13.4.3.1 Runtime Semantics: 평가

UpdateExpression : LeftHandSideExpression --
  1. lhs를 LeftHandSideExpression의 ? Evaluation으로 둡니다.
  2. LeftHandSideExpression의 AssignmentTargetType이 web-compat이면 ReferenceError 예외를 던집니다.
  3. oldValue를 ? ToNumeric(? GetValue(lhs))로 둡니다.
  4. oldValue가 Number이면, 다음을 수행합니다.
    1. newValue를 Number::subtract(oldValue, 1𝔽)로 둡니다.
  5. 그렇지 않으면,
    1. 단언: oldValue는 BigInt입니다.
    2. newValue를 BigInt::subtract(oldValue, 1ℤ)로 둡니다.
  6. ? PutValue(lhs, newValue)를 수행합니다.
  7. oldValue를 반환합니다.

13.4.4 전위 증가 연산자

13.4.4.1 Runtime Semantics: 평가

UpdateExpression : ++ UnaryExpression
  1. expr을 UnaryExpression의 ? Evaluation으로 둡니다.
  2. UnaryExpression의 AssignmentTargetType이 web-compat이면 ReferenceError 예외를 던집니다.
  3. oldValue를 ? ToNumeric(? GetValue(expr))로 둡니다.
  4. oldValue가 Number이면, 다음을 수행합니다.
    1. newValue를 Number::add(oldValue, 1𝔽)로 둡니다.
  5. 그렇지 않으면,
    1. 단언: oldValue는 BigInt입니다.
    2. newValue를 BigInt::add(oldValue, 1ℤ)로 둡니다.
  6. ? PutValue(expr, newValue)를 수행합니다.
  7. newValue를 반환합니다.

13.4.5 전위 감소 연산자

13.4.5.1 Runtime Semantics: 평가

UpdateExpression : -- UnaryExpression
  1. expr을 UnaryExpression의 ? Evaluation으로 둡니다.
  2. UnaryExpression의 AssignmentTargetType이 web-compat이면 ReferenceError 예외를 던집니다.
  3. oldValue를 ? ToNumeric(? GetValue(expr))로 둡니다.
  4. oldValue가 Number이면, 다음을 수행합니다.
    1. newValue를 Number::subtract(oldValue, 1𝔽)로 둡니다.
  5. 그렇지 않으면,
    1. 단언: oldValue는 BigInt입니다.
    2. newValue를 BigInt::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] CoverAwaitExpressionAndAwaitUsingDeclarationHead[?Yield] CoverAwaitExpressionAndAwaitUsingDeclarationHead[Yield] : await UnaryExpression[?Yield, +Await]

보충 구문

다음 생성 규칙의 인스턴스를 처리할 때
UnaryExpression : CoverAwaitExpressionAndAwaitUsingDeclarationHead
CoverAwaitExpressionAndAwaitUsingDeclarationHead의 해석은 다음 문법을 사용하여 구체화됩니다:

AwaitExpression[Yield] : await UnaryExpression[?Yield, +Await]

13.5.1 delete 연산자

13.5.1.1 Static Semantics: 조기 오류

UnaryExpression : delete UnaryExpression 참고

마지막 규칙은 첫 번째 규칙을 재귀적으로 적용하기 때문에 delete (((foo)))와 같은 표현식이 조기 오류를 생성함을 의미합니다.

13.5.1.2 Runtime Semantics: 평가

UnaryExpression : delete UnaryExpression
  1. ref를 UnaryExpression의 ? Evaluation으로 둡니다.
  2. ref가 Reference Record가 아니면 true를 반환합니다.
  3. IsUnresolvableReference(ref)가 true이면, 다음을 수행합니다.
    1. 단언: ref.[[Strict]]은 false입니다.
    2. true를 반환합니다.
  4. IsPropertyReference(ref)가 true이면, 다음을 수행합니다.
    1. 단언: 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. deleteStatus가 false이고 ref.[[Strict]]이 true이면 TypeError 예외를 던집니다.
    7. deleteStatus를 반환합니다.
  5. base를 ref.[[Base]]로 둡니다.
  6. 단언: base는 Environment Record입니다.
  7. ? base.DeleteBinding(ref.[[ReferencedName]])을 반환합니다.
참고 1

delete 연산자가 엄격 모드 코드 안에 나타날 때 그 UnaryExpression이 변수, 함수 인수 또는 함수 이름에 대한 직접 참조이면 SyntaxError 예외가 던져집니다. 또한 delete 연산자가 엄격 모드 코드 안에 나타나고 삭제할 프로퍼티의 속성이 { [[Configurable]]: false }이거나 다른 이유로 삭제할 수 없으면 TypeError 예외가 던져집니다.

참고 2

4.c 단계에서 생성될 수 있는 객체는 위 추상 연산과 일반 객체 [[Delete]] 내부 메서드 바깥에서는 접근할 수 없습니다. 구현체는 실제로 해당 객체를 생성하지 않도록 선택할 수 있습니다.

13.5.2 void 연산자

13.5.2.1 Runtime Semantics: 평가

UnaryExpression : void UnaryExpression
  1. expr을 UnaryExpression의 ? Evaluation으로 둡니다.
  2. ? GetValue(expr)를 수행합니다.
  3. undefined를 반환합니다.
참고

값을 사용하지 않더라도 관찰 가능한 부작용이 있을 수 있으므로 GetValue를 호출해야 합니다.

13.5.3 typeof 연산자

13.5.3.1 Runtime Semantics: 평가

UnaryExpression : typeof UnaryExpression
  1. value를 UnaryExpression의 ? Evaluation으로 둡니다.
  2. value가 Reference Record이면, 다음을 수행합니다.
    1. IsUnresolvableReference(value)가 true이면 "undefined"를 반환합니다.
  3. value를 ? GetValue(value)로 설정합니다.
  4. value가 undefined이면 "undefined"를 반환합니다.
  5. value가 null이면 "object"를 반환합니다.
  6. value가 String이면 "string"을 반환합니다.
  7. value가 Symbol이면 "symbol"을 반환합니다.
  8. value가 Boolean이면 "boolean"을 반환합니다.
  9. value가 Number이면 "number"를 반환합니다.
  10. value가 BigInt이면 "bigint"를 반환합니다.
  11. 단언: value는 Object입니다.
  12. Normative Optional
    호스트가 웹 브라우저이거나 그 밖의 방식으로 [[IsHTMLDDA]] 내부 슬롯을 지원하면, 다음을 수행합니다.
    1. value에 [[IsHTMLDDA]] 내부 슬롯이 있으면 "undefined"를 반환합니다.
  13. value에 [[Call]] 내부 메서드가 있으면 "function"을 반환합니다.
  14. "object"를 반환합니다.

13.5.4 단항 + 연산자

참고

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

13.5.4.1 Runtime Semantics: 평가

UnaryExpression : + UnaryExpression
  1. expr을 UnaryExpression의 ? Evaluation으로 둡니다.
  2. ? ToNumber(? GetValue(expr))를 반환합니다.

13.5.5 단항 - 연산자

참고

단항 - 연산자는 피연산자를 숫자 값으로 변환한 다음 부호를 반전합니다. +0𝔽의 부호를 반전하면 -0𝔽이 되고, -0𝔽의 부호를 반전하면 +0𝔽이 됩니다.

13.5.5.1 Runtime Semantics: 평가

UnaryExpression : - UnaryExpression
  1. expr을 UnaryExpression의 ? Evaluation으로 둡니다.
  2. oldValue를 ? ToNumeric(? GetValue(expr))로 둡니다.
  3. oldValue가 Number이면 Number::unaryMinus(oldValue)를 반환합니다.
  4. 단언: oldValue는 BigInt입니다.
  5. BigInt::unaryMinus(oldValue)를 반환합니다.

13.5.6 비트 NOT 연산자 ( ~ )

13.5.6.1 Runtime Semantics: 평가

UnaryExpression : ~ UnaryExpression
  1. expr을 UnaryExpression의 ? Evaluation으로 둡니다.
  2. oldValue를 ? ToNumeric(? GetValue(expr))로 둡니다.
  3. oldValue가 Number이면 Number::bitwiseNOT(oldValue)을 반환합니다.
  4. 단언: oldValue는 BigInt입니다.
  5. BigInt::bitwiseNOT(oldValue)을 반환합니다.

13.5.7 논리 NOT 연산자 ( ! )

13.5.7.1 Runtime Semantics: 평가

UnaryExpression : ! UnaryExpression
  1. expr을 UnaryExpression의 ? Evaluation으로 둡니다.
  2. oldValue를 ToBoolean(? GetValue(expr))로 둡니다.
  3. oldValue가 true이면 false를 반환합니다.
  4. true를 반환합니다.

13.6 지수 연산자

구문

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

13.6.1 Runtime Semantics: 평가

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 * / % 참고
  • * 연산자는 곱셈을 수행하여 피연산자의 곱을 생성합니다.
  • / 연산자는 나눗셈을 수행하여 피연산자의 몫을 생성합니다.
  • % 연산자는 암묵적인 나눗셈에서 피연산자의 나머지를 생성합니다.

13.7.1 Runtime Semantics: 평가

MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression
  1. opText를 MultiplicativeOperator와 일치하는 소스 텍스트로 둡니다.
  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 덧셈 연산자 ( + )

참고

덧셈 연산자는 문자열 연결 또는 숫자 덧셈을 수행합니다.

13.8.1.1 Runtime Semantics: 평가

AdditiveExpression : AdditiveExpression + MultiplicativeExpression
  1. ? EvaluateStringOrNumericBinaryExpression(AdditiveExpression, +, MultiplicativeExpression)을 반환합니다.

13.8.2 뺄셈 연산자 ( - )

참고

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

13.8.2.1 Runtime Semantics: 평가

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 왼쪽 시프트 연산자 ( << )

참고

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

13.9.1.1 Runtime Semantics: 평가

ShiftExpression : ShiftExpression << AdditiveExpression
  1. ? EvaluateStringOrNumericBinaryExpression(ShiftExpression, <<, AdditiveExpression)을 반환합니다.

13.9.2 부호 있는 오른쪽 시프트 연산자 ( >> )

참고

왼쪽 피연산자에 대해 오른쪽 피연산자가 지정한 양만큼 부호를 채우는 비트 단위 오른쪽 시프트 연산을 수행합니다.

13.9.2.1 Runtime Semantics: 평가

ShiftExpression : ShiftExpression >> AdditiveExpression
  1. ? EvaluateStringOrNumericBinaryExpression(ShiftExpression, >>, AdditiveExpression)을 반환합니다.

13.9.3 부호 없는 오른쪽 시프트 연산자 ( >>> )

참고

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

13.9.3.1 Runtime Semantics: 평가

ShiftExpression : ShiftExpression >>> AdditiveExpression
  1. ? EvaluateStringOrNumericBinaryExpression(ShiftExpression, >>>, AdditiveExpression)을 반환합니다.

13.10 관계 연산자

참고 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] 참고 2

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

13.10.1 Runtime Semantics: 평가

RelationalExpression : RelationalExpression < ShiftExpression
  1. leftRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 ShiftExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. result를 ? IsLessThan(leftValue, rightValue, true)로 둡니다.
  6. result가 undefined이면 false를 반환합니다.
  7. result를 반환합니다.
RelationalExpression : RelationalExpression > ShiftExpression
  1. leftRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 ShiftExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. result를 ? IsLessThan(rightValue, leftValue, false)로 둡니다.
  6. result가 undefined이면 false를 반환합니다.
  7. result를 반환합니다.
RelationalExpression : RelationalExpression <= ShiftExpression
  1. leftRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 ShiftExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. result를 ? IsLessThan(rightValue, leftValue, false)로 둡니다.
  6. result가 true 또는 undefined이면 false를 반환합니다.
  7. true를 반환합니다.
RelationalExpression : RelationalExpression >= ShiftExpression
  1. leftRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 ShiftExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. result를 ? IsLessThan(leftValue, rightValue, true)로 둡니다.
  6. result가 true 또는 undefined이면 false를 반환합니다.
  7. true를 반환합니다.
RelationalExpression : RelationalExpression instanceof ShiftExpression
  1. leftRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 ShiftExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. ? InstanceofOperator(leftValue, rightValue)를 반환합니다.
RelationalExpression : RelationalExpression in ShiftExpression
  1. leftRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 ShiftExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. rightValue가 Object가 아니면 TypeError 예외를 던집니다.
  6. ? HasProperty(rightValue, ? ToPropertyKey(leftValue))를 반환합니다.
RelationalExpression : PrivateIdentifier in ShiftExpression
  1. privateIdentifier를 PrivateIdentifier의 StringValue로 둡니다.
  2. rightRef를 ShiftExpression의 ? Evaluation으로 둡니다.
  3. rightValue를 ? GetValue(rightRef)로 둡니다.
  4. rightValue가 Object가 아니면 TypeError 예외를 던집니다.
  5. privateEnv를 실행 중인 실행 컨텍스트의 PrivateEnvironment로 둡니다.
  6. 단언: privateEnv는 null이 아닙니다.
  7. privateName을 ResolvePrivateIdentifier(privateEnv, privateIdentifier)로 둡니다.
  8. PrivateElementFind(rightValue, privateName)이 empty이면 false를 반환합니다.
  9. true를 반환합니다.

13.10.2 InstanceofOperator ( value, target )

추상 연산 InstanceofOperator. 인수 value (ECMAScript 언어 값) 및 target (ECMAScript 언어 값). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). target의 %Symbol.hasInstance% 메서드를 참조하거나, 해당 메서드가 없으면 target의 "prototype" 프로퍼티 값이 value의 프로토타입 체인에 존재하는지를 결정하여 value가 target의 인스턴스인지 판별하는 일반 알고리즘을 구현합니다. 호출되면 다음 단계를 수행한다.

  1. target이 Object가 아니면 TypeError 예외를 던집니다.
  2. instOfHandler를 ? GetMethod(target, %Symbol.hasInstance%)로 둡니다.
  3. instOfHandler가 undefined가 아니면, 다음을 수행합니다.
    1. ToBoolean(? Call(instOfHandler, target, « value »))을 반환합니다.
  4. IsCallable(target)이 false이면 TypeError 예외를 던집니다.
  5. ? OrdinaryHasInstance(target, value)를 반환합니다.
참고

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

13.11 동등 연산자

참고

동등 연산자를 평가한 결과는 항상 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: 평가

EqualityExpression : EqualityExpression == RelationalExpression
  1. leftRef를 EqualityExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. ? IsLooselyEqual(rightValue, leftValue)을 반환합니다.
EqualityExpression : EqualityExpression != RelationalExpression
  1. leftRef를 EqualityExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. result를 ? IsLooselyEqual(rightValue, leftValue)로 둡니다.
  6. result가 true이면 false를 반환합니다.
  7. true를 반환합니다.
EqualityExpression : EqualityExpression === RelationalExpression
  1. leftRef를 EqualityExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. IsStrictlyEqual(rightValue, leftValue)을 반환합니다.
EqualityExpression : EqualityExpression !== RelationalExpression
  1. leftRef를 EqualityExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 RelationalExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. result를 IsStrictlyEqual(rightValue, leftValue)로 둡니다.
  6. result가 true이면 false를 반환합니다.
  7. true를 반환합니다.
참고 1

동등 연산자는 다음 불변 조건을 유지합니다:

  • A != B는 !(A == B)와 동등합니다.
  • A와 B의 평가 순서를 제외하면 A == B는 B == A와 동등합니다.
참고 2

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

  • new String("a") == "a" 및 "a" == new String("a")는 모두 true입니다.
  • new String("a") == new String("a")는 false입니다.
참고 3

String 비교는 코드 단위 값 시퀀스에 대한 단순 동등성 검사를 사용합니다. 유니코드 명세에 정의된 문자 또는 문자열 동등성과 정렬 순서에 대한 더 복잡하고 의미 지향적인 정의를 사용하려고 시도하지 않습니다. 따라서 유니코드 표준에 따라 정규적으로 같은 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: 평가

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] 참고

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

13.13.1 Runtime Semantics: 평가

LogicalANDExpression : LogicalANDExpression && BitwiseORExpression
  1. leftRef를 LogicalANDExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. ToBoolean(leftValue)이 false이면 leftValue를 반환합니다.
  4. rightRef를 BitwiseORExpression의 ? Evaluation으로 둡니다.
  5. ? GetValue(rightRef)를 반환합니다.
LogicalORExpression : LogicalORExpression || LogicalANDExpression
  1. leftRef를 LogicalORExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. ToBoolean(leftValue)이 true이면 leftValue를 반환합니다.
  4. rightRef를 LogicalANDExpression의 ? Evaluation으로 둡니다.
  5. ? GetValue(rightRef)를 반환합니다.
CoalesceExpression : CoalesceExpressionHead ?? BitwiseORExpression
  1. leftRef를 CoalesceExpressionHead의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. leftValue가 undefined도 null도 아니면 leftValue를 반환합니다.
  4. rightRef를 BitwiseORExpression의 ? Evaluation으로 둡니다.
  5. ? GetValue(rightRef)를 반환합니다.

13.14 조건 연산자 ( ? : )

구문

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

ECMAScript의 ConditionalExpression 문법은 두 번째 하위 표현식을 Expression로 허용하지만 세 번째 표현식은 ConditionalExpression로 제한하는 C 및 Java의 문법과 약간 다릅니다. ECMAScript에서 이렇게 다른 이유는 조건문의 어느 분기에서도 할당 표현식을 사용할 수 있도록 하고, 가운데 표현식에 쉼표 표현식을 사용하는 혼란스럽고 실용성이 매우 낮은 경우를 제거하기 위해서입니다.

13.14.1 Runtime Semantics: 평가

ConditionalExpression : ShortCircuitExpression ? AssignmentExpression : AssignmentExpression
  1. leftRef를 ShortCircuitExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ToBoolean(? GetValue(leftRef))로 둡니다.
  3. leftValue가 true이면, 다음을 수행합니다.
    1. trueRef를 첫 번째 AssignmentExpression의 ? Evaluation으로 둡니다.
    2. ? GetValue(trueRef)를 반환합니다.
  4. falseRef를 두 번째 AssignmentExpression의 ? Evaluation으로 둡니다.
  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: 조기 오류

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

13.15.2 Runtime Semantics: 평가

AssignmentExpression : LeftHandSideExpression = AssignmentExpression
  1. LeftHandSideExpression이 ObjectLiteral도 ArrayLiteral도 아니면, 다음을 수행합니다.
    1. leftRef를 LeftHandSideExpression의 ? Evaluation으로 둡니다.
    2. LeftHandSideExpression의 AssignmentTargetType이 web-compat이면 ReferenceError 예외를 던집니다.
    3. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 LeftHandSideExpression의 IsIdentifierRef가 true이면, 다음을 수행합니다.
      1. lhs를 LeftHandSideExpression의 StringValue로 둡니다.
      2. rightValue를 인수 lhs를 사용한 AssignmentExpression의 ? NamedEvaluation으로 둡니다.
    4. 그렇지 않으면,
      1. rightRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
      2. rightValue를 ? GetValue(rightRef)로 둡니다.
    5. ? PutValue(leftRef, rightValue)를 수행합니다.
    6. rightValue를 반환합니다.
  2. assignmentPattern을 LeftHandSideExpression이 포괄하는 AssignmentPattern으로 둡니다.
  3. rightRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. 인수 rightValue를 사용한 assignmentPattern의 ? DestructuringAssignmentEvaluation을 수행합니다.
  6. rightValue를 반환합니다.
AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression
  1. leftRef를 LeftHandSideExpression의 ? Evaluation으로 둡니다.
  2. LeftHandSideExpression의 AssignmentTargetType이 web-compat이면 ReferenceError 예외를 던집니다.
  3. leftValue를 ? GetValue(leftRef)로 둡니다.
  4. rightRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
  5. rightValue를 ? GetValue(rightRef)로 둡니다.
  6. assignmentOpText를 AssignmentOperator와 일치하는 소스 텍스트로 둡니다.
  7. opText를 다음 표에서 assignmentOpText와 연결된 유니코드 코드 포인트 시퀀스로 둡니다:
    assignmentOpText opText
    **= **
    *= *
    /= /
    %= %
    += +
    -= -
    <<= <<
    >>= >>
    >>>= >>>
    &= &
    ^= ^
    |= |
  8. result를 ? ApplyStringOrNumericBinaryOperator(leftValue, opText, rightValue)로 둡니다.
  9. ? PutValue(leftRef, result)를 수행합니다.
  10. result를 반환합니다.
AssignmentExpression : LeftHandSideExpression &&= AssignmentExpression
  1. leftRef를 LeftHandSideExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. ToBoolean(leftValue)이 false이면 leftValue를 반환합니다.
  4. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 LeftHandSideExpression의 IsIdentifierRef가 true이면, 다음을 수행합니다.
    1. lhs를 LeftHandSideExpression의 StringValue로 둡니다.
    2. rightValue를 인수 lhs를 사용한 AssignmentExpression의 ? NamedEvaluation으로 둡니다.
  5. 그렇지 않으면,
    1. rightRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
    2. rightValue를 ? GetValue(rightRef)로 둡니다.
  6. ? PutValue(leftRef, rightValue)를 수행합니다.
  7. rightValue를 반환합니다.
AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression
  1. leftRef를 LeftHandSideExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. ToBoolean(leftValue)이 true이면 leftValue를 반환합니다.
  4. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 LeftHandSideExpression의 IsIdentifierRef가 true이면, 다음을 수행합니다.
    1. lhs를 LeftHandSideExpression의 StringValue로 둡니다.
    2. rightValue를 인수 lhs를 사용한 AssignmentExpression의 ? NamedEvaluation으로 둡니다.
  5. 그렇지 않으면,
    1. rightRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
    2. rightValue를 ? GetValue(rightRef)로 둡니다.
  6. ? PutValue(leftRef, rightValue)를 수행합니다.
  7. rightValue를 반환합니다.
AssignmentExpression : LeftHandSideExpression ??= AssignmentExpression
  1. leftRef를 LeftHandSideExpression의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. leftValue가 undefined도 null도 아니면 leftValue를 반환합니다.
  4. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이고 LeftHandSideExpression의 IsIdentifierRef가 true이면, 다음을 수행합니다.
    1. lhs를 LeftHandSideExpression의 StringValue로 둡니다.
    2. rightValue를 인수 lhs를 사용한 AssignmentExpression의 ? NamedEvaluation으로 둡니다.
  5. 그렇지 않으면,
    1. rightRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
    2. rightValue를 ? GetValue(rightRef)로 둡니다.
  6. ? PutValue(leftRef, rightValue)를 수행합니다.
  7. rightValue를 반환합니다.
참고

이 표현식이 엄격 모드 코드 안에 나타날 때 1.e, 3, 2, 2, 2 단계의 leftRef가 해석 불가능한 참조이면 런타임 오류입니다. 이 경우 ReferenceError 예외를 던집니다. 또한 9, 6, 6, 6 단계의 leftRef가 속성 값 { [[Writable]]: false }를 갖는 데이터 프로퍼티, 속성 값 { [[Setter]]: undefined }를 갖는 접근자 프로퍼티, 또는 IsExtensible 술어가 false를 반환하는 객체의 존재하지 않는 프로퍼티에 대한 참조이면 런타임 오류입니다. 이러한 경우에는 TypeError 예외를 던집니다.

13.15.3 ApplyStringOrNumericBinaryOperator ( leftValue, opText, rightValue )

추상 연산 ApplyStringOrNumericBinaryOperator. 인수 leftValue (ECMAScript 언어 값), opText ((**, *, /, %, +, -, <<, >>, >>>, &, ^ 또는 |)) 및 rightValue (ECMAScript 언어 값). 반환값: (정상 완료 (값: (String, BigInt 또는 Number)) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. opText가 +이면, 다음을 수행합니다.
    1. leftPrimitive를 ? ToPrimitive(leftValue)로 둡니다.
    2. rightPrimitive를 ? ToPrimitive(rightValue)로 둡니다.
    3. leftPrimitive가 String이거나 rightPrimitive가 String이면, 다음을 수행합니다.
      1. leftString을 ? ToString(leftPrimitive)으로 둡니다.
      2. rightString을 ? ToString(rightPrimitive)으로 둡니다.
      3. leftString과 rightString의 문자열 연결을 반환합니다.
    4. leftValue를 leftPrimitive로 설정합니다.
    5. rightValue를 rightPrimitive로 설정합니다.
  2. 참고: 이 시점에서는 숫자 연산이어야 합니다.
  3. leftNumber를 ? ToNumeric(leftValue)로 둡니다.
  4. rightNumber를 ? ToNumeric(rightValue)로 둡니다.
  5. SameType(leftNumber, rightNumber)이 false이면 TypeError 예외를 던집니다.
  6. leftNumber가 BigInt이면, 다음을 수행합니다.
    1. opText가 **이면 ? BigInt::exponentiate(leftNumber, rightNumber)를 반환합니다.
    2. opText가 /이면 ? BigInt::divide(leftNumber, rightNumber)를 반환합니다.
    3. opText가 %이면 ? BigInt::remainder(leftNumber, rightNumber)를 반환합니다.
    4. opText가 >>>이면 ? BigInt::unsignedRightShift(leftNumber, rightNumber)를 반환합니다.
    5. operation을 다음 표에서 opText와 연결된 추상 연산으로 둡니다:
      opText operation
      * BigInt::multiply
      + BigInt::add
      - BigInt::subtract
      << BigInt::leftShift
      >> BigInt::signedRightShift
      & BigInt::bitwiseAND
      ^ BigInt::bitwiseXOR
      | BigInt::bitwiseOR
  7. 그렇지 않으면,
    1. 단언: leftNumber는 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(leftNumber, rightNumber)을 반환합니다.
참고 1

1.a 및 1.b 단계의 ToPrimitive 호출에는 hint가 제공되지 않습니다. Date를 제외한 모든 표준 객체는 hint가 없는 경우를 number가 제공된 것처럼 처리하며, Date는 hint가 없는 경우를 string이 제공된 것처럼 처리합니다. 특수 객체는 hint가 없는 경우를 다른 방식으로 처리할 수 있습니다.

참고 2

1.c 단계는 logical-and 연산 대신 logical-or 연산을 사용한다는 점에서 IsLessThan 알고리즘의 3 단계와 다릅니다.

13.15.4 EvaluateStringOrNumericBinaryExpression ( leftOperand, opText, rightOperand )

추상 연산 EvaluateStringOrNumericBinaryExpression. 인수 leftOperand (구문 분석 노드), opText ((**, *, /, %, +, -, <<, >>, >>>, &, ^ 또는 |)) 및 rightOperand (구문 분석 노드). 반환값: (정상 완료 (값: (String, BigInt 또는 Number)) 또는 중도 완료). 호출되면 다음 단계를 수행한다.

  1. leftRef를 leftOperand의 ? Evaluation으로 둡니다.
  2. leftValue를 ? GetValue(leftRef)로 둡니다.
  3. rightRef를 rightOperand의 ? Evaluation으로 둡니다.
  4. rightValue를 ? GetValue(rightRef)로 둡니다.
  5. ? ApplyStringOrNumericBinaryOperator(leftValue, opText, rightValue)를 반환합니다.

13.15.5 구조 분해 할당

보충 구문

특정 상황에서 다음 생성 규칙의 인스턴스를 처리할 때
AssignmentExpression : LeftHandSideExpression = AssignmentExpression
LeftHandSideExpression의 해석은 다음 문법을 사용하여 구체화됩니다:

AssignmentPattern[Yield, Await] : ObjectAssignmentPattern[?Yield, ?Await] ArrayAssignmentPattern[?Yield, ?Await] ObjectAssignmentPattern[Yield, Await] : { } { AssignmentRestProperty[?Yield, ?Await] } { AssignmentPropertyList[?Yield, ?Await] ,opt } { AssignmentPropertyList[?Yield, ?Await] , AssignmentRestProperty[?Yield, ?Await] } 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: 조기 오류

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

13.15.5.2 Runtime Semantics: DestructuringAssignmentEvaluation

구문 지향 연산 DestructuringAssignmentEvaluation. 인수 value (ECMAScript 언어 값). 반환값: (정상 완료 (값: unused) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

ObjectAssignmentPattern : { }
  1. ? RequireObjectCoercible(value)를 수행합니다.
  2. unused를 반환합니다.
ObjectAssignmentPattern : { AssignmentPropertyList ,opt }
  1. ? RequireObjectCoercible(value)를 수행합니다.
  2. 인수 value를 사용한 AssignmentPropertyList의 ? PropertyDestructuringAssignmentEvaluation을 수행합니다.
  3. unused를 반환합니다.
ObjectAssignmentPattern : { AssignmentRestProperty }
  1. ? RequireObjectCoercible(value)를 수행합니다.
  2. excludedNames를 새로운 빈 List로 둡니다.
  3. 인수 value 및 excludedNames를 사용한 AssignmentRestProperty의 ? RestDestructuringAssignmentEvaluation을 반환합니다.
ObjectAssignmentPattern : { AssignmentPropertyList , AssignmentRestProperty }
  1. ? RequireObjectCoercible(value)를 수행합니다.
  2. excludedNames를 인수 value를 사용한 AssignmentPropertyList의 ? PropertyDestructuringAssignmentEvaluation으로 둡니다.
  3. 인수 value 및 excludedNames를 사용한 AssignmentRestProperty의 ? RestDestructuringAssignmentEvaluation을 반환합니다.
ArrayAssignmentPattern : [ ]
  1. iteratorRecord를 ? GetIterator(value, sync)로 둡니다.
  2. ? IteratorClose(iteratorRecord, NormalCompletion(unused))를 반환합니다.
ArrayAssignmentPattern : [ Elision ]
  1. iteratorRecord를 ? GetIterator(value, sync)로 둡니다.
  2. result를 Completion(인수 iteratorRecord를 사용한 Elision의 IteratorDestructuringAssignmentEvaluation)로 둡니다.
  3. iteratorRecord.[[Done]]이 false이면 ? IteratorClose(iteratorRecord, result)를 반환합니다.
  4. result를 반환합니다.
ArrayAssignmentPattern : [ Elisionopt AssignmentRestElement ]
  1. iteratorRecord를 ? GetIterator(value, sync)로 둡니다.
  2. Elision이 존재하면, 다음을 수행합니다.
    1. status를 Completion(인수 iteratorRecord를 사용한 Elision의 IteratorDestructuringAssignmentEvaluation)로 둡니다.
    2. status가 비정상 완료이면, 다음을 수행합니다.
      1. 단언: iteratorRecord.[[Done]]은 true입니다.
      2. ? status를 반환합니다.
  3. result를 Completion(인수 iteratorRecord를 사용한 AssignmentRestElement의 IteratorDestructuringAssignmentEvaluation)로 둡니다.
  4. iteratorRecord.[[Done]]이 false이면 ? IteratorClose(iteratorRecord, result)를 반환합니다.
  5. result를 반환합니다.
ArrayAssignmentPattern : [ AssignmentElementList ]
  1. iteratorRecord를 ? GetIterator(value, sync)로 둡니다.
  2. result를 Completion(인수 iteratorRecord를 사용한 AssignmentElementList의 IteratorDestructuringAssignmentEvaluation)로 둡니다.
  3. iteratorRecord.[[Done]]이 false이면 ? IteratorClose(iteratorRecord, result)를 반환합니다.
  4. result를 반환합니다.
ArrayAssignmentPattern : [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
  1. iteratorRecord를 ? GetIterator(value, sync)로 둡니다.
  2. status를 Completion(인수 iteratorRecord를 사용한 AssignmentElementList의 IteratorDestructuringAssignmentEvaluation)로 둡니다.
  3. status가 비정상 완료이면, 다음을 수행합니다.
    1. iteratorRecord.[[Done]]이 false이면 ? IteratorClose(iteratorRecord, status)를 반환합니다.
    2. ? status를 반환합니다.
  4. Elision이 존재하면, 다음을 수행합니다.
    1. status를 Completion(인수 iteratorRecord를 사용한 Elision의 IteratorDestructuringAssignmentEvaluation)으로 설정합니다.
    2. status가 비정상 완료이면, 다음을 수행합니다.
      1. 단언: iteratorRecord.[[Done]]은 true입니다.
      2. ? status를 반환합니다.
  5. AssignmentRestElement가 존재하면, 다음을 수행합니다.
    1. status를 Completion(인수 iteratorRecord를 사용한 AssignmentRestElement의 IteratorDestructuringAssignmentEvaluation)으로 설정합니다.
  6. iteratorRecord.[[Done]]이 false이면 ? IteratorClose(iteratorRecord, status)를 반환합니다.
  7. ? status를 반환합니다.

13.15.5.3 Runtime Semantics: PropertyDestructuringAssignmentEvaluation

구문 지향 연산 PropertyDestructuringAssignmentEvaluation. 인수 value (ECMAScript 언어 값). 반환값: (정상 완료 (값: 리스트 (요소: 프로퍼티 키)) 또는 중도 완료). 구조 분해된 모든 프로퍼티 키의 목록을 수집합니다. 다음 생성 규칙별로 정의된다.

AssignmentPropertyList : AssignmentPropertyList , AssignmentProperty
  1. propertyNames를 인수 value를 사용한 AssignmentPropertyList의 ? PropertyDestructuringAssignmentEvaluation으로 둡니다.
  2. nextNames를 인수 value를 사용한 AssignmentProperty의 ? PropertyDestructuringAssignmentEvaluation으로 둡니다.
  3. propertyNames와 nextNames의 목록 연결을 반환합니다.
AssignmentProperty : IdentifierReference Initializeropt
  1. propertyName을 IdentifierReference의 StringValue로 둡니다.
  2. leftRef를 ? ResolveBinding(propertyName)으로 둡니다.
  3. value를 ? GetV(value, propertyName)로 설정합니다.
  4. Initializer가 존재하고 value가 undefined이면, 다음을 수행합니다.
    1. IsAnonymousFunctionDefinition(Initializer)이 true이면, 다음을 수행합니다.
      1. value를 인수 propertyName을 사용한 Initializer의 ? NamedEvaluation으로 설정합니다.
    2. 그렇지 않으면,
      1. defaultValue를 Initializer의 ? Evaluation으로 둡니다.
      2. value를 ? GetValue(defaultValue)로 설정합니다.
  5. ? PutValue(leftRef, value)를 수행합니다.
  6. « propertyName »을 반환합니다.
AssignmentProperty : PropertyName : AssignmentElement
  1. name을 PropertyName의 ? Evaluation으로 둡니다.
  2. 인수 value 및 name을 사용한 AssignmentElement의 ? KeyedDestructuringAssignmentEvaluation을 수행합니다.
  3. « name »을 반환합니다.

13.15.5.4 Runtime Semantics: RestDestructuringAssignmentEvaluation

구문 지향 연산 RestDestructuringAssignmentEvaluation. 인수 value (ECMAScript 언어 값) 및 excludedNames (리스트 (요소: 프로퍼티 키)). 반환값: (정상 완료 (값: unused) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

AssignmentRestProperty : ... DestructuringAssignmentTarget
  1. leftRef를 DestructuringAssignmentTarget의 ? Evaluation으로 둡니다.
  2. restObj를 OrdinaryObjectCreate(%Object.prototype%)로 둡니다.
  3. ? CopyDataProperties(restObj, value, excludedNames)를 수행합니다.
  4. ? PutValue(leftRef, restObj)를 반환합니다.

13.15.5.5 Runtime Semantics: IteratorDestructuringAssignmentEvaluation

구문 지향 연산 IteratorDestructuringAssignmentEvaluation. 인수 iteratorRecord (Iterator 레코드). 반환값: (정상 완료 (값: unused) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

AssignmentElementList : AssignmentElisionElement
  1. 인수 iteratorRecord를 사용한 AssignmentElisionElement의 ? IteratorDestructuringAssignmentEvaluation을 반환합니다.
AssignmentElementList : AssignmentElementList , AssignmentElisionElement
  1. 인수 iteratorRecord를 사용한 AssignmentElementList의 ? IteratorDestructuringAssignmentEvaluation을 수행합니다.
  2. 인수 iteratorRecord를 사용한 AssignmentElisionElement의 ? IteratorDestructuringAssignmentEvaluation을 반환합니다.
AssignmentElisionElement : AssignmentElement
  1. 인수 iteratorRecord를 사용한 AssignmentElement의 ? IteratorDestructuringAssignmentEvaluation을 반환합니다.
AssignmentElisionElement : Elision AssignmentElement
  1. 인수 iteratorRecord를 사용한 Elision의 ? IteratorDestructuringAssignmentEvaluation을 수행합니다.
  2. 인수 iteratorRecord를 사용한 AssignmentElement의 ? IteratorDestructuringAssignmentEvaluation을 반환합니다.
Elision : ,
  1. iteratorRecord.[[Done]]이 false이면, 다음을 수행합니다.
    1. ? IteratorStep(iteratorRecord)을 수행합니다.
  2. unused를 반환합니다.
Elision : Elision ,
  1. 인수 iteratorRecord를 사용한 Elision의 ? IteratorDestructuringAssignmentEvaluation을 수행합니다.
  2. iteratorRecord.[[Done]]이 false이면, 다음을 수행합니다.
    1. ? IteratorStep(iteratorRecord)을 수행합니다.
  3. unused를 반환합니다.
AssignmentElement : DestructuringAssignmentTarget Initializeropt
  1. DestructuringAssignmentTarget이 ObjectLiteral도 ArrayLiteral도 아니면, 다음을 수행합니다.
    1. leftRef를 DestructuringAssignmentTarget의 ? Evaluation으로 둡니다.
  2. value를 undefined로 둡니다.
  3. iteratorRecord.[[Done]]이 false이면, 다음을 수행합니다.
    1. next를 ? IteratorStepValue(iteratorRecord)로 둡니다.
    2. next가 done이 아니면, 다음을 수행합니다.
      1. value를 next로 설정합니다.
  4. Initializer가 존재하고 value가 undefined이면, 다음을 수행합니다.
    1. IsAnonymousFunctionDefinition(Initializer)이 true이고 DestructuringAssignmentTarget의 IsIdentifierRef가 true이면, 다음을 수행합니다.
      1. target을 DestructuringAssignmentTarget의 StringValue로 둡니다.
      2. value를 인수 target을 사용한 Initializer의 ? NamedEvaluation으로 설정합니다.
    2. 그렇지 않으면,
      1. defaultValue를 Initializer의 ? Evaluation으로 둡니다.
      2. value를 ? GetValue(defaultValue)로 설정합니다.
  5. DestructuringAssignmentTarget이 ObjectLiteral 또는 ArrayLiteral이면, 다음을 수행합니다.
    1. nestedAssignmentPattern을 DestructuringAssignmentTarget이 포괄하는 AssignmentPattern으로 둡니다.
    2. 인수 value를 사용한 nestedAssignmentPattern의 ? DestructuringAssignmentEvaluation을 반환합니다.
  6. ? PutValue(leftRef, value)를 반환합니다.
참고

구조 분해 패턴이 아닌 DestructuringAssignmentTarget을 반복자에 접근하거나 Initializer를 평가하기 전에 평가하여 왼쪽에서 오른쪽으로의 평가 순서를 유지합니다.

AssignmentRestElement : ... DestructuringAssignmentTarget
  1. DestructuringAssignmentTarget이 ObjectLiteral도 ArrayLiteral도 아니면, 다음을 수행합니다.
    1. leftRef를 DestructuringAssignmentTarget의 ? Evaluation으로 둡니다.
  2. array를 ! ArrayCreate(0)으로 둡니다.
  3. n을 0으로 둡니다.
  4. iteratorRecord.[[Done]]이 false인 동안 다음을 반복합니다.
    1. next를 ? IteratorStepValue(iteratorRecord)로 둡니다.
    2. next가 done이 아니면, 다음을 수행합니다.
      1. ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), next)를 수행합니다.
      2. n을 n + 1로 설정합니다.
  5. DestructuringAssignmentTarget이 ObjectLiteral도 ArrayLiteral도 아니면, 다음을 수행합니다.
    1. ? PutValue(leftRef, array)를 반환합니다.
  6. nestedAssignmentPattern을 DestructuringAssignmentTarget이 포괄하는 AssignmentPattern으로 둡니다.
  7. 인수 array를 사용한 nestedAssignmentPattern의 ? DestructuringAssignmentEvaluation을 반환합니다.

13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation

구문 지향 연산 KeyedDestructuringAssignmentEvaluation. 인수 value (ECMAScript 언어 값) 및 propertyName (프로퍼티 키). 반환값: (정상 완료 (값: unused) 또는 중도 완료). 다음 생성 규칙별로 정의된다.

AssignmentElement : DestructuringAssignmentTarget Initializeropt
  1. DestructuringAssignmentTarget이 ObjectLiteral도 ArrayLiteral도 아니면, 다음을 수행합니다.
    1. leftRef를 DestructuringAssignmentTarget의 ? Evaluation으로 둡니다.
  2. value를 ? GetV(value, propertyName)로 설정합니다.
  3. Initializer가 존재하고 value가 undefined이면, 다음을 수행합니다.
    1. IsAnonymousFunctionDefinition(Initializer)이 true이고 DestructuringAssignmentTarget의 IsIdentifierRef가 true이면, 다음을 수행합니다.
      1. target을 DestructuringAssignmentTarget의 StringValue로 둡니다.
      2. rhsValue를 인수 target을 사용한 Initializer의 ? NamedEvaluation으로 둡니다.
    2. 그렇지 않으면,
      1. defaultValue를 Initializer의 ? Evaluation으로 둡니다.
      2. rhsValue를 ? GetValue(defaultValue)로 둡니다.
  4. 그렇지 않으면,
    1. rhsValue를 value로 둡니다.
  5. DestructuringAssignmentTarget이 ObjectLiteral 또는 ArrayLiteral이면, 다음을 수행합니다.
    1. assignmentPattern을 DestructuringAssignmentTarget이 포괄하는 AssignmentPattern으로 둡니다.
    2. 인수 rhsValue를 사용한 assignmentPattern의 ? DestructuringAssignmentEvaluation을 반환합니다.
  6. ? PutValue(leftRef, rhsValue)를 반환합니다.

13.16 쉼표 연산자 ( , )

구문

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

13.16.1 Runtime Semantics: 평가

Expression : Expression , AssignmentExpression
  1. leftRef를 Expression의 ? Evaluation으로 둡니다.
  2. ? GetValue(leftRef)를 수행합니다.
  3. rightRef를 AssignmentExpression의 ? Evaluation으로 둡니다.
  4. ? GetValue(rightRef)를 반환합니다.
참고

값을 사용하지 않더라도 관찰 가능한 부작용이 있을 수 있으므로 GetValue를 호출해야 합니다.