7 Abstract Operations

이 operation들은 ECMAScript language의 일부가 아닙니다. 이들은 ECMAScript language의 semantics specification을 돕기 위해서만 여기에 정의됩니다. 더 specialized된 다른 abstract operation은 이 명세 전반에 걸쳐 정의됩니다.

7.1 Type Conversion

ECMAScript language는 필요에 따라 automatic type conversion을 implicitly 수행합니다. 특정 construct의 semantics를 명확히 하기 위해 conversion abstract operation의 set을 정의하는 것이 유용합니다. conversion abstract operation은 polymorphic합니다. 즉, 어떤 ECMAScript language type의 value도 accept할 수 있습니다. 그러나 이러한 operation에는 다른 specification type이 사용되지 않습니다.

BigInt type은 ECMAScript language에서 implicit conversion을 가지지 않습니다. programmer는 다른 type의 value를 convert하려면 BigInt를 명시적으로 호출해야 합니다.

7.1.1 ToPrimitive ( input [ , preferredType ] )

The abstract operation ToPrimitive takes argument input (an ECMAScript language value) and optional argument preferredType (string or number) and returns either a normal completion containing an ECMAScript language value or a throw completion. input argument를 non-Object type으로 convert합니다. object가 둘 이상의 primitive type으로 convert할 수 있으면, optional hint preferredType을 사용하여 그 type을 favour할 수 있습니다. It performs the following steps when called:

  1. input이 Object이면, 다음을 수행한다.
    1. exoticToPrimitive를 ? GetMethod(input, %Symbol.toPrimitive%)로 둔다.
    2. exoticToPrimitiveundefined가 아니면, 다음을 수행한다.
      1. preferredType이 present하지 않으면, 다음을 수행한다.
        1. hint"default"로 둔다.
      2. 그렇지 않고 preferredTypestring이면, 다음을 수행한다.
        1. hint"string"으로 둔다.
      3. 그렇지 않으면,
        1. Assert: preferredTypenumber이다.
        2. hint"number"로 둔다.
      4. result를 ? Call(exoticToPrimitive, input, « hint »)로 둔다.
      5. result가 Object가 아니면, result를 반환한다.
      6. TypeError exception을 throw한다.
    3. preferredType이 present하지 않으면, preferredTypenumber로 설정한다.
    4. OrdinaryToPrimitive(input, preferredType)를 반환한다.
  2. input을 반환한다.
Note

ToPrimitive가 hint 없이 호출되면, 일반적으로 hint가 number인 것처럼 behave합니다. 그러나 object는 %Symbol.toPrimitive% method를 정의하여 이 behaviour를 over-ride할 수 있습니다. 이 명세에서 정의된 object 중 Date(21.4.4.45 참조)와 Symbol object(20.4.3.5 참조)만 default ToPrimitive behaviour를 over-ride합니다. Date는 hint의 absence를 hint가 string인 것처럼 취급합니다.

7.1.1.1 OrdinaryToPrimitive ( obj, hint )

The abstract operation OrdinaryToPrimitive takes arguments obj (an Object) and hint (string or number) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. hintstring이면, 다음을 수행한다.
    1. methodNames를 « "toString", "valueOf" »로 둔다.
  2. 그렇지 않으면,
    1. methodNames를 « "valueOf", "toString" »로 둔다.
  3. methodNames의 각 element name에 대해, 다음을 수행한다.
    1. method를 ? Get(obj, name)으로 둔다.
    2. IsCallable(method)가 true이면, 다음을 수행한다.
      1. result를 ? Call(method, obj)로 둔다.
      2. result가 Object가 아니면, result를 반환한다.
  4. TypeError exception을 throw한다.

7.1.2 ToBoolean ( arg )

The abstract operation ToBoolean takes argument arg (an ECMAScript language value) and returns a Boolean. argBoolean type의 value로 convert합니다. It performs the following steps when called:

  1. arg가 Boolean이면, arg를 반환한다.
  2. argundefined, null, +0𝔽, -0𝔽, NaN, 0, 또는 empty String 중 하나이면, false를 반환한다.
  3. host가 web browser이거나 그 밖에 [[IsHTMLDDA]] Internal Slot를 support하면, 다음을 수행한다.
    1. arg가 Object이고 arg[[IsHTMLDDA]] internal slot을 가지면, false를 반환한다.
  4. true를 반환한다.

7.1.3 ToNumeric ( arg )

The abstract operation ToNumeric takes argument arg (an ECMAScript language value) and returns either a normal completion containing either a Number or a BigInt, or a throw completion. arg를 Number 또는 BigInt로 convert한 값을 반환합니다. It performs the following steps when called:

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

7.1.4 ToNumber ( arg )

The abstract operation ToNumber takes argument arg (an ECMAScript language value) and returns either a normal completion containing a Number or a throw completion. argNumber type의 value로 convert합니다. It performs the following steps when called:

  1. arg가 Number이면, arg를 반환한다.
  2. arg가 Symbol 또는 BigInt이면, TypeError exception을 throw한다.
  3. argundefined이면, NaN을 반환한다.
  4. argnull 또는 false이면, +0𝔽를 반환한다.
  5. argtrue이면, 1𝔽를 반환한다.
  6. arg가 String이면, StringToNumber(arg)를 반환한다.
  7. Assert: arg는 Object이다.
  8. primitiveValue를 ? ToPrimitive(arg, number)로 둔다.
  9. Assert: primitiveValue는 Object가 아니다.
  10. ToNumber(primitiveValue)를 반환한다.

7.1.4.1 String Type에 적용되는 ToNumber

abstract operation StringToNumber는 다음 grammar를 사용하여 String value를 Number value로 convert하는 방법을 specified합니다.

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

위에서 명시적으로 정의되지 않은 모든 grammar symbol은 numeric literal에 대한 Lexical Grammar(12.9.3)에서 사용되는 definition을 가집니다.

Note

StringNumericLiteral의 syntax와 NumericLiteral 사이에는 몇 가지 difference가 있음에 유의해야 합니다:

7.1.4.1.1 StringToNumber ( string )

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

  1. literalParseText(string, StringNumericLiteral)로 둔다.
  2. literal이 error의 List이면, NaN을 반환한다.
  3. literalStringNumericValue를 반환한다.

7.1.4.1.2 Runtime Semantics: StringNumericValue

The syntax-directed operation StringNumericValue takes no arguments and returns a Number.

Note

StringNumericLiteral을 Number value로 conversion하는 것은 전체적으로 NumericLiteralNumericValue determination(12.9.3 참조)과 유사하지만, 일부 detail은 다릅니다.

It is defined piecewise over the following productions:

StringNumericLiteral ::: StrWhiteSpaceopt
  1. +0𝔽를 반환한다.
StringNumericLiteral ::: StrWhiteSpaceopt StrNumericLiteral StrWhiteSpaceopt
  1. StrNumericLiteralStringNumericValue를 반환한다.
StrNumericLiteral ::: NonDecimalIntegerLiteral
  1. 𝔽(NonDecimalIntegerLiteral의 MV)를 반환한다.
StrDecimalLiteral ::: - StrUnsignedDecimalLiteral
  1. aStrUnsignedDecimalLiteralStringNumericValue로 둔다.
  2. a+0𝔽이면, -0𝔽를 반환한다.
  3. -a를 반환한다.
StrUnsignedDecimalLiteral ::: Infinity
  1. +∞𝔽를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits . DecimalDigitsopt ExponentPartopt
  1. a를 첫 번째 DecimalDigits의 MV로 둔다.
  2. 두 번째 DecimalDigits가 present하면, 다음을 수행한다.
    1. b를 두 번째 DecimalDigits의 MV로 둔다.
    2. n을 두 번째 DecimalDigits 안의 code point 수로 둔다.
  3. 그렇지 않으면,
    1. b를 0으로 둔다.
    2. n을 0으로 둔다.
  4. ExponentPart가 present하면 eExponentPart의 MV로 둔다. 그렇지 않으면 e를 0으로 둔다.
  5. RoundMVResult((a + (b × 10-n)) × 10e)를 반환한다.
StrUnsignedDecimalLiteral ::: . DecimalDigits ExponentPartopt
  1. bDecimalDigits의 MV로 둔다.
  2. ExponentPart가 present하면 eExponentPart의 MV로 둔다. 그렇지 않으면 e를 0으로 둔다.
  3. nDecimalDigits 안의 code point 수로 둔다.
  4. RoundMVResult(b × 10e - n)를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPartopt
  1. aDecimalDigits의 MV로 둔다.
  2. ExponentPart가 present하면 eExponentPart의 MV로 둔다. 그렇지 않으면 e를 0으로 둔다.
  3. RoundMVResult(a × 10e)를 반환한다.

7.1.4.1.3 RoundMVResult ( n )

The abstract operation RoundMVResult takes argument n (a mathematical value) and returns a Number. nimplementation-defined 방식으로 Number로 convert합니다. 이 abstract operation의 목적상, digit은 zero가 아니거나 그 왼쪽에 non-zero digit이 있고 그 오른쪽에 non-zero digit이 있으면 significant합니다. 이 abstract operation의 목적상, mathematical value의 representation이 “denoted by”하는 mathematical valuemathematical value의 “decimal representation of”의 inverse입니다. It performs the following steps when called:

  1. n의 decimal representation이 20개 이하의 significant digit을 가지면, 𝔽(n)을 반환한다.
  2. option1n의 decimal representation에서 20번째 뒤의 각 significant digit을 0 digit으로 replacing한 결과가 denoted by하는 mathematical value로 둔다.
  3. option2n의 decimal representation에서 20번째 뒤의 각 significant digit을 0 digit으로 replacing한 다음 20번째 position에서 incrementing한 결과가 denoted by하는 mathematical value로 둔다(필요에 따라 carrying).
  4. chosenoption1 또는 option2implementation-defined choice로 둔다.
  5. 𝔽(chosen)을 반환한다.

7.1.5 ToIntegerOrInfinity ( arg )

The abstract operation ToIntegerOrInfinity takes argument arg (an ECMAScript language value) and returns either a normal completion containing either an integer, +∞, or -∞, or a throw completion. arg를 fractional part가 truncated된 Number value를 나타내는 integer로 convert하거나, 그 Number value가 infinite이면 +∞ 또는 -∞로 convert합니다. It performs the following steps when called:

  1. number를 ? ToNumber(arg)로 둔다.
  2. numberNaN, +0𝔽, 또는 -0𝔽 중 하나이면, 0을 반환한다.
  3. number+∞𝔽이면, +∞를 반환한다.
  4. number-∞𝔽이면, -∞를 반환한다.
  5. truncate((number))를 반환한다.
Note
𝔽(ToIntegerOrInfinity(x))는 어떤 value x에 대해서도 결코 -0𝔽를 반환하지 않습니다. fractional part의 truncation은 xmathematical value로 converting한 뒤 수행됩니다.

7.1.6 ToFixedSizeInteger ( int, signed, bitWidth )

The abstract operation ToFixedSizeInteger takes arguments int (an integer, +∞, or -∞), signed (unsigned or signed), and bitWidth (a positive integer) and returns an integer. int를 0부터 2bitWidth - 1까지의 inclusive interval(signedunsigned인 경우) 또는 -2bitWidth - 1부터 2bitWidth - 1 - 1까지의 inclusive interval(signedsigned인 경우)에 있는 2bitWidthinteger 중 하나로 map합니다. It performs the following steps when called:

  1. int = +∞ 또는 int = -∞이면, 0을 반환한다.
  2. fixedIntint modulo 2bitWidth로 둔다.
  3. NOTE: 다음 step은 fixedInt의 two's complement representation을 change하지 않는다.
  4. signedsigned이고 fixedInt ≥ 2bitWidth - 1이면, fixedIntfixedInt - 2bitWidth로 설정한다.
  5. fixedInt를 반환한다.
Note

ToFixedSizeInteger는 idempotent입니다. 즉, 어떤 ECMAScript language value x에 대해서도 ToFixedSizeInteger(ToFixedSizeInteger(x, signed, bitWidth), signed, bitWidth)는 ToFixedSizeInteger(x, signed, bitWidth)와 같습니다. 실제로 +∞와 -∞가 0으로 mapped되므로, 이 invariant는 signed의 inversion에서도 유지됩니다(예: ToFixedSizeInteger(ToFixedSizeInteger(x, signed, 32), unsigned, 32)는 ToFixedSizeInteger(x, unsigned, 32)와 같습니다).

7.1.7 ToInt32 ( arg )

The abstract operation ToInt32 takes argument arg (an ECMAScript language value) and returns either a normal completion containing an integral Number or a throw completion. arg𝔽(-231)부터 𝔽(231 - 1)까지의 inclusive interval에 있는 232개의 integral Number value 중 하나로 convert하며, -0𝔽는 제외합니다. It performs the following steps when called:

  1. int를 ? ToIntegerOrInfinity(arg)로 둔다.
  2. 𝔽(ToFixedSizeInteger(int, signed, 32))를 반환한다.

7.1.8 ToUint32 ( arg )

The abstract operation ToUint32 takes argument arg (an ECMAScript language value) and returns either a normal completion containing an integral Number or a throw completion. arg+0𝔽부터 𝔽(232 - 1)까지의 inclusive interval에 있는 232개의 integral Number value 중 하나로 convert합니다. It performs the following steps when called:

  1. int를 ? ToIntegerOrInfinity(arg)로 둔다.
  2. 𝔽(ToFixedSizeInteger(int, unsigned, 32))를 반환한다.

7.1.9 ToInt16 ( arg )

The abstract operation ToInt16 takes argument arg (an ECMAScript language value) and returns either a normal completion containing an integral Number or a throw completion. arg𝔽(-215)부터 𝔽(215 - 1)까지의 inclusive interval에 있는 216개의 integral Number value 중 하나로 convert하며, -0𝔽는 제외합니다. It performs the following steps when called:

  1. int를 ? ToIntegerOrInfinity(arg)로 둔다.
  2. 𝔽(ToFixedSizeInteger(int, signed, 16))를 반환한다.

7.1.10 ToUint16 ( arg )

The abstract operation ToUint16 takes argument arg (an ECMAScript language value) and returns either a normal completion containing an integral Number or a throw completion. arg+0𝔽부터 𝔽(216 - 1)까지의 inclusive interval에 있는 216개의 integral Number value 중 하나로 convert합니다. It performs the following steps when called:

  1. int를 ? ToIntegerOrInfinity(arg)로 둔다.
  2. 𝔽(ToFixedSizeInteger(int, unsigned, 16))를 반환한다.

7.1.11 ToInt8 ( arg )

The abstract operation ToInt8 takes argument arg (an ECMAScript language value) and returns either a normal completion containing an integral Number or a throw completion. arg-128𝔽부터 127𝔽까지의 inclusive interval에 있는 28개의 integral Number value 중 하나로 convert하며, -0𝔽는 제외합니다. It performs the following steps when called:

  1. int를 ? ToIntegerOrInfinity(arg)로 둔다.
  2. 𝔽(ToFixedSizeInteger(int, signed, 8))를 반환한다.

7.1.12 ToUint8 ( arg )

The abstract operation ToUint8 takes argument arg (an ECMAScript language value) and returns either a normal completion containing an integral Number or a throw completion. arg+0𝔽부터 255𝔽까지의 inclusive interval에 있는 28개의 integral Number value 중 하나로 convert합니다. It performs the following steps when called:

  1. int를 ? ToIntegerOrInfinity(arg)로 둔다.
  2. 𝔽(ToFixedSizeInteger(int, unsigned, 8))를 반환한다.

7.1.13 ToUint8Clamp ( arg )

The abstract operation ToUint8Clamp takes argument arg (an ECMAScript language value) and returns either a normal completion containing an integral Number or a throw completion. arg+0𝔽부터 255𝔽까지의 inclusive interval에 있는 28개의 integral Number value 중 하나로 clamp하고 round합니다. It performs the following steps when called:

  1. number를 ? ToNumber(arg)로 둔다.
  2. numberNaN이면, +0𝔽를 반환한다.
  3. mvnumberextended mathematical value로 둔다.
  4. clampedmv를 0과 255 사이로 clamping한 결과로 둔다.
  5. ffloor(clamped)로 둔다.
  6. clamped < f + 0.5이면, 𝔽(f)를 반환한다.
  7. clamped > f + 0.5이면, 𝔽(f + 1)를 반환한다.
  8. f가 even이면, 𝔽(f)를 반환한다.
  9. 𝔽(f + 1)를 반환한다.
Note

대부분의 다른 ECMAScript integer conversion operation과 달리, ToUint8Clamp는 non-integral value를 truncate하지 않고 round합니다. 또한 “round half to even” tie-breaking을 사용하며, 이는 Math.round의 “round half up” tie-breaking과 다릅니다.

7.1.14 ToBigInt ( arg )

The abstract operation ToBigInt takes argument arg (an ECMAScript language value) and returns either a normal completion containing a BigInt or a throw completion. arg를 BigInt value로 convert하거나, Number로부터의 implicit conversion이 required되면 throw합니다. It performs the following steps when called:

  1. primitive를 ? ToPrimitive(arg, number)로 둔다.
  2. primitiveTable 12에서 대응하는 value를 반환한다.
Table 12: BigInt Conversions
Argument Type Result
Undefined TypeError exception을 throw한다.
Null TypeError exception을 throw한다.
Boolean primitivetrue이면 1n을 반환하고, primitivefalse이면 0n을 반환한다.
BigInt primitive를 반환한다.
Number TypeError exception을 throw한다.
String
  1. nStringToBigInt(primitive)로 둔다.
  2. nundefined이면, SyntaxError exception을 throw한다.
  3. n을 반환한다.
Symbol TypeError exception을 throw한다.

7.1.15 StringToBigInt ( string )

The abstract operation StringToBigInt takes argument string (a String) and returns a BigInt or undefined. It performs the following steps when called:

  1. literalParseText(string, StringIntegerLiteral)로 둔다.
  2. literal이 error의 List이면, undefined를 반환한다.
  3. mvliteral의 MV로 둔다.
  4. Assert: mvinteger이다.
  5. (mv)를 반환한다.

7.1.15.1 StringIntegerLiteral Grammar

StringToBigInt는 다음 grammar를 사용합니다.

Syntax

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

7.1.15.2 Runtime Semantics: MV

7.1.16 ToBigInt64 ( arg )

The abstract operation ToBigInt64 takes argument arg (an ECMAScript language value) and returns either a normal completion containing a BigInt or a throw completion. arg(-263)부터 (263 - 1)까지의 inclusive interval에 있는 264개의 BigInt value 중 하나로 convert합니다. It performs the following steps when called:

  1. int(? ToBigInt(arg))로 둔다.
  2. (ToFixedSizeInteger(int, signed, 64))를 반환한다.

7.1.17 ToBigUint64 ( arg )

The abstract operation ToBigUint64 takes argument arg (an ECMAScript language value) and returns either a normal completion containing a BigInt or a throw completion. arg0부터 (264 - 1)까지의 inclusive interval에 있는 264개의 BigInt value 중 하나로 convert합니다. It performs the following steps when called:

  1. int(? ToBigInt(arg))로 둔다.
  2. (ToFixedSizeInteger(int, unsigned, 64))를 반환한다.

7.1.18 ToString ( arg )

The abstract operation ToString takes argument arg (an ECMAScript language value) and returns either a normal completion containing a String or a throw completion. argString type의 value로 convert합니다. It performs the following steps when called:

  1. arg가 String이면, arg를 반환한다.
  2. arg가 Symbol이면, TypeError exception을 throw한다.
  3. argundefined이면, "undefined"를 반환한다.
  4. argnull이면, "null"을 반환한다.
  5. argtrue이면, "true"를 반환한다.
  6. argfalse이면, "false"를 반환한다.
  7. arg가 Number이면, Number::toString(arg, 10)을 반환한다.
  8. arg가 BigInt이면, BigInt::toString(arg, 10)을 반환한다.
  9. Assert: arg는 Object이다.
  10. primitiveValue를 ? ToPrimitive(arg, string)로 둔다.
  11. Assert: primitiveValue는 Object가 아니다.
  12. ToString(primitiveValue)를 반환한다.

7.1.19 ToObject ( arg )

The abstract operation ToObject takes argument arg (an ECMAScript language value) and returns either a normal completion containing an Object or a throw completion. argObject type의 value로 convert합니다. It performs the following steps when called:

  1. argundefined 또는 null이면, TypeError exception을 throw한다.
  2. arg가 Boolean이면, [[BooleanData]] internal slot이 arg로 set된 새 Boolean object를 반환한다. Boolean object의 description은 20.3를 참조한다.
  3. arg가 Number이면, [[NumberData]] internal slot이 arg로 set된 새 Number object를 반환한다. Number object의 description은 21.1를 참조한다.
  4. arg가 String이면, [[StringData]] internal slot이 arg로 set된 새 String object를 반환한다. String object의 description은 22.1를 참조한다.
  5. arg가 Symbol이면, [[SymbolData]] internal slot이 arg로 set된 새 Symbol object를 반환한다. Symbol object의 description은 20.4를 참조한다.
  6. arg가 BigInt이면, [[BigIntData]] internal slot이 arg로 set된 새 BigInt object를 반환한다. BigInt object의 description은 21.2를 참조한다.
  7. Assert: arg는 Object이다.
  8. arg를 반환한다.

7.1.20 ToPropertyKey ( arg )

The abstract operation ToPropertyKey takes argument arg (an ECMAScript language value) and returns either a normal completion containing a property key or a throw completion. argproperty key로 사용할 수 있는 value로 convert합니다. It performs the following steps when called:

  1. key를 ? ToPrimitive(arg, string)로 둔다.
  2. key가 Symbol이면, 다음을 수행한다.
    1. key를 반환한다.
  3. ToString(key)를 반환한다.

7.1.21 ToLength ( arg )

The abstract operation ToLength takes argument arg (an ECMAScript language value) and returns either a normal completion containing a non-negative integral Number or a throw completion. argarray-like object의 length로 사용하기에 suitable한 non-negative integral Number로 clamp하고 truncate합니다. It performs the following steps when called:

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

7.1.22 CanonicalNumericIndexString ( arg )

The abstract operation CanonicalNumericIndexString takes argument arg (a String) and returns a Number or undefined. arg"-0"이거나 어떤 Number value n에 대해 정확히 ToString(n)과 match하면, 각각의 Number value를 반환합니다. 그렇지 않으면 undefined를 반환합니다. It performs the following steps when called:

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

canonical numeric string은 CanonicalNumericIndexString abstract operation이 undefined를 반환하지 않는 모든 String입니다.

7.1.23 ToIndex ( arg )

The abstract operation ToIndex takes argument arg (an ECMAScript language value) and returns either a normal completion containing a non-negative integer or a throw completion. arginteger로 convert하고, 그것이 non-negative이며 integer index에 대응하면 그 integer를 반환합니다. 그렇지 않으면 exception을 throw합니다. It performs the following steps when called:

  1. int를 ? ToIntegerOrInfinity(arg)로 둔다.
  2. int가 0부터 253 - 1까지의 inclusive interval 안에 없으면, RangeError exception을 throw한다.
  3. int를 반환한다.

7.2 Testing and Comparison Operations

7.2.1 RequireObjectCoercible ( arg )

The abstract operation RequireObjectCoercible takes argument arg (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. argToObject를 사용하여 Object로 convert될 수 없는 value이면 error를 throw합니다. It performs the following steps when called:

  1. argundefined 또는 null이면, TypeError exception을 throw한다.
  2. unused를 반환한다.

7.2.2 IsArray ( arg )

The abstract operation IsArray takes argument arg (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. arg가 Object가 아니면, false를 반환한다.
  2. argArray exotic object이면, true를 반환한다.
  3. argProxy exotic object이면, 다음을 수행한다.
    1. ValidateNonRevokedProxy(arg)를 수행한다.
    2. proxyTargetarg.[[ProxyTarget]]으로 둔다.
    3. IsArray(proxyTarget)를 반환한다.
  4. false를 반환한다.

7.2.3 IsCallable ( arg )

The abstract operation IsCallable takes argument arg (an ECMAScript language value) and returns a Boolean. arg[[Call]] internal method를 가진 callable function인지 determine합니다. It performs the following steps when called:

  1. arg가 Object가 아니면, false를 반환한다.
  2. arg[[Call]] internal method를 가지면, true를 반환한다.
  3. false를 반환한다.

7.2.4 IsConstructor ( arg )

The abstract operation IsConstructor takes argument arg (an ECMAScript language value) and returns a Boolean. arg[[Construct]] internal method를 가진 function object인지 determine합니다. It performs the following steps when called:

  1. arg가 Object가 아니면, false를 반환한다.
  2. arg[[Construct]] internal method를 가지면, true를 반환한다.
  3. false를 반환한다.

7.2.5 IsExtensible ( obj )

The abstract operation IsExtensible takes argument obj (an Object) and returns either a normal completion containing a Boolean or a throw completion. additional property가 obj에 added될 수 있는지 determine하는 데 사용됩니다. It performs the following steps when called:

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

7.2.6 IsRegExp ( arg )

The abstract operation IsRegExp takes argument arg (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

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

7.2.7 Static Semantics: IsStringWellFormedUnicode ( string )

The abstract operation IsStringWellFormedUnicode takes argument string (a String) and returns a Boolean. 6.1.4에 설명된 대로 string을 UTF-16으로 encoded된 code point의 sequence로 interpret하고, 이것이 well formed UTF-16 sequence인지 determine합니다. It performs the following steps when called:

  1. lengthstring의 length로 둔다.
  2. k를 0으로 둔다.
  3. k < length인 동안 Repeat한다.
    1. codePointCodePointAt(string, k)로 둔다.
    2. codePoint.[[IsUnpairedSurrogate]]true이면, false를 반환한다.
    3. kk + codePoint.[[CodeUnitCount]]로 설정한다.
  4. true를 반환한다.

7.2.8 SameType ( x, y )

The abstract operation SameType takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns a Boolean. 두 argument가 같은 type인지 여부를 determine합니다. 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 (an ECMAScript language value) and y (an ECMAScript language value) and returns a Boolean. 두 argument가 같은 value인지 여부를 determine합니다. 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

이 algorithm은 모든 NaN value를 equivalent로 취급하고 +0𝔽-0𝔽를 differentiate한다는 점에서 IsStrictlyEqual Algorithm과 다릅니다.

7.2.10 SameValueZero ( x, y )

The abstract operation SameValueZero takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns a Boolean. 두 argument가 같은 value인지 여부를 determine합니다(+0𝔽-0𝔽의 차이를 ignoring). 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𝔽를 equivalent로 취급한다는 점에서만 SameValue와 다릅니다.

7.2.11 SameValueNonNumber ( x, y )

The abstract operation SameValueNonNumber takes arguments x (an ECMAScript language value, but not a Number) and y (an ECMAScript language value, but not a Number) and returns a Boolean. It performs the following steps when called:

  1. Assert: SameType(x, y)는 true이다.
  2. xundefined 또는 null이면, true를 반환한다.
  3. x가 BigInt이면, 다음을 수행한다.
    1. BigInt::equal(x, y)를 반환한다.
  4. x가 String이면, 다음을 수행한다.
    1. xy가 같은 length와 같은 position의 같은 code unit을 가지면, true를 반환한다.
    2. false를 반환한다.
  5. x가 Boolean이면, 다음을 수행한다.
    1. xtrue이고 ytrue이면, true를 반환한다.
    2. xfalse이고 yfalse이면, true를 반환한다.
    3. false를 반환한다.
  6. NOTE: 다른 모든 ECMAScript language value는 identity로 비교된다.
  7. xy이면, true를 반환한다.
  8. false를 반환한다.
Note 1
expository purpose상, 일부 case는 불필요하더라도 이 algorithm 안에서 separately handled됩니다.
Note 2
x is y”가 의미하는 바의 detail은 5.2.8에 있습니다.

7.2.12 IsLessThan ( x, y, leftFirst )

The abstract operation IsLessThan takes arguments x (an ECMAScript language value), y (an ECMAScript language value), and leftFirst (a Boolean) and returns either a normal completion containing either a Boolean or undefined, or a throw completion. comparison x < y에 대한 semantics를 제공하며, true, false, 또는 undefined(operand가 같은 numeric type의 comparable value로 coerced될 수 없음을 나타냄)를 반환합니다. leftFirst flag는 potentially visible side-effect가 있는 operation이 xy에 대해 수행되는 order를 control하는 데 사용됩니다. 이는 ECMAScript가 expression의 left to right evaluation을 specify하기 때문에 필요합니다. leftFirsttrue이면, x parameter는 y parameter에 대응하는 expression의 왼쪽에 나타나는 expression에 대응합니다. leftFirstfalse이면, 그 반대이며 operation은 x보다 y에 먼저 수행되어야 합니다. It performs the following steps when called:

  1. leftFirsttrue이면, 다음을 수행한다.
    1. px를 ? ToPrimitive(x, number)로 둔다.
    2. py를 ? ToPrimitive(y, number)로 둔다.
  2. 그렇지 않으면,
    1. NOTE: left to right evaluation을 preserve하려면 evaluation order가 reversed되어야 한다.
    2. py를 ? ToPrimitive(y, number)로 둔다.
    3. px를 ? ToPrimitive(x, number)로 둔다.
  3. px가 String이고 py가 String이면, 다음을 수행한다.
    1. lxpx의 length로 둔다.
    2. lypy의 length로 둔다.
    3. 0 ≤ i < min(lx, ly)인 각 integer i에 대해, ascending order로 다음을 수행한다.
      1. cxpx 안의 index i에 있는 code unit의 numeric value로 둔다.
      2. cypy 안의 index i에 있는 code unit의 numeric value로 둔다.
      3. cx < cy이면, true를 반환한다.
      4. cx > cy이면, false를 반환한다.
    4. lx < ly이면, true를 반환한다.
    5. false를 반환한다.
  4. px가 BigInt이고 py가 String이면, 다음을 수행한다.
    1. nyStringToBigInt(py)로 둔다.
    2. nyundefined이면, undefined를 반환한다.
    3. BigInt::lessThan(px, ny)를 반환한다.
  5. px가 String이고 py가 BigInt이면, 다음을 수행한다.
    1. nxStringToBigInt(px)로 둔다.
    2. nxundefined이면, undefined를 반환한다.
    3. BigInt::lessThan(nx, py)를 반환한다.
  6. NOTE: pxpy는 primitive value이므로, evaluation order는 중요하지 않다.
  7. nx를 ? ToNumeric(px)로 둔다.
  8. ny를 ? ToNumeric(py)로 둔다.
  9. SameType(nx, ny)가 true이면, 다음을 수행한다.
    1. nx가 Number이면, Number::lessThan(nx, ny)를 반환한다.
    2. Assert: nx는 BigInt이다.
    3. BigInt::lessThan(nx, ny)를 반환한다.
  10. Assert: nx는 BigInt이고 ny는 Number이거나, nx는 Number이고 ny는 BigInt이다.
  11. nxNaN이거나 nyNaN이면, undefined를 반환한다.
  12. nx-∞𝔽이거나 ny+∞𝔽이면, true를 반환한다.
  13. nx+∞𝔽이거나 ny-∞𝔽이면, false를 반환한다.
  14. (nx) < (ny)이면, true를 반환한다.
  15. false를 반환한다.
Note 1

Step 3는 logical-or operation 대신 logical-and operation을 사용한다는 점에서 addition operator +(13.15.3)를 handle하는 algorithm의 step 1.c와 다릅니다.

Note 2

String의 comparison은 UTF-16 code unit value의 sequence에 대한 simple lexicographic ordering을 사용합니다. Unicode specification에 정의된 character 또는 string equality와 collating order의 더 complex하고 semantically oriented definition을 사용하려는 attempt는 없습니다. 따라서 Unicode Standard에 따라 canonically equal하지만 같은 normalization form이 아닌 String value는 unequal로 test될 수 있습니다. 또한 code unit에 의한 lexicographic ordering은 surrogate pair를 포함하는 String에서 code point에 의한 ordering과 다르다는 점에 유의하십시오.

7.2.13 IsLooselyEqual ( x, y )

The abstract operation IsLooselyEqual takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. == operator에 대한 semantics를 제공합니다. 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. host가 web browser이거나 그 밖에 [[IsHTMLDDA]] Internal Slot를 support하면, 다음을 수행한다.
    1. x가 Object이고 x[[IsHTMLDDA]] internal slot을 가지며 yundefined 또는 null 중 하나이면, true를 반환한다.
    2. xundefined 또는 null 중 하나이고, y가 Object이며 y[[IsHTMLDDA]] internal slot을 가지면, 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. xfinite가 아니거나 yfinite가 아니면, false를 반환한다.
    2. (x) = (y)이면, true를 반환한다.
    3. false를 반환한다.
  14. false를 반환한다.

7.2.14 IsStrictlyEqual ( x, y )

The abstract operation IsStrictlyEqual takes arguments x (an ECMAScript language value) and y (an ECMAScript language value) and returns a Boolean. === operator에 대한 semantics를 제공합니다. 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

이 algorithm은 signed zero와 NaN의 treatment에서 SameValue Algorithm과 다릅니다.

7.3 Operations on Objects

7.3.1 MakeBasicObject ( internalSlotsList )

The abstract operation MakeBasicObject takes argument internalSlotsList (a List of internal slot names) and returns an Object. algorithmically 생성되는 모든 ECMAScript object의 source이며, ordinary objectexotic object를 모두 포함합니다. 모든 object를 creating하는 데 사용되는 common step을 factored out하고 object creation을 centralize합니다. It performs the following steps when called:

  1. internalSlotsListinternalSlotsList와 « [[PrivateElements]] »의 list-concatenation으로 설정한다.
  2. internalSlotsList 안의 각 name에 대한 internal slot을 가진 newly created object obj를 둔다.
  3. NOTE: Object Internal Methods and Internal Slots에 설명된 것처럼, 그러한 각 internal slot의 initial value는 달리 specified되지 않는 한 undefined이다.
  4. obj.[[PrivateElements]]를 새 empty List로 설정한다.
  5. obj의 essential internal method를 10.1에 specified된 default ordinary object definition으로 설정한다.
  6. Assert: caller가 obj[[GetPrototypeOf]][[SetPrototypeOf]] essential internal method를 모두 overriding하지 않을 것이라면, internalSlotsList[[Prototype]]을 포함한다.
  7. Assert: caller가 obj[[SetPrototypeOf]], [[IsExtensible]], [[PreventExtensions]] essential internal method를 모두 overriding하지 않을 것이라면, internalSlotsList[[Extensible]]을 포함한다.
  8. internalSlotsList[[Extensible]]을 포함하면, obj.[[Extensible]]true로 설정한다.
  9. obj를 반환한다.
Note

이 명세 안에서 exotic objectArrayCreateBoundFunctionCreate 같은 abstract operation에서 먼저 MakeBasicObject를 호출하여 basic, foundational object를 얻은 다음, 해당 object의 internal method 일부 또는 전부를 overriding하여 생성됩니다. exotic object creation을 encapsulate하기 위해, object의 essential internal method는 이러한 operation 밖에서는 결코 modified되지 않습니다.

7.3.2 Get ( obj, propertyKey )

The abstract operation Get takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing an ECMAScript language value or a throw completion. object의 특정 property의 value를 retrieve하는 데 사용됩니다. It performs the following steps when called:

  1. obj.[[Get]](propertyKey, obj)를 반환한다.

7.3.3 GetV ( value, propertyKey )

The abstract operation GetV takes arguments value (an ECMAScript language value) and propertyKey (a property key) and returns either a normal completion containing an ECMAScript language value or a throw completion. ECMAScript language value의 특정 property의 value를 retrieve하는 데 사용됩니다. value가 object가 아니면, value의 type에 appropriate한 wrapper object를 사용하여 property lookup이 수행됩니다. It performs the following steps when called:

  1. obj를 ? ToObject(value)로 둔다.
  2. obj.[[Get]](propertyKey, value)를 반환한다.

7.3.4 Set ( obj, propertyKey, value, throw )

The abstract operation Set takes arguments obj (an Object), propertyKey (a property key), value (an ECMAScript language value), and throw (a Boolean) and returns either a normal completion containing unused or a throw completion. object의 특정 property의 value를 set하는 데 사용됩니다. value는 property의 new value입니다. It performs the following steps when called:

  1. success를 ? obj.[[Set]](propertyKey, value, obj)로 둔다.
  2. successfalse이고 throwtrue이면, TypeError exception을 throw한다.
  3. unused를 반환한다.

7.3.5 CreateDataProperty ( obj, propertyKey, value )

The abstract operation CreateDataProperty takes arguments obj (an Object), propertyKey (a property key), and value (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. object의 new own property를 create하는 데 사용됩니다. It performs the following steps when called:

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

이 abstract operation은 ECMAScript language assignment operator가 생성하는 property에 사용되는 것과 같은 default로 attribute가 set된 property를 생성합니다. 일반적으로 property는 이미 존재하지 않습니다. 존재하지만 configurable하지 않거나 obj가 extensible하지 않으면, [[DefineOwnProperty]]false를 반환합니다.

7.3.6 CreateDataPropertyOrThrow ( obj, propertyKey, value )

The abstract operation CreateDataPropertyOrThrow takes arguments obj (an Object), propertyKey (a property key), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. object의 new own property를 create하는 데 사용됩니다. requested property update를 수행할 수 없으면 TypeError exception을 throw합니다. It performs the following steps when called:

  1. success를 ? CreateDataProperty(obj, propertyKey, value)로 둔다.
  2. successfalse이면, TypeError exception을 throw한다.
  3. unused를 반환한다.
Note

이 abstract operation은 ECMAScript language assignment operator가 생성하는 property에 사용되는 것과 같은 default로 attribute가 set된 property를 생성합니다. 일반적으로 property는 이미 존재하지 않습니다. 존재하지만 configurable하지 않거나 obj가 extensible하지 않으면, [[DefineOwnProperty]]false를 반환하여 이 operation이 TypeError exception을 throw하게 합니다.

7.3.7 CreateNonEnumerableDataPropertyOrThrow ( obj, propertyKey, value )

The abstract operation CreateNonEnumerableDataPropertyOrThrow takes arguments obj (an Object), propertyKey (a property key), and value (an ECMAScript language value) and returns unused. ordinary object의 new non-enumerable own property를 create하는 데 사용됩니다. It performs the following steps when called:

  1. Assert: obj는 non-configurable property가 없는 ordinary, extensible object이다.
  2. newDesc를 PropertyDescriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }로 둔다.
  3. DefinePropertyOrThrow(obj, propertyKey, newDesc)를 수행한다.
  4. unused를 반환한다.
Note

이 abstract operation은 enumerable하지 않다는 점을 제외하고 ECMAScript language assignment operator가 생성하는 property에 사용되는 것과 같은 default로 attribute가 set된 property를 생성합니다. 일반적으로 property는 이미 존재하지 않습니다. 존재하는 경우에도, DefinePropertyOrThrow는 정상적으로 complete함이 guaranteed됩니다.

7.3.8 DefinePropertyOrThrow ( obj, propertyKey, propertyDesc )

The abstract operation DefinePropertyOrThrow takes arguments obj (an Object), propertyKey (a property key), and propertyDesc (a Property Descriptor) and returns either a normal completion containing unused or a throw completion. requested property update를 수행할 수 없으면 TypeError exception을 throw하는 방식으로 object의 [[DefineOwnProperty]] internal method를 call하는 데 사용됩니다. It performs the following steps when called:

  1. success를 ? obj.[[DefineOwnProperty]](propertyKey, propertyDesc)로 둔다.
  2. successfalse이면, TypeError exception을 throw한다.
  3. unused를 반환한다.

7.3.9 DeletePropertyOrThrow ( obj, propertyKey )

The abstract operation DeletePropertyOrThrow takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing unused or a throw completion. object의 특정 own property를 remove하는 데 사용됩니다. property가 configurable하지 않으면 exception을 throw합니다. It performs the following steps when called:

  1. success를 ? obj.[[Delete]](propertyKey)로 둔다.
  2. successfalse이면, TypeError exception을 throw한다.
  3. unused를 반환한다.

7.3.10 GetMethod ( value, propertyKey )

The abstract operation GetMethod takes arguments value (an ECMAScript language value) and propertyKey (a property key) and returns either a normal completion containing either a function object or undefined, or a throw completion. property의 value가 function일 것으로 expected될 때 ECMAScript language value의 특정 property의 value를 get하는 데 사용됩니다. It performs the following steps when called:

  1. func를 ? GetV(value, propertyKey)로 둔다.
  2. funcundefined 또는 null이면, undefined를 반환한다.
  3. IsCallable(func)가 false이면, TypeError exception을 throw한다.
  4. func를 반환한다.

7.3.11 HasProperty ( obj, propertyKey )

The abstract operation HasProperty takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. object가 specified property key를 가진 property를 가지는지 determine하는 데 사용됩니다. property는 own 또는 inherited일 수 있습니다. It performs the following steps when called:

  1. obj.[[HasProperty]](propertyKey)를 반환한다.

7.3.12 HasOwnProperty ( obj, propertyKey )

The abstract operation HasOwnProperty takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. object가 specified property key를 가진 own property를 가지는지 determine하는 데 사용됩니다. It performs the following steps when called:

  1. propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
  2. propertyDescundefined이면, false를 반환한다.
  3. true를 반환한다.

7.3.13 Call ( func, thisValue [ , argList ] )

The abstract operation Call takes arguments func (an ECMAScript language value) and thisValue (an ECMAScript language value) and optional argument argList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. function object[[Call]] internal method를 call하는 데 사용됩니다. funcfunction object이고, thisValue[[Call]]this value인 ECMAScript language value이며, argList는 internal method의 corresponding argument로 passed되는 value입니다. argList가 present하지 않으면, 새 empty List가 그 value로 사용됩니다. It performs the following steps when called:

  1. argList가 present하지 않으면, argList를 새 empty List로 설정한다.
  2. IsCallable(func)가 false이면, TypeError exception을 throw한다.
  3. func.[[Call]](thisValue, argList)를 반환한다.

7.3.14 Construct ( ctor [ , argList [ , newTarget ] ] )

The abstract operation Construct takes argument ctor (a constructor) and optional arguments argList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. function object[[Construct]] internal method를 call하는 데 사용됩니다. argListnewTarget은 internal method의 corresponding argument로 passed될 value입니다. argList가 present하지 않으면, 새 empty List가 그 value로 사용됩니다. newTarget이 present하지 않으면, ctor가 그 value로 사용됩니다. It performs the following steps when called:

  1. newTarget이 present하지 않으면, newTargetctor로 설정한다.
  2. argList가 present하지 않으면, argList를 새 empty List로 설정한다.
  3. ctor.[[Construct]](argList, newTarget)를 반환한다.
Note

newTarget이 present하지 않으면, 이 operation은 new F(...argumentsList)와 equivalent합니다.

7.3.15 SetIntegrityLevel ( obj, level )

The abstract operation SetIntegrityLevel takes arguments obj (an Object) and level (sealed or frozen) and returns either a normal completion containing a Boolean or a throw completion. object의 own property set을 fix하는 데 사용됩니다. It performs the following steps when called:

  1. status를 ? obj.[[PreventExtensions]]()로 둔다.
  2. statusfalse이면, false를 반환한다.
  3. keys를 ? obj.[[OwnPropertyKeys]]()로 둔다.
  4. levelsealed이면, 다음을 수행한다.
    1. keys의 각 element key에 대해, 다음을 수행한다.
      1. DefinePropertyOrThrow(obj, key, PropertyDescriptor { [[Configurable]]: false })를 수행한다.
  5. 그렇지 않으면,
    1. Assert: levelfrozen이다.
    2. keys의 각 element key에 대해, 다음을 수행한다.
      1. currentDesc를 ? obj.[[GetOwnProperty]](key)로 둔다.
      2. currentDescundefined가 아니면, 다음을 수행한다.
        1. IsAccessorDescriptor(currentDesc)가 true이면, 다음을 수행한다.
          1. propertyDesc를 PropertyDescriptor { [[Configurable]]: false }로 둔다.
        2. 그렇지 않으면,
          1. propertyDesc를 PropertyDescriptor { [[Configurable]]: false, [[Writable]]: false }로 둔다.
        3. DefinePropertyOrThrow(obj, key, propertyDesc)를 수행한다.
  6. true를 반환한다.

7.3.16 TestIntegrityLevel ( obj, level )

The abstract operation TestIntegrityLevel takes arguments obj (an Object) and level (sealed or frozen) and returns either a normal completion containing a Boolean or a throw completion. object의 own property set이 fixed되어 있는지 determine하는 데 사용됩니다. It performs the following steps when called:

  1. extensible을 ? IsExtensible(obj)로 둔다.
  2. extensibletrue이면, false를 반환한다.
  3. NOTE: object가 extensible이면, 그 property는 전혀 examined되지 않는다.
  4. keys를 ? obj.[[OwnPropertyKeys]]()로 둔다.
  5. keys의 각 element key에 대해, 다음을 수행한다.
    1. currentDesc를 ? obj.[[GetOwnProperty]](key)로 둔다.
    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 (a List of ECMAScript language values) and returns an Array. elements가 제공하는 element를 가진 Array를 create하는 데 사용됩니다. It performs the following steps when called:

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

7.3.18 LengthOfArrayLike ( obj )

The abstract operation LengthOfArrayLike takes argument obj (an Object) and returns either a normal completion containing a non-negative integer or a throw completion. array-like object의 "length" property value를 반환합니다. It performs the following steps when called:

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

array-like object는 이 operation이 normal completion을 반환하는 모든 object입니다.

Note 1
일반적으로 array-like object는 integer index name을 가진 property도 일부 가집니다. 그러나 이는 이 definition의 requirement는 아닙니다.
Note 2
Array와 String object는 array-like object의 example입니다.

7.3.19 CreateListFromArrayLike ( obj [ , validElementTypes ] )

The abstract operation CreateListFromArrayLike takes argument obj (an ECMAScript language value) and optional argument validElementTypes (all or property-key) and returns either a normal completion containing a List of ECMAScript language values or a throw completion. obj의 indexed property가 제공하는 element를 가진 List value를 create하는 데 사용됩니다. validElementTypes는 element로 allowed되는 value의 type을 나타냅니다. It performs the following steps when called:

  1. validElementTypes가 present하지 않으면, validElementTypesall로 설정한다.
  2. obj가 Object가 아니면, TypeError exception을 throw한다.
  3. length를 ? LengthOfArrayLike(obj)로 둔다.
  4. list를 새 empty List로 둔다.
  5. index를 0으로 둔다.
  6. index < length인 동안 Repeat한다.
    1. indexName을 ! ToString(𝔽(index))으로 둔다.
    2. next를 ? Get(obj, indexName)로 둔다.
    3. validElementTypesproperty-key이고 nextproperty key가 아니면, TypeError exception을 throw한다.
    4. nextlist에 append한다.
    5. indexindex + 1로 설정한다.
  7. list를 반환한다.

7.3.20 Invoke ( value, propertyKey [ , argList ] )

The abstract operation Invoke takes arguments value (an ECMAScript language value) and propertyKey (a property key) and optional argument argList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. ECMAScript language value의 method property를 call하는 데 사용됩니다. value는 property의 lookup point와 call의 this value 둘 다로 사용됩니다. argList는 method에 passed되는 argument value의 list입니다. argList가 present하지 않으면, 새 empty List가 그 value로 사용됩니다. It performs the following steps when called:

  1. argList가 present하지 않으면, argList를 새 empty List로 설정한다.
  2. func를 ? GetV(value, propertyKey)로 둔다.
  3. Call(func, value, argList)를 반환한다.

7.3.21 OrdinaryHasInstance ( ctor, instance )

The abstract operation OrdinaryHasInstance takes arguments ctor (an ECMAScript language value) and instance (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. instancector가 제공하는 instance object inheritance path에서 inherit하는지 determine하기 위한 default algorithm을 implements합니다. It performs the following steps when called:

  1. IsCallable(ctor)가 false이면, false를 반환한다.
  2. ctor[[BoundTargetFunction]] internal slot을 가지면, 다음을 수행한다.
    1. boundCtorctor.[[BoundTargetFunction]]으로 둔다.
    2. InstanceofOperator(instance, boundCtor)를 반환한다.
  3. instance가 Object가 아니면, false를 반환한다.
  4. proto를 ? Get(ctor, "prototype")로 둔다.
  5. proto가 Object가 아니면, TypeError exception을 throw한다.
  6. Repeat,
    1. instance를 ? instance.[[GetPrototypeOf]]()로 설정한다.
    2. instancenull이면, false를 반환한다.
    3. SameValue(proto, instance)가 true이면, true를 반환한다.

7.3.22 SpeciesConstructor ( obj, defaultCtor )

The abstract operation SpeciesConstructor takes arguments obj (an Object) and defaultCtor (a constructor) and returns either a normal completion containing a constructor or a throw completion. obj에서 derived된 new object를 create하는 데 사용해야 하는 constructor를 retrieve하는 데 사용됩니다. defaultCtorobj에서 시작하여 constructor %Symbol.species% property를 찾을 수 없을 때 사용할 constructor입니다. It performs the following steps when called:

  1. ctor를 ? Get(obj, "constructor")로 둔다.
  2. ctorundefined이면, defaultCtor를 반환한다.
  3. ctor가 Object가 아니면, TypeError exception을 throw한다.
  4. species를 ? Get(ctor, %Symbol.species%)로 둔다.
  5. speciesundefined 또는 null이면, defaultCtor를 반환한다.
  6. IsConstructor(species)가 true이면, species를 반환한다.
  7. TypeError exception을 throw한다.

7.3.23 EnumerableOwnProperties ( obj, kind )

The abstract operation EnumerableOwnProperties takes arguments obj (an Object) and kind (key, value, or key+value) and returns either a normal completion containing a List of ECMAScript language values or a throw completion. It performs the following steps when called:

  1. ownKeys를 ? obj.[[OwnPropertyKeys]]()로 둔다.
  2. results를 새 empty List로 둔다.
  3. ownKeys의 각 element key에 대해, 다음을 수행한다.
    1. key가 String이면, 다음을 수행한다.
      1. propertyDesc를 ? obj.[[GetOwnProperty]](key)로 둔다.
      2. propertyDescundefined가 아니고 propertyDesc.[[Enumerable]]true이면, 다음을 수행한다.
        1. kindkey이면, 다음을 수행한다.
          1. keyresults에 append한다.
        2. 그렇지 않으면,
          1. value를 ? Get(obj, key)로 둔다.
          2. kindvalue이면, 다음을 수행한다.
            1. valueresults에 append한다.
          3. 그렇지 않으면,
            1. Assert: kindkey+value이다.
            2. entryCreateArrayFromListkey, value »)로 둔다.
            3. entryresults에 append한다.
  4. results를 반환한다.

7.3.24 GetFunctionRealm ( func )

The abstract operation GetFunctionRealm takes argument func (a function object) and returns either a normal completion containing a Realm Record or a throw completion. It performs the following steps when called:

  1. func[[Realm]] internal slot을 가지면, 다음을 수행한다.
    1. func.[[Realm]]을 반환한다.
  2. funcbound function exotic object이면, 다음을 수행한다.
    1. boundTargetFuncfunc.[[BoundTargetFunction]]으로 둔다.
    2. GetFunctionRealm(boundTargetFunc)를 반환한다.
  3. funcProxy exotic object이면, 다음을 수행한다.
    1. ValidateNonRevokedProxy(func)를 수행한다.
    2. proxyTargetfunc.[[ProxyTarget]]으로 둔다.
    3. Assert: proxyTargetfunction object이다.
    4. GetFunctionRealm(proxyTarget)를 반환한다.
  4. current Realm Record를 반환한다.
Note

Step 4func[[Realm]] internal slot을 가지지 않는 non-standard function exotic object인 경우에만 도달됩니다.

7.3.25 CopyDataProperties ( target, source, excludedItems )

The abstract operation CopyDataProperties takes arguments target (an Object), source (an ECMAScript language value), and excludedItems (a List of property keys) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

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

여기서 passed되는 target은 항상 newly created object이며, error가 thrown되는 경우 직접 accessible하지 않습니다.

7.3.26 PrivateElementFind ( obj, privateName )

The abstract operation PrivateElementFind takes arguments obj (an Object) and privateName (a Private Name) and returns a PrivateElement or empty. It performs the following steps when called:

  1. obj.[[PrivateElements]]entry.[[Key]]privateNamePrivateElement entry를 contain하면, 다음을 수행한다.
    1. entry를 반환한다.
  2. empty를 반환한다.

7.3.27 PrivateFieldAdd ( obj, privateName, value )

The abstract operation PrivateFieldAdd takes arguments obj (an Object), privateName (a Private Name), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. host가 web browser이면, 다음을 수행한다.
    1. HostEnsureCanAddPrivateElement(obj)를 수행한다.
  2. entryPrivateElementFind(obj, privateName)로 둔다.
  3. entryempty가 아니면, TypeError exception을 throw한다.
  4. PrivateElement { [[Key]]: privateName, [[Kind]]: field, [[Value]]: value }를 obj.[[PrivateElements]]에 append한다.
  5. unused를 반환한다.

7.3.28 PrivateMethodOrAccessorAdd ( obj, method )

The abstract operation PrivateMethodOrAccessorAdd takes arguments obj (an Object) and method (a PrivateElement) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. Assert: method.[[Kind]]method 또는 accessor 중 하나이다.
  2. host가 web browser이면, 다음을 수행한다.
    1. HostEnsureCanAddPrivateElement(obj)를 수행한다.
  3. entryPrivateElementFind(obj, method.[[Key]])로 둔다.
  4. entryempty가 아니면, TypeError exception을 throw한다.
  5. methodobj.[[PrivateElements]]에 append한다.
  6. unused를 반환한다.
Note

private method와 accessor의 value는 instance 간에 shared됩니다. 이 operation은 method 또는 accessor의 새 copy를 생성하지 않습니다.

7.3.29 HostEnsureCanAddPrivateElement ( obj )

The host-defined abstract operation HostEnsureCanAddPrivateElement takes argument obj (an Object) and returns either a normal completion containing unused or a throw completion. host environment가 특정 host-defined exotic object에 private element가 추가되는 것을 prevent할 수 있게 합니다.

HostEnsureCanAddPrivateElement의 implementation은 다음 requirement를 conform해야 합니다:

  • objhost-defined exotic object가 아니면, 이 abstract operation은 NormalCompletion(unused)를 반환하고 다른 step을 수행하지 않아야 합니다.
  • 같은 argument로 이 abstract operation을 두 번 call하면, 같은 kind의 Completion Record를 반환해야 합니다.

HostEnsureCanAddPrivateElement의 default implementation은 NormalCompletion(unused)를 반환하는 것입니다.

이 abstract operation은 web browser인 ECMAScript host에 의해서만 invoked됩니다.

7.3.30 PrivateGet ( obj, privateName )

The abstract operation PrivateGet takes arguments obj (an Object) and privateName (a Private Name) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. entryPrivateElementFind(obj, privateName)로 둔다.
  2. entryempty이면, TypeError exception을 throw한다.
  3. entry.[[Kind]]field 또는 method 중 하나이면, 다음을 수행한다.
    1. entry.[[Value]]를 반환한다.
  4. Assert: entry.[[Kind]]accessor이다.
  5. entry.[[Get]]undefined이면, TypeError exception을 throw한다.
  6. getterentry.[[Get]]으로 둔다.
  7. Call(getter, obj)를 반환한다.

7.3.31 PrivateSet ( obj, privateName, value )

The abstract operation PrivateSet takes arguments obj (an Object), privateName (a Private Name), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. entryPrivateElementFind(obj, privateName)로 둔다.
  2. entryempty이면, TypeError exception을 throw한다.
  3. entry.[[Kind]]method이면, TypeError exception을 throw한다.
  4. entry.[[Kind]]field이면, 다음을 수행한다.
    1. entry.[[Value]]value로 설정한다.
  5. 그렇지 않으면,
    1. Assert: entry.[[Kind]]accessor이다.
    2. entry.[[Set]]undefined이면, TypeError exception을 throw한다.
    3. setterentry.[[Set]]으로 둔다.
    4. Call(setter, obj, « value »)를 수행한다.
  6. unused를 반환한다.

7.3.32 DefineField ( receiver, fieldRecord )

The abstract operation DefineField takes arguments receiver (an Object) and fieldRecord (a ClassFieldDefinition Record) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. fieldNamefieldRecord.[[Name]]으로 둔다.
  2. initializerfieldRecord.[[Initializer]]로 둔다.
  3. initializerempty가 아니면, 다음을 수행한다.
    1. initValue를 ? Call(initializer, receiver)로 둔다.
  4. 그렇지 않으면,
    1. initValueundefined로 둔다.
  5. fieldNamePrivate Name이면, 다음을 수행한다.
    1. PrivateFieldAdd(receiver, fieldName, initValue)를 수행한다.
  6. 그렇지 않으면,
    1. Assert: fieldNameproperty key이다.
    2. CreateDataPropertyOrThrow(receiver, fieldName, initValue)를 수행한다.
  7. unused를 반환한다.

7.3.33 InitializeInstanceElements ( obj, ctor )

The abstract operation InitializeInstanceElements takes arguments obj (an Object) and ctor (an ECMAScript function object or a built-in function object) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. methodsctor.[[PrivateMethods]]로 둔다.
  2. methods의 각 PrivateElement method에 대해, 다음을 수행한다.
    1. PrivateMethodOrAccessorAdd(obj, method)를 수행한다.
  3. fieldsctor.[[Fields]]로 둔다.
  4. fields의 각 element fieldRecord에 대해, 다음을 수행한다.
    1. DefineField(obj, fieldRecord)를 수행한다.
  5. unused를 반환한다.

7.3.34 AddValueToKeyedGroup ( groups, key, value )

The abstract operation AddValueToKeyedGroup takes arguments groups (a List of Records with fields [[Key]] (an ECMAScript language value) and [[Elements]] (a List of ECMAScript language values)), key (an ECMAScript language value), and value (an ECMAScript language value) and returns unused. It performs the following steps when called:

  1. groups의 각 Record { [[Key]], [[Elements]] } group에 대해, 다음을 수행한다.
    1. SameValue(group.[[Key]], key)가 true이면, 다음을 수행한다.
      1. Assert: groups의 정확히 한 element가 이 criterion을 만족한다.
      2. valuegroup.[[Elements]]에 append한다.
      3. unused를 반환한다.
  2. groupRecord { [[Key]]: key, [[Elements]]: « value » }로 둔다.
  3. groupgroups에 append한다.
  4. unused를 반환한다.

7.3.35 GroupBy ( items, callback, keyCoercion )

The abstract operation GroupBy takes arguments items (an ECMAScript language value), callback (an ECMAScript language value), and keyCoercion (property or collection) and returns either a normal completion containing a List of Records with fields [[Key]] (an ECMAScript language value) and [[Elements]] (a List of ECMAScript language values), or a throw completion. It performs the following steps when called:

  1. RequireObjectCoercible(items)를 수행한다.
  2. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  3. groups를 새 empty List로 둔다.
  4. iteratorRecord를 ? GetIterator(items, sync)로 둔다.
  5. k를 0으로 둔다.
  6. Repeat,
    1. k ≥ 253 - 1이면, 다음을 수행한다.
      1. errorThrowCompletion(a newly created TypeError object)로 둔다.
      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. 그렇지 않으면,
      1. Assert: keyCoercioncollection이다.
      2. keyCanonicalizeKeyedCollectionKey(key)로 설정한다.
    9. AddValueToKeyedGroup(groups, key, value)를 수행한다.
    10. kk + 1로 설정한다.

7.3.36 GetOptionsObject ( options )

The abstract operation GetOptionsObject takes argument options (an ECMAScript language value) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. optionsundefined이면, 다음을 수행한다.
    1. OrdinaryObjectCreate(null)를 반환한다.
  2. options가 Object이면, 다음을 수행한다.
    1. options를 반환한다.
  3. TypeError exception을 throw한다.

7.3.37 SetterThatIgnoresPrototypeProperties ( thisValue, home, propertyKey, value )

The abstract operation SetterThatIgnoresPrototypeProperties takes arguments thisValue (an ECMAScript language value), home (an Object), propertyKey (a property key), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. thisValue가 Object가 아니면, 다음을 수행한다.
    1. TypeError exception을 throw한다.
  2. SameValue(thisValue, home)가 true이면, 다음을 수행한다.
    1. NOTE: 여기서 throw하는 것은 strict mode code에서 home object의 non-writable data property에 assignment하는 것을 emulates한다.
    2. TypeError exception을 throw한다.
  3. propertyDesc를 ? thisValue.[[GetOwnProperty]](propertyKey)로 둔다.
  4. propertyDescundefined이면, 다음을 수행한다.
    1. CreateDataPropertyOrThrow(thisValue, propertyKey, value)를 수행한다.
  5. 그렇지 않으면,
    1. Set(thisValue, propertyKey, value, true)를 수행한다.
  6. unused를 반환한다.

7.4 Iterator Objects에 대한 Operations

Common Iteration Interfaces(27.1)를 참조하십시오.

7.4.1 Iterator Records

Iterator Recordnext method와 함께 iterator 또는 async iterator를 encapsulate하는 데 사용되는 Record value입니다.

Iterator Record는 Table 13에 listed된 field를 가집니다.

Table 13: Iterator Record Fields
Field Name Value Meaning
[[Iterator]] Object iterator interface 또는 async iterator interface를 conform하는 object입니다.
[[NextMethod]] ECMAScript language value [[Iterator]] object의 next method입니다.
[[Done]] Boolean iterator가 completed되었거나 closed되었는지 여부입니다.

7.4.2 GetIteratorDirect ( obj )

The abstract operation GetIteratorDirect takes argument obj (an Object) and returns either a normal completion containing an Iterator Record or a 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 (an ECMAScript language value) and method (a function object) and returns either a normal completion containing an Iterator Record or a throw completion. It performs the following steps when called:

  1. iterator를 ? Call(method, obj)로 둔다.
  2. iterator가 Object가 아니면, TypeError exception을 throw한다.
  3. GetIteratorDirect(iterator)를 반환한다.

7.4.4 GetIterator ( obj, kind )

The abstract operation GetIterator takes arguments obj (an ECMAScript language value) and kind (sync or async) and returns either a normal completion containing an Iterator Record or a 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 exception을 throw한다.
      3. syncIteratorRecord를 ? GetIteratorFromMethod(obj, syncMethod)로 둔다.
      4. CreateAsyncFromSyncIterator(syncIteratorRecord)를 반환한다.
  2. 그렇지 않으면,
    1. method를 ? GetMethod(obj, %Symbol.iterator%)로 둔다.
  3. methodundefined이면, TypeError exception을 throw한다.
  4. GetIteratorFromMethod(obj, method)를 반환한다.

7.4.5 GetIteratorFlattenable ( obj, primitiveHandling )

The abstract operation GetIteratorFlattenable takes arguments obj (an ECMAScript language value) and primitiveHandling (iterate-string-primitives or reject-primitives) and returns either a normal completion containing an Iterator Record or a throw completion. It performs the following steps when called:

  1. obj가 Object가 아니면, 다음을 수행한다.
    1. primitiveHandlingreject-primitives이면, TypeError exception을 throw한다.
    2. Assert: primitiveHandlingiterate-string-primitives이다.
    3. obj가 String이 아니면, TypeError exception을 throw한다.
  2. method를 ? GetMethod(obj, %Symbol.iterator%)로 둔다.
  3. methodundefined이면, 다음을 수행한다.
    1. iteratorobj로 둔다.
  4. 그렇지 않으면,
    1. iterator를 ? Call(method, obj)로 둔다.
  5. iterator가 Object가 아니면, TypeError exception을 throw한다.
  6. GetIteratorDirect(iterator)를 반환한다.

7.4.6 IteratorNext ( iteratorRecord [ , value ] )

The abstract operation IteratorNext takes argument iteratorRecord (an Iterator Record) and optional argument value (an ECMAScript language value) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. value가 present하지 않으면, 다음을 수행한다.
    1. resultCompletion(Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]))로 둔다.
  2. 그렇지 않으면,
    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 exception을 throw한다.
  6. result를 반환한다.

7.4.7 IteratorComplete ( iteratorResult )

The abstract operation IteratorComplete takes argument iteratorResult (an Object) and returns either a normal completion containing a Boolean or a 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 (an Object) and returns either a normal completion containing an ECMAScript language value or a 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 (an Iterator Record) and returns either a normal completion containing either an Object or done, or a throw completion. iteratorRecord.[[NextMethod]]를 호출하여 iteratorRecord.[[Iterator]]로부터 next value를 request하고, iterator가 끝에 도달했음을 나타내는 done 또는 next value가 available하면 IteratorResult object를 반환합니다. 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 (an Iterator Record) and returns either a normal completion containing either an ECMAScript language value or done, or a throw completion. iteratorRecord.[[NextMethod]]를 호출하여 iteratorRecord.[[Iterator]]로부터 next value를 request하고, iterator가 끝에 도달했음을 나타내는 done 또는 next value가 available하면 IteratorResult object의 value를 반환합니다. 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 (an Iterator Record) and completion (a Completion Record) and returns a Completion Record. iterator가 completed state에 도달했을 때 일반적으로 수행할 action을 수행해야 함을 notify하는 데 사용됩니다. It performs the following steps when called:

  1. Assert: 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 exception을 throw한다.
  8. completion을 반환한다.

7.4.12 IteratorCloseAll ( iterators, completion )

The abstract operation IteratorCloseAll takes arguments iterators (a List of Iterator Records) and completion (a Completion Record) and returns a Completion Record. It performs the following steps when called:

  1. iterators의 각 element iterator에 대해, reverse List order로 다음을 수행한다.
    1. completionCompletion(IteratorClose(iterator, completion))으로 설정한다.
  2. completion을 반환한다.

7.4.13 IfAbruptCloseIterator ( value, iteratorRecord )

IfAbruptCloseIterator는 Iterator Record를 사용하는 algorithm step sequence에 대한 shorthand입니다. 다음 형식의 algorithm step은:

  1. IfAbruptCloseIterator(value, iteratorRecord).

다음과 같은 의미입니다:

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

7.4.14 IfAbruptCloseIterators ( value, iteratorRecords )

IfAbruptCloseIterators는 Iterator Record의 list를 사용하는 algorithm step sequence에 대한 shorthand입니다. 다음 형식의 algorithm step은:

  1. IfAbruptCloseIterators(value, iteratorRecords).

다음과 같은 의미입니다:

  1. Assert: valueCompletion Record이다.
  2. valueabrupt completion이면, ? IteratorCloseAll(iteratorRecords, value)를 반환한다.
  3. value를 ! value로 설정한다.

7.4.15 AsyncIteratorClose ( iteratorRecord, completion )

The abstract operation AsyncIteratorClose takes arguments iteratorRecord (an Iterator Record) and completion (a Completion Record) and returns a Completion Record. async iterator가 completed state에 도달했을 때 일반적으로 수행할 action을 수행해야 함을 notify하는 데 사용됩니다. It performs the following steps when called:

  1. Assert: 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 exception을 throw한다.
  8. completion을 반환한다.

7.4.16 IfAbruptCloseAsyncIterator ( value, iteratorRecord )

IfAbruptCloseAsyncIterator는 Iterator Record를 사용하는 algorithm step sequence에 대한 shorthand입니다. 다음 형식의 algorithm step은:

  1. IfAbruptCloseAsyncIterator(value, iteratorRecord).

다음과 같은 의미입니다:

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

7.4.17 CreateIteratorResultObject ( value, done )

The abstract operation CreateIteratorResultObject takes arguments value (an ECMAScript language value) and done (a Boolean) and returns an Object that conforms to the IteratorResult interface. IteratorResult interface를 conform하는 object를 생성합니다. 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.18 CreateListIteratorRecord ( list )

The abstract operation CreateListIteratorRecord takes argument list (a List of ECMAScript language values) and returns an Iterator Record. [[NextMethod]]list의 successive element를 반환하는 Iterator Record를 생성합니다. It performs the following steps when called:

  1. closure를 parameter가 없고 list를 capture하며 called될 때 다음 step을 수행하는 새 Abstract Closure로 둔다:
    1. list의 각 element value에 대해, 다음을 수행한다.
      1. GeneratorYield(CreateIteratorResultObject(value, false))를 수행한다.
    2. NormalCompletion(undefined)를 반환한다.
  2. iteratorCreateIteratorFromClosure(closure, empty, %Iterator.prototype%)로 둔다.
  3. Iterator Record { [[Iterator]]: iterator, [[NextMethod]]: %GeneratorPrototype.next%, [[Done]]: false }를 반환한다.
Note

list iterator object는 ECMAScript code에서 직접 accessible하지 않습니다.

7.4.19 IteratorToList ( iteratorRecord )

The abstract operation IteratorToList takes argument iteratorRecord (an Iterator Record) and returns either a normal completion containing a List of ECMAScript language values or a throw completion. It performs the following steps when called:

  1. values를 새 empty List로 둔다.
  2. Repeat,
    1. next를 ? IteratorStepValue(iteratorRecord)로 둔다.
    2. nextdone이면, 다음을 수행한다.
      1. values를 반환한다.
    3. nextvalues에 append한다.

7.5 Disposable 객체에 대한 연산

공통 리소스 관리 인터페이스(27.2.1)를 참조한다.

7.5.1 DisposableResource 레코드

DisposableResource 레코드는 폐기 가능한 객체를 해당 객체를 폐기하는 데 사용되는 메서드와 함께 캡슐화하는 데 사용되는 Record 값이다. DisposableResource 레코드는 CreateDisposableResource 추상 연산에 의해 생성된다.

DisposableResource 레코드에는 Table 14에 나열된 필드가 있다:

Table 14: DisposableResource 레코드 필드
필드 이름 의미
[[ResourceValue]] Object 또는 undefined 폐기될 값.
[[Kind]] sync-dispose 또는 async-dispose 리소스가 using 선언 또는 DisposableStack 객체(sync-dispose)에 의해 추가되었는지, 아니면 await using 선언 또는 AsyncDisposableStack 객체(async-dispose)에 의해 추가되었는지를 나타낸다.
[[DisposeMethod]] 함수 객체 또는 undefined 리소스가 폐기될 때 [[ResourceValue]]this 값으로 하여 호출될 함수 객체.

7.5.2 AddDisposableResource ( disposableResourceStack, value, kind [ , method ] )

The abstract operation AddDisposableResource takes arguments disposableResourceStack (DisposableResource 레코드List), value (ECMAScript 언어 값), and kind (sync-dispose 또는 async-dispose) and optional argument method (함수 객체) and returns unused를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. method가 존재하면,
    1. 단언: valueundefined이다.
    2. resource를 ? CreateDisposableResource(undefined, kind, method)로 둔다.
  2. 그렇지 않으면,
    1. valuenull 또는 undefined이고 kindsync-dispose이면, unused를 반환한다.
    2. NOTE: valuenull 또는 undefined이고 kindasync-dispose인 경우, 나중에 리소스가 폐기될 때 여전히 Await를 수행하도록 보장하기 위해 리소스가 평가되었음을 기록한다.
    3. resource를 ? CreateDisposableResource(value, kind)로 둔다.
  3. resourcedisposableResourceStack에 추가한다.
  4. unused를 반환한다.

7.5.3 CreateDisposableResource ( value, kind [ , method ] )

The abstract operation CreateDisposableResource takes arguments value (ECMAScript 언어 값) and kind (sync-dispose 또는 async-dispose) and optional argument method (함수 객체) and returns DisposableResource 레코드를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. method가 존재하지 않으면,
    1. valuenull 또는 undefined이면,
      1. valueundefined로 설정한다.
      2. methodundefined로 설정한다.
    2. 그렇지 않으면,
      1. method를 ? GetDisposeMethod(value, kind)로 설정한다.
      2. methodundefined이면, TypeError 예외를 던진다.
  2. DisposableResource 레코드 { [[ResourceValue]]: value, [[Kind]]: kind, [[DisposeMethod]]: method }를 반환한다.

7.5.4 GetDisposeMethod ( value, kind )

The abstract operation GetDisposeMethod takes arguments value (an ECMAScript language value) and kind (sync-dispose or async-dispose) and returns either a normal completion containing either a function object or undefined, or a throw completion. It performs the following steps when called:

  1. value가 Object가 아니면, TypeError 예외를 던진다.
  2. kindsync-dispose이면, ? GetMethod(value, %Symbol.dispose%)를 반환한다.
  3. 단언: kindasync-dispose이다.
  4. asyncMethod를 ? GetMethod(value, %Symbol.asyncDispose%)로 둔다.
  5. asyncMethodundefined가 아니면, asyncMethod를 반환한다.
  6. syncMethod를 ? GetMethod(value, %Symbol.dispose%)로 둔다.
  7. syncMethodundefined이면, undefined를 반환한다.
  8. syncMethod를 캡처하고 호출될 때 다음 단계를 수행하는, 매개변수가 없는 새 Abstract Closureclosure를 둔다:
    1. objthis 값으로 둔다.
    2. promiseCapability를 ! NewPromiseCapability(%Promise%)로 둔다.
    3. resultCompletion(Call(syncMethod, obj))로 둔다.
    4. IfAbruptRejectPromise(result, promiseCapability).
    5. Call(promiseCapability.[[Resolve]], undefined, « undefined »)를 수행한다.
    6. promiseCapability.[[Promise]]를 반환한다.
  9. NOTE: 이 함수는 사용자 코드에 관찰되지 않는다. 이 함수는 동기 %Symbol.dispose% 메서드에서 반환된 Promise가 await되지 않도록 하고, 동기 예외가 거부된 Promise로 변환되도록 보장하는 데 사용된다.
  10. CreateBuiltinFunction(closure, 0, "", « »)를 반환한다.

7.5.5 DisposeResources ( disposableResourceStack, completion )

The abstract operation DisposeResources takes arguments disposableResourceStack (a List of DisposableResource Records) and completion (either a normal completion containing either an ECMAScript language value or empty, or an abrupt completion) and returns either a normal completion containing either an ECMAScript language value or empty, or an abrupt completion. It performs the following steps when called:

  1. needsAwaitfalse로 둔다.
  2. hasAwaitedfalse로 둔다.
  3. outputCompletioncompletion으로 둔다.
  4. disposableResourceStack의 각 요소 resource에 대해, 역 List 순서로 다음을 수행한다.
    1. valueresource.[[ResourceValue]]로 둔다.
    2. kindresource.[[Kind]]로 둔다.
    3. methodresource.[[DisposeMethod]]로 둔다.
    4. kindsync-dispose이고, needsAwaittrue이며, hasAwaitedfalse이면,
      1. Await(undefined)를 수행한다.
      2. needsAwaitfalse로 설정한다.
    5. methodundefined가 아니면,
      1. resultCompletion(Call(method, value))로 둔다.
      2. result가 정상 완료이고 kindasync-dispose이면,
        1. resultCompletion(Await(result.[[Value]]))로 설정한다.
        2. hasAwaitedtrue로 설정한다.
      3. result가 throw 완료이면,
        1. outputCompletion이 throw 완료이면,
          1. resultresult.[[Value]]로 설정한다.
          2. suppressedoutputCompletion.[[Value]]로 둔다.
          3. error를 새로 생성된 SuppressedError 객체로 둔다.
          4. CreateNonEnumerableDataPropertyOrThrow(error, "error", result)를 수행한다.
          5. CreateNonEnumerableDataPropertyOrThrow(error, "suppressed", suppressed)를 수행한다.
          6. outputCompletionThrowCompletion(error)로 설정한다.
        2. 그렇지 않으면,
          1. outputCompletionresult로 설정한다.
    6. 그렇지 않으면,
      1. 단언: kindasync-dispose이다.
      2. needsAwaittrue로 설정한다.
      3. NOTE: 이는 await using 선언의 초기화된 값이 null 또는 undefined였던 경우만 나타낼 수 있다.
  5. needsAwaittrue이고 hasAwaitedfalse이면,
    1. Await(undefined)를 수행한다.
  6. NOTE: 이 시점에서 disposableResourceStack은 다시는 사용되지 않는다. disposableResourceStack의 내용은 가비지 컬렉션과 같은 방식으로 구현에서 폐기될 수 있다.
  7. outputCompletion을 반환한다.