7 추상 연산(Abstract Operations)

이 연산들은 ECMAScript 언어의 일부가 아니며; ECMAScript 언어의 의미론을 명세하기 쉽게 하기 위해 여기에서만 정의됩니다. 이 명세 전반에 걸쳐 보다 특수화된 다른 추상 연산들이 정의됩니다.

7.1 타입 변환(Type Conversion)

ECMAScript 언어는 필요에 따라 자동으로 암시적 타입 변환을 수행합니다. 특정 구성의 의미론을 명확히 하기 위해 일련의 변환 추상 연산을 정의하는 것이 유용합니다. 변환 추상 연산은 다형적이며; 어떤 ECMAScript 언어 타입의 값이든 받을 수 있습니다. 그러나 다른 명세 타입은 이러한 연산과 함께 사용되지 않습니다.

BigInt 타입은 ECMAScript 언어에서 암시적 변환이 없습니다; 프로그래머는 다른 타입에서 값을 변환하기 위해 반드시 BigInt를 명시적으로 호출해야 합니다.

7.1.1 ToPrimitive ( input [ , preferredType ] )

The abstract operation ToPrimitive takes argument input (ECMAScript 언어 값) and optional argument preferredType (string 또는 number) and returns ECMAScript 언어 값을 담는 normal completion 또는 throw completion. input 인수를 비-Object 타입으로 변환합니다. 객체가 둘 이상의 원시 타입으로 변환 가능하다면 선택적 힌트 preferredType을 사용하여 그 타입을 우선할 수 있습니다. It performs the following steps when called:

  1. input이 Object이면,
    1. exoticToPrim을 ? GetMethod(input, %Symbol.toPrimitive%)로 둔다.
    2. exoticToPrimundefined가 아니면,
      1. preferredType이 존재하지 않으면,
        1. hint"default"로 둔다.
      2. Else if preferredTypestring이면,
        1. hint"string"으로 둔다.
      3. Else,
        1. 단언: preferredTypenumber이다.
        2. hint"number"로 둔다.
      4. result를 ? Call(exoticToPrim, input, « hint »)로 둔다.
      5. result가 Object가 아니면 result를 반환한다.
      6. TypeError 예외를 던진다.
    3. preferredType이 존재하지 않으면 preferredTypenumber로 둔다.
    4. OrdinaryToPrimitive(input, preferredType)을 반환한다.
  2. input을 반환한다.
Note

ToPrimitive가 힌트 없이 호출되면 일반적으로 힌트가 number인 것처럼 동작합니다. 그러나 객체는 %Symbol.toPrimitive% 메서드를 정의하여 이 동작을 재정의할 수 있습니다. 이 명세에 정의된 객체 중 Date( 21.4.4.45 참조 )와 Symbol 객체( 20.4.3.5 참조 )만이 기본 ToPrimitive 동작을 재정의합니다. Date는 힌스가 없는 경우 힌트가 string인 것처럼 취급합니다.

7.1.1.1 OrdinaryToPrimitive ( O, hint )

The abstract operation OrdinaryToPrimitive takes arguments O (Object) and hint (string 또는 number) and returns ECMAScript 언어 값을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. hintstring이면,
    1. methodNames를 « "toString", "valueOf" »로 둔다.
  2. Else,
    1. methodNames를 « "valueOf", "toString" »으로 둔다.
  3. methodNames의 각 요소 name에 대해,
    1. method를 ? Get(O, name)으로 둔다.
    2. IsCallable(method)가 true이면,
      1. result를 ? Call(method, O)로 둔다.
      2. result가 Object가 아니면 result를 반환한다.
  4. TypeError 예외를 던진다.

7.1.2 ToBoolean ( argument )

The abstract operation ToBoolean takes argument argument (ECMAScript 언어 값) and returns Boolean. argumentBoolean 타입 값으로 변환합니다. It performs the following steps when called:

  1. argument가 Boolean이면 argument를 반환한다.
  2. argumentundefined, null, +0𝔽, -0𝔽, NaN, 0, 또는 빈 String 중 하나이면 false를 반환한다.
  3. Normative Optional
    호스트가 웹 브라우저이거나 [[IsHTMLDDA]] 내부 슬롯를 지원하면,
    1. argument가 Object이고 [[IsHTMLDDA]] 내부 슬롯을 갖고 있으면 false를 반환한다.
  4. true를 반환한다.

7.1.3 ToNumeric ( value )

The abstract operation ToNumeric takes argument value (ECMAScript 언어 값) and returns Number 또는 BigInt를 담는 normal completion 또는 throw completion. value를 Number 또는 BigInt로 변환하여 반환합니다. It performs the following steps when called:

  1. primValue를 ? ToPrimitive(value, number)로 둔다.
  2. primValue가 BigInt이면 primValue를 반환한다.
  3. ToNumber(primValue)를 반환한다.

7.1.4 ToNumber ( argument )

The abstract operation ToNumber takes argument argument (ECMAScript 언어 값) and returns Number를 담는 normal completion 또는 throw completion. argumentNumber 타입 값으로 변환합니다. It performs the following steps when called:

  1. argument가 Number이면 argument를 반환한다.
  2. argument가 Symbol 또는 BigInt이면 TypeError 예외를 던진다.
  3. argumentundefined이면 NaN을 반환한다.
  4. argumentnull 또는 false이면 +0𝔽을 반환한다.
  5. argumenttrue이면 1𝔽을 반환한다.
  6. argument가 String이면 StringToNumber(argument)를 반환한다.
  7. 단언: argument는 Object이다.
  8. primValue를 ? ToPrimitive(argument, number)로 둔다.
  9. 단언: primValue는 Object가 아니다.
  10. ToNumber(primValue)를 반환한다.

7.1.4.1 String 타입에 적용된 ToNumber

추상 연산 StringToNumber는 다음 문법을 사용하여 String 값을 Number 값으로 변환하는 방법을 지정합니다.

Syntax

StringNumericLiteral ::: StrWhiteSpaceopt StrWhiteSpaceopt StrNumericLiteral StrWhiteSpaceopt StrWhiteSpace ::: StrWhiteSpaceChar StrWhiteSpaceopt StrWhiteSpaceChar ::: WhiteSpace LineTerminator StrNumericLiteral ::: StrDecimalLiteral NonDecimalIntegerLiteral[~Sep] StrDecimalLiteral ::: StrUnsignedDecimalLiteral + StrUnsignedDecimalLiteral - StrUnsignedDecimalLiteral StrUnsignedDecimalLiteral ::: Infinity DecimalDigits[~Sep] . DecimalDigits[~Sep]opt ExponentPart[~Sep]opt . DecimalDigits[~Sep] ExponentPart[~Sep]opt DecimalDigits[~Sep] ExponentPart[~Sep]opt

위에서 명시적으로 정의되지 않은 모든 문법 기호는 숫자 리터럴에 대한 어휘 문법(12.9.3)에서 사용된 정의를 갖습니다.

Note

StringNumericLiteralNumericLiteral의 문법에는 다음과 같은 차이가 있습니다:

7.1.4.1.1 StringToNumber ( str )

The abstract operation StringToNumber takes argument str (String) and returns Number. It performs the following steps when called:

  1. literal을 ParseText(str, StringNumericLiteral)로 둔다.
  2. literal이 오류들의 List이면 NaN을 반환한다.
  3. literal의 StringNumericValue를 반환한다.

7.1.4.1.2 런타임 의미론: StringNumericValue : Number

The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS.

Note

StringNumericLiteral을 Number 값으로 변환하는 과정은 전반적으로 NumericLiteral의 NumericValue 결정(12.9.3)과 유사하지만 일부 세부 사항은 다릅니다.

It is defined piecewise over the following productions:

StringNumericLiteral ::: StrWhiteSpaceopt
  1. +0𝔽을 반환한다.
StringNumericLiteral ::: StrWhiteSpaceopt StrNumericLiteral StrWhiteSpaceopt
  1. StrNumericLiteral의 StringNumericValue를 반환한다.
StrNumericLiteral ::: NonDecimalIntegerLiteral
  1. 𝔽(MV of NonDecimalIntegerLiteral)을 반환한다.
StrDecimalLiteral ::: - StrUnsignedDecimalLiteral
  1. aStrUnsignedDecimalLiteral의 StringNumericValue로 둔다.
  2. a+0𝔽이면 -0𝔽을 반환한다.
  3. -a를 반환한다.
StrUnsignedDecimalLiteral ::: Infinity
  1. +∞𝔽를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits . DecimalDigitsopt ExponentPartopt
  1. a를 첫 번째 DecimalDigits의 MV로 둔다.
  2. 두 번째 DecimalDigits가 존재하면,
    1. b를 두 번째 DecimalDigits의 MV로 둔다.
    2. n을 두 번째 DecimalDigits의 코드 포인트 수로 둔다.
  3. Else,
    1. b를 0으로 둔다.
    2. n을 0으로 둔다.
  4. ExponentPart가 존재하면 eExponentPart의 MV로, 아니면 e를 0으로 둔다.
  5. RoundMVResult((a + (b × 10-n)) × 10e)를 반환한다.
StrUnsignedDecimalLiteral ::: . DecimalDigits ExponentPartopt
  1. bDecimalDigits의 MV로 둔다.
  2. ExponentPart가 존재하면 eExponentPart의 MV로, 아니면 e를 0으로 둔다.
  3. nDecimalDigits의 코드 포인트 수로 둔다.
  4. RoundMVResult(b × 10e - n)를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPartopt
  1. aDecimalDigits의 MV로 둔다.
  2. ExponentPart가 존재하면 eExponentPart의 MV로, 아니면 e를 0으로 둔다.
  3. RoundMVResult(a × 10e)를 반환한다.

7.1.4.1.3 RoundMVResult ( n )

The abstract operation RoundMVResult takes argument n (수학적 값) and returns Number. 구현 정의 방식으로 n을 Number로 변환합니다. 이 추상 연산의 목적상, 어떤 자릿수가 0이 아니거나 그 왼쪽에 0이 아닌 자릿수가 있고 오른쪽에 0이 아닌 자릿수가 있는 경우 유효 자릿수입니다. 또한 “수학적 값을 나타내는 표현”의 수학적 값은 “수학적 값의 10진 표현”의 역입니다. It performs the following steps when called:

  1. n의 10진 표현이 20개 이하의 유효 자릿수를 가지면 𝔽(n)을 반환한다.
  2. option1을: n의 10진 표현에서 20번째 이후 모든 유효 자릿수를 0으로 대체한 결과가 나타내는 수학적 값으로 둔다.
  3. option2를: n의 10진 표현에서 20번째 이후 모든 유효 자릿수를 0으로 대체한 다음 20번째 위치를 (필요한 자리 올림과 함께) 1 증가시킨 결과가 나타내는 수학적 값으로 둔다.
  4. chosen구현 정의option1 또는 option2 중 하나로 둔다.
  5. 𝔽(chosen)을 반환한다.

7.1.5 ToIntegerOrInfinity ( argument )

The abstract operation ToIntegerOrInfinity takes argument argument (ECMAScript 언어 값) and returns 정수, +∞ 또는 -∞ 중 하나를 담는 normal completion 또는 throw completion. argument를 그 Number 값에서 소수 부분을 절단한 정수로, 혹은 그 Number 값이 무한대일 경우 +∞ 또는 -∞로 변환합니다. It performs the following steps when called:

  1. number를 ? ToNumber(argument)로 둔다.
  2. numberNaN, +0𝔽, -0𝔽 중 하나이면 0을 반환한다.
  3. number+∞𝔽이면 +∞를 반환한다.
  4. number-∞𝔽이면 -∞를 반환한다.
  5. truncate((number))를 반환한다.
Note
𝔽(ToIntegerOrInfinity(x))는 어떤 x에 대해서도 -0𝔽을 반환하지 않습니다. 소수 부분 절단은 x수학적 값으로 변환한 후 수행됩니다.

7.1.6 ToInt32 ( argument )

The abstract operation ToInt32 takes argument argument (ECMAScript 언어 값) and returns 적분 Number를 담는 normal completion 또는 throw completion. argument𝔽(-231)부터 𝔽(231 - 1)까지(포함) 232개의 적분 Number 값 중 하나로 변환합니다. It performs the following steps when called:

  1. number를 ? ToNumber(argument)로 둔다.
  2. number유한이 아니거나 +0𝔽 또는 -0𝔽이면 +0𝔽을 반환한다.
  3. inttruncate((number))로 둔다.
  4. int32bitint modulo 232로 둔다.
  5. int32bit ≥ 231이면 𝔽(int32bit - 232)을, 아니면 𝔽(int32bit)을 반환한다.
Note

위 정의에 따른 ToInt32의 성질:

  • ToInt32 추상 연산은 멱등성: 자신의 결과에 다시 적용해도 값은 변하지 않습니다.
  • 모든 x에 대해 ToInt32(ToUint32(x))는 ToInt32(x)와 동일한 값입니다. (이 후속 성질을 보존하기 위해 +∞𝔽-∞𝔽+0𝔽으로 매핑됩니다.)
  • ToInt32는 -0𝔽+0𝔽으로 매핑합니다.

7.1.7 ToUint32 ( argument )

The abstract operation ToUint32 takes argument argument (ECMAScript 언어 값) and returns 적분 Number를 담는 normal completion 또는 throw completion. argument+0𝔽에서 𝔽(232 - 1)까지(포함) 232개의 적분 Number 값 중 하나로 변환합니다. It performs the following steps when called:

  1. number를 ? ToNumber(argument)로 둔다.
  2. number유한이 아니거나 +0𝔽 또는 -0𝔽이면 +0𝔽을 반환한다.
  3. inttruncate((number))로 둔다.
  4. int32bitint modulo 232로 둔다.
  5. 𝔽(int32bit)를 반환한다.
Note

위 정의에 따른 ToUint32의 성질:

  • 5 단계가 ToUint32와 ToInt32의 유일한 차이점입니다.
  • ToUint32 추상 연산은 멱등성입니다.
  • 모든 x에 대해 ToUint32(ToInt32(x))는 ToUint32(x)와 동일합니다. (+∞𝔽, -∞𝔽+0𝔽으로 매핑되는 이유.)
  • ToUint32는 -0𝔽+0𝔽으로 매핑합니다.

7.1.8 ToInt16 ( argument )

The abstract operation ToInt16 takes argument argument (ECMAScript 언어 값) and returns 적분 Number를 담는 normal completion 또는 throw completion. argument𝔽(-215)부터 𝔽(215 - 1)까지(포함) 216개의 적분 Number 값 중 하나로 변환합니다. It performs the following steps when called:

  1. number를 ? ToNumber(argument)로 둔다.
  2. number유한이 아니거나 +0𝔽 또는 -0𝔽이면 +0𝔽을 반환한다.
  3. inttruncate((number))로 둔다.
  4. int16bitint modulo 216으로 둔다.
  5. int16bit ≥ 215이면 𝔽(int16bit - 216)을, 아니면 𝔽(int16bit)을 반환한다.

7.1.9 ToUint16 ( argument )

The abstract operation ToUint16 takes argument argument (ECMAScript 언어 값) and returns 적분 Number를 담는 normal completion 또는 throw completion. argument+0𝔽에서 𝔽(216 - 1)까지(포함) 216개의 적분 Number 값 중 하나로 변환합니다. It performs the following steps when called:

  1. number를 ? ToNumber(argument)로 둔다.
  2. number유한이 아니거나 +0𝔽 또는 -0𝔽이면 +0𝔽을 반환한다.
  3. inttruncate((number))로 둔다.
  4. int16bitint modulo 216으로 둔다.
  5. 𝔽(int16bit)를 반환한다.
Note

위 정의에 따른 ToUint16의 성질:

  • 4 단계에서 216을 232 대신 사용하는 점이 ToUint32와 ToUint16의 유일한 차이입니다.
  • ToUint16은 -0𝔽+0𝔽으로 매핑합니다.

7.1.10 ToInt8 ( argument )

The abstract operation ToInt8 takes argument argument (ECMAScript 언어 값) and returns 적분 Number를 담는 normal completion 또는 throw completion. argument-128𝔽에서 127𝔽까지(포함) 28개의 적분 Number 값 중 하나로 변환합니다. It performs the following steps when called:

  1. number를 ? ToNumber(argument)로 둔다.
  2. number유한이 아니거나 +0𝔽 또는 -0𝔽이면 +0𝔽을 반환한다.
  3. inttruncate((number))로 둔다.
  4. int8bitint modulo 28로 둔다.
  5. int8bit ≥ 27이면 𝔽(int8bit - 28)을, 아니면 𝔽(int8bit)을 반환한다.

7.1.11 ToUint8 ( argument )

The abstract operation ToUint8 takes argument argument (ECMAScript 언어 값) and returns 적분 Number를 담는 normal completion 또는 throw completion. argument+0𝔽에서 255𝔽까지(포함) 28개의 적분 Number 값 중 하나로 변환합니다. It performs the following steps when called:

  1. number를 ? ToNumber(argument)로 둔다.
  2. number유한이 아니거나 +0𝔽 또는 -0𝔽이면 +0𝔽을 반환한다.
  3. inttruncate((number))로 둔다.
  4. int8bitint modulo 28로 둔다.
  5. 𝔽(int8bit)를 반환한다.

7.1.12 ToUint8Clamp ( argument )

The abstract operation ToUint8Clamp takes argument argument (ECMAScript 언어 값) and returns 적분 Number를 담는 normal completion 또는 throw completion. argument+0𝔽에서 255𝔽까지(포함) 28개의 적분 Number 값 중 하나로 클램프(clamp)하고 반올림합니다. It performs the following steps when called:

  1. number를 ? ToNumber(argument)로 둔다.
  2. numberNaN이면 +0𝔽을 반환한다.
  3. mvnumber의 확장된 수학적 값으로 둔다.
  4. clampedmv를 0과 255 사이로 클램프한 결과로 둔다.
  5. ffloor(clamped)로 둔다.
  6. clamped < f + 0.5이면 𝔽(f)를 반환한다.
  7. clamped > f + 0.5이면 𝔽(f + 1)을 반환한다.
  8. f가 짝수이면 𝔽(f)를; 아니면 𝔽(f + 1)을 반환한다.
Note

대부분 다른 ECMAScript 정수 변환 연산과 달리 ToUint8Clamp는 비정수 값을 절단(truncate)하지 않고 반올림합니다. 또한 “round half up”을 사용하는 Math.round와 달리 “round half to even” 절충 규칙을 사용합니다.

7.1.13 ToBigInt ( argument )

The abstract operation ToBigInt takes argument argument (ECMAScript 언어 값) and returns BigInt를 담는 normal completion 또는 throw completion. argument를 BigInt 값으로 변환하며, Number에서의 암시적 변환이 필요하다면 예외를 던집니다. It performs the following steps when called:

  1. prim을 ? ToPrimitive(argument, number)로 둔다.
  2. Table 12prim이 대응하는 값을 반환한다.
Table 12: BigInt 변환
Argument 타입 결과
Undefined TypeError 예외를 던진다.
Null TypeError 예외를 던진다.
Boolean primtrue이면 1n, false이면 0n을 반환한다.
BigInt prim을 반환한다.
Number TypeError 예외를 던진다.
String
  1. nStringToBigInt(prim)로 둔다.
  2. nundefined이면 SyntaxError 예외를 던진다.
  3. n을 반환한다.
Symbol TypeError 예외를 던진다.

7.1.14 StringToBigInt ( str )

The abstract operation StringToBigInt takes argument str (String) and returns BigInt 또는 undefined. It performs the following steps when called:

  1. literal을 ParseText(str, StringIntegerLiteral)로 둔다.
  2. literal이 오류들의 List이면 undefined를 반환한다.
  3. mvliteral의 MV로 둔다.
  4. 단언: mv는 정수이다.
  5. (mv)를 반환한다.

7.1.14.1 StringIntegerLiteral 문법

StringToBigInt는 다음 문법을 사용합니다.

Syntax

StringIntegerLiteral ::: StrWhiteSpaceopt StrWhiteSpaceopt StrIntegerLiteral StrWhiteSpaceopt StrIntegerLiteral ::: SignedInteger[~Sep] NonDecimalIntegerLiteral[~Sep]

7.1.14.2 런타임 의미론: MV

7.1.15 ToBigInt64 ( argument )

The abstract operation ToBigInt64 takes argument argument (ECMAScript 언어 값) and returns BigInt를 담는 normal completion 또는 throw completion. argument(-263)부터 (263 - 1)까지(포함) 264개의 BigInt 값 중 하나로 변환합니다. It performs the following steps when called:

  1. n을 ? ToBigInt(argument)로 둔다.
  2. int64bit(n) modulo 264로 둔다.
  3. int64bit ≥ 263이면 (int64bit - 264)을, 아니면 (int64bit)을 반환한다.

7.1.16 ToBigUint64 ( argument )

The abstract operation ToBigUint64 takes argument argument (ECMAScript 언어 값) and returns BigInt를 담는 normal completion 또는 throw completion. argument0에서 (264 - 1)까지(포함) 264개의 BigInt 값 중 하나로 변환합니다. It performs the following steps when called:

  1. n을 ? ToBigInt(argument)로 둔다.
  2. int64bit(n) modulo 264로 둔다.
  3. (int64bit)를 반환한다.

7.1.17 ToString ( argument )

The abstract operation ToString takes argument argument (ECMAScript 언어 값) and returns String을 담는 normal completion 또는 throw completion. argumentString 타입 값으로 변환합니다. It performs the following steps when called:

  1. argument가 String이면 argument를 반환한다.
  2. argument가 Symbol이면 TypeError 예외를 던진다.
  3. argumentundefined이면 "undefined"를 반환한다.
  4. argumentnull이면 "null"을 반환한다.
  5. argumenttrue이면 "true"를 반환한다.
  6. argumentfalse이면 "false"를 반환한다.
  7. argument가 Number이면 Number::toString(argument, 10)을 반환한다.
  8. argument가 BigInt이면 BigInt::toString(argument, 10)을 반환한다.
  9. 단언: argument는 Object이다.
  10. primValue를 ? ToPrimitive(argument, string)으로 둔다.
  11. 단언: primValue는 Object가 아니다.
  12. ToString(primValue)를 반환한다.

7.1.18 ToObject ( argument )

The abstract operation ToObject takes argument argument (ECMAScript 언어 값) and returns Object를 담는 normal completion 또는 throw completion. argumentObject 타입 값으로 변환합니다. It performs the following steps when called:

  1. argumentundefined 또는 null이면 TypeError 예외를 던진다.
  2. argument가 Boolean이면 [[BooleanData]] 내부 슬롯이 argument로 설정된 새 Boolean 객체를 반환한다. Boolean 객체 설명은 20.3 참조.
  3. argument가 Number이면 [[NumberData]] 내부 슬롯이 argument로 설정된 새 Number 객체를 반환한다. Number 객체 설명은 21.1 참조.
  4. argument가 String이면 [[StringData]] 내부 슬롯이 argument로 설정된 새 String 객체를 반환한다. String 객체 설명은 22.1 참조.
  5. argument가 Symbol이면 [[SymbolData]] 내부 슬롯이 argument로 설정된 새 Symbol 객체를 반환한다. Symbol 객체 설명은 20.4 참조.
  6. argument가 BigInt이면 [[BigIntData]] 내부 슬롯이 argument로 설정된 새 BigInt 객체를 반환한다. BigInt 객체 설명은 21.2 참조.
  7. 단언: argument는 Object이다.
  8. argument를 반환한다.

7.1.19 ToPropertyKey ( argument )

The abstract operation ToPropertyKey takes argument argument (ECMAScript 언어 값) and returns 프로퍼티 키를 담는 normal completion 또는 throw completion. argument프로퍼티 키로 사용할 수 있는 값으로 변환합니다. It performs the following steps when called:

  1. key를 ? ToPrimitive(argument, string)으로 둔다.
  2. key가 Symbol이면
    1. key를 반환한다.
  3. ToString(key)를 반환한다.

7.1.20 ToLength ( argument )

The abstract operation ToLength takes argument argument (ECMAScript 언어 값) and returns 음이 아닌 적분 Number를 담는 normal completion 또는 throw completion. argument를 배열 유사 객체의 length로 사용 가능하도록 음이 아닌 적분 Number로 클램프(clamp) 및 절단(truncate)합니다. It performs the following steps when called:

  1. len을 ? ToIntegerOrInfinity(argument)로 둔다.
  2. len ≤ 0이면 +0𝔽을 반환한다.
  3. 𝔽(min(len, 253 - 1))을 반환한다.

7.1.21 CanonicalNumericIndexString ( argument )

The abstract operation CanonicalNumericIndexString takes argument argument (String) and returns Number 또는 undefined. argument"-0"이거나 어떤 Number 값 n에 대해 ToString(n)과 정확히 일치하면 해당 Number 값을 반환합니다. 그렇지 않으면 undefined를 반환합니다. It performs the following steps when called:

  1. argument"-0"이면 -0𝔽을 반환한다.
  2. n을 ! ToNumber(argument)로 둔다.
  3. ToString(n)이 argument이면 n을 반환한다.
  4. undefined를 반환한다.

canonical numeric string은 CanonicalNumericIndexString 추상 연산이 undefined를 반환하지 않는 모든 String입니다.

7.1.22 ToIndex ( value )

The abstract operation ToIndex takes argument value (ECMAScript 언어 값) and returns 음이 아닌 정수를 담는 normal completion 또는 throw completion. value를 정수로 변환하고, 그 정수가 음이 아니며 정수 인덱스에 대응되면 그 정수를 반환합니다. 그렇지 않으면 예외를 던집니다. It performs the following steps when called:

  1. integer를 ? ToIntegerOrInfinity(value)로 둔다.
  2. integer가 0에서 253 - 1 (포함) 사이에 없으면 RangeError 예외를 던진다.
  3. integer를 반환한다.

7.2 테스트 및 비교 연산(Testing and Comparison Operations)

7.2.1 RequireObjectCoercible ( argument )

The abstract operation RequireObjectCoercible takes argument argument (ECMAScript 언어 값) and returns unused을 담는 normal completion 또는 throw completion. argumentToObject로 Object로 변환될 수 없는 값이면 에러를 던집니다. It performs the following steps when called:

  1. argumentundefined 또는 null이면 TypeError 예외를 던진다.
  2. unused를 반환한다.

7.2.2 IsArray ( argument )

The abstract operation IsArray takes argument argument (ECMAScript 언어 값) and returns Boolean을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. argument가 Object가 아니면 false를 반환한다.
  2. argument가 Array 이국 객체이면 true를 반환한다.
  3. argument가 Proxy 이국 객체이면,
    1. ValidateNonRevokedProxy(argument)를 수행한다.
    2. proxyTargetargument.[[ProxyTarget]]으로 둔다.
    3. IsArray(proxyTarget)을 반환한다.
  4. false를 반환한다.

7.2.3 IsCallable ( argument )

The abstract operation IsCallable takes argument argument (ECMAScript 언어 값) and returns Boolean. argument[[Call]] 내부 메소드를 가진 호출 가능 함수인지 결정합니다. It performs the following steps when called:

  1. argument가 Object가 아니면 false를 반환한다.
  2. argument[[Call]] 내부 메소드를 가지면 true를 반환한다.
  3. false를 반환한다.

7.2.4 IsConstructor ( argument )

The abstract operation IsConstructor takes argument argument (ECMAScript 언어 값) and returns Boolean. argument[[Construct]] 내부 메소드를 가진 함수 객체인지 결정합니다. It performs the following steps when called:

  1. argument가 Object가 아니면 false를 반환한다.
  2. argument[[Construct]] 내부 메소드를 가지면 true를 반환한다.
  3. false를 반환한다.

7.2.5 IsExtensible ( O )

The abstract operation IsExtensible takes argument O (Object) and returns Boolean을 담는 normal completion 또는 throw completion. O에 추가 프로퍼티를 더할 수 있는지 결정하는 데 사용됩니다. It performs the following steps when called:

  1. O.[[IsExtensible]]()를 반환한다.

7.2.6 IsRegExp ( argument )

The abstract operation IsRegExp takes argument argument (ECMAScript 언어 값) and returns Boolean을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. argument가 Object가 아니면 false를 반환한다.
  2. matcher를 ? Get(argument, %Symbol.match%)로 둔다.
  3. matcherundefined가 아니면 ToBoolean(matcher)를 반환한다.
  4. argument[[RegExpMatcher]] 내부 슬롯을 가지면 true를 반환한다.
  5. false를 반환한다.

7.2.7 Static Semantics: IsStringWellFormedUnicode ( string )

The abstract operation IsStringWellFormedUnicode takes argument string (String) and returns Boolean. 6.1.4에 설명된 대로 string을 UTF-16 인코딩된 코드 포인트 시퀀스로 해석하고 이것이 well formed UTF-16 시퀀스인지 판정합니다. It performs the following steps when called:

  1. lenstring의 길이로 둔다.
  2. k를 0으로 둔다.
  3. k < len 동안 반복,
    1. cp를 CodePointAt(string, k)로 둔다.
    2. cp.[[IsUnpairedSurrogate]]true이면 false를 반환한다.
    3. kk + cp.[[CodeUnitCount]]로 둔다.
  4. true를 반환한다.

7.2.8 SameType ( x, y )

The abstract operation SameType takes arguments x (ECMAScript 언어 값) and y (ECMAScript 언어 값) and returns Boolean. 두 인수가 같은 타입인지 판정합니다. It performs the following steps when called:

  1. xundefined이고 yundefined이면 true를 반환한다.
  2. xnull이고 ynull이면 true를 반환한다.
  3. x가 Boolean이고 y가 Boolean이면 true를 반환한다.
  4. x가 Number이고 y가 Number이면 true를 반환한다.
  5. x가 BigInt이고 y가 BigInt이면 true를 반환한다.
  6. x가 Symbol이고 y가 Symbol이면 true를 반환한다.
  7. x가 String이고 y가 String이면 true를 반환한다.
  8. x가 Object이고 y가 Object이면 true를 반환한다.
  9. false를 반환한다.

7.2.9 SameValue ( x, y )

The abstract operation SameValue takes arguments x (ECMAScript 언어 값) and y (ECMAScript 언어 값) and returns Boolean. 두 인수가 같은 값인지 판정합니다. It performs the following steps when called:

  1. SameType(x, y)가 false이면 false를 반환한다.
  2. x가 Number이면,
    1. Number::sameValue(x, y)를 반환한다.
  3. SameValueNonNumber(x, y)를 반환한다.
Note

이 알고리즘은 모든 NaN 값을 동등하게 취급하고 +0𝔽-0𝔽을 구분한다는 점에서 IsStrictlyEqual 알고리즘과 다릅니다.

7.2.10 SameValueZero ( x, y )

The abstract operation SameValueZero takes arguments x (ECMAScript 언어 값) and y (ECMAScript 언어 값) and returns Boolean. 두 인수가 같은 값인지 ( +0𝔽-0𝔽의 차이를 무시하고 ) 판정합니다. It performs the following steps when called:

  1. SameType(x, y)가 false이면 false를 반환한다.
  2. x가 Number이면,
    1. Number::sameValueZero(x, y)를 반환한다.
  3. SameValueNonNumber(x, y)를 반환한다.
Note

SameValueZero는 +0𝔽-0𝔽을 동일하게 취급한다는 점만 SameValue와 다릅니다.

7.2.11 SameValueNonNumber ( x, y )

The abstract operation SameValueNonNumber takes arguments x (Number가 아닌 ECMAScript 언어 값) and y (Number가 아닌 ECMAScript 언어 값) and returns Boolean. It performs the following steps when called:

  1. 단언: SameType(x, y)는 true이다.
  2. xundefined 또는 null이면 true를 반환한다.
  3. x가 BigInt이면
    1. BigInt::equal(x, y)를 반환한다.
  4. x가 String이면
    1. xy가 동일 길이이며 같은 위치에 동일 코드 유닛을 가지면 true, 아니면 false를 반환한다.
  5. x가 Boolean이면
    1. xy가 모두 true 또는 모두 false이면 true, 아니면 false를 반환한다.
  6. 주: 다른 모든 ECMAScript 언어 값은 동일성(identity)으로 비교된다.
  7. xy이면 true, 아니면 false를 반환한다.
Note 1
설명을 위해 일부 경우는 필요 없더라도 별도로 다룹니다.
Note 2
"x is y"의 구체적 의미는 5.2.7에 자세히 있습니다.

7.2.12 IsLessThan ( x, y, LeftFirst )

The abstract operation IsLessThan takes arguments x (ECMAScript 언어 값), y (ECMAScript 언어 값), and LeftFirst (Boolean) and returns Boolean 또는 undefined를 담는 normal completion 또는 throw completion. x < y 비교의 의미론을 제공하며, true, false, 또는 (적어도 한 피연산자가 NaN임을 나타내는) undefined를 반환합니다. LeftFirst 플래그는 x, y에 잠재적으로 부작용 있는 연산의 순서를 제어합니다. 이는 ECMAScript가 표현식을 좌→우로 평가하도록 규정하기 때문에 필요합니다. LeftFirsttrue이면 x 매개변수는 y 매개변수 표현식의 왼쪽에 오는 표현식에 해당합니다. false이면 반대이며 연산은 x 이전에 y에 수행되어야 합니다. It performs the following steps when called:

  1. LeftFirsttrue이면,
    1. px를 ? ToPrimitive(x, number)로 둔다.
    2. py를 ? ToPrimitive(y, number)로 둔다.
  2. Else,
    1. 주: 좌→우 평가를 보존하기 위해 평가 순서를 반전해야 한다.
    2. py를 ? ToPrimitive(y, number)로 둔다.
    3. px를 ? ToPrimitive(x, number)로 둔다.
  3. px가 String이고 py가 String이면,
    1. lxpx의 길이로 둔다.
    2. lypy의 길이로 둔다.
    3. 0 ≤ i < min(lx, ly)인 각 정수 i에 대해 오름차순으로,
      1. cxpx의 인덱스 i 위치 코드 유닛의 숫자 값으로 둔다.
      2. cypy의 인덱스 i 위치 코드 유닛의 숫자 값으로 둔다.
      3. cx < cy이면 true를 반환한다.
      4. cx > cy이면 false를 반환한다.
    4. lx < ly이면 true, 아니면 false를 반환한다.
  4. Else,
    1. px가 BigInt이고 py가 String이면,
      1. nyStringToBigInt(py)로 둔다.
      2. nyundefined이면 undefined를 반환한다.
      3. BigInt::lessThan(px, ny)를 반환한다.
    2. px가 String이고 py가 BigInt이면,
      1. nxStringToBigInt(px)로 둔다.
      2. nxundefined이면 undefined를 반환한다.
      3. BigInt::lessThan(nx, py)를 반환한다.
    3. 주: px, py는 원시 값이므로 평가 순서는 중요하지 않다.
    4. nx를 ? ToNumeric(px)로 둔다.
    5. ny를 ? ToNumeric(py)로 둔다.
    6. SameType(nx, ny)가 true이면,
      1. nx가 Number이면
        1. Number::lessThan(nx, ny)를 반환한다.
      2. Else,
        1. 단언: nx는 BigInt이다.
        2. BigInt::lessThan(nx, ny)를 반환한다.
    7. 단언: nx는 BigInt이고 ny는 Number, 또는 nx는 Number이고 ny는 BigInt.
    8. nx 또는 nyNaN이면 undefined를 반환한다.
    9. nx-∞𝔽이거나 ny+∞𝔽이면 true를 반환한다.
    10. nx+∞𝔽이거나 ny-∞𝔽이면 false를 반환한다.
    11. (nx) < (ny)이면 true, 아니면 false를 반환한다.
Note 1

3 단계는 덧셈 연산자 +를 처리하는 알고리즘(13.15.3)의 1.c 단계와 논리 OR 대신 논리 AND를 사용하는 점에서 다릅니다.

Note 2

String 비교는 UTF-16 코드 유닛 값 시퀀스에 대한 단순한 사전식(lexicographic) 순서를 사용합니다. Unicode 명세에서 정의한 더 복잡하고 의미론 지향적인 문자/문자열 동등성이나 정렬 순서를 사용하려 하지 않습니다. 따라서 Unicode 표준에 따라 정규적으로 동등하지만 정규화 형태가 다른 String 값은 불일치로 판정될 수 있습니다. 또한 surrogate pair를 포함한 String의 경우 코드 유닛 기반 사전식 순서는 코드 포인트 기반 순서와 다를 수 있습니다.

7.2.13 IsLooselyEqual ( x, y )

The abstract operation IsLooselyEqual takes arguments x (ECMAScript 언어 값) and y (ECMAScript 언어 값) and returns Boolean을 담는 normal completion 또는 throw completion. == 연산자의 의미론을 제공합니다. It performs the following steps when called:

  1. SameType(x, y)가 true이면,
    1. IsStrictlyEqual(x, y)를 반환한다.
  2. xnull이고 yundefined이면 true를 반환한다.
  3. xundefined이고 ynull이면 true를 반환한다.
  4. Normative Optional
    호스트가 웹 브라우저이거나 [[IsHTMLDDA]] 내부 슬롯를 지원하면,
    1. x가 Object이고 x[[IsHTMLDDA]] 내부 슬롯을 가지며 yundefined 또는 null이면 true를 반환한다.
    2. xundefined 또는 null이고 y가 Object이며 y[[IsHTMLDDA]] 내부 슬롯을 가지면 true를 반환한다.
  5. x가 Number이고 y가 String이면 ! IsLooselyEqual(x, ! ToNumber(y))를 반환한다.
  6. x가 String이고 y가 Number이면 ! IsLooselyEqual(! ToNumber(x), y)를 반환한다.
  7. x가 BigInt이고 y가 String이면,
    1. nStringToBigInt(y)로 둔다.
    2. nundefined이면 false를 반환한다.
    3. IsLooselyEqual(x, n)을 반환한다.
  8. x가 String이고 y가 BigInt이면 ! IsLooselyEqual(y, x)를 반환한다.
  9. x가 Boolean이면 ! IsLooselyEqual(! ToNumber(x), y)를 반환한다.
  10. y가 Boolean이면 ! IsLooselyEqual(x, ! ToNumber(y))를 반환한다.
  11. x가 String, Number, BigInt, Symbol 중 하나이고 y가 Object이면 ! IsLooselyEqual(x, ? ToPrimitive(y))를 반환한다.
  12. x가 Object이고 y가 String, Number, BigInt, Symbol 중 하나이면 ! IsLooselyEqual(? ToPrimitive(x), y)를 반환한다.
  13. x가 BigInt이고 y가 Number이거나 x가 Number이고 y가 BigInt이면,
    1. x 또는 y유한이 아니면 false를 반환한다.
    2. (x) = (y)이면 true, 아니면 false를 반환한다.
  14. false를 반환한다.

7.2.14 IsStrictlyEqual ( x, y )

The abstract operation IsStrictlyEqual takes arguments x (ECMAScript 언어 값) and y (ECMAScript 언어 값) and returns Boolean. === 연산자의 의미론을 제공합니다. It performs the following steps when called:

  1. SameType(x, y)가 false이면 false를 반환한다.
  2. x가 Number이면,
    1. Number::equal(x, y)를 반환한다.
  3. SameValueNonNumber(x, y)를 반환한다.
Note

이 알고리즘은 부호 있는 0 및 NaN 처리에서 SameValue 알고리즘과 다릅니다.

7.3 객체에 대한 연산(Operations on Objects)

7.3.1 MakeBasicObject ( internalSlotsList )

The abstract operation MakeBasicObject takes argument internalSlotsList (내부 슬롯 이름들의 List) and returns Object. 알고리즘적으로 생성되는 모든 ECMAScript 객체(ordinary 및 exotic 포함)의 근원입니다. 모든 객체 생성에서 사용되는 공통 단계를 분리하고 객체 생성을 중앙화합니다. It performs the following steps when called:

  1. internalSlotsListinternalSlotsList와 « [[PrivateElements]] »의 list-concatenation으로 설정한다.
  2. internalSlotsList의 각 이름에 대한 내부 슬롯을 가진 새로 생성된 객체 obj를 둔다.
  3. 주: Object 내부 메소드와 내부 슬롯에 설명된 대로 달리 지정되지 않으면 각 내부 슬롯의 초기값은 undefined이다.
  4. obj.[[PrivateElements]]를 새 빈 List로 둔다.
  5. obj의 essential 내부 메소드를 10.1에 지정된 기본 ordinary object 정의로 설정한다.
  6. 단언: 호출자가 obj[[GetPrototypeOf]][[SetPrototypeOf]] essential 내부 메소드를 모두 재정의하지 않을 경우 internalSlotsList[[Prototype]]을 포함한다.
  7. 단언: 호출자가 obj[[SetPrototypeOf]], [[IsExtensible]], [[PreventExtensions]] essential 내부 메소드를 모두 재정의하지 않을 경우 internalSlotsList[[Extensible]]을 포함한다.
  8. internalSlotsList[[Extensible]]을 포함하면 obj.[[Extensible]]true로 둔다.
  9. obj를 반환한다.
Note

이 명세 내에서 exotic 객체는 ArrayCreate, BoundFunctionCreate 같은 추상 연산에서 먼저 MakeBasicObject를 호출하여 기본 객체를 얻고 그 후 그 객체의 일부 또는 모든 내부 메소드를 재정의하여 생성됩니다. exotic 객체 생성을 캡슐화하기 위해 객체의 essential 내부 메소드는 그러한 연산 외부에서는 수정되지 않습니다.

7.3.2 Get ( O, P )

The abstract operation Get takes arguments O (Object) and P (프로퍼티 키) and returns ECMAScript 언어 값을 담는 normal completion 또는 throw completion. 객체의 특정 프로퍼티 값을 가져오는 데 사용됩니다. It performs the following steps when called:

  1. O.[[Get]](P, O)를 반환한다.

7.3.3 GetV ( V, P )

The abstract operation GetV takes arguments V (ECMAScript 언어 값) and P (프로퍼티 키) and returns ECMAScript 언어 값을 담는 normal completion 또는 throw completion. ECMAScript 언어 값의 특정 프로퍼티 값을 가져오는 데 사용됩니다. 값이 객체가 아니면 해당 타입에 적합한 래퍼 객체를 사용하여 프로퍼티 조회가 수행됩니다. It performs the following steps when called:

  1. O를 ? ToObject(V)로 둔다.
  2. O.[[Get]](P, V)를 반환한다.

7.3.4 Set ( O, P, V, Throw )

The abstract operation Set takes arguments O (Object), P (프로퍼티 키), V (ECMAScript 언어 값), and Throw (Boolean) and returns unused을 담는 normal completion 또는 throw completion. 객체의 특정 프로퍼티 값을 설정하는 데 사용됩니다. V는 프로퍼티의 새 값입니다. It performs the following steps when called:

  1. success를 ? O.[[Set]](P, V, O)로 둔다.
  2. successfalse이고 Throwtrue이면 TypeError 예외를 던진다.
  3. unused를 반환한다.

7.3.5 CreateDataProperty ( O, P, V )

The abstract operation CreateDataProperty takes arguments O (Object), P (프로퍼티 키), and V (ECMAScript 언어 값) and returns Boolean을 담는 normal completion 또는 throw completion. 객체의 새로운 own 프로퍼티를 생성하는 데 사용됩니다. It performs the following steps when called:

  1. newDesc를 PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }로 둔다.
  2. O.[[DefineOwnProperty]](P, newDesc)를 반환한다.
Note

이 추상 연산은 ECMAScript 대입 연산자가 생성하는 프로퍼티와 동일 기본 속성 값을 가진 프로퍼티를 생성합니다. 일반적으로 프로퍼티는 미존재 상태입니다. 존재하고 비구성이거나 O가 비확장 가능이면 [[DefineOwnProperty]]false를 반환합니다.

7.3.6 CreateDataPropertyOrThrow ( O, P, V )

The abstract operation CreateDataPropertyOrThrow takes arguments O (Object), P (프로퍼티 키), and V (ECMAScript 언어 값) and returns unused을 담는 normal completion 또는 throw completion. 객체의 새로운 own 프로퍼티를 생성하는 데 사용되며, 요청된 프로퍼티 갱신이 수행될 수 없으면 TypeError 예외를 던집니다. It performs the following steps when called:

  1. success를 ? CreateDataProperty(O, P, V)로 둔다.
  2. successfalse이면 TypeError 예외를 던진다.
  3. unused를 반환한다.
Note

이 추상 연산은 ECMAScript 대입 연산자가 생성하는 프로퍼티와 동일 기본 속성을 가지는 프로퍼티를 생성합니다. 일반적으로 프로퍼티는 미존재 상태입니다. 존재하고 비구성이거나 O가 비확장 가능이면 [[DefineOwnProperty]]false를 반환하여 이 연산이 TypeError를 던지게 됩니다.

7.3.7 CreateNonEnumerableDataPropertyOrThrow ( O, P, V )

The abstract operation CreateNonEnumerableDataPropertyOrThrow takes arguments O (Object), P (프로퍼티 키), and V (ECMAScript 언어 값) and returns unused. ordinary 객체의 새 비열거 own 프로퍼티를 생성하는 데 사용됩니다. It performs the following steps when called:

  1. 단언: O는 비구성 프로퍼티가 없는 ordinary, 확장 가능한 객체이다.
  2. newDesc를 PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }로 둔다.
  3. DefinePropertyOrThrow(O, P, newDesc)를 수행한다.
  4. unused를 반환한다.
Note

이 추상 연산은 ECMAScript 대입 연산자가 생성하는 프로퍼티와 동일 기본 속성을 가지되 열거 가능하지 않은 프로퍼티를 생성합니다. 일반적으로 프로퍼티는 미존재 상태입니다. 존재하는 경우 DefinePropertyOrThrow는 정상적으로 완료됨이 보장됩니다.

7.3.8 DefinePropertyOrThrow ( O, P, desc )

The abstract operation DefinePropertyOrThrow takes arguments O (Object), P (프로퍼티 키), and desc (Property Descriptor) and returns unused을 담는 normal completion 또는 throw completion. 객체의 [[DefineOwnProperty]] 내부 메소드를 호출하되, 요청된 프로퍼티 갱신이 수행될 수 없으면 TypeError 예외를 던집니다. It performs the following steps when called:

  1. success를 ? O.[[DefineOwnProperty]](P, desc)로 둔다.
  2. successfalse이면 TypeError 예외를 던진다.
  3. unused를 반환한다.

7.3.9 DeletePropertyOrThrow ( O, P )

The abstract operation DeletePropertyOrThrow takes arguments O (Object) and P (프로퍼티 키) and returns unused을 담는 normal completion 또는 throw completion. 객체의 특정 own 프로퍼티를 제거하는 데 사용됩니다. 프로퍼티가 비구성이면 예외를 던집니다. It performs the following steps when called:

  1. success를 ? O.[[Delete]](P)로 둔다.
  2. successfalse이면 TypeError 예외를 던진다.
  3. unused를 반환한다.

7.3.10 GetMethod ( V, P )

The abstract operation GetMethod takes arguments V (ECMAScript 언어 값) and P (프로퍼티 키) and returns 함수 객체 또는 undefined를 담는 normal completion 또는 throw completion. 프로퍼티 값이 함수일 것으로 기대되는 ECMAScript 언어 값의 특정 프로퍼티 값을 얻는 데 사용됩니다. It performs the following steps when called:

  1. func을 ? GetV(V, P)로 둔다.
  2. funcundefined 또는 null이면 undefined를 반환한다.
  3. IsCallable(func)가 false이면 TypeError 예외를 던진다.
  4. func를 반환한다.

7.3.11 HasProperty ( O, P )

The abstract operation HasProperty takes arguments O (Object) and P (프로퍼티 키) and returns Boolean을 담는 normal completion 또는 throw completion. 객체가 지정된 프로퍼티 키를 가진 프로퍼티(own 또는 상속)를 갖는지 판정합니다. It performs the following steps when called:

  1. O.[[HasProperty]](P)를 반환한다.

7.3.12 HasOwnProperty ( O, P )

The abstract operation HasOwnProperty takes arguments O (Object) and P (프로퍼티 키) and returns Boolean을 담는 normal completion 또는 throw completion. 객체가 지정된 프로퍼티 키를 가진 own 프로퍼티를 갖는지 판정합니다. It performs the following steps when called:

  1. desc를 ? O.[[GetOwnProperty]](P)로 둔다.
  2. descundefined이면 false를 반환한다.
  3. true를 반환한다.

7.3.13 Call ( F, V [ , argumentsList ] )

The abstract operation Call takes arguments F (ECMAScript 언어 값) and V (ECMAScript 언어 값) and optional argument argumentsList (ECMAScript 언어 값들의 List) and returns ECMAScript 언어 값을 담는 normal completion 또는 throw completion. 함수 객체[[Call]] 내부 메소드를 호출하는 데 사용됩니다. F함수 객체, V[[Call]]this 값, argumentsList는 내부 메소드의 해당 인자에 전달되는 값입니다. argumentsList가 없으면 새 빈 List가 사용됩니다. It performs the following steps when called:

  1. argumentsList가 존재하지 않으면 새 빈 List로 설정한다.
  2. IsCallable(F)가 false이면 TypeError 예외를 던진다.
  3. F.[[Call]](V, argumentsList)를 반환한다.

7.3.14 Construct ( F [ , argumentsList [ , newTarget ] ] )

The abstract operation Construct takes argument F (생성자) and optional arguments argumentsList (ECMAScript 언어 값들의 List) and newTarget (생성자) and returns Object를 담는 normal completion 또는 throw completion. 함수 객체[[Construct]] 내부 메소드를 호출하는 데 사용됩니다. argumentsList, newTarget은 내부 메소드에 전달될 해당 인자 값입니다. argumentsList가 없으면 새 빈 List가, newTarget이 없으면 F가 사용됩니다. It performs the following steps when called:

  1. newTarget이 존재하지 않으면 newTargetF로 둔다.
  2. argumentsList가 존재하지 않으면 새 빈 List로 둔다.
  3. F.[[Construct]](argumentsList, newTarget)를 반환한다.
Note

newTarget이 없으면 이 연산은 new F(...argumentsList)와 동일합니다.

7.3.15 SetIntegrityLevel ( O, level )

The abstract operation SetIntegrityLevel takes arguments O (Object) and level (sealed 또는 frozen) and returns Boolean을 담는 normal completion 또는 throw completion. 객체의 own 프로퍼티 집합을 고정(fix)하는 데 사용됩니다. It performs the following steps when called:

  1. status를 ? O.[[PreventExtensions]]()로 둔다.
  2. statusfalse이면 false를 반환한다.
  3. keys를 ? O.[[OwnPropertyKeys]]()로 둔다.
  4. levelsealed이면,
    1. keys의 각 요소 k에 대해
      1. DefinePropertyOrThrow(O, k, PropertyDescriptor { [[Configurable]]: false })를 수행한다.
  5. Else,
    1. 단언: levelfrozen.
    2. keys의 각 요소 k에 대해
      1. currentDesc를 ? O.[[GetOwnProperty]](k)로 둔다.
      2. currentDescundefined가 아니면,
        1. IsAccessorDescriptor(currentDesc)가 true이면
          1. desc를 PropertyDescriptor { [[Configurable]]: false }로 둔다.
        2. Else,
          1. desc를 PropertyDescriptor { [[Configurable]]: false, [[Writable]]: false }로 둔다.
        3. DefinePropertyOrThrow(O, k, desc)를 수행한다.
  6. true를 반환한다.

7.3.16 TestIntegrityLevel ( O, level )

The abstract operation TestIntegrityLevel takes arguments O (Object) and level (sealed 또는 frozen) and returns Boolean을 담는 normal completion 또는 throw completion. 객체의 own 프로퍼티 집합이 고정되어 있는지 판정하는 데 사용됩니다. It performs the following steps when called:

  1. extensible을 ? IsExtensible(O)로 둔다.
  2. extensibletrue이면 false를 반환한다.
  3. 주: 객체가 확장이 가능하면 프로퍼티를 검사하지 않는다.
  4. keys를 ? O.[[OwnPropertyKeys]]()로 둔다.
  5. keys의 각 요소 k에 대해
    1. currentDesc를 ? O.[[GetOwnProperty]](k)로 둔다.
    2. currentDescundefined가 아니면,
      1. currentDesc.[[Configurable]]true이면 false를 반환한다.
      2. levelfrozen이고 IsDataDescriptor(currentDesc)가 true이면,
        1. currentDesc.[[Writable]]true이면 false를 반환한다.
  6. true를 반환한다.

7.3.17 CreateArrayFromList ( elements )

The abstract operation CreateArrayFromList takes argument elements (ECMAScript 언어 값들의 List) and returns Array. 요소가 elements로 제공되는 Array를 생성하는 데 사용됩니다. It performs the following steps when called:

  1. array를 ! ArrayCreate(0)로 둔다.
  2. n을 0으로 둔다.
  3. elements의 각 요소 e에 대해
    1. CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), e)를 수행한다.
    2. nn + 1로 둔다.
  4. array를 반환한다.

7.3.18 LengthOfArrayLike ( obj )

The abstract operation LengthOfArrayLike takes argument obj (Object) and returns 음이 아닌 정수를 담는 normal completion 또는 throw completion. 배열 유사 객체의 "length" 프로퍼티 값을 반환합니다. It performs the following steps when called:

  1. (? ToLength(? Get(obj, "length")))를 반환한다.

array-like object는 이 연산이 normal completion을 반환하는 모든 객체입니다.

Note 1
일반적으로 array-like object는 정수 인덱스 이름을 가진 몇몇 프로퍼티도 가집니다. 그러나 이것은 필수 조건이 아닙니다.
Note 2
Array와 String 객체가 array-like object의 예입니다.

7.3.19 CreateListFromArrayLike ( obj [ , validElementTypes ] )

The abstract operation CreateListFromArrayLike takes argument obj (ECMAScript 언어 값) and optional argument validElementTypes (all 또는 property-key) and returns ECMAScript 언어 값들의 List를 담는 normal completion 또는 throw completion. obj의 인덱스된 프로퍼티가 제공하는 요소로 이루어진 List 값을 생성하는 데 사용됩니다. validElementTypes는 요소로 허용되는 값 타입을 지정합니다. It performs the following steps when called:

  1. validElementTypes가 존재하지 않으면 all로 설정한다.
  2. obj가 Object가 아니면 TypeError 예외를 던진다.
  3. len을 ? LengthOfArrayLike(obj)로 둔다.
  4. list를 새 빈 List로 둔다.
  5. index를 0으로 둔다.
  6. index < len 동안 반복,
    1. indexName을 ! ToString(𝔽(index))로 둔다.
    2. next를 ? Get(obj, indexName)로 둔다.
    3. validElementTypesproperty-key이고 next프로퍼티 키가 아니면 TypeError 예외를 던진다.
    4. nextlist에 추가한다.
    5. indexindex + 1로 둔다.
  7. list를 반환한다.

7.3.20 Invoke ( V, P [ , argumentsList ] )

The abstract operation Invoke takes arguments V (ECMAScript 언어 값) and P (프로퍼티 키) and optional argument argumentsList (ECMAScript 언어 값들의 List) and returns ECMAScript 언어 값을 담는 normal completion 또는 throw completion. ECMAScript 언어 값의 메서드 프로퍼티를 호출하는 데 사용됩니다. V는 프로퍼티 조회 지점이자 호출의 this 값입니다. argumentsList는 메서드에 전달되는 인자 값 리스트입니다. argumentsList가 없으면 새 빈 List가 사용됩니다. It performs the following steps when called:

  1. argumentsList가 존재하지 않으면 새 빈 List로 둔다.
  2. func을 ? GetV(V, P)로 둔다.
  3. Call(func, V, argumentsList)를 반환한다.

7.3.21 OrdinaryHasInstance ( C, O )

The abstract operation OrdinaryHasInstance takes arguments C (ECMAScript 언어 값) and O (ECMAScript 언어 값) and returns Boolean을 담는 normal completion 또는 throw completion. OC가 제공한 인스턴스 객체 상속 경로를 상속하는지 여부를 결정하는 기본 알고리즘을 구현합니다. It performs the following steps when called:

  1. IsCallable(C)가 false이면 false를 반환한다.
  2. C[[BoundTargetFunction]] 내부 슬롯을 가지면,
    1. BCC.[[BoundTargetFunction]]으로 둔다.
    2. InstanceofOperator(O, BC)를 반환한다.
  3. O가 Object가 아니면 false를 반환한다.
  4. P를 ? Get(C, "prototype")으로 둔다.
  5. P가 Object가 아니면 TypeError 예외를 던진다.
  6. 반복,
    1. O를 ? O.[[GetPrototypeOf]]()로 둔다.
    2. Onull이면 false를 반환한다.
    3. SameValue(P, O)가 true이면 true를 반환한다.

7.3.22 SpeciesConstructor ( O, defaultConstructor )

The abstract operation SpeciesConstructor takes arguments O (Object) and defaultConstructor (생성자) and returns 생성자를 담는 normal completion 또는 throw completion. O로부터 파생된 새 객체를 생성할 때 사용해야 하는 생성자를 가져오는 데 사용됩니다. defaultConstructorO부터 시작하여 %Symbol.species% 프로퍼티 생성자를 찾을 수 없을 때 사용할 생성자입니다. It performs the following steps when called:

  1. C를 ? Get(O, "constructor")로 둔다.
  2. Cundefined이면 defaultConstructor를 반환한다.
  3. C가 Object가 아니면 TypeError 예외를 던진다.
  4. S를 ? Get(C, %Symbol.species%)로 둔다.
  5. Sundefined 또는 null이면 defaultConstructor를 반환한다.
  6. IsConstructor(S)가 true이면 S를 반환한다.
  7. TypeError 예외를 던진다.

7.3.23 EnumerableOwnProperties ( O, kind )

The abstract operation EnumerableOwnProperties takes arguments O (Object) and kind (key, value, 또는 key+value) and returns ECMAScript 언어 값들의 List를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ownKeys를 ? O.[[OwnPropertyKeys]]()로 둔다.
  2. results를 새 빈 List로 둔다.
  3. ownKeys의 각 요소 key에 대해
    1. key가 String이면,
      1. desc를 ? O.[[GetOwnProperty]](key)로 둔다.
      2. descundefined가 아니고 desc.[[Enumerable]]true이면,
        1. kindkey이면
          1. keyresults에 추가한다.
        2. Else,
          1. value를 ? Get(O, key)로 둔다.
          2. kindvalue이면
            1. valueresults에 추가한다.
          3. Else,
            1. 단언: kindkey+value.
            2. entryCreateArrayFromListkey, value »)로 둔다.
            3. entryresults에 추가한다.
  4. results를 반환한다.

7.3.24 GetFunctionRealm ( obj )

The abstract operation GetFunctionRealm takes argument obj (함수 객체) and returns Realm Record를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. obj[[Realm]] 내부 슬롯을 가지면
    1. obj.[[Realm]]을 반환한다.
  2. obj가 bound function exotic 객체이면
    1. boundTargetFunctionobj.[[BoundTargetFunction]]으로 둔다.
    2. GetFunctionRealm(boundTargetFunction)을 반환한다.
  3. obj가 Proxy 이국 객체이면
    1. ValidateNonRevokedProxy(obj)를 수행한다.
    2. proxyTargetobj.[[ProxyTarget]]으로 둔다.
    3. 단언: proxyTarget함수 객체이다.
    4. GetFunctionRealm(proxyTarget)을 반환한다.
  4. 현재 Realm Record를 반환한다.
Note

4 단계는 obj[[Realm]] 내부 슬롯이 없는 비표준 함수 이국 객체인 경우에만 도달합니다.

7.3.25 CopyDataProperties ( target, source, excludedItems )

The abstract operation CopyDataProperties takes arguments target (Object), source (ECMAScript 언어 값), and excludedItems (프로퍼티 키들의 List) and returns unused을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. sourceundefined 또는 null이면 unused를 반환한다.
  2. from을 ! ToObject(source)로 둔다.
  3. keys를 ? from.[[OwnPropertyKeys]]()로 둔다.
  4. keys의 각 요소 nextKey에 대해
    1. excludedfalse로 둔다.
    2. excludedItems의 각 요소 e에 대해
      1. SameValue(e, nextKey)가 true이면
        1. excludedtrue로 둔다.
    3. excludedfalse이면
      1. desc를 ? from.[[GetOwnProperty]](nextKey)로 둔다.
      2. descundefined가 아니고 desc.[[Enumerable]]true이면
        1. propValue를 ? Get(from, nextKey)로 둔다.
        2. CreateDataPropertyOrThrow(target, nextKey, propValue)를 수행한다.
  5. unused를 반환한다.
Note

여기에 전달되는 target은 항상 새로 생성된 객체이며, 오류 발생 시 직접 접근할 수 없습니다.

7.3.26 PrivateElementFind ( O, P )

The abstract operation PrivateElementFind takes arguments O (Object) and P (Private Name) and returns PrivateElement 또는 empty. It performs the following steps when called:

  1. O.[[PrivateElements]]pe.[[Key]]PPrivateElement pe를 포함하면
    1. pe를 반환한다.
  2. empty를 반환한다.

7.3.27 PrivateFieldAdd ( O, P, value )

The abstract operation PrivateFieldAdd takes arguments O (Object), P (Private Name), and value (ECMAScript 언어 값) and returns unused을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. 호스트가 웹 브라우저이면
    1. HostEnsureCanAddPrivateElement(O)를 수행한다.
  2. entryPrivateElementFind(O, P)로 둔다.
  3. entryempty가 아니면 TypeError 예외를 던진다.
  4. PrivateElement { [[Key]]: P, [[Kind]]: field, [[Value]]: value }를 O.[[PrivateElements]]에 추가한다.
  5. unused를 반환한다.

7.3.28 PrivateMethodOrAccessorAdd ( O, method )

The abstract operation PrivateMethodOrAccessorAdd takes arguments O (Object) and method (PrivateElement) and returns unused을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. 단언: method.[[Kind]]method 또는 accessor이다.
  2. 호스트가 웹 브라우저이면
    1. HostEnsureCanAddPrivateElement(O)를 수행한다.
  3. entryPrivateElementFind(O, method.[[Key]])로 둔다.
  4. entryempty가 아니면 TypeError 예외를 던진다.
  5. methodO.[[PrivateElements]]에 추가한다.
  6. unused를 반환한다.
Note

private 메서드와 접근자의 값은 인스턴스 간에 공유됩니다. 이 연산은 메서드나 접근자의 새 복사본을 만들지 않습니다.

7.3.29 HostEnsureCanAddPrivateElement ( O )

The host-defined abstract operation HostEnsureCanAddPrivateElement takes argument O (Object) and returns unused을 담는 normal completion 또는 throw completion. 호스트 환경이 특정 호스트 정의 exotic 객체에 private element 추가를 방지할 수 있도록 합니다.

HostEnsureCanAddPrivateElement 구현은 다음 요구사항을 따라야 합니다:

  • O호스트 정의 exotic 객체가 아니면 이 추상 연산은 NormalCompletion(unused)을 반환하고 다른 단계를 수행하지 않아야 합니다.
  • 같은 인수로 이 추상 연산을 두 번 호출하면 동일한 종류의 Completion Record를 반환해야 합니다.

HostEnsureCanAddPrivateElement의 기본 구현은 NormalCompletion(unused)을 반환하는 것입니다.

이 추상 연산은 ECMAScript 호스트가 웹 브라우저인 경우에만 호출됩니다.

7.3.30 PrivateGet ( O, P )

The abstract operation PrivateGet takes arguments O (Object) and P (Private Name) and returns ECMAScript 언어 값을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. entryPrivateElementFind(O, P)로 둔다.
  2. entryempty이면 TypeError 예외를 던진다.
  3. entry.[[Kind]]field 또는 method이면
    1. entry.[[Value]]를 반환한다.
  4. 단언: entry.[[Kind]]accessor이다.
  5. entry.[[Get]]undefined이면 TypeError 예외를 던진다.
  6. getterentry.[[Get]]으로 둔다.
  7. Call(getter, O)를 반환한다.

7.3.31 PrivateSet ( O, P, value )

The abstract operation PrivateSet takes arguments O (Object), P (Private Name), and value (ECMAScript 언어 값) and returns unused을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. entryPrivateElementFind(O, P)로 둔다.
  2. entryempty이면 TypeError 예외를 던진다.
  3. entry.[[Kind]]field이면
    1. entry.[[Value]]value로 설정한다.
  4. Else if entry.[[Kind]]method이면
    1. TypeError 예외를 던진다.
  5. Else,
    1. 단언: entry.[[Kind]]accessor.
    2. entry.[[Set]]undefined이면 TypeError 예외를 던진다.
    3. setterentry.[[Set]]으로 둔다.
    4. Call(setter, O, « value »)를 수행한다.
  6. unused를 반환한다.

7.3.32 DefineField ( receiver, fieldRecord )

The abstract operation DefineField takes arguments receiver (Object) and fieldRecord (ClassFieldDefinition Record) and returns unused을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. fieldNamefieldRecord.[[Name]]으로 둔다.
  2. initializerfieldRecord.[[Initializer]]로 둔다.
  3. initializerempty가 아니면
    1. initValue를 ? Call(initializer, receiver)로 둔다.
  4. Else,
    1. initValueundefined로 둔다.
  5. fieldNamePrivate Name이면
    1. PrivateFieldAdd(receiver, fieldName, initValue)를 수행한다.
  6. Else,
    1. 단언: fieldName프로퍼티 키이다.
    2. CreateDataPropertyOrThrow(receiver, fieldName, initValue)를 수행한다.
  7. unused를 반환한다.

7.3.33 InitializeInstanceElements ( O, constructor )

The abstract operation InitializeInstanceElements takes arguments O (Object) and constructor (ECMAScript 함수 객체) and returns unused을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. methodsconstructor.[[PrivateMethods]]로 둔다.
  2. methods의 각 PrivateElement method에 대해
    1. PrivateMethodOrAccessorAdd(O, method)를 수행한다.
  3. fieldsconstructor.[[Fields]]로 둔다.
  4. fields의 각 요소 fieldRecord에 대해
    1. DefineField(O, fieldRecord)를 수행한다.
  5. unused를 반환한다.

7.3.34 AddValueToKeyedGroup ( groups, key, value )

The abstract operation AddValueToKeyedGroup takes arguments groups (필드 [[Key]](ECMAScript 언어 값)와 [[Elements]](ECMAScript 언어 값들의 List)를 가진 Record들의 List), key (ECMAScript 언어 값), and value (ECMAScript 언어 값) and returns unused. It performs the following steps when called:

  1. groups의 각 Record { [[Key]], [[Elements]] } g에 대해
    1. SameValue(g.[[Key]], key)가 true이면
      1. 단언: 정확히 한 요소만 이 조건을 만족한다.
      2. valueg.[[Elements]]에 추가한다.
      3. unused를 반환한다.
  2. groupRecord { [[Key]]: key, [[Elements]]: « value » }로 둔다.
  3. groupgroups에 추가한다.
  4. unused를 반환한다.

7.3.35 GroupBy ( items, callback, keyCoercion )

The abstract operation GroupBy takes arguments items (ECMAScript 언어 값), callback (ECMAScript 언어 값), and keyCoercion (property 또는 collection) and returns 필드 [[Key]](ECMAScript 언어 값) 및 [[Elements]](ECMAScript 언어 값들의 List)를 가진 Record들의 List를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. RequireObjectCoercible(items)를 수행한다.
  2. IsCallable(callback)이 false이면 TypeError 예외를 던진다.
  3. groups를 새 빈 List로 둔다.
  4. iteratorRecord를 ? GetIterator(items, sync)로 둔다.
  5. k를 0으로 둔다.
  6. 반복,
    1. k ≥ 253 - 1이면
      1. errorThrowCompletion(새로 생성된 TypeError 객체)로 둔다.
      2. IteratorClose(iteratorRecord, error)를 반환한다.
    2. next를 ? IteratorStepValue(iteratorRecord)로 둔다.
    3. nextdone이면
      1. groups를 반환한다.
    4. valuenext로 둔다.
    5. keyCompletion(Call(callback, undefined, « value, 𝔽(k) »))로 둔다.
    6. IfAbruptCloseIterator(key, iteratorRecord).
    7. keyCoercionproperty이면
      1. keyCompletion(ToPropertyKey(key))로 둔다.
      2. IfAbruptCloseIterator(key, iteratorRecord).
    8. Else,
      1. 단언: keyCoercioncollection.
      2. keyCanonicalizeKeyedCollectionKey(key)로 둔다.
    9. AddValueToKeyedGroup(groups, key, value)를 수행한다.
    10. kk + 1로 둔다.

7.3.36 SetterThatIgnoresPrototypeProperties ( thisValue, home, p, v )

The abstract operation SetterThatIgnoresPrototypeProperties takes arguments thisValue (ECMAScript 언어 값), home (Object), p (프로퍼티 키), and v (ECMAScript 언어 값) and returns unused을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. thisValue가 Object가 아니면
    1. TypeError 예외를 던진다.
  2. SameValue(thisValue, home)가 true이면
    1. 주: 여기서 던지는 것은 strict mode 코드에서 home 객체의 쓰기 불가능 데이터 프로퍼티에 대입하는 것과 유사하다.
    2. TypeError 예외를 던진다.
  3. desc를 ? thisValue.[[GetOwnProperty]](p)로 둔다.
  4. descundefined이면
    1. CreateDataPropertyOrThrow(thisValue, p, v)를 수행한다.
  5. Else,
    1. Set(thisValue, p, v, true)를 수행한다.
  6. unused를 반환한다.

7.4 이터레이터 객체에 대한 연산(Operations on Iterator Objects)

공통 반복 인터페이스는 27.1 참조.

7.4.1 Iterator Record

Iterator Record는 이터레이터 또는 async 이터레이터와 그 next 메서드를 캡슐화하는 데 사용되는 Record 값입니다.

Iterator Record는 Table 13에 나열된 필드를 가집니다.

Table 13: Iterator Record 필드
필드 이름 의미
[[Iterator]] Object 이터레이터 인터페이스 또는 async 이터레이터 인터페이스를 준수하는 객체.
[[NextMethod]] ECMAScript 언어 값 [[Iterator]] 객체의 next 메서드.
[[Done]] Boolean 이터레이터가 완료되었거나 닫혔는지 여부.

7.4.2 GetIteratorDirect ( obj )

The abstract operation GetIteratorDirect takes argument obj (Object) and returns Iterator Record를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. nextMethod를 ? Get(obj, "next")로 둔다.
  2. iteratorRecordIterator Record { [[Iterator]]: obj, [[NextMethod]]: nextMethod, [[Done]]: false }로 둔다.
  3. iteratorRecord를 반환한다.

7.4.3 GetIteratorFromMethod ( obj, method )

The abstract operation GetIteratorFromMethod takes arguments obj (ECMAScript 언어 값) and method (함수 객체) and returns Iterator Record를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. iterator를 ? Call(method, obj)로 둔다.
  2. iterator가 Object가 아니면 TypeError 예외를 던진다.
  3. GetIteratorDirect(iterator)를 반환한다.

7.4.4 GetIterator ( obj, kind )

The abstract operation GetIterator takes arguments obj (ECMAScript 언어 값) and kind (sync 또는 async) and returns Iterator Record를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. kindasync이면,
    1. method를 ? GetMethod(obj, %Symbol.asyncIterator%)로 둔다.
    2. methodundefined이면,
      1. syncMethod를 ? GetMethod(obj, %Symbol.iterator%)로 둔다.
      2. syncMethodundefined이면 TypeError 예외를 던진다.
      3. syncIteratorRecord를 ? GetIteratorFromMethod(obj, syncMethod)로 둔다.
      4. CreateAsyncFromSyncIterator(syncIteratorRecord)를 반환한다.
  2. Else,
    1. method를 ? GetMethod(obj, %Symbol.iterator%)로 둔다.
  3. methodundefined이면 TypeError 예외를 던진다.
  4. GetIteratorFromMethod(obj, method)를 반환한다.

7.4.5 GetIteratorFlattenable ( obj, primitiveHandling )

The abstract operation GetIteratorFlattenable takes arguments obj (ECMAScript 언어 값) and primitiveHandling (iterate-string-primitives 또는 reject-primitives) and returns Iterator Record를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. obj가 Object가 아니면,
    1. primitiveHandlingreject-primitives이면 TypeError 예외를 던진다.
    2. 단언: primitiveHandlingiterate-string-primitives.
    3. obj가 String이 아니면 TypeError 예외를 던진다.
  2. method를 ? GetMethod(obj, %Symbol.iterator%)로 둔다.
  3. methodundefined이면
    1. iteratorobj로 둔다.
  4. Else,
    1. iterator를 ? Call(method, obj)로 둔다.
  5. iterator가 Object가 아니면 TypeError 예외를 던진다.
  6. GetIteratorDirect(iterator)를 반환한다.

7.4.6 IteratorNext ( iteratorRecord [ , value ] )

The abstract operation IteratorNext takes argument iteratorRecord (Iterator Record) and optional argument value (ECMAScript 언어 값) and returns Object를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. value가 존재하지 않으면
    1. resultCompletion(Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]))로 둔다.
  2. Else,
    1. resultCompletion(Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »))로 둔다.
  3. resultthrow completion이면
    1. iteratorRecord.[[Done]]true로 둔다.
    2. result를 반환한다.
  4. result를 ! result로 둔다.
  5. result가 Object가 아니면
    1. iteratorRecord.[[Done]]true로 둔다.
    2. TypeError 예외를 던진다.
  6. result를 반환한다.

7.4.7 IteratorComplete ( iteratorResult )

The abstract operation IteratorComplete takes argument iteratorResult (Object) and returns Boolean을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. ToBoolean(? Get(iteratorResult, "done" ))을 반환한다.

7.4.8 IteratorValue ( iteratorResult )

The abstract operation IteratorValue takes argument iteratorResult (Object) and returns ECMAScript 언어 값을 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. Get(iteratorResult, "value")를 반환한다.

7.4.9 IteratorStep ( iteratorRecord )

The abstract operation IteratorStep takes argument iteratorRecord (Iterator Record) and returns Object 또는 done을 담는 normal completion 또는 throw completion. iteratorRecord.[[Iterator]]에서 iteratorRecord.[[NextMethod]]를 호출해 다음 값을 요청하고, 이터레이터가 끝에 도달했음을 나타내는 done 또는 다음 값을 사용할 수 있다면 IteratorResult 객체를 반환합니다. It performs the following steps when called:

  1. result를 ? IteratorNext(iteratorRecord)로 둔다.
  2. doneCompletion(IteratorComplete(result))로 둔다.
  3. donethrow completion이면
    1. iteratorRecord.[[Done]]true로 둔다.
    2. done을 반환한다.
  4. done을 ! done으로 둔다.
  5. donetrue이면
    1. iteratorRecord.[[Done]]true로 둔다.
    2. done을 반환한다.
  6. result를 반환한다.

7.4.10 IteratorStepValue ( iteratorRecord )

The abstract operation IteratorStepValue takes argument iteratorRecord (Iterator Record) and returns ECMAScript 언어 값 또는 done을 담는 normal completion 또는 throw completion. iteratorRecord.[[Iterator]]에서 iteratorRecord.[[NextMethod]]를 호출해 다음 값을 요청하고, 끝에 도달했으면 done을, 다음 값이 있으면 IteratorResult 객체의 값을 반환합니다. It performs the following steps when called:

  1. result를 ? IteratorStep(iteratorRecord)로 둔다.
  2. resultdone이면
    1. done을 반환한다.
  3. valueCompletion(IteratorValue(result))로 둔다.
  4. valuethrow completion이면
    1. iteratorRecord.[[Done]]true로 둔다.
  5. value를 반환한다.

7.4.11 IteratorClose ( iteratorRecord, completion )

The abstract operation IteratorClose takes arguments iteratorRecord (Iterator Record) and completion (Completion Record) and returns Completion Record. 이터레이터가 완료 상태에 도달했을 때 일반적으로 수행할 동작을 실행하도록 알리는 데 사용됩니다. It performs the following steps when called:

  1. 단언: iteratorRecord.[[Iterator]]는 Object이다.
  2. iteratoriteratorRecord.[[Iterator]]로 둔다.
  3. innerResultCompletion(GetMethod(iterator, "return" ))로 둔다.
  4. innerResultnormal completion이면
    1. returninnerResult.[[Value]]로 둔다.
    2. returnundefined이면 ? completion을 반환한다.
    3. innerResultCompletion(Call(return, iterator))로 둔다.
  5. completionthrow completion이면 ? completion을 반환한다.
  6. innerResultthrow completion이면 ? innerResult를 반환한다.
  7. innerResult.[[Value]]가 Object가 아니면 TypeError 예외를 던진다.
  8. completion을 반환한다.

7.4.12 IfAbruptCloseIterator ( value, iteratorRecord )

IfAbruptCloseIterator는 Iterator Record를 사용하는 알고리즘 단계의 축약 표현입니다. 다음 형태의 알고리즘 단계:

  1. IfAbruptCloseIterator(value, iteratorRecord).

는 다음과 동일한 의미입니다:

  1. 단언: valueCompletion Record이다.
  2. valueabrupt completion이면 ? IteratorClose(iteratorRecord, value)를 반환한다.
  3. Else, value를 ! value로 설정한다.

7.4.13 AsyncIteratorClose ( iteratorRecord, completion )

The abstract operation AsyncIteratorClose takes arguments iteratorRecord (Iterator Record) and completion (Completion Record) and returns Completion Record. async 이터레이터가 완료 상태에 도달했을 때 일반적으로 수행할 동작을 실행하도록 알리는 데 사용됩니다. It performs the following steps when called:

  1. 단언: iteratorRecord.[[Iterator]]는 Object이다.
  2. iteratoriteratorRecord.[[Iterator]]로 둔다.
  3. innerResultCompletion(GetMethod(iterator, "return" ))로 둔다.
  4. innerResultnormal completion이면
    1. returninnerResult.[[Value]]로 둔다.
    2. returnundefined이면 ? completion을 반환한다.
    3. innerResultCompletion(Call(return, iterator))로 둔다.
    4. innerResultnormal completion이면 innerResultCompletion(Await(innerResult.[[Value]]))로 둔다.
  5. completionthrow completion이면 ? completion을 반환한다.
  6. innerResultthrow completion이면 ? innerResult를 반환한다.
  7. innerResult.[[Value]]가 Object가 아니면 TypeError 예외를 던진다.
  8. completion을 반환한다.

7.4.14 CreateIteratorResultObject ( value, done )

The abstract operation CreateIteratorResultObject takes arguments value (ECMAScript 언어 값) and done (Boolean) and returns IteratorResult 인터페이스를 준수하는 Object. IteratorResult 인터페이스를 준수하는 객체를 생성합니다. It performs the following steps when called:

  1. objOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  2. CreateDataPropertyOrThrow(obj, "value", value)를 수행한다.
  3. CreateDataPropertyOrThrow(obj, "done", done)를 수행한다.
  4. obj를 반환한다.

7.4.15 CreateListIteratorRecord ( list )

The abstract operation CreateListIteratorRecord takes argument list (ECMAScript 언어 값들의 List) and returns Iterator Record. [[NextMethod]]list의 연속 요소를 반환하는 Iterator Record를 생성합니다. It performs the following steps when called:

  1. closure를 매개변수 없고 list를 캡처하며 호출 시 다음 단계를 수행하는 새 Abstract Closure로 둔다:
    1. list의 각 요소 E에 대해
      1. GeneratorYield(CreateIteratorResultObject(E, false))를 수행한다.
    2. NormalCompletion(undefined)를 반환한다.
  2. iteratorCreateIteratorFromClosure(closure, empty, %Iterator.prototype%)로 둔다.
  3. Iterator Record { [[Iterator]]: iterator, [[NextMethod]]: %GeneratorPrototype.next%, [[Done]]: false }를 반환한다.
Note

list 이터레이터 객체는 ECMAScript 코드에서 직접 접근할 수 없습니다.

7.4.16 IteratorToList ( iteratorRecord )

The abstract operation IteratorToList takes argument iteratorRecord (Iterator Record) and returns ECMAScript 언어 값들의 List를 담는 normal completion 또는 throw completion. It performs the following steps when called:

  1. values를 새 빈 List로 둔다.
  2. 반복,
    1. next를 ? IteratorStepValue(iteratorRecord)로 둔다.
    2. nextdone이면
      1. values를 반환한다.
    3. nextvalues에 추가한다.