23 Indexed Collections

23.1 Array Objects

Array는 certain class의 property names에 special treatment를 부여하는 exotic objects입니다. 이 special treatment의 definition은 10.4.2를 참조하십시오.

23.1.1 The Array Constructor

Array constructor는:

  • %Array%입니다.
  • global object"Array" property의 initial value입니다.
  • constructor로 called될 때 new Array를 create하고 initialize합니다.
  • constructor가 아니라 function으로 called될 때도 new Array를 create하고 initialize합니다. 따라서 function call Array(…)는 same arguments를 가진 object creation expression new Array(…)와 equivalent합니다.
  • arguments의 number 및 types에 따라 behaviour가 달라지는 function입니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다. exotic Array behaviour를 inherit하려는 subclass constructorsArray exotic objects인 subclass instances를 initialize하기 위해 Array constructor에 대한 super call을 include해야 합니다. 그러나 Array.prototype methods의 대부분은 this value가 Array exotic object인지에 dependent하지 않은 generic methods입니다.

23.1.1.1 Array ( ...values )

이 function은 called될 때 다음 steps를 수행합니다:

  1. NewTarget이 undefined이면 newTarget을 active function object로 둔다; else newTarget을 NewTarget으로 둔다.
  2. proto를 ? GetPrototypeFromConstructor(newTarget, "%Array.prototype%")로 둔다.
  3. numberOfArgsvalues 안의 elements 수로 둔다.
  4. numberOfArgs = 0이면, ! ArrayCreate(0, proto)를 반환한다.
  5. numberOfArgs = 1이면, 다음을 수행한다.
    1. lengthvalues[0]로 둔다.
    2. array를 ! ArrayCreate(0, proto)로 둔다.
    3. length가 Number가 아니면, 다음을 수행한다.
      1. CreateDataPropertyOrThrow(array, "0", length)를 수행한다.
      2. intLength1𝔽로 둔다.
    4. Else,
      1. intLength를 ! ToUint32(length)로 둔다.
      2. SameValueZero(intLength, length)가 false이면, RangeError exception을 throw한다.
    5. Set(array, "length", intLength, true)를 수행한다.
    6. array를 반환한다.
  6. Assert: numberOfArgs ≥ 2이다.
  7. array를 ? ArrayCreate(numberOfArgs, proto)로 둔다.
  8. k를 0으로 둔다.
  9. Repeat, while k < numberOfArgs,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. itemKvalues[k]로 둔다.
    3. CreateDataPropertyOrThrow(array, propertyKey, itemK)를 수행한다.
    4. kk + 1로 설정한다.
  10. Assert: array"length" property의 mathematical valuenumberOfArgs이다.
  11. array를 반환한다.

23.1.2 Properties of the Array Constructor

Array constructor는:

  • value가 %Function.prototype%[[Prototype]] internal slot을 가집니다.
  • value가 1𝔽"length" property를 가집니다.
  • 다음 properties를 가집니다:

23.1.2.1 Array.from ( items [ , mapper [ , thisArg ] ] )

이 function은 called될 때 다음 steps를 수행합니다:

  1. ctorthis value로 둔다.
  2. mapperundefined이면, 다음을 수행한다.
    1. mappingfalse로 둔다.
  3. Else,
    1. IsCallable(mapper)가 false이면, TypeError exception을 throw한다.
    2. mappingtrue로 둔다.
  4. usingIterator를 ? GetMethod(items, %Symbol.iterator%)로 둔다.
  5. usingIteratorundefined가 아니면, 다음을 수행한다.
    1. IsConstructor(ctor)가 true이면, 다음을 수행한다.
      1. array를 ? Construct(ctor)로 둔다.
    2. Else,
      1. array를 ! ArrayCreate(0)로 둔다.
    3. iteratorRecord를 ? GetIteratorFromMethod(items, usingIterator)로 둔다.
    4. k를 0으로 둔다.
    5. Repeat,
      1. k ≥ 253 - 1이면, 다음을 수행한다.
        1. errorThrowCompletion(newly created TypeError object)로 둔다.
        2. IteratorClose(iteratorRecord, error)를 반환한다.
      2. propertyKey를 ! ToString(𝔽(k))로 둔다.
      3. next를 ? IteratorStepValue(iteratorRecord)로 둔다.
      4. nextdone이면, 다음을 수행한다.
        1. Set(array, "length", 𝔽(k), true)를 수행한다.
        2. array를 반환한다.
      5. mappingtrue이면, 다음을 수행한다.
        1. mappedValueCompletion(Call(mapper, thisArg, « next, 𝔽(k) »))로 둔다.
        2. IfAbruptCloseIterator(mappedValue, iteratorRecord).
      6. Else,
        1. mappedValuenext로 둔다.
      7. defineStatusCompletion(CreateDataPropertyOrThrow(array, propertyKey, mappedValue))로 둔다.
      8. IfAbruptCloseIterator(defineStatus, iteratorRecord).
      9. kk + 1로 설정한다.
  6. NOTE: itemsiterable이 아니므로 array-like object라고 assume한다.
  7. arrayLike를 ! ToObject(items)로 둔다.
  8. length를 ? LengthOfArrayLike(arrayLike)로 둔다.
  9. IsConstructor(ctor)가 true이면, 다음을 수행한다.
    1. array를 ? Construct(ctor, « 𝔽(length) »)로 둔다.
  10. Else,
    1. array를 ? ArrayCreate(length)로 둔다.
  11. k를 0으로 둔다.
  12. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ? Get(arrayLike, propertyKey)로 둔다.
    3. mappingtrue이면, 다음을 수행한다.
      1. mappedValue를 ? Call(mapper, thisArg, « kValue, 𝔽(k) »)로 둔다.
    4. Else,
      1. mappedValuekValue로 둔다.
    5. CreateDataPropertyOrThrow(array, propertyKey, mappedValue)를 수행한다.
    6. kk + 1로 설정한다.
  13. Set(array, "length", 𝔽(length), true)를 수행한다.
  14. array를 반환한다.
Note

이 method는 intentionally generic factory method입니다; its this value가 Array constructor일 것을 require하지 않습니다. 따라서 single numeric argument와 함께 called될 수 있는 any other constructors로 transferred되거나 inherited될 수 있습니다.

23.1.2.2 Array.fromAsync ( items [ , mapper [ , thisArg ] ] )

이 async function은 called될 때 다음 steps를 수행합니다:

  1. ctorthis value로 둔다.
  2. mappingfalse로 둔다.
  3. mapperundefined가 아니면, 다음을 수행한다.
    1. IsCallable(mapper)가 false이면, TypeError exception을 throw한다.
    2. mappingtrue로 설정한다.
  4. iteratorRecordundefined로 둔다.
  5. usingAsyncIterator를 ? GetMethod(items, %Symbol.asyncIterator%)로 둔다.
  6. usingAsyncIteratorundefined이면, 다음을 수행한다.
    1. usingSyncIterator를 ? GetMethod(items, %Symbol.iterator%)로 둔다.
    2. usingSyncIteratorundefined가 아니면, 다음을 수행한다.
      1. iteratorRecordCreateAsyncFromSyncIterator(? GetIteratorFromMethod(items, usingSyncIterator))로 설정한다.
  7. Else,
    1. iteratorRecord를 ? GetIteratorFromMethod(items, usingAsyncIterator)로 설정한다.
  8. iteratorRecordundefined가 아니면, 다음을 수행한다.
    1. IsConstructor(ctor)가 true이면, 다음을 수행한다.
      1. array를 ? Construct(ctor)로 둔다.
    2. Else,
      1. array를 ! ArrayCreate(0)로 둔다.
    3. k를 0으로 둔다.
    4. Repeat,
      1. k ≥ 253 - 1이면, 다음을 수행한다.
        1. errorThrowCompletion(newly created TypeError object)로 둔다.
        2. AsyncIteratorClose(iteratorRecord, error)를 반환한다.
      2. propertyKey를 ! ToString(𝔽(k))로 둔다.
      3. nextResult를 ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]])로 둔다.
      4. nextResult를 ? Await(nextResult)로 설정한다.
      5. nextResult가 Object가 아니면, TypeError exception을 throw한다.
      6. done을 ? IteratorComplete(nextResult)로 둔다.
      7. donetrue이면, 다음을 수행한다.
        1. Set(array, "length", 𝔽(k), true)를 수행한다.
        2. array를 반환한다.
      8. nextValue를 ? IteratorValue(nextResult)로 둔다.
      9. mappingtrue이면, 다음을 수행한다.
        1. mappedValueCompletion(Call(mapper, thisArg, « nextValue, 𝔽(k) »))로 둔다.
        2. IfAbruptCloseAsyncIterator(mappedValue, iteratorRecord).
        3. mappedValueCompletion(Await(mappedValue))로 설정한다.
        4. IfAbruptCloseAsyncIterator(mappedValue, iteratorRecord).
      10. Else,
        1. mappedValuenextValue로 둔다.
      11. defineStatusCompletion(CreateDataPropertyOrThrow(array, propertyKey, mappedValue))로 둔다.
      12. IfAbruptCloseAsyncIterator(defineStatus, iteratorRecord).
      13. kk + 1로 설정한다.
  9. Else,
    1. NOTE: itemsasync iterableiterable도 아니므로 array-like object라고 assume한다.
    2. arrayLike를 ! ToObject(items)로 둔다.
    3. length를 ? LengthOfArrayLike(arrayLike)로 둔다.
    4. IsConstructor(ctor)가 true이면, 다음을 수행한다.
      1. array를 ? Construct(ctor, « 𝔽(length) »)로 둔다.
    5. Else,
      1. array를 ? ArrayCreate(length)로 둔다.
    6. k를 0으로 둔다.
    7. Repeat, while k < length,
      1. propertyKey를 ! ToString(𝔽(k))로 둔다.
      2. kValue를 ? Get(arrayLike, propertyKey)로 둔다.
      3. kValue를 ? Await(kValue)로 설정한다.
      4. mappingtrue이면, 다음을 수행한다.
        1. mappedValue를 ? Call(mapper, thisArg, « kValue, 𝔽(k) »)로 둔다.
        2. mappedValue를 ? Await(mappedValue)로 설정한다.
      5. Else,
        1. mappedValuekValue로 둔다.
      6. CreateDataPropertyOrThrow(array, propertyKey, mappedValue)를 수행한다.
      7. kk + 1로 설정한다.
    8. Set(array, "length", 𝔽(length), true)를 수행한다.
    9. array를 반환한다.
Note

이 method는 intentionally generic factory method입니다; its this value가 Array constructor일 것을 require하지 않습니다. 따라서 single numeric argument와 함께 called될 수 있는 any other constructors로 transferred되거나 inherited될 수 있습니다.

23.1.2.3 Array.isArray ( arg )

이 function은 called될 때 다음 steps를 수행합니다:

  1. IsArray(arg)를 반환한다.

23.1.2.4 Array.of ( ...items )

이 method는 called될 때 다음 steps를 수행합니다:

  1. lengthitems 안의 elements 수로 둔다.
  2. lengthNumber𝔽(length)로 둔다.
  3. ctorthis value로 둔다.
  4. IsConstructor(ctor)가 true이면, 다음을 수행한다.
    1. array를 ? Construct(ctor, « lengthNumber »)로 둔다.
  5. Else,
    1. array를 ? ArrayCreate(length)로 둔다.
  6. k를 0으로 둔다.
  7. Repeat, while k < length,
    1. kValueitems[k]로 둔다.
    2. propertyKey를 ! ToString(𝔽(k))로 둔다.
    3. CreateDataPropertyOrThrow(array, propertyKey, kValue)를 수행한다.
    4. kk + 1로 설정한다.
  8. Set(array, "length", lengthNumber, true)를 수행한다.
  9. array를 반환한다.
Note

이 method는 intentionally generic factory method입니다; its this value가 Array constructor일 것을 require하지 않습니다. 따라서 single numeric argument와 함께 called될 수 있는 other constructors로 transferred되거나 inherited될 수 있습니다.

23.1.2.5 Array.prototype

Array.prototype의 value는 Array prototype object입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

23.1.2.6 get Array [ %Symbol.species% ]

Array[%Symbol.species%]는 set accessor function이 undefinedaccessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:

  1. this value를 반환한다.

이 function의 "name" property의 value는 "get [Symbol.species]"입니다.

Note

Array prototype methods는 normally their this value의 constructor를 사용하여 derived object를 create합니다. However, subclass constructor는 its %Symbol.species% property를 redefining하여 그 default behaviour를 over-ride할 수 있습니다.

23.1.3 Properties of the Array Prototype Object

Array prototype object는:

  • %Array.prototype%입니다.
  • Array exotic object이며 such objects에 대해 specified된 internal methods를 가집니다.
  • initial value가 +0𝔽이고 attributes가 { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }인 "length" property를 가집니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.
Note

Array prototype object는 ECMAScript 2015 specification 이전에 created된 ECMAScript code와의 compatibility를 ensure하기 위해 Array exotic object로 specified됩니다.

23.1.3.1 Array.prototype.at ( index )

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. relativeIndex를 ? ToIntegerOrInfinity(index)로 둔다.
  4. relativeIndex ≥ 0이면, 다음을 수행한다.
    1. krelativeIndex로 둔다.
  5. Else,
    1. klength + relativeIndex로 둔다.
  6. k < 0 또는 klength이면, undefined를 반환한다.
  7. Get(obj, ! ToString(𝔽(k)))를 반환한다.

23.1.3.2 Array.prototype.concat ( ...items )

이 method는 object의 array elements 뒤에 each argument의 array elements가 followed되는 array를 반환합니다.

called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. array를 ? ArraySpeciesCreate(obj, 0)로 둔다.
  3. nextIndex를 0으로 둔다.
  4. objitems 앞에 prepend한다.
  5. items의 각 element item에 대해, 다음을 수행한다.
    1. spreadable을 ? IsConcatSpreadable(item)로 둔다.
    2. spreadabletrue이면, 다음을 수행한다.
      1. length를 ? LengthOfArrayLike(item)로 둔다.
      2. nextIndex + length > 253 - 1이면, TypeError exception을 throw한다.
      3. sourceIndex를 0으로 둔다.
      4. Repeat, while sourceIndex < length,
        1. propertyKey를 ! ToString(𝔽(sourceIndex))로 둔다.
        2. exists를 ? HasProperty(item, propertyKey)로 둔다.
        3. existstrue이면, 다음을 수행한다.
          1. subElement를 ? Get(item, propertyKey)로 둔다.
          2. CreateDataPropertyOrThrow(array, ! ToString(𝔽(nextIndex)), subElement)를 수행한다.
        4. nextIndexnextIndex + 1로 설정한다.
        5. sourceIndexsourceIndex + 1로 설정한다.
    3. Else,
      1. NOTE: item은 spread되지 않고 single item으로 added된다.
      2. nextIndex ≥ 253 - 1이면, TypeError exception을 throw한다.
      3. CreateDataPropertyOrThrow(array, ! ToString(𝔽(nextIndex)), item)를 수행한다.
      4. nextIndexnextIndex + 1로 설정한다.
  6. Set(array, "length", 𝔽(nextIndex), true)를 수행한다.
  7. array를 반환한다.

이 method의 "length" property는 1𝔽입니다.

Note 1

step 6에서 "length" property를 explicitly setting하는 것은 items의 final non-empty element가 trailing holes를 가지거나 array가 built-in Array가 아닌 경우에도 length가 correct함을 ensure하기 위한 것입니다.

Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.2.1 IsConcatSpreadable ( obj )

The abstract operation IsConcatSpreadable takes argument obj (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. obj가 Object가 아니면, false를 반환한다.
  2. spreadable을 ? Get(obj, %Symbol.isConcatSpreadable%)로 둔다.
  3. spreadableundefined가 아니면, ToBoolean(spreadable)를 반환한다.
  4. IsArray(obj)를 반환한다.

23.1.3.3 Array.prototype.constructor

Array.prototype.constructor의 initial value는 %Array%입니다.

23.1.3.4 Array.prototype.copyWithin ( target, start [ , end ] )

Note 1

end argument는 optional입니다. 제공되지 않으면, this value의 length가 사용됩니다.

Note 2

target이 negative이면, array의 length인 length에 대해 length + target로 treated됩니다. start가 negative이면, length + start로 treated됩니다. end가 negative이면, length + end로 treated됩니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. relativeTarget을 ? ToIntegerOrInfinity(target)로 둔다.
  4. relativeTarget = -∞이면, to를 0으로 둔다.
  5. Else if relativeTarget < 0이면, tomax(length + relativeTarget, 0)으로 둔다.
  6. Else, tomin(relativeTarget, length)로 둔다.
  7. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  8. relativeStart = -∞이면, from을 0으로 둔다.
  9. Else if relativeStart < 0이면, frommax(length + relativeStart, 0)으로 둔다.
  10. Else, frommin(relativeStart, length)로 둔다.
  11. endundefined이면 relativeEndlength로 둔다; else relativeEnd를 ? ToIntegerOrInfinity(end)로 둔다.
  12. relativeEnd = -∞이면, final을 0으로 둔다.
  13. Else if relativeEnd < 0이면, finalmax(length + relativeEnd, 0)으로 둔다.
  14. Else, finalmin(relativeEnd, length)로 둔다.
  15. countmin(final - from, length - to)로 둔다.
  16. from < to이고 to < from + count이면, 다음을 수행한다.
    1. direction을 -1로 둔다.
    2. fromfrom + count - 1로 설정한다.
    3. toto + count - 1로 설정한다.
  17. Else,
    1. direction을 1로 둔다.
  18. Repeat, while count > 0,
    1. fromKey를 ! ToString(𝔽(from))로 둔다.
    2. toKey를 ! ToString(𝔽(to))로 둔다.
    3. fromPresent를 ? HasProperty(obj, fromKey)로 둔다.
    4. fromPresenttrue이면, 다음을 수행한다.
      1. fromValue를 ? Get(obj, fromKey)로 둔다.
      2. Set(obj, toKey, fromValue, true)를 수행한다.
    5. Else,
      1. Assert: fromPresentfalse이다.
      2. DeletePropertyOrThrow(obj, toKey)를 수행한다.
    6. fromfrom + direction으로 설정한다.
    7. toto + direction으로 설정한다.
    8. countcount - 1로 설정한다.
  19. obj를 반환한다.
Note 3

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.5 Array.prototype.entries ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. CreateArrayIterator(obj, key+value)를 반환한다.

23.1.3.6 Array.prototype.every ( callback [ , thisArg ] )

Note 1

callback은 three arguments를 accept하고 Boolean value로 coercible한 value를 return하는 function이어야 합니다. everycallbackfalse를 return하는 element를 find할 때까지 array에 present한 each element마다 ascending order로 callback을 once call합니다. such element가 found되면, every는 immediately false를 반환합니다. Otherwise, everytrue를 반환합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.

thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.

callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.

every는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.

every에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. every call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 every가 them을 visit하는 time의 value입니다; every call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다. every는 mathematics의 “for all” quantifier처럼 acts합니다. 특히 empty array에 대해서는 true를 반환합니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  4. k를 0으로 둔다.
  5. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. testResultToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), obj »))로 둔다.
      3. testResultfalse이면, false를 반환한다.
    4. kk + 1로 설정한다.
  6. true를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.7 Array.prototype.fill ( value [ , start [ , end ] ] )

Note 1

start argument는 optional입니다. 제공되지 않으면, +0𝔽이 사용됩니다.

end argument는 optional입니다. 제공되지 않으면, this value의 length가 사용됩니다.

Note 2

start가 negative이면, array의 length인 length에 대해 length + start로 treated됩니다. end가 negative이면, length + end로 treated됩니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  4. relativeStart = -∞이면, k를 0으로 둔다.
  5. Else if relativeStart < 0이면, kmax(length + relativeStart, 0)으로 둔다.
  6. Else, kmin(relativeStart, length)로 둔다.
  7. endundefined이면 relativeEndlength로 둔다; else relativeEnd를 ? ToIntegerOrInfinity(end)로 둔다.
  8. relativeEnd = -∞이면, final을 0으로 둔다.
  9. Else if relativeEnd < 0이면, finalmax(length + relativeEnd, 0)으로 둔다.
  10. Else, finalmin(relativeEnd, length)로 둔다.
  11. Repeat, while k < final,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. Set(obj, propertyKey, value, true)를 수행한다.
    3. kk + 1로 설정한다.
  12. obj를 반환한다.
Note 3

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.8 Array.prototype.filter ( callback [ , thisArg ] )

Note 1

callback은 three arguments를 accept하고 Boolean value로 coercible한 value를 return하는 function이어야 합니다. filter는 array의 each element에 대해 ascending order로 callback을 once call하고, callbacktrue를 return하는 all values의 new array를 constructs합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.

thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.

callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.

filter는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.

filter에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. filter call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면 callback에 passed되는 그 value는 filter가 them을 visit하는 time의 value입니다; filter call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  4. array를 ? ArraySpeciesCreate(obj, 0)로 둔다.
  5. k를 0으로 둔다.
  6. to를 0으로 둔다.
  7. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. selectedToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), obj »))로 둔다.
      3. selectedtrue이면, 다음을 수행한다.
        1. CreateDataPropertyOrThrow(array, ! ToString(𝔽(to)), kValue)를 수행한다.
        2. toto + 1로 설정한다.
    4. kk + 1로 설정한다.
  8. array를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.9 Array.prototype.find ( predicate [ , thisArg ] )

Note 1

이 method는 predicatetrue로 coerce되는 value를 return하는 one을 find할 때까지 array의 each element에 대해 ascending index order로 predicate를 once call합니다. such element가 found되면, find는 immediately that element value를 반환합니다. Otherwise, findundefined를 반환합니다.

additional information은 FindViaPredicate를 참조하십시오.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. findRecord를 ? FindViaPredicate(obj, length, ascending, predicate, thisArg)로 둔다.
  4. findRecord.[[Value]]를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.10 Array.prototype.findIndex ( predicate [ , thisArg ] )

Note 1

이 method는 predicatetrue로 coerce되는 value를 return하는 one을 find할 때까지 array의 each element에 대해 ascending index order로 predicate를 once call합니다. such element가 found되면, findIndex는 immediately that element value의 index를 반환합니다. Otherwise, findIndex는 -1을 반환합니다.

additional information은 FindViaPredicate를 참조하십시오.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. findRecord를 ? FindViaPredicate(obj, length, ascending, predicate, thisArg)로 둔다.
  4. findRecord.[[Index]]를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.11 Array.prototype.findLast ( predicate [ , thisArg ] )

Note 1

이 method는 predicatetrue로 coerce되는 value를 return하는 one을 find할 때까지 array의 each element에 대해 descending index order로 predicate를 once call합니다. such element가 found되면, findLast는 immediately that element value를 반환합니다. Otherwise, findLastundefined를 반환합니다.

additional information은 FindViaPredicate를 참조하십시오.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. findRecord를 ? FindViaPredicate(obj, length, descending, predicate, thisArg)로 둔다.
  4. findRecord.[[Value]]를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.12 Array.prototype.findLastIndex ( predicate [ , thisArg ] )

Note 1

이 method는 predicatetrue로 coerce되는 value를 return하는 one을 find할 때까지 array의 each element에 대해 descending index order로 predicate를 once call합니다. such element가 found되면, findLastIndex는 immediately that element value의 index를 반환합니다. Otherwise, findLastIndex는 -1을 반환합니다.

additional information은 FindViaPredicate를 참조하십시오.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. findRecord를 ? FindViaPredicate(obj, length, descending, predicate, thisArg)로 둔다.
  4. findRecord.[[Index]]를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array object일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.12.1 FindViaPredicate ( obj, length, direction, predicate, thisArg )

The abstract operation FindViaPredicate takes arguments obj (an Object), length (a non-negative integer), direction (ascending or descending), predicate (an ECMAScript language value), and thisArg (an ECMAScript language value) and returns either a normal completion containing a Record with fields [[Index]] (an integral Number) and [[Value]] (an ECMAScript language value) or a throw completion.

objarray-like object 또는 TypedArray이어야 합니다. 이 operation은 predicatetrue로 coerce되는 value를 return하는 one을 find할 때까지 obj의 each element에 대해 ascending index order 또는 descending index order(direction에 의해 indicated됨)로 predicate를 once call합니다. 그 point에서, 이 operation은 found된 element의 index 및 value를 giving하는 Record를 반환합니다. such element가 found되지 않으면, 이 operation은 index에 -1𝔽을, value에 undefined를 specify하는 Record를 반환합니다.

predicate는 function이어야 합니다. array의 element에 대해 called될 때, three arguments가 passed됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다. Its return value는 Boolean value로 coerced됩니다.

thisArgpredicate의 each invocation에 대한 this value로 사용됩니다.

이 operation은 called된 object를 directly mutate하지 않지만, object는 predicate calls에 의해 mutated될 수 있습니다.

processed되는 elements의 range는 predicate에 대한 first call 전에, traversal이 begin되기 직전에 set됩니다. 이 뒤 array에 appended되는 elements는 predicate에 의해 visited되지 않습니다. array의 existing elements가 changed되면, predicate에 passed되는 그 value는 이 operation이 them을 visit하는 time의 value입니다. traversal이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements도 still visited되며, prototype에서 looked up되거나 undefined입니다.

It performs the following steps when called:

  1. IsCallable(predicate)가 false이면, TypeError exception을 throw한다.
  2. directionascending이면, 다음을 수행한다.
    1. indices를 0(inclusive)부터 length(exclusive)까지의 interval 안의 integers를 ascending order로 가진 List로 둔다.
  3. Else,
    1. indices를 0(inclusive)부터 length(exclusive)까지의 interval 안의 integers를 descending order로 가진 List로 둔다.
  4. indices의 각 integer k에 대해, 다음을 수행한다.
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. NOTE: objTypedArray이면, following invocation of Getnormal completion을 반환한다.
    3. kValue를 ? Get(obj, propertyKey)로 둔다.
    4. testResult를 ? Call(predicate, thisArg, « kValue, 𝔽(k), obj »)로 둔다.
    5. ToBoolean(testResult)가 true이면, Record { [[Index]]: 𝔽(k), [[Value]]: kValue }를 반환한다.
  5. Record { [[Index]]: -1𝔽, [[Value]]: undefined }를 반환한다.

23.1.3.13 Array.prototype.flat ( [ depth ] )

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. sourceLength를 ? LengthOfArrayLike(obj)로 둔다.
  3. depthNumber를 1로 둔다.
  4. depthundefined가 아니면, 다음을 수행한다.
    1. depthNumber를 ? ToIntegerOrInfinity(depth)로 설정한다.
    2. depthNumber < 0이면, depthNumber를 0으로 설정한다.
  5. array를 ? ArraySpeciesCreate(obj, 0)로 둔다.
  6. FlattenIntoArray(array, obj, sourceLength, 0, depthNumber)를 수행한다.
  7. array를 반환한다.

23.1.3.13.1 FlattenIntoArray ( target, source, sourceLength, start, depth [ , mapperFunc [ , thisArg ] ] )

The abstract operation FlattenIntoArray takes arguments target (an Object), source (an Object), sourceLength (a non-negative integer), start (a non-negative integer), and depth (a non-negative integer or +∞) and optional arguments mapperFunc (a function object) and thisArg (an ECMAScript language value) and returns either a normal completion containing a non-negative integer or a throw completion. It performs the following steps when called:

  1. Assert: mapperFunc가 present이면, IsCallable(mapperFunc)는 true이고, thisArg는 present이며, depth는 1이다.
  2. targetIndexstart로 둔다.
  3. sourceIndex+0𝔽로 둔다.
  4. Repeat, while (sourceIndex) < sourceLength,
    1. propertyKey를 ! ToString(sourceIndex)로 둔다.
    2. exists를 ? HasProperty(source, propertyKey)로 둔다.
    3. existstrue이면, 다음을 수행한다.
      1. element를 ? Get(source, propertyKey)로 둔다.
      2. mapperFunc가 present이면, 다음을 수행한다.
        1. element를 ? Call(mapperFunc, thisArg, « element, sourceIndex, source »)로 설정한다.
      3. shouldFlattenfalse로 둔다.
      4. depth > 0이면, 다음을 수행한다.
        1. shouldFlatten을 ? IsArray(element)로 설정한다.
      5. shouldFlattentrue이면, 다음을 수행한다.
        1. depth = +∞이면 newDepth를 +∞로 둔다.
        2. Else, newDepthdepth - 1로 둔다.
        3. elementLength를 ? LengthOfArrayLike(element)로 둔다.
        4. targetIndex를 ? FlattenIntoArray(target, element, elementLength, targetIndex, newDepth)로 설정한다.
      6. Else,
        1. targetIndex ≥ 253 - 1이면, TypeError exception을 throw한다.
        2. CreateDataPropertyOrThrow(target, ! ToString(𝔽(targetIndex)), element)를 수행한다.
        3. targetIndextargetIndex + 1로 설정한다.
    4. sourceIndexsourceIndex + 1𝔽로 설정한다.
  5. targetIndex를 반환한다.

23.1.3.14 Array.prototype.flatMap ( mapperFunc [ , thisArg ] )

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. sourceLength를 ? LengthOfArrayLike(obj)로 둔다.
  3. IsCallable(mapperFunc)가 false이면, TypeError exception을 throw한다.
  4. array를 ? ArraySpeciesCreate(obj, 0)로 둔다.
  5. FlattenIntoArray(array, obj, sourceLength, 0, 1, mapperFunc, thisArg)를 수행한다.
  6. array를 반환한다.

23.1.3.15 Array.prototype.forEach ( callback [ , thisArg ] )

Note 1

callback은 three arguments를 accept하는 function이어야 합니다. forEach는 array에 present한 each element마다 ascending order로 callback을 once call합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.

thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.

callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.

forEach는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.

forEach에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. forEach call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 forEach가 them을 visit하는 time의 value입니다; forEach call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  4. k를 0으로 둔다.
  5. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. Call(callback, thisArg, « kValue, 𝔽(k), obj »)를 수행한다.
    4. kk + 1로 설정한다.
  6. undefined를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.16 Array.prototype.includes ( searchElement [ , fromIndex ] )

Note 1

이 method는 SameValueZero algorithm을 사용하여 searchElement를 array의 elements와 ascending order로 compare하고, any position에서 found되면 true를 반환합니다; otherwise, false를 반환합니다.

optional second argument fromIndex의 default는 +0𝔽입니다(즉, whole array가 searched됩니다). 그것이 array의 length보다 크거나 같으면, false가 returned됩니다, 즉 array는 searched되지 않습니다. 그것이 -0𝔽보다 작으면, fromIndex를 compute하기 위해 array의 end로부터의 offset으로 사용됩니다. computed index가 +0𝔽보다 작거나 같으면, whole array가 searched됩니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. length = 0이면, false를 반환한다.
  4. startIndex를 ? ToIntegerOrInfinity(fromIndex)로 둔다.
  5. Assert: fromIndexundefined이면, startIndex는 0이다.
  6. startIndex = +∞이면, false를 반환한다.
  7. startIndex = -∞이면, startIndex를 0으로 설정한다.
  8. startIndex ≥ 0이면, 다음을 수행한다.
    1. kstartIndex로 둔다.
  9. Else,
    1. klength + startIndex로 둔다.
    2. k < 0이면, k를 0으로 설정한다.
  10. Repeat, while k < length,
    1. elementK를 ? Get(obj, ! ToString(𝔽(k)))로 둔다.
    2. SameValueZero(searchElement, elementK)가 true이면, true를 반환한다.
    3. kk + 1로 설정한다.
  11. false를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

Note 3

이 method는 similar indexOf method와 intentionally two ways에서 다릅니다. First, IsStrictlyEqual 대신 SameValueZero algorithm을 사용하여 NaN array elements를 detect할 수 있습니다. Second, missing array elements를 skip하지 않고, 대신 them을 undefined로 treating합니다.

23.1.3.17 Array.prototype.indexOf ( searchElement [ , fromIndex ] )

이 method는 IsStrictlyEqual algorithm을 사용하여 searchElement를 array의 elements와 ascending order로 compare하고, one or more indices에서 found되면 smallest such index를 반환합니다; otherwise, -1𝔽를 반환합니다.

Note 1

optional second argument fromIndex의 default는 +0𝔽입니다(즉, whole array가 searched됩니다). 그것이 array의 length보다 크거나 같으면, -1𝔽가 returned됩니다, 즉 array는 searched되지 않습니다. 그것이 -0𝔽보다 작으면, array의 end로부터 offset을 compute하는 데 사용됩니다. computed index가 +0𝔽보다 작거나 같으면, whole array가 searched됩니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. length = 0이면, -1𝔽를 반환한다.
  4. startIndex를 ? ToIntegerOrInfinity(fromIndex)로 둔다.
  5. Assert: fromIndexundefined이면, startIndex는 0이다.
  6. startIndex = +∞이면, -1𝔽를 반환한다.
  7. startIndex = -∞이면, startIndex를 0으로 설정한다.
  8. startIndex ≥ 0이면, 다음을 수행한다.
    1. kstartIndex로 둔다.
  9. Else,
    1. klength + startIndex로 둔다.
    2. k < 0이면, k를 0으로 설정한다.
  10. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. elementK를 ? Get(obj, propertyKey)로 둔다.
      2. IsStrictlyEqual(searchElement, elementK)가 true이면, 𝔽(k)를 반환한다.
    4. kk + 1로 설정한다.
  11. -1𝔽를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.18 Array.prototype.join ( separator )

이 method는 array의 elements를 Strings로 convert한 뒤, separator의 occurrences로 separated하여 these Strings를 concatenates합니다. separator가 provided되지 않으면, single comma가 separator로 사용됩니다.

called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. separatorundefined이면, sep","로 둔다.
  4. Else, sep를 ? ToString(separator)로 둔다.
  5. result를 empty String으로 둔다.
  6. k를 0으로 둔다.
  7. Repeat, while k < length,
    1. k > 0이면, resultresultsepstring-concatenation으로 설정한다.
    2. element를 ? Get(obj, ! ToString(𝔽(k)))로 둔다.
    3. elementundefinednull도 아니면, 다음을 수행한다.
      1. elementString을 ? ToString(element)로 둔다.
      2. resultresultelementStringstring-concatenation으로 설정한다.
    4. kk + 1로 설정한다.
  8. result를 반환한다.
Note

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.19 Array.prototype.keys ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. CreateArrayIterator(obj, key)를 반환한다.

23.1.3.20 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )

Note 1

이 method는 IsStrictlyEqual algorithm을 사용하여 searchElement를 array의 elements와 descending order로 compare하고, one or more indices에서 found되면 largest such index를 반환합니다; otherwise, -1𝔽를 반환합니다.

optional second argument fromIndex의 default는 array의 length minus one입니다(즉, whole array가 searched됩니다). 그것이 array의 length보다 크거나 같으면, whole array가 searched됩니다. 그것이 -0𝔽보다 작으면, array의 end로부터 offset을 compute하는 데 사용됩니다. computed index가 -0𝔽보다 작으면, -1𝔽가 returned됩니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. length = 0이면, -1𝔽를 반환한다.
  4. fromIndex가 present이면 startIndex를 ? ToIntegerOrInfinity(fromIndex)로 둔다; else startIndexlength - 1로 둔다.
  5. startIndex = -∞이면, -1𝔽를 반환한다.
  6. startIndex ≥ 0이면, 다음을 수행한다.
    1. kmin(startIndex, length - 1)로 둔다.
  7. Else,
    1. klength + startIndex로 둔다.
  8. Repeat, while k ≥ 0,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. elementK를 ? Get(obj, propertyKey)로 둔다.
      2. IsStrictlyEqual(searchElement, elementK)가 true이면, 𝔽(k)를 반환한다.
    4. kk - 1로 설정한다.
  9. -1𝔽를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.21 Array.prototype.map ( callback [ , thisArg ] )

Note 1

callback은 three arguments를 accept하는 function이어야 합니다. map은 array의 each element에 대해 ascending order로 callback을 once call하고, results로부터 new Array를 constructs합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.

thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.

callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.

map은 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.

map에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. map call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 map이 them을 visit하는 time의 value입니다; map call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  4. array를 ? ArraySpeciesCreate(obj, length)로 둔다.
  5. k를 0으로 둔다.
  6. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. mappedValue를 ? Call(callback, thisArg, « kValue, 𝔽(k), obj »)로 둔다.
      3. CreateDataPropertyOrThrow(array, propertyKey, mappedValue)를 수행한다.
    4. kk + 1로 설정한다.
  7. array를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.22 Array.prototype.pop ( )

Note 1

이 method는 array의 last element를 removes하고 그것을 반환합니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. length = 0이면, 다음을 수행한다.
    1. Set(obj, "length", +0𝔽, true)를 수행한다.
    2. undefined를 반환한다.
  4. Assert: length > 0이다.
  5. newLength𝔽(length - 1)로 둔다.
  6. index를 ! ToString(newLength)로 둔다.
  7. element를 ? Get(obj, index)로 둔다.
  8. DeletePropertyOrThrow(obj, index)를 수행한다.
  9. Set(obj, "length", newLength, true)를 수행한다.
  10. element를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.23 Array.prototype.push ( ...items )

Note 1

이 method는 arguments를 그들이 appear하는 order로 array의 end에 appends합니다. 이는 array의 new length를 반환합니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. argCountitems 안의 elements 수로 둔다.
  4. length + argCount > 253 - 1이면, TypeError exception을 throw한다.
  5. items의 각 element item에 대해, 다음을 수행한다.
    1. Set(obj, ! ToString(𝔽(length)), item, true)를 수행한다.
    2. lengthlength + 1로 설정한다.
  6. Set(obj, "length", 𝔽(length), true)를 수행한다.
  7. 𝔽(length)를 반환한다.

이 method의 "length" property는 1𝔽입니다.

Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.24 Array.prototype.reduce ( callback [ , initialValue ] )

Note 1

callback은 four arguments를 take하는 function이어야 합니다. reduceinitialValue가 provided되지 않는 한 first element를 skipping하면서, array에 present한 each element에 대해 ascending order로 callback을 once call합니다.

callback은 four arguments와 함께 called됩니다: previousValue(callback에 대한 previous call로부터의 value), currentValue(current element의 value), currentIndex, 그리고 traversed되는 object입니다. callback이 처음 called될 때, previousValuecurrentValue는 two values 중 하나일 수 있습니다. reduce call에 initialValue가 supplied되었으면, previousValueinitialValue가 되고 currentValue는 array의 first value가 됩니다. initialValue가 supplied되지 않았으면, previousValue는 array의 first value가 되고 currentValue는 second가 됩니다. array가 no elements를 contain하고 initialValue가 provided되지 않으면 TypeError입니다.

reduce는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.

reduce에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. reduce call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 reduce가 them을 visit하는 time의 value입니다; reduce call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  4. length = 0이고 initialValue가 present하지 않으면, TypeError exception을 throw한다.
  5. k를 0으로 둔다.
  6. accumulatorundefined로 둔다.
  7. initialValue가 present이면, 다음을 수행한다.
    1. accumulatorinitialValue로 설정한다.
  8. Else,
    1. kPresentfalse로 둔다.
    2. Repeat, while kPresent is false and k < length,
      1. propertyKey를 ! ToString(𝔽(k))로 둔다.
      2. kPresent를 ? HasProperty(obj, propertyKey)로 설정한다.
      3. kPresenttrue이면, 다음을 수행한다.
        1. accumulator를 ? Get(obj, propertyKey)로 설정한다.
      4. kk + 1로 설정한다.
    3. kPresentfalse이면, TypeError exception을 throw한다.
  9. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. accumulator를 ? Call(callback, undefined, « accumulator, kValue, 𝔽(k), obj »)로 설정한다.
    4. kk + 1로 설정한다.
  10. accumulator를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.25 Array.prototype.reduceRight ( callback [ , initialValue ] )

Note 1

callback은 four arguments를 take하는 function이어야 합니다. reduceRightinitialValue가 provided되지 않는 한 first call을 skipping하면서, array에 present한 each element에 대해 descending order로 callback을 once call합니다.

callback은 four arguments와 함께 called됩니다: previousValue(callback에 대한 previous call로부터의 value), currentValue(current element의 value), currentIndex, 그리고 traversed되는 object입니다. function이 처음 called될 때, previousValuecurrentValue는 two values 중 하나일 수 있습니다. reduceRight call에 initialValue가 supplied되었으면, previousValueinitialValue가 되고 currentValue는 array의 last value가 됩니다. initialValue가 supplied되지 않았으면, previousValue는 array의 last value가 되고 currentValue는 second-to-last value가 됩니다. array가 no elements를 contain하고 initialValue가 provided되지 않으면 TypeError입니다.

reduceRight는 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.

reduceRight에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. reduceRight call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 callback에 의해 changed되면, callback에 passed되는 그 value는 reduceRight가 them을 visit하는 time의 value입니다; reduceRight call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  4. length = 0이고 initialValue가 present하지 않으면, TypeError exception을 throw한다.
  5. klength - 1로 둔다.
  6. accumulatorundefined로 둔다.
  7. initialValue가 present이면, 다음을 수행한다.
    1. accumulatorinitialValue로 설정한다.
  8. Else,
    1. kPresentfalse로 둔다.
    2. Repeat, while kPresent is false and k ≥ 0,
      1. propertyKey를 ! ToString(𝔽(k))로 둔다.
      2. kPresent를 ? HasProperty(obj, propertyKey)로 설정한다.
      3. kPresenttrue이면, 다음을 수행한다.
        1. accumulator를 ? Get(obj, propertyKey)로 설정한다.
      4. kk - 1로 설정한다.
    3. kPresentfalse이면, TypeError exception을 throw한다.
  9. Repeat, while k ≥ 0,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. accumulator를 ? Call(callback, undefined, « accumulator, kValue, 𝔽(k), obj »)로 설정한다.
    4. kk - 1로 설정한다.
  10. accumulator를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.26 Array.prototype.reverse ( )

Note 1

이 method는 array의 elements를 rearrange하여 their order를 reverse합니다. 이는 reversed array를 반환합니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. middlefloor(length / 2)로 둔다.
  4. lower를 0으로 둔다.
  5. Repeat, while lowermiddle,
    1. upperlength - lower - 1로 둔다.
    2. upperP를 ! ToString(𝔽(upper))로 둔다.
    3. lowerP를 ! ToString(𝔽(lower))로 둔다.
    4. lowerExists를 ? HasProperty(obj, lowerP)로 둔다.
    5. lowerExiststrue이면, 다음을 수행한다.
      1. lowerValue를 ? Get(obj, lowerP)로 둔다.
    6. upperExists를 ? HasProperty(obj, upperP)로 둔다.
    7. upperExiststrue이면, 다음을 수행한다.
      1. upperValue를 ? Get(obj, upperP)로 둔다.
    8. lowerExiststrue이고 upperExiststrue이면, 다음을 수행한다.
      1. Set(obj, lowerP, upperValue, true)를 수행한다.
      2. Set(obj, upperP, lowerValue, true)를 수행한다.
    9. Else if lowerExistsfalse이고 upperExiststrue이면, 다음을 수행한다.
      1. Set(obj, lowerP, upperValue, true)를 수행한다.
      2. DeletePropertyOrThrow(obj, upperP)를 수행한다.
    10. Else if lowerExiststrue이고 upperExistsfalse이면, 다음을 수행한다.
      1. DeletePropertyOrThrow(obj, lowerP)를 수행한다.
      2. Set(obj, upperP, lowerValue, true)를 수행한다.
    11. Else,
      1. Assert: lowerExistsupperExists는 모두 false이다.
      2. NOTE: action은 required되지 않는다.
    12. lowerlower + 1로 설정한다.
  6. obj를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.27 Array.prototype.shift ( )

이 method는 array의 first element를 removes하고 그것을 반환합니다.

called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. length = 0이면, 다음을 수행한다.
    1. Set(obj, "length", +0𝔽, true)를 수행한다.
    2. undefined를 반환한다.
  4. first를 ? Get(obj, "0")로 둔다.
  5. k를 1로 둔다.
  6. Repeat, while k < length,
    1. from을 ! ToString(𝔽(k))로 둔다.
    2. to를 ! ToString(𝔽(k - 1))로 둔다.
    3. fromPresent를 ? HasProperty(obj, from)로 둔다.
    4. fromPresenttrue이면, 다음을 수행한다.
      1. fromValue를 ? Get(obj, from)로 둔다.
      2. Set(obj, to, fromValue, true)를 수행한다.
    5. Else,
      1. Assert: fromPresentfalse이다.
      2. DeletePropertyOrThrow(obj, to)를 수행한다.
    6. kk + 1로 설정한다.
  7. DeletePropertyOrThrow(obj, ! ToString(𝔽(length - 1)))를 수행한다.
  8. Set(obj, "length", 𝔽(length - 1), true)를 수행한다.
  9. first를 반환한다.
Note

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.28 Array.prototype.slice ( start, end )

이 method는 element start부터 element end 전까지(or endundefined이면 array의 end까지) array의 elements를 contain하는 array를 반환합니다. start가 negative이면, array의 length인 length에 대해 length + start로 treated됩니다. end가 negative이면, array의 length인 length에 대해 length + end로 treated됩니다.

called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  4. relativeStart = -∞이면, k를 0으로 둔다.
  5. Else if relativeStart < 0이면, kmax(length + relativeStart, 0)으로 둔다.
  6. Else, kmin(relativeStart, length)로 둔다.
  7. endundefined이면 relativeEndlength로 둔다; else relativeEnd를 ? ToIntegerOrInfinity(end)로 둔다.
  8. relativeEnd = -∞이면, final을 0으로 둔다.
  9. Else if relativeEnd < 0이면, finalmax(length + relativeEnd, 0)으로 둔다.
  10. Else, finalmin(relativeEnd, length)로 둔다.
  11. countmax(final - k, 0)으로 둔다.
  12. array를 ? ArraySpeciesCreate(obj, count)로 둔다.
  13. resultIndex를 0으로 둔다.
  14. Repeat, while k < final,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. CreateDataPropertyOrThrow(array, ! ToString(𝔽(resultIndex)), kValue)를 수행한다.
    4. kk + 1로 설정한다.
    5. resultIndexresultIndex + 1로 설정한다.
  15. Set(array, "length", 𝔽(resultIndex), true)를 수행한다.
  16. array를 반환한다.
Note 1

step 15에서 "length" property를 explicitly setting하는 것은 array가 built-in Array가 아닌 경우에도 length가 correct함을 ensure하기 위한 것입니다.

Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.29 Array.prototype.some ( callback [ , thisArg ] )

Note 1

callback은 three arguments를 accept하고 Boolean value로 coercible한 value를 return하는 function이어야 합니다. somecallbacktrue를 return하는 one을 find할 때까지 array에 present한 each element에 대해 ascending order로 callback을 once call합니다. such element가 found되면, some은 immediately true를 반환합니다. Otherwise, somefalse를 반환합니다. callback은 actually exist하는 array의 elements에 대해서만 called됩니다; array의 missing elements에 대해서는 called되지 않습니다.

thisArg parameter가 provided되면, callback의 each invocation에 대한 this value로 사용됩니다. provided되지 않으면, 대신 undefined가 사용됩니다.

callback은 three arguments와 함께 called됩니다: element의 value, element의 index, 그리고 traversed되는 object입니다.

some은 called된 object를 directly mutate하지 않지만, object는 callback calls에 의해 mutated될 수 있습니다.

some에 의해 processed되는 elements의 range는 callback에 대한 first call 전에 set됩니다. some call이 begin된 뒤 array에 appended되는 elements는 callback에 의해 visited되지 않습니다. array의 existing elements가 changed되면, callback에 passed되는 그 value는 some이 them을 visit하는 time의 value입니다; some call이 begin된 뒤 그리고 visited되기 전에 deleted되는 elements는 visited되지 않습니다. some은 mathematics의 “exists” quantifier처럼 acts합니다. 특히 empty array에 대해서는 false를 반환합니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  4. k를 0으로 둔다.
  5. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. testResultToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), obj »))로 둔다.
      3. testResulttrue이면, true를 반환한다.
    4. kk + 1로 설정한다.
  6. false를 반환한다.
Note 2

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.30 Array.prototype.sort ( comparator )

이 method는 this array의 elements를 sorts합니다. comparatorundefined가 아니면, arguments xy two를 accept하고 x < y이면 negative Number, x > y이면 positive Number, otherwise zero를 return하는 function이어야 합니다.

called될 때 다음 steps를 수행합니다:

  1. comparatorundefined가 아니고 IsCallable(comparator)가 false이면, TypeError exception을 throw한다.
  2. obj를 ? ToObject(this value)로 둔다.
  3. length를 ? LengthOfArrayLike(obj)로 둔다.
  4. comparator를 capture하고 called될 때 다음 steps를 수행하는, parameters (x, y)를 가진 새 Abstract Closure sortCompare를 둔다:
    1. CompareArrayElements(x, y, comparator)를 반환한다.
  5. sortedList를 ? SortIndexedProperties(obj, length, sortCompare, skip-holes)로 둔다.
  6. itemCountsortedList 안의 elements 수로 둔다.
  7. j를 0으로 둔다.
  8. Repeat, while j < itemCount,
    1. Set(obj, ! ToString(𝔽(j)), sortedList[j], true)를 수행한다.
    2. jj + 1로 설정한다.
  9. NOTE: step 5SortIndexedProperties call은 skip-holes를 사용한다. remaining indices는 detected되어 sort에서 excluded된 holes 수를 preserve하기 위해 deleted된다.
  10. Repeat, while j < length,
    1. DeletePropertyOrThrow(obj, ! ToString(𝔽(j)))를 수행한다.
    2. jj + 1로 설정한다.
  11. obj를 반환한다.
Note 1

non-existent property values는 always undefined property values보다 greater로 compare되고, undefined는 always any other value보다 greater로 compare되므로(CompareArrayElements 참조), undefined property values는 always result의 end로 sort되고, 그 뒤에 non-existent property values가 followed됩니다.

Note 2

steps 56ToString abstract operations에 의해 performed되는 method calls는 sortCompareconsistent comparator로 behave하지 않게 할 potential을 가집니다.

Note 3

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.30.1 SortIndexedProperties ( obj, length, sortCompare, holes )

The abstract operation SortIndexedProperties takes arguments obj (an Object), length (a non-negative integer), sortCompare (an Abstract Closure with two parameters), and holes (skip-holes or read-through-holes) 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. items를 새 empty List로 둔다.
  2. k를 0으로 둔다.
  3. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. holesskip-holes이면, 다음을 수행한다.
      1. kRead를 ? HasProperty(obj, propertyKey)로 둔다.
    3. Else,
      1. Assert: holesread-through-holes이다.
      2. kReadtrue로 둔다.
    4. kReadtrue이면, 다음을 수행한다.
      1. kValue를 ? Get(obj, propertyKey)로 둔다.
      2. kValueitems에 append한다.
    5. kk + 1로 설정한다.
  4. implementation-defined sequence of calls to sortCompare를 사용하여 items를 Sort한다. such call이 abrupt completion을 return하면, sortCompare에 대한 any further calls를 수행하기 전에 stop하고 that Completion Record를 반환한다.
  5. items를 반환한다.

sort order는 위 algorithm의 step 4 completion 후 items의 ordering입니다. sortCompareitems의 elements에 대한 consistent comparator가 아니면 sort orderimplementation-defined입니다. SortIndexedProperties가 Array.prototype.sort 또는 Array.prototype.toSorted에 의해 invoked될 때, comparatorundefined이고 sortCompare에 argument로 passed되는 any specific value에 대한 ToString의 all applications가 same result를 produce하지 않으면 sort orderimplementation-defined입니다.

sort orderimplementation-defined로 specified되지 않는 한, 다음 conditions를 모두 satisfy해야 합니다:

  • itemCount보다 작은 non-negative integers의 어떤 mathematical permutation π가 존재하여, itemCount보다 작은 every non-negative integer j에 대해 element old[j]가 exactly new[π(j)]와 same해야 합니다.
  • 그런 다음 itemCount보다 작은 all non-negative integers jk에 대해, (sortCompare(old[j], old[k])) < 0이면, π(j) < π(k)입니다.
  • 그리고 j < k < itemCount인 all non-negative integers jk에 대해, (sortCompare(old[j], old[k])) = 0이면, π(j) < π(k)입니다; 즉, sort는 stable입니다.

여기서 notation old[j]는 step 4가 executed되기 전의 items[j]를 refer하는 데 사용되고, notation new[j]는 step 4가 executed된 후의 items[j]를 refer하는 데 사용됩니다.

Abstract Closure 또는 function comparator는 set values 안의 all values a, b, 및 c(possibly same value)에 대해 below requirements가 모두 met되면 values values의 set에 대한 consistent comparator입니다: notation a <C b(comparator(a, b)) < 0를 의미합니다; a =C b(comparator(a, b)) = 0를 의미합니다; 그리고 a >C b(comparator(a, b)) > 0를 의미합니다.

  • specific pair of values ab가 two arguments로 given될 때 comparator(a, b)를 calling하면 always same value v를 return합니다. Furthermore, v는 Number이고, vNaN이 아닙니다. 이는 given pair of a and b에 대해 a <C b, a =C b, 및 a >C b 중 exactly one이 true일 것을 imply함에 note하십시오.
  • comparator(a, b)를 calling해도 obj 또는 obj의 prototype chain에 있는 any object를 modify하지 않습니다.
  • a =C a (reflexivity)
  • a =C b이면, b =C a입니다 (symmetry)
  • a =C b이고 b =C c이면, a =C c입니다 (transitivity of =C)
  • a <C b이고 b <C c이면, a <C c입니다 (transitivity of <C)
  • a >C b이고 b >C c이면, a >C c입니다 (transitivity of >C)
Note

위 conditions는 comparator가 set values를 equivalence classes로 divide하고, 이러한 equivalence classes가 totally ordered되도록 ensure하는 데 necessary and sufficient합니다.

23.1.3.30.2 CompareArrayElements ( x, y, comparator )

The abstract operation CompareArrayElements takes arguments x (an ECMAScript language value), y (an ECMAScript language value), and comparator (a function object or undefined) and returns either a normal completion containing a Number or an abrupt completion. It performs the following steps when called:

  1. xundefined이고 yundefined이면, +0𝔽를 반환한다.
  2. xundefined이면, 1𝔽를 반환한다.
  3. yundefined이면, -1𝔽를 반환한다.
  4. comparatorundefined가 아니면, 다음을 수행한다.
    1. result를 ? ToNumber(? Call(comparator, undefined, « x, y »))로 둔다.
    2. resultNaN이면, +0𝔽를 반환한다.
    3. result를 반환한다.
  5. xString을 ? ToString(x)로 둔다.
  6. yString을 ? ToString(y)로 둔다.
  7. xSmaller를 ! IsLessThan(xString, yString, true)로 둔다.
  8. xSmallertrue이면, -1𝔽를 반환한다.
  9. ySmaller를 ! IsLessThan(yString, xString, true)로 둔다.
  10. ySmallertrue이면, 1𝔽를 반환한다.
  11. +0𝔽를 반환한다.

23.1.3.31 Array.prototype.splice ( start, deleteCount, ...items )

Note 1

이 method는 integer index start에서 starting하는 array의 deleteCount elements를 deletes하고, them을 items의 elements로 replaces합니다. 이는 deleted elements(if any)를 contain하는 Array를 반환합니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  4. relativeStart = -∞이면, actualStart를 0으로 둔다.
  5. Else if relativeStart < 0이면, actualStartmax(length + relativeStart, 0)으로 둔다.
  6. Else, actualStartmin(relativeStart, length)로 둔다.
  7. itemCountitems 안의 elements 수로 둔다.
  8. start가 present하지 않으면, 다음을 수행한다.
    1. actualDeleteCount를 0으로 둔다.
  9. Else if deleteCount가 present하지 않으면, 다음을 수행한다.
    1. actualDeleteCountlength - actualStart로 둔다.
  10. Else,
    1. dc를 ? ToIntegerOrInfinity(deleteCount)로 둔다.
    2. actualDeleteCountdc를 0과 length - actualStart 사이로 clamping한 result로 둔다.
  11. length + itemCount - actualDeleteCount > 253 - 1이면, TypeError exception을 throw한다.
  12. deletedArray를 ? ArraySpeciesCreate(obj, actualDeleteCount)로 둔다.
  13. k를 0으로 둔다.
  14. Repeat, while k < actualDeleteCount,
    1. from을 ! ToString(𝔽(actualStart + k))로 둔다.
    2. HasProperty(obj, from)가 true이면, 다음을 수행한다.
      1. fromValue를 ? Get(obj, from)로 둔다.
      2. CreateDataPropertyOrThrow(deletedArray, ! ToString(𝔽(k)), fromValue)를 수행한다.
    3. kk + 1로 설정한다.
  15. Set(deletedArray, "length", 𝔽(actualDeleteCount), true)를 수행한다.
  16. itemCount < actualDeleteCount이면, 다음을 수행한다.
    1. kactualStart로 설정한다.
    2. Repeat, while k < (length - actualDeleteCount),
      1. from을 ! ToString(𝔽(k + actualDeleteCount))로 둔다.
      2. to를 ! ToString(𝔽(k + itemCount))로 둔다.
      3. HasProperty(obj, from)가 true이면, 다음을 수행한다.
        1. fromValue를 ? Get(obj, from)로 둔다.
        2. Set(obj, to, fromValue, true)를 수행한다.
      4. Else,
        1. DeletePropertyOrThrow(obj, to)를 수행한다.
      5. kk + 1로 설정한다.
    3. klength로 설정한다.
    4. Repeat, while k > (length - actualDeleteCount + itemCount),
      1. DeletePropertyOrThrow(obj, ! ToString(𝔽(k - 1)))를 수행한다.
      2. kk - 1로 설정한다.
  17. Else if itemCount > actualDeleteCount이면, 다음을 수행한다.
    1. k를 (length - actualDeleteCount)로 설정한다.
    2. Repeat, while k > actualStart,
      1. from을 ! ToString(𝔽(k + actualDeleteCount - 1))로 둔다.
      2. to를 ! ToString(𝔽(k + itemCount - 1))로 둔다.
      3. HasProperty(obj, from)가 true이면, 다음을 수행한다.
        1. fromValue를 ? Get(obj, from)로 둔다.
        2. Set(obj, to, fromValue, true)를 수행한다.
      4. Else,
        1. DeletePropertyOrThrow(obj, to)를 수행한다.
      5. kk - 1로 설정한다.
  18. kactualStart로 설정한다.
  19. items의 각 element item에 대해, 다음을 수행한다.
    1. Set(obj, ! ToString(𝔽(k)), item, true)를 수행한다.
    2. kk + 1로 설정한다.
  20. Set(obj, "length", 𝔽(length - actualDeleteCount + itemCount), true)를 수행한다.
  21. deletedArray를 반환한다.
Note 2

steps 1520에서 "length" property를 explicitly setting하는 것은 objects가 built-in Arrays가 아닌 경우에도 lengths가 correct함을 ensure하기 위한 것입니다.

Note 3

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.32 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )

ECMA-402 Internationalization API를 include하는 ECMAScript implementation은 ECMA-402 specification에 specified된 대로 이 method를 implement해야 합니다. ECMAScript implementation이 ECMA-402 API를 include하지 않으면 이 method의 다음 specification이 사용됩니다.

Note 1

ECMA-402의 first edition은 이 method에 대한 replacement specification을 include하지 않았습니다.

이 method의 optional parameters의 meanings는 ECMA-402 specification에 defined되어 있습니다; ECMA-402 support를 include하지 않는 implementations는 those parameter positions를 anything else에 사용해서는 안 됩니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. array를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(array)로 둔다.
  3. separatorhost environment의 current locale에 appropriate한 implementation-defined list-separator String value(such as ", ")로 둔다.
  4. result를 empty String으로 둔다.
  5. k를 0으로 둔다.
  6. Repeat, while k < length,
    1. k > 0이면, resultresultseparatorstring-concatenation으로 설정한다.
    2. element를 ? Get(array, ! ToString(𝔽(k)))로 둔다.
    3. elementundefinednull도 아니면, 다음을 수행한다.
      1. elementString을 ? ToString(? Invoke(element, "toLocaleString"))로 둔다.
      2. resultresultelementStringstring-concatenation으로 설정한다.
    4. kk + 1로 설정한다.
  7. result를 반환한다.
Note 2

이 method는 array의 elements를 their toLocaleString methods를 사용하여 Strings로 convert한 뒤, implementation-defined locale-sensitive separator String의 occurrences로 separated하여 these Strings를 concatenates합니다. 이 method는 host environment의 current locale의 conventions와 corresponding하는 locale-sensitive result를 yield하도록 intended된다는 점을 제외하면 toString과 analogous합니다.

Note 3

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.33 Array.prototype.toReversed ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. array를 ? ArrayCreate(length)로 둔다.
  4. k를 0으로 둔다.
  5. Repeat, while k < length,
    1. from을 ! ToString(𝔽(length - k - 1))로 둔다.
    2. propertyKey를 ! ToString(𝔽(k))로 둔다.
    3. fromValue를 ? Get(obj, from)로 둔다.
    4. CreateDataPropertyOrThrow(array, propertyKey, fromValue)를 수행한다.
    5. kk + 1로 설정한다.
  6. array를 반환한다.

23.1.3.34 Array.prototype.toSorted ( comparator )

이 method는 called될 때 다음 steps를 수행합니다:

  1. comparatorundefined가 아니고 IsCallable(comparator)가 false이면, TypeError exception을 throw한다.
  2. obj를 ? ToObject(this value)로 둔다.
  3. length를 ? LengthOfArrayLike(obj)로 둔다.
  4. array를 ? ArrayCreate(length)로 둔다.
  5. comparator를 capture하고 called될 때 다음 steps를 수행하는, parameters (x, y)를 가진 새 Abstract Closure sortCompare를 둔다:
    1. CompareArrayElements(x, y, comparator)를 반환한다.
  6. sortedList를 ? SortIndexedProperties(obj, length, sortCompare, read-through-holes)로 둔다.
  7. j를 0으로 둔다.
  8. Repeat, while j < length,
    1. CreateDataPropertyOrThrow(array, ! ToString(𝔽(j)), sortedList[j])를 수행한다.
    2. jj + 1로 설정한다.
  9. array를 반환한다.

23.1.3.35 Array.prototype.toSpliced ( start, skipCount, ...items )

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  4. relativeStart = -∞이면, actualStart를 0으로 둔다.
  5. Else if relativeStart < 0이면, actualStartmax(length + relativeStart, 0)으로 둔다.
  6. Else, actualStartmin(relativeStart, length)로 둔다.
  7. insertCountitems 안의 elements 수로 둔다.
  8. start가 present하지 않으면, 다음을 수행한다.
    1. actualSkipCount를 0으로 둔다.
  9. Else if skipCount가 present하지 않으면, 다음을 수행한다.
    1. actualSkipCountlength - actualStart로 둔다.
  10. Else,
    1. sc를 ? ToIntegerOrInfinity(skipCount)로 둔다.
    2. actualSkipCountsc를 0과 length - actualStart 사이로 clamping한 result로 둔다.
  11. newLengthlength + insertCount - actualSkipCount로 둔다.
  12. newLength > 253 - 1이면, TypeError exception을 throw한다.
  13. newArray를 ? ArrayCreate(newLength)로 둔다.
  14. writeIndex를 0으로 둔다.
  15. readIndexactualStart + actualSkipCount로 둔다.
  16. Repeat, while writeIndex < actualStart,
    1. propertyKey를 ! ToString(𝔽(writeIndex))로 둔다.
    2. iValue를 ? Get(obj, propertyKey)로 둔다.
    3. CreateDataPropertyOrThrow(newArray, propertyKey, iValue)를 수행한다.
    4. writeIndexwriteIndex + 1로 설정한다.
  17. items의 각 element item에 대해, 다음을 수행한다.
    1. propertyKey를 ! ToString(𝔽(writeIndex))로 둔다.
    2. CreateDataPropertyOrThrow(newArray, propertyKey, item)를 수행한다.
    3. writeIndexwriteIndex + 1로 설정한다.
  18. Repeat, while writeIndex < newLength,
    1. propertyKey를 ! ToString(𝔽(writeIndex))로 둔다.
    2. from을 ! ToString(𝔽(readIndex))로 둔다.
    3. fromValue를 ? Get(obj, from)로 둔다.
    4. CreateDataPropertyOrThrow(newArray, propertyKey, fromValue)를 수행한다.
    5. writeIndexwriteIndex + 1로 설정한다.
    6. readIndexreadIndex + 1로 설정한다.
  19. newArray를 반환한다.

23.1.3.36 Array.prototype.toString ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. array를 ? ToObject(this value)로 둔다.
  2. func를 ? Get(array, "join")로 둔다.
  3. IsCallable(func)가 false이면, func를 intrinsic function %Object.prototype.toString%으로 설정한다.
  4. Call(func, array)를 반환한다.
Note

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.37 Array.prototype.unshift ( ...items )

이 method는 arguments를 array의 start에 prepends하여, array 안에서 their order가 argument list에 appear하는 order와 same이 되도록 합니다.

called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. argCountitems 안의 elements 수로 둔다.
  4. argCount > 0이면, 다음을 수행한다.
    1. length + argCount > 253 - 1이면, TypeError exception을 throw한다.
    2. klength로 둔다.
    3. Repeat, while k > 0,
      1. from을 ! ToString(𝔽(k - 1))로 둔다.
      2. to를 ! ToString(𝔽(k + argCount - 1))로 둔다.
      3. fromPresent를 ? HasProperty(obj, from)로 둔다.
      4. fromPresenttrue이면, 다음을 수행한다.
        1. fromValue를 ? Get(obj, from)로 둔다.
        2. Set(obj, to, fromValue, true)를 수행한다.
      5. Else,
        1. Assert: fromPresentfalse이다.
        2. DeletePropertyOrThrow(obj, to)를 수행한다.
      6. kk - 1로 설정한다.
    4. j+0𝔽로 둔다.
    5. items의 각 element item에 대해, 다음을 수행한다.
      1. Set(obj, ! ToString(j), item, true)를 수행한다.
      2. jj + 1𝔽로 설정한다.
  5. Set(obj, "length", 𝔽(length + argCount), true)를 수행한다.
  6. 𝔽(length + argCount)를 반환한다.

이 method의 "length" property는 1𝔽입니다.

Note

이 method는 intentionally generic입니다; its this value가 Array일 것을 require하지 않습니다. 따라서 method로 사용하기 위해 other kinds of objects에 transferred될 수 있습니다.

23.1.3.38 Array.prototype.values ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. CreateArrayIterator(obj, value)를 반환한다.

23.1.3.39 Array.prototype.with ( index, value )

이 method는 called될 때 다음 steps를 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(obj)로 둔다.
  3. relativeIndex를 ? ToIntegerOrInfinity(index)로 둔다.
  4. relativeIndex ≥ 0이면 actualIndexrelativeIndex로 둔다.
  5. Else, actualIndexlength + relativeIndex로 둔다.
  6. actualIndexlength 또는 actualIndex < 0이면, RangeError exception을 throw한다.
  7. array를 ? ArrayCreate(length)로 둔다.
  8. k를 0으로 둔다.
  9. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. k = actualIndex이면 fromValuevalue로 둔다.
    3. Else, fromValue를 ? Get(obj, propertyKey)로 둔다.
    4. CreateDataPropertyOrThrow(array, propertyKey, fromValue)를 수행한다.
    5. kk + 1로 설정한다.
  10. array를 반환한다.

23.1.3.40 Array.prototype [ %Symbol.iterator% ] ( )

%Symbol.iterator% property의 initial value는 23.1.3.38에 defined된 %Array.prototype.values%입니다.

23.1.3.41 Array.prototype [ %Symbol.unscopables% ]

%Symbol.unscopables% data property의 initial value는 다음 steps로 created된 object입니다:

  1. unscopableListOrdinaryObjectCreate(null)로 둔다.
  2. CreateDataPropertyOrThrow(unscopableList, "at", true)를 수행한다.
  3. CreateDataPropertyOrThrow(unscopableList, "copyWithin", true)를 수행한다.
  4. CreateDataPropertyOrThrow(unscopableList, "entries", true)를 수행한다.
  5. CreateDataPropertyOrThrow(unscopableList, "fill", true)를 수행한다.
  6. CreateDataPropertyOrThrow(unscopableList, "find", true)를 수행한다.
  7. CreateDataPropertyOrThrow(unscopableList, "findIndex", true)를 수행한다.
  8. CreateDataPropertyOrThrow(unscopableList, "findLast", true)를 수행한다.
  9. CreateDataPropertyOrThrow(unscopableList, "findLastIndex", true)를 수행한다.
  10. CreateDataPropertyOrThrow(unscopableList, "flat", true)를 수행한다.
  11. CreateDataPropertyOrThrow(unscopableList, "flatMap", true)를 수행한다.
  12. CreateDataPropertyOrThrow(unscopableList, "includes", true)를 수행한다.
  13. CreateDataPropertyOrThrow(unscopableList, "keys", true)를 수행한다.
  14. CreateDataPropertyOrThrow(unscopableList, "toReversed", true)를 수행한다.
  15. CreateDataPropertyOrThrow(unscopableList, "toSorted", true)를 수행한다.
  16. CreateDataPropertyOrThrow(unscopableList, "toSpliced", true)를 수행한다.
  17. CreateDataPropertyOrThrow(unscopableList, "values", true)를 수행한다.
  18. unscopableList를 반환한다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

Note

이 object의 own property names는 ECMAScript 2015 specification 이전에는 Array.prototype의 standard properties로 included되지 않았던 property names입니다. 이러한 names는 with statement binding purposes에서 ignored되어, outer scope의 binding으로 these names 중 하나를 사용하고, 그 binding이 binding object가 Array인 with statement에 의해 shadowed될 수 있는 existing code의 behaviour를 preserve합니다.

"with"unscopableList에 included되지 않는 reason은 그것이 이미 reserved word이기 때문입니다.

23.1.4 Properties of Array Instances

Array instances는 Array exotic objects이며 such objects에 대해 specified된 internal methods를 가집니다. Array instances는 Array prototype object로부터 properties를 inherit합니다.

Array instances는 "length" property와 array index names를 가진 enumerable properties의 set을 가집니다.

23.1.4.1 length

Array instance의 "length" property는 그 value가 name이 array index인 every configurable own property의 name보다 always numerically greater인 data property입니다.

"length" property는 initially attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

Note

"length" property의 value를 reducing하는 것은 array index가 old length value와 new length value 사이에 있는 own array elements를 deleting하는 side-effect를 가집니다. However, non-configurable properties는 deleted될 수 없습니다. Array의 "length" property를 array의 existing non-configurable array-indexed property의 largest numeric own property name보다 numerically less than or equal인 value로 set하려고 attempt하면, length는 that non-configurable numeric own property name보다 one greater인 numeric value로 set됩니다. 10.4.2.1를 참조하십시오.

23.1.5 Array Iterator Objects

Array Iterator는 some specific Array instance object에 대한 specific iteration을 represent하는 object입니다. Array Iterator objects를 위한 named constructor는 없습니다. 대신, Array Iterator objects는 Array instance objects의 certain methods를 calling하여 created됩니다.

23.1.5.1 CreateArrayIterator ( array, kind )

The abstract operation CreateArrayIterator takes arguments array (an Object) and kind (key+value, key, or value) and returns an Object. such iterators를 return하는 Array methods를 위한 iterator objects를 create하는 데 사용됩니다. It performs the following steps when called:

  1. iteratorOrdinaryObjectCreate(%ArrayIteratorPrototype%, « [[IteratedArrayLike]], [[ArrayLikeNextIndex]], [[ArrayLikeIterationKind]] »)로 둔다.
  2. iterator.[[IteratedArrayLike]]array로 설정한다.
  3. iterator.[[ArrayLikeNextIndex]]를 0으로 설정한다.
  4. iterator.[[ArrayLikeIterationKind]]kind로 설정한다.
  5. iterator를 반환한다.

23.1.5.2 The %ArrayIteratorPrototype% Object

%ArrayIteratorPrototype% object는:

23.1.5.2.1 %ArrayIteratorPrototype%.next ( )

  1. iteratorObjthis value로 둔다.
  2. iteratorObj가 Object가 아니면, TypeError exception을 throw한다.
  3. iteratorObjArray Iterator Instance의 all internal slots(23.1.5.3)를 가지지 않으면, TypeError exception을 throw한다.
  4. arrayiteratorObj.[[IteratedArrayLike]]로 둔다.
  5. arrayundefined이면, CreateIteratorResultObject(undefined, true)를 반환한다.
  6. indexiteratorObj.[[ArrayLikeNextIndex]]로 둔다.
  7. kinditeratorObj.[[ArrayLikeIterationKind]]로 둔다.
  8. array[[TypedArrayName]] internal slot을 가지면, 다음을 수행한다.
    1. taRecordMakeTypedArrayWithBufferWitnessRecord(array, seq-cst)로 둔다.
    2. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
    3. lengthTypedArrayLength(taRecord)로 둔다.
  9. Else,
    1. length를 ? LengthOfArrayLike(array)로 둔다.
  10. indexlength이면, 다음을 수행한다.
    1. iteratorObj.[[IteratedArrayLike]]undefined로 설정한다.
    2. CreateIteratorResultObject(undefined, true)를 반환한다.
  11. iteratorObj.[[ArrayLikeNextIndex]]index + 1로 설정한다.
  12. indexNumber𝔽(index)로 둔다.
  13. kindkey이면, 다음을 수행한다.
    1. resultindexNumber로 둔다.
  14. Else,
    1. elementKey를 ! ToString(indexNumber)로 둔다.
    2. elementValue를 ? Get(array, elementKey)로 둔다.
    3. kindvalue이면, 다음을 수행한다.
      1. resultelementValue로 둔다.
    4. Else,
      1. Assert: kindkey+value이다.
      2. resultCreateArrayFromListindexNumber, elementValue »)로 둔다.
  15. CreateIteratorResultObject(result, false)를 반환한다.

23.1.5.2.2 %ArrayIteratorPrototype% [ %Symbol.toStringTag% ]

%Symbol.toStringTag% property의 initial value는 String value "Array Iterator"입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

23.1.5.3 Properties of Array Iterator Instances

Array Iterator instances는 %ArrayIteratorPrototype% intrinsic object로부터 properties를 inherit하는 ordinary objects입니다. Array Iterator instances는 Table 70에 listed된 internal slots로 initially created됩니다.

Table 70: Internal Slots of Array Iterator Instances
Internal Slot Type Description
[[IteratedArrayLike]] an Object or undefined iterated되고 있는 array-like object입니다.
[[ArrayLikeNextIndex]] a non-negative integer iterator가 examine할 next element의 integer index입니다.
[[ArrayLikeIterationKind]] key+value, key, or value iteration의 each element에 대해 return되는 것이 무엇인지 identify하는 value입니다.

23.2 TypedArray Objects

TypedArray는 underlying binary data buffer(25.1)의 array-like view를 제공합니다. TypedArray element typeTypedArray instance의 all elements가 가지는 underlying binary scalar data type입니다. supported element types 각각에 대해 Table 71에 listed된 distinct TypedArray constructor가 있습니다. Table 71의 each constructor는 corresponding distinct prototype object를 가집니다.

Table 71: The TypedArray Constructors
Constructor Name and Intrinsic Element Type Element Size Conversion Operation Description
Int8Array
%Int8Array%
int8 1 ToInt8 8-bit two's complement signed integer
Uint8Array
%Uint8Array%
uint8 1 ToUint8 8-bit unsigned integer
Uint8ClampedArray
%Uint8ClampedArray%
uint8clamped 1 ToUint8Clamp 8-bit unsigned integer (clamped conversion)
Int16Array
%Int16Array%
int16 2 ToInt16 16-bit two's complement signed integer
Uint16Array
%Uint16Array%
uint16 2 ToUint16 16-bit unsigned integer
Int32Array
%Int32Array%
int32 4 ToInt32 32-bit two's complement signed integer
Uint32Array
%Uint32Array%
uint32 4 ToUint32 32-bit unsigned integer
BigInt64Array
%BigInt64Array%
bigint64 8 ToBigInt64 64-bit two's complement signed integer
BigUint64Array
%BigUint64Array%
biguint64 8 ToBigUint64 64-bit unsigned integer
Float16Array
%Float16Array%
float16 2 16-bit IEEE floating point
Float32Array
%Float32Array%
float32 4 32-bit IEEE floating point
Float64Array
%Float64Array%
float64 8 64-bit IEEE floating point

아래 definitions에서, TypedArray에 대한 references는 위 table의 appropriate constructor name으로 replaced되어야 합니다.

23.2.1 The %TypedArray% Intrinsic Object

%TypedArray% intrinsic object는:

  • all TypedArray constructor objects가 inherit하는 constructor function object입니다.
  • its corresponding prototype object와 함께, all TypedArray constructors 및 their instances가 inherit하는 common properties를 제공합니다.
  • global name을 가지지 않으며 global object의 property로 appear하지 않습니다.
  • various TypedArray constructors의 abstract superclass처럼 acts합니다.
  • abstract class constructor이므로 invoked될 때 error를 throw합니다. TypedArray constructors는 이에 대한 super call을 수행하지 않습니다.

23.2.1.1 %TypedArray% ( )

이 function은 called될 때 다음 steps를 수행합니다:

  1. TypeError exception을 throw한다.

이 function의 "length" property는 +0𝔽입니다.

23.2.2 Properties of the %TypedArray% Intrinsic Object

%TypedArray% intrinsic object는:

  • value가 %Function.prototype%[[Prototype]] internal slot을 가집니다.
  • value가 "TypedArray""name" property를 가집니다.
  • 다음 properties를 가집니다:

23.2.2.1 %TypedArray%.from ( source [ , mapper [ , thisArg ] ] )

이 method는 called될 때 다음 steps를 수행합니다:

  1. ctorthis value로 둔다.
  2. IsConstructor(ctor)가 false이면, TypeError exception을 throw한다.
  3. mapperundefined이면, 다음을 수행한다.
    1. mappingfalse로 둔다.
  4. Else,
    1. IsCallable(mapper)가 false이면, TypeError exception을 throw한다.
    2. mappingtrue로 둔다.
  5. usingIterator를 ? GetMethod(source, %Symbol.iterator%)로 둔다.
  6. usingIteratorundefined가 아니면, 다음을 수행한다.
    1. values를 ? IteratorToList(? GetIteratorFromMethod(source, usingIterator))로 둔다.
    2. lengthvalues 안의 elements 수로 둔다.
    3. targetObj를 ? TypedArrayCreateFromConstructor(ctor, « 𝔽(length) »)로 둔다.
    4. k를 0으로 둔다.
    5. Repeat, while k < length,
      1. propertyKey를 ! ToString(𝔽(k))로 둔다.
      2. kValuevalues의 first element로 둔다.
      3. values에서 first element를 remove한다.
      4. mappingtrue이면, 다음을 수행한다.
        1. mappedValue를 ? Call(mapper, thisArg, « kValue, 𝔽(k) »)로 둔다.
      5. Else,
        1. mappedValuekValue로 둔다.
      6. Set(targetObj, propertyKey, mappedValue, true)를 수행한다.
      7. kk + 1로 설정한다.
    6. Assert: values는 now empty List이다.
    7. targetObj를 반환한다.
  7. NOTE: sourceiterable object가 아니므로, already array-like object라고 assume한다.
  8. arrayLike를 ! ToObject(source)로 둔다.
  9. length를 ? LengthOfArrayLike(arrayLike)로 둔다.
  10. targetObj를 ? TypedArrayCreateFromConstructor(ctor, « 𝔽(length) »)로 둔다.
  11. k를 0으로 둔다.
  12. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ? Get(arrayLike, propertyKey)로 둔다.
    3. mappingtrue이면, 다음을 수행한다.
      1. mappedValue를 ? Call(mapper, thisArg, « kValue, 𝔽(k) »)로 둔다.
    4. Else,
      1. mappedValuekValue로 둔다.
    5. Set(targetObj, propertyKey, mappedValue, true)를 수행한다.
    6. kk + 1로 설정한다.
  13. targetObj를 반환한다.

23.2.2.2 %TypedArray%.of ( ...items )

이 method는 called될 때 다음 steps를 수행합니다:

  1. lengthitems 안의 elements 수로 둔다.
  2. ctorthis value로 둔다.
  3. IsConstructor(ctor)가 false이면, TypeError exception을 throw한다.
  4. newObj를 ? TypedArrayCreateFromConstructor(ctor, « 𝔽(length) »)로 둔다.
  5. k를 0으로 둔다.
  6. Repeat, while k < length,
    1. kValueitems[k]로 둔다.
    2. propertyKey를 ! ToString(𝔽(k))로 둔다.
    3. Set(newObj, propertyKey, kValue, true)를 수행한다.
    4. kk + 1로 설정한다.
  7. newObj를 반환한다.

23.2.2.3 %TypedArray%.prototype

%TypedArray%.prototype의 initial value는 %TypedArray% prototype object입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

23.2.2.4 get %TypedArray% [ %Symbol.species% ]

%TypedArray%[%Symbol.species%]는 set accessor function이 undefinedaccessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:

  1. this value를 반환한다.

이 function의 "name" property의 value는 "get [Symbol.species]"입니다.

Note

%TypedArray.prototype% methods는 normally their this value의 constructor를 사용하여 derived object를 create합니다. However, subclass constructor는 its %Symbol.species% property를 redefining하여 그 default behaviour를 over-ride할 수 있습니다.

23.2.3 Properties of the %TypedArray% Prototype Object

%TypedArray% prototype object는:

  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.
  • %TypedArray.prototype%입니다.
  • ordinary object입니다.
  • [[ViewedArrayBuffer]] 또는 TypedArray instance objects에 specific한 any other internal slots를 가지지 않습니다.

23.2.3.1 %TypedArray%.prototype.at ( index )

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. relativeIndex를 ? ToIntegerOrInfinity(index)로 둔다.
  5. relativeIndex ≥ 0이면, 다음을 수행한다.
    1. krelativeIndex로 둔다.
  6. Else,
    1. klength + relativeIndex로 둔다.
  7. k < 0 또는 klength이면, undefined를 반환한다.
  8. Get(obj, ! ToString(𝔽(k)))를 반환한다.

23.2.3.2 get %TypedArray%.prototype.buffer

%TypedArray%.prototype.buffer는 set accessor function이 undefinedaccessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. RequireInternalSlot(obj, [[TypedArrayName]])를 수행한다.
  3. Assert: obj[[ViewedArrayBuffer]] internal slot을 가진다.
  4. bufferobj.[[ViewedArrayBuffer]]로 둔다.
  5. buffer를 반환한다.

23.2.3.3 get %TypedArray%.prototype.byteLength

%TypedArray%.prototype.byteLength는 set accessor function이 undefinedaccessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. RequireInternalSlot(obj, [[TypedArrayName]])를 수행한다.
  3. Assert: obj[[ViewedArrayBuffer]] internal slot을 가진다.
  4. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 둔다.
  5. IsTypedArrayOutOfBounds(taRecord)가 true이면, +0𝔽를 반환한다.
  6. sizeTypedArrayByteLength(taRecord)로 둔다.
  7. 𝔽(size)를 반환한다.

23.2.3.4 get %TypedArray%.prototype.byteOffset

%TypedArray%.prototype.byteOffset는 set accessor function이 undefinedaccessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. RequireInternalSlot(obj, [[TypedArrayName]])를 수행한다.
  3. Assert: obj[[ViewedArrayBuffer]] internal slot을 가진다.
  4. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 둔다.
  5. IsTypedArrayOutOfBounds(taRecord)가 true이면, +0𝔽를 반환한다.
  6. offsetobj.[[ByteOffset]]으로 둔다.
  7. 𝔽(offset)을 반환한다.

23.2.3.5 %TypedArray%.prototype.constructor

%TypedArray%.prototype.constructor의 initial value는 %TypedArray%입니다.

23.2.3.6 %TypedArray%.prototype.copyWithin ( target, start [ , end ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.4에 defined된 Array.prototype.copyWithin의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. relativeTarget을 ? ToIntegerOrInfinity(target)로 둔다.
  5. relativeTarget = -∞이면, targetIndex를 0으로 둔다.
  6. Else if relativeTarget < 0이면, targetIndexmax(length + relativeTarget, 0)으로 둔다.
  7. Else, targetIndexmin(relativeTarget, length)로 둔다.
  8. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  9. relativeStart = -∞이면, startIndex를 0으로 둔다.
  10. Else if relativeStart < 0이면, startIndexmax(length + relativeStart, 0)으로 둔다.
  11. Else, startIndexmin(relativeStart, length)로 둔다.
  12. endundefined이면 relativeEndlength로 둔다; else relativeEnd를 ? ToIntegerOrInfinity(end)로 둔다.
  13. relativeEnd = -∞이면, endIndex를 0으로 둔다.
  14. Else if relativeEnd < 0이면, endIndexmax(length + relativeEnd, 0)으로 둔다.
  15. Else, endIndexmin(relativeEnd, length)로 둔다.
  16. countmin(endIndex - startIndex, length - targetIndex)로 둔다.
  17. count > 0이면, 다음을 수행한다.
    1. NOTE: copying은 source data의 bit-level encoding을 preserve하는 manner로 performed되어야 한다.
    2. bufferobj.[[ViewedArrayBuffer]]로 둔다.
    3. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 설정한다.
    4. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
    5. lengthTypedArrayLength(taRecord)로 설정한다.
    6. NOTE: above steps의 side-effects가 obj의 size를 reduced했을 수 있으며, 이 경우 copying은 still-applicable longest prefix로 proceed해야 한다.
    7. countmin(count, length - startIndex, length - targetIndex)로 설정한다.
    8. elementSizeTypedArrayElementSize(obj)로 둔다.
    9. byteOffsetobj.[[ByteOffset]]으로 둔다.
    10. toByteIndex를 (targetIndex × elementSize) + byteOffset으로 둔다.
    11. fromByteIndex를 (startIndex × elementSize) + byteOffset으로 둔다.
    12. countBytescount × elementSize로 둔다.
    13. fromByteIndex < toByteIndex이고 toByteIndex < fromByteIndex + countBytes이면, 다음을 수행한다.
      1. direction을 -1로 둔다.
      2. fromByteIndexfromByteIndex + countBytes - 1로 설정한다.
      3. toByteIndextoByteIndex + countBytes - 1로 설정한다.
    14. Else,
      1. direction을 1로 둔다.
    15. Repeat, while countBytes > 0,
      1. valueGetValueFromBuffer(buffer, fromByteIndex, uint8, true, unordered)로 둔다.
      2. SetValueInBuffer(buffer, toByteIndex, uint8, value, true, unordered)를 수행한다.
      3. fromByteIndexfromByteIndex + direction으로 설정한다.
      4. toByteIndextoByteIndex + direction으로 설정한다.
      5. countBytescountBytes - 1로 설정한다.
  18. obj를 반환한다.

23.2.3.7 %TypedArray%.prototype.entries ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. ValidateTypedArray(obj, seq-cst)를 수행한다.
  3. CreateArrayIterator(obj, key+value)를 반환한다.

23.2.3.8 %TypedArray%.prototype.every ( callback [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.6에 defined된 Array.prototype.every의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  5. k를 0으로 둔다.
  6. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ! Get(obj, propertyKey)로 둔다.
    3. testResultToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), obj »))로 둔다.
    4. testResultfalse이면, false를 반환한다.
    5. kk + 1로 설정한다.
  7. true를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.9 %TypedArray%.prototype.fill ( value [ , start [ , end ] ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.7에 defined된 Array.prototype.fill의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. obj.[[ContentType]]bigint이면, value를 ? ToBigInt(value)로 설정한다.
  5. Else, value를 ? ToNumber(value)로 설정한다.
  6. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  7. relativeStart = -∞이면, startIndex를 0으로 둔다.
  8. Else if relativeStart < 0이면, startIndexmax(length + relativeStart, 0)으로 둔다.
  9. Else, startIndexmin(relativeStart, length)로 둔다.
  10. endundefined이면 relativeEndlength로 둔다; else relativeEnd를 ? ToIntegerOrInfinity(end)로 둔다.
  11. relativeEnd = -∞이면, endIndex를 0으로 둔다.
  12. Else if relativeEnd < 0이면, endIndexmax(length + relativeEnd, 0)으로 둔다.
  13. Else, endIndexmin(relativeEnd, length)로 둔다.
  14. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 설정한다.
  15. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
  16. lengthTypedArrayLength(taRecord)로 설정한다.
  17. endIndexmin(endIndex, length)로 설정한다.
  18. kstartIndex로 둔다.
  19. Repeat, while k < endIndex,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. Set(obj, propertyKey, value, true)를 수행한다.
    3. kk + 1로 설정한다.
  20. obj를 반환한다.

23.2.3.10 %TypedArray%.prototype.filter ( callback [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.8에 defined된 Array.prototype.filter의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  5. kept를 새 empty List로 둔다.
  6. captured를 0으로 둔다.
  7. k를 0으로 둔다.
  8. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ! Get(obj, propertyKey)로 둔다.
    3. selectedToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), obj »))로 둔다.
    4. selectedtrue이면, 다음을 수행한다.
      1. kValuekept에 append한다.
      2. capturedcaptured + 1로 설정한다.
    5. kk + 1로 설정한다.
  9. result를 ? TypedArraySpeciesCreate(obj, « 𝔽(captured) »)로 둔다.
  10. n을 0으로 둔다.
  11. kept의 각 element element에 대해, 다음을 수행한다.
    1. Set(result, ! ToString(𝔽(n)), element, true)를 수행한다.
    2. nn + 1로 설정한다.
  12. result를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.11 %TypedArray%.prototype.find ( predicate [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.9에 defined된 Array.prototype.find의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. findRecord를 ? FindViaPredicate(obj, length, ascending, predicate, thisArg)로 둔다.
  5. findRecord.[[Value]]를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.12 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.10에 defined된 Array.prototype.findIndex의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. findRecord를 ? FindViaPredicate(obj, length, ascending, predicate, thisArg)로 둔다.
  5. findRecord.[[Index]]를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.13 %TypedArray%.prototype.findLast ( predicate [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.11에 defined된 Array.prototype.findLast의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. findRecord를 ? FindViaPredicate(obj, length, descending, predicate, thisArg)로 둔다.
  5. findRecord.[[Value]]를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.14 %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.12에 defined된 Array.prototype.findLastIndex의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. findRecord를 ? FindViaPredicate(obj, length, descending, predicate, thisArg)로 둔다.
  5. findRecord.[[Index]]를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.15 %TypedArray%.prototype.forEach ( callback [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.15에 defined된 Array.prototype.forEach의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  5. k를 0으로 둔다.
  6. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ! Get(obj, propertyKey)로 둔다.
    3. Call(callback, thisArg, « kValue, 𝔽(k), obj »)를 수행한다.
    4. kk + 1로 설정한다.
  7. undefined를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.16 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.16에 defined된 Array.prototype.includes의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. length = 0이면, false를 반환한다.
  5. n을 ? ToIntegerOrInfinity(fromIndex)로 둔다.
  6. Assert: fromIndexundefined이면, n은 0이다.
  7. n = +∞이면, false를 반환한다.
  8. n = -∞이면, n을 0으로 설정한다.
  9. n ≥ 0이면, 다음을 수행한다.
    1. kn으로 둔다.
  10. Else,
    1. klength + n으로 둔다.
    2. k < 0이면, k를 0으로 설정한다.
  11. Repeat, while k < length,
    1. elementK를 ! Get(obj, ! ToString(𝔽(k)))로 둔다.
    2. SameValueZero(searchElement, elementK)가 true이면, true를 반환한다.
    3. kk + 1로 설정한다.
  12. false를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.17 %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.17에 defined된 Array.prototype.indexOf의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. length = 0이면, -1𝔽를 반환한다.
  5. n을 ? ToIntegerOrInfinity(fromIndex)로 둔다.
  6. Assert: fromIndexundefined이면, n은 0이다.
  7. n = +∞이면, -1𝔽를 반환한다.
  8. n = -∞이면, n을 0으로 설정한다.
  9. n ≥ 0이면, 다음을 수행한다.
    1. kn으로 둔다.
  10. Else,
    1. klength + n으로 둔다.
    2. k < 0이면, k를 0으로 설정한다.
  11. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ! HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. elementK를 ! Get(obj, propertyKey)로 둔다.
      2. IsStrictlyEqual(searchElement, elementK)가 true이면, 𝔽(k)를 반환한다.
    4. kk + 1로 설정한다.
  12. -1𝔽를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.18 %TypedArray%.prototype.join ( separator )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.18에 defined된 Array.prototype.join의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. separatorundefined이면, sep","로 둔다.
  5. Else, sep를 ? ToString(separator)로 둔다.
  6. result를 empty String으로 둔다.
  7. k를 0으로 둔다.
  8. Repeat, while k < length,
    1. k > 0이면, resultresultsepstring-concatenation으로 설정한다.
    2. element를 ! Get(obj, ! ToString(𝔽(k)))로 둔다.
    3. elementundefined가 아니면, 다음을 수행한다.
      1. elementString을 ! ToString(element)로 둔다.
      2. resultresultelementStringstring-concatenation으로 설정한다.
    4. kk + 1로 설정한다.
  9. result를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.19 %TypedArray%.prototype.keys ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. ValidateTypedArray(obj, seq-cst)를 수행한다.
  3. CreateArrayIterator(obj, key)를 반환한다.

23.2.3.20 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.20에 defined된 Array.prototype.lastIndexOf의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. length = 0이면, -1𝔽를 반환한다.
  5. fromIndex가 present이면 n을 ? ToIntegerOrInfinity(fromIndex)로 둔다; else nlength - 1로 둔다.
  6. n = -∞이면, -1𝔽를 반환한다.
  7. n ≥ 0이면, 다음을 수행한다.
    1. kmin(n, length - 1)로 둔다.
  8. Else,
    1. klength + n으로 둔다.
  9. Repeat, while k ≥ 0,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ! HasProperty(obj, propertyKey)로 둔다.
    3. kPresenttrue이면, 다음을 수행한다.
      1. elementK를 ! Get(obj, propertyKey)로 둔다.
      2. IsStrictlyEqual(searchElement, elementK)가 true이면, 𝔽(k)를 반환한다.
    4. kk - 1로 설정한다.
  10. -1𝔽를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.21 get %TypedArray%.prototype.length

%TypedArray%.prototype.length는 set accessor function이 undefinedaccessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. RequireInternalSlot(obj, [[TypedArrayName]])를 수행한다.
  3. Assert: obj[[ViewedArrayBuffer]][[ArrayLength]] internal slots를 가진다.
  4. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 둔다.
  5. IsTypedArrayOutOfBounds(taRecord)가 true이면, +0𝔽를 반환한다.
  6. lengthTypedArrayLength(taRecord)로 둔다.
  7. 𝔽(length)를 반환한다.

이 function은 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.22 %TypedArray%.prototype.map ( callback [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.21에 defined된 Array.prototype.map의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  5. result를 ? TypedArraySpeciesCreate(obj, « 𝔽(length) »)로 둔다.
  6. k를 0으로 둔다.
  7. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ! Get(obj, propertyKey)로 둔다.
    3. mappedValue를 ? Call(callback, thisArg, « kValue, 𝔽(k), obj »)로 둔다.
    4. Set(result, propertyKey, mappedValue, true)를 수행한다.
    5. kk + 1로 설정한다.
  8. result를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.23 %TypedArray%.prototype.reduce ( callback [ , initialValue ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.24에 defined된 Array.prototype.reduce의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  5. length = 0이고 initialValue가 present하지 않으면, TypeError exception을 throw한다.
  6. k를 0으로 둔다.
  7. accumulatorundefined로 둔다.
  8. initialValue가 present이면, 다음을 수행한다.
    1. accumulatorinitialValue로 설정한다.
  9. Else,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. accumulator를 ! Get(obj, propertyKey)로 설정한다.
    3. kk + 1로 설정한다.
  10. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ! Get(obj, propertyKey)로 둔다.
    3. accumulator를 ? Call(callback, undefined, « accumulator, kValue, 𝔽(k), obj »)로 설정한다.
    4. kk + 1로 설정한다.
  11. accumulator를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.24 %TypedArray%.prototype.reduceRight ( callback [ , initialValue ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.25에 defined된 Array.prototype.reduceRight의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  5. length = 0이고 initialValue가 present하지 않으면, TypeError exception을 throw한다.
  6. klength - 1로 둔다.
  7. accumulatorundefined로 둔다.
  8. initialValue가 present이면, 다음을 수행한다.
    1. accumulatorinitialValue로 설정한다.
  9. Else,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. accumulator를 ! Get(obj, propertyKey)로 설정한다.
    3. kk - 1로 설정한다.
  10. Repeat, while k ≥ 0,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ! Get(obj, propertyKey)로 둔다.
    3. accumulator를 ? Call(callback, undefined, « accumulator, kValue, 𝔽(k), obj »)로 설정한다.
    4. kk - 1로 설정한다.
  11. accumulator를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.25 %TypedArray%.prototype.reverse ( )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.26에 defined된 Array.prototype.reverse의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. middlefloor(length / 2)로 둔다.
  5. lower를 0으로 둔다.
  6. Repeat, while lowermiddle,
    1. upperlength - lower - 1로 둔다.
    2. upperP를 ! ToString(𝔽(upper))로 둔다.
    3. lowerP를 ! ToString(𝔽(lower))로 둔다.
    4. lowerValue를 ! Get(obj, lowerP)로 둔다.
    5. upperValue를 ! Get(obj, upperP)로 둔다.
    6. Set(obj, lowerP, upperValue, true)를 수행한다.
    7. Set(obj, upperP, lowerValue, true)를 수행한다.
    8. lowerlower + 1로 설정한다.
  7. obj를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.26 %TypedArray%.prototype.set ( source [ , offset ] )

이 method는 source에서 values를 reading하여 이 TypedArray 안에 multiple values를 sets합니다. details는 source의 type에 따라 differ합니다. optional offset value는 values가 written되는 이 TypedArray 안의 first element index를 indicates합니다. omitted되면, 0으로 assumed됩니다.

called될 때 다음 steps를 수행합니다:

  1. targetthis value로 둔다.
  2. RequireInternalSlot(target, [[TypedArrayName]])를 수행한다.
  3. Assert: target[[ViewedArrayBuffer]] internal slot을 가진다.
  4. targetOffset을 ? ToIntegerOrInfinity(offset)으로 둔다.
  5. targetOffset < 0이면, RangeError exception을 throw한다.
  6. source[[TypedArrayName]] internal slot을 가진 Object이면, 다음을 수행한다.
    1. SetTypedArrayFromTypedArray(target, targetOffset, source)를 수행한다.
  7. Else,
    1. SetTypedArrayFromArrayLike(target, targetOffset, source)를 수행한다.
  8. undefined를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.26.1 SetTypedArrayFromArrayLike ( target, targetOffset, source )

The abstract operation SetTypedArrayFromArrayLike takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (an ECMAScript language value, but not a TypedArray) and returns either a normal completion containing unused or a throw completion. source에서 values를 reading하여, index targetOffset에서 starting하여 target 안에 multiple values를 sets합니다. It performs the following steps when called:

  1. targetRecordMakeTypedArrayWithBufferWitnessRecord(target, seq-cst)로 둔다.
  2. IsTypedArrayOutOfBounds(targetRecord)가 true이면, TypeError exception을 throw한다.
  3. targetLengthTypedArrayLength(targetRecord)로 둔다.
  4. source를 ? ToObject(source)로 설정한다.
  5. sourceLength를 ? LengthOfArrayLike(source)로 둔다.
  6. targetOffset = +∞이면, RangeError exception을 throw한다.
  7. sourceLength + targetOffset > targetLength이면, RangeError exception을 throw한다.
  8. k를 0으로 둔다.
  9. Repeat, while k < sourceLength,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. value를 ? Get(source, propertyKey)로 둔다.
    3. targetIndex𝔽(targetOffset + k)로 둔다.
    4. TypedArraySetElement(target, targetIndex, value)를 수행한다.
    5. kk + 1로 설정한다.
  10. unused를 반환한다.

23.2.3.26.2 SetTypedArrayFromTypedArray ( target, targetOffset, source )

The abstract operation SetTypedArrayFromTypedArray takes arguments target (a TypedArray), targetOffset (a non-negative integer or +∞), and source (a TypedArray) and returns either a normal completion containing unused or a throw completion. source에서 values를 reading하여, index targetOffset에서 starting하여 target 안에 multiple values를 sets합니다. It performs the following steps when called:

  1. targetBuffertarget.[[ViewedArrayBuffer]]로 둔다.
  2. targetRecordMakeTypedArrayWithBufferWitnessRecord(target, seq-cst)로 둔다.
  3. IsTypedArrayOutOfBounds(targetRecord)가 true이면, TypeError exception을 throw한다.
  4. targetLengthTypedArrayLength(targetRecord)로 둔다.
  5. sourceBuffersource.[[ViewedArrayBuffer]]로 둔다.
  6. sourceRecordMakeTypedArrayWithBufferWitnessRecord(source, seq-cst)로 둔다.
  7. IsTypedArrayOutOfBounds(sourceRecord)가 true이면, TypeError exception을 throw한다.
  8. sourceLengthTypedArrayLength(sourceRecord)로 둔다.
  9. targetTypeTypedArrayElementType(target)으로 둔다.
  10. targetElementSizeTypedArrayElementSize(target)로 둔다.
  11. targetByteOffsettarget.[[ByteOffset]]으로 둔다.
  12. sourceTypeTypedArrayElementType(source)로 둔다.
  13. sourceElementSizeTypedArrayElementSize(source)로 둔다.
  14. sourceByteOffsetsource.[[ByteOffset]]으로 둔다.
  15. targetOffset = +∞이면, RangeError exception을 throw한다.
  16. sourceLength + targetOffset > targetLength이면, RangeError exception을 throw한다.
  17. target.[[ContentType]]source.[[ContentType]]이 아니면, TypeError exception을 throw한다.
  18. IsSharedArrayBuffer(sourceBuffer)가 true이고, IsSharedArrayBuffer(targetBuffer)가 true이며, sourceBuffer.[[ArrayBufferData]]targetBuffer.[[ArrayBufferData]]이면 sameSharedArrayBuffertrue로 둔다; else sameSharedArrayBufferfalse로 둔다.
  19. SameValue(sourceBuffer, targetBuffer)가 true이거나 sameSharedArrayBuffertrue이면, 다음을 수행한다.
    1. sourceByteLengthTypedArrayByteLength(sourceRecord)로 둔다.
    2. sourceBuffer를 ? CloneArrayBuffer(sourceBuffer, sourceByteOffset, sourceByteLength)로 설정한다.
    3. sourceByteIndex를 0으로 둔다.
  20. Else,
    1. sourceByteIndexsourceByteOffset으로 둔다.
  21. targetByteIndex를 (targetOffset × targetElementSize) + targetByteOffset으로 둔다.
  22. limittargetByteIndex + (targetElementSize × sourceLength)로 둔다.
  23. sourceTypetargetType이면, 다음을 수행한다.
    1. NOTE: transfer는 source data의 bit-level encoding을 preserve하는 manner로 performed되어야 한다.
    2. Repeat, while targetByteIndex < limit,
      1. valueGetValueFromBuffer(sourceBuffer, sourceByteIndex, uint8, true, unordered)로 둔다.
      2. SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered)를 수행한다.
      3. sourceByteIndexsourceByteIndex + 1로 설정한다.
      4. targetByteIndextargetByteIndex + 1로 설정한다.
  24. Else,
    1. Repeat, while targetByteIndex < limit,
      1. valueGetValueFromBuffer(sourceBuffer, sourceByteIndex, sourceType, true, unordered)로 둔다.
      2. SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, unordered)를 수행한다.
      3. sourceByteIndexsourceByteIndex + sourceElementSize로 설정한다.
      4. targetByteIndextargetByteIndex + targetElementSize로 설정한다.
  25. unused를 반환한다.

23.2.3.27 %TypedArray%.prototype.slice ( start, end )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.28에 defined된 Array.prototype.slice의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. sourceArrayLengthTypedArrayLength(taRecord)로 둔다.
  4. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  5. relativeStart = -∞이면, startIndex를 0으로 둔다.
  6. Else if relativeStart < 0이면, startIndexmax(sourceArrayLength + relativeStart, 0)으로 둔다.
  7. Else, startIndexmin(relativeStart, sourceArrayLength)로 둔다.
  8. endundefined이면 relativeEndsourceArrayLength로 둔다; else relativeEnd를 ? ToIntegerOrInfinity(end)로 둔다.
  9. relativeEnd = -∞이면, endIndex를 0으로 둔다.
  10. Else if relativeEnd < 0이면, endIndexmax(sourceArrayLength + relativeEnd, 0)으로 둔다.
  11. Else, endIndexmin(relativeEnd, sourceArrayLength)로 둔다.
  12. countBytesmax(endIndex - startIndex, 0)으로 둔다.
  13. resultArray를 ? TypedArraySpeciesCreate(obj, « 𝔽(countBytes) »)로 둔다.
  14. countBytes > 0이면, 다음을 수행한다.
    1. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 설정한다.
    2. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
    3. endIndexmin(endIndex, TypedArrayLength(taRecord))로 설정한다.
    4. countBytesmax(endIndex - startIndex, 0)으로 설정한다.
    5. sourceTypeTypedArrayElementType(obj)로 둔다.
    6. targetTypeTypedArrayElementType(resultArray)로 둔다.
    7. sourceTypetargetType이면, 다음을 수행한다.
      1. NOTE: transfer는 source data의 bit-level encoding을 preserve하는 manner로 performed되어야 한다.
      2. sourceBufferobj.[[ViewedArrayBuffer]]로 둔다.
      3. targetBufferresultArray.[[ViewedArrayBuffer]]로 둔다.
      4. elementSizeTypedArrayElementSize(obj)로 둔다.
      5. sourceByteOffsetobj.[[ByteOffset]]으로 둔다.
      6. sourceByteIndex를 (startIndex × elementSize) + sourceByteOffset으로 둔다.
      7. targetByteIndexresultArray.[[ByteOffset]]으로 둔다.
      8. endByteIndextargetByteIndex + (countBytes × elementSize)로 둔다.
      9. Repeat, while targetByteIndex < endByteIndex,
        1. valueGetValueFromBuffer(sourceBuffer, sourceByteIndex, uint8, true, unordered)로 둔다.
        2. SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered)를 수행한다.
        3. sourceByteIndexsourceByteIndex + 1로 설정한다.
        4. targetByteIndextargetByteIndex + 1로 설정한다.
    8. Else,
      1. n을 0으로 둔다.
      2. kstartIndex로 둔다.
      3. Repeat, while k < endIndex,
        1. propertyKey를 ! ToString(𝔽(k))로 둔다.
        2. kValue를 ! Get(obj, propertyKey)로 둔다.
        3. Set(resultArray, ! ToString(𝔽(n)), kValue, true)를 수행한다.
        4. kk + 1로 설정한다.
        5. nn + 1로 설정한다.
  15. resultArray를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.28 %TypedArray%.prototype.some ( callback [ , thisArg ] )

이 method의 arguments에 대한 interpretation 및 use는 23.1.3.29에 defined된 Array.prototype.some의 경우와 같습니다.

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. IsCallable(callback)가 false이면, TypeError exception을 throw한다.
  5. k를 0으로 둔다.
  6. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ! Get(obj, propertyKey)로 둔다.
    3. testResultToBoolean(? Call(callback, thisArg, « kValue, 𝔽(k), obj »))로 둔다.
    4. testResulttrue이면, true를 반환한다.
    5. kk + 1로 설정한다.
  7. false를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.29 %TypedArray%.prototype.sort ( comparator )

이는 below에 described된 경우를 제외하고 23.1.3.30에 defined된 Array.prototype.sort의 requirements와 same requirements를 implements하는 distinct method입니다. 이 method의 implementation은 this value가 fixed length를 가지며 integer-indexed properties가 sparse하지 않은 object라는 knowledge로 optimized될 수 있습니다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

called될 때 다음 steps를 수행합니다:

  1. comparatorundefined가 아니고 IsCallable(comparator)가 false이면, TypeError exception을 throw한다.
  2. objthis value로 둔다.
  3. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  4. lengthTypedArrayLength(taRecord)로 둔다.
  5. NOTE: following closure는 23.1.3.30에서 사용되는 string comparison이 아니라 numeric comparison을 수행한다.
  6. comparator를 capture하고 called될 때 다음 steps를 수행하는, parameters (x, y)를 가진 새 Abstract Closure sortCompare를 둔다:
    1. CompareTypedArrayElements(x, y, comparator)를 반환한다.
  7. sortedList를 ? SortIndexedProperties(obj, length, sortCompare, read-through-holes)로 둔다.
  8. j를 0으로 둔다.
  9. Repeat, while j < length,
    1. Set(obj, ! ToString(𝔽(j)), sortedList[j], true)를 수행한다.
    2. jj + 1로 설정한다.
  10. obj를 반환한다.
Note

NaN은 always any other value보다 greater로 compare되므로(CompareTypedArrayElements 참조), comparator가 provided되지 않을 때 NaN property values는 always result의 end로 sort됩니다.

23.2.3.30 %TypedArray%.prototype.subarray ( start, end )

이 method는 element type이 this TypedArray의 element type이고 ArrayBuffer가 this TypedArray의 ArrayBuffer인 new TypedArray를 반환하며, start(inclusive)부터 end(exclusive)까지의 interval 안의 elements를 referencing합니다. start 또는 end 중 어느 하나가 negative이면, beginning에서가 아니라 array의 end로부터의 index를 refer합니다.

called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. RequireInternalSlot(obj, [[TypedArrayName]])를 수행한다.
  3. Assert: obj[[ViewedArrayBuffer]] internal slot을 가진다.
  4. bufferobj.[[ViewedArrayBuffer]]로 둔다.
  5. sourceRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 둔다.
  6. IsTypedArrayOutOfBounds(sourceRecord)가 true이면, 다음을 수행한다.
    1. sourceLength를 0으로 둔다.
  7. Else,
    1. sourceLengthTypedArrayLength(sourceRecord)로 둔다.
  8. relativeStart를 ? ToIntegerOrInfinity(start)로 둔다.
  9. relativeStart = -∞이면, startIndex를 0으로 둔다.
  10. Else if relativeStart < 0이면, startIndexmax(sourceLength + relativeStart, 0)으로 둔다.
  11. Else, startIndexmin(relativeStart, sourceLength)로 둔다.
  12. elementSizeTypedArrayElementSize(obj)로 둔다.
  13. sourceByteOffsetobj.[[ByteOffset]]으로 둔다.
  14. beginByteOffsetsourceByteOffset + (startIndex × elementSize)로 둔다.
  15. obj.[[ArrayLength]]auto이고 endundefined이면, 다음을 수행한다.
    1. argList를 « buffer, 𝔽(beginByteOffset) »로 둔다.
  16. Else,
    1. endundefined이면 relativeEndsourceLength로 둔다; else relativeEnd를 ? ToIntegerOrInfinity(end)로 둔다.
    2. relativeEnd = -∞이면, endIndex를 0으로 둔다.
    3. Else if relativeEnd < 0이면, endIndexmax(sourceLength + relativeEnd, 0)으로 둔다.
    4. Else, endIndexmin(relativeEnd, sourceLength)로 둔다.
    5. newLengthmax(endIndex - startIndex, 0)으로 둔다.
    6. argList를 « buffer, 𝔽(beginByteOffset), 𝔽(newLength) »로 둔다.
  17. TypedArraySpeciesCreate(obj, argList)를 반환한다.

이 method는 generic하지 않습니다. this value는 [[TypedArrayName]] internal slot을 가진 object여야 합니다.

23.2.3.31 %TypedArray%.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )

이는 TypedArrayLength"length"[[Get]]을 performing하는 대신 called된다는 점을 제외하고 23.1.3.32에 defined된 Array.prototype.toLocaleString과 same algorithm을 implements하는 distinct method입니다. underlying buffer가 resizable하지 않을 때 this value가 fixed length를 가지며 integer-indexed properties가 sparse하지 않다는 knowledge로 algorithm의 implementation이 optimized될 수 있습니다. However, such optimization은 algorithm의 specified behaviour에 any observable changes를 introduce해서는 안 됩니다.

이 method는 generic하지 않습니다. algorithm을 evaluating하기 전에 ValidateTypedArraythis value와 seq-cst를 arguments로 하여 called됩니다. 그 result가 abrupt completion이면, algorithm을 evaluating하는 대신 that exception이 thrown됩니다.

Note

ECMAScript implementation이 ECMA-402 Internationalization API를 include하면, 이 method는 ECMA-402 specification 안의 Array.prototype.toLocaleString용 algorithm에 based됩니다.

23.2.3.32 %TypedArray%.prototype.toReversed ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. resultArray를 ? TypedArrayCreateSameType(obj, length)로 둔다.
  5. k를 0으로 둔다.
  6. Repeat, while k < length,
    1. from을 ! ToString(𝔽(length - k - 1))로 둔다.
    2. propertyKey를 ! ToString(𝔽(k))로 둔다.
    3. fromValue를 ! Get(obj, from)로 둔다.
    4. Set(resultArray, propertyKey, fromValue, true)를 수행한다.
    5. kk + 1로 설정한다.
  7. resultArray를 반환한다.

23.2.3.33 %TypedArray%.prototype.toSorted ( comparator )

이 method는 called될 때 다음 steps를 수행합니다:

  1. comparatorundefined가 아니고 IsCallable(comparator)가 false이면, TypeError exception을 throw한다.
  2. objthis value로 둔다.
  3. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  4. lengthTypedArrayLength(taRecord)로 둔다.
  5. resultArray를 ? TypedArrayCreateSameType(obj, length)로 둔다.
  6. NOTE: following closure는 23.1.3.34에서 사용되는 string comparison이 아니라 numeric comparison을 수행한다.
  7. comparator를 capture하고 called될 때 다음 steps를 수행하는, parameters (x, y)를 가진 새 Abstract Closure sortCompare를 둔다:
    1. CompareTypedArrayElements(x, y, comparator)를 반환한다.
  8. sortedList를 ? SortIndexedProperties(obj, length, sortCompare, read-through-holes)로 둔다.
  9. j를 0으로 둔다.
  10. Repeat, while j < length,
    1. Set(resultArray, ! ToString(𝔽(j)), sortedList[j], true)를 수행한다.
    2. jj + 1로 설정한다.
  11. resultArray를 반환한다.

23.2.3.34 %TypedArray%.prototype.toString ( )

"toString" property의 initial value는 23.1.3.36에 defined된 %Array.prototype.toString%입니다.

23.2.3.35 %TypedArray%.prototype.values ( )

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. ValidateTypedArray(obj, seq-cst)를 수행한다.
  3. CreateArrayIterator(obj, value)를 반환한다.

23.2.3.36 %TypedArray%.prototype.with ( index, value )

이 method는 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. taRecord를 ? ValidateTypedArray(obj, seq-cst)로 둔다.
  3. lengthTypedArrayLength(taRecord)로 둔다.
  4. relativeIndex를 ? ToIntegerOrInfinity(index)로 둔다.
  5. relativeIndex ≥ 0이면 actualIndexrelativeIndex로 둔다.
  6. Else, actualIndexlength + relativeIndex로 둔다.
  7. obj.[[ContentType]]bigint이면, numericValue를 ? ToBigInt(value)로 둔다.
  8. Else, numericValue를 ? ToNumber(value)로 둔다.
  9. IsValidIntegerIndex(obj, 𝔽(actualIndex))가 false이면, RangeError exception을 throw한다.
  10. resultArray를 ? TypedArrayCreateSameType(obj, length)로 둔다.
  11. k를 0으로 둔다.
  12. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. k = actualIndex이면 fromValuenumericValue로 둔다.
    3. Else, fromValue를 ! Get(obj, propertyKey)로 둔다.
    4. Set(resultArray, propertyKey, fromValue, true)를 수행한다.
    5. kk + 1로 설정한다.
  13. resultArray를 반환한다.

23.2.3.37 %TypedArray%.prototype [ %Symbol.iterator% ] ( )

%Symbol.iterator% property의 initial value는 23.2.3.35에 defined된 %TypedArray.prototype.values%입니다.

23.2.3.38 get %TypedArray%.prototype [ %Symbol.toStringTag% ]

%TypedArray%.prototype[%Symbol.toStringTag%]는 set accessor function이 undefinedaccessor property입니다. Its get accessor function은 called될 때 다음 steps를 수행합니다:

  1. objthis value로 둔다.
  2. obj가 Object가 아니면, undefined를 반환한다.
  3. obj[[TypedArrayName]] internal slot을 가지지 않으면, undefined를 반환한다.
  4. nameobj.[[TypedArrayName]]으로 둔다.
  5. Assert: name은 String이다.
  6. name을 반환한다.

이 property는 attributes { [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

이 function의 "name" property의 initial value는 "get [Symbol.toStringTag]"입니다.

23.2.4 TypedArray Objects용 Abstract Operations

23.2.4.1 TypedArrayCreateFromConstructor ( ctor, argList )

The abstract operation TypedArrayCreateFromConstructor takes arguments ctor (a constructor) and argList (a List of ECMAScript language values) and returns either a normal completion containing a TypedArray or a throw completion. constructor function을 사용한 new TypedArray의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:

  1. ta를 ? Construct(ctor, argList)로 둔다.
  2. taRecord를 ? ValidateTypedArray(ta, seq-cst)로 둔다.
  3. Assert: taProperties of TypedArray Instances에 mentioned된 all internal slots를 가진다.
  4. argList 안의 elements 수가 1이고 argList[0]이 Number이면, 다음을 수행한다.
    1. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
    2. lengthTypedArrayLength(taRecord)로 둔다.
    3. length < (argList[0])이면, TypeError exception을 throw한다.
  5. ta를 반환한다.

23.2.4.2 TypedArrayCreateSameType ( exemplar, length )

The abstract operation TypedArrayCreateSameType takes arguments exemplar (a TypedArray) and length (a non-negative integer) and returns either a normal completion containing a TypedArray or a throw completion. exemplar에서 derived된 constructor function을 사용한 new TypedArray의 creation을 specify하는 데 사용됩니다. %Symbol.species% 사용을 통해 custom TypedArray subclasses를 construct할 수 있는 TypedArraySpeciesCreate와 달리, 이 operation은 항상 built-in TypedArray constructors 중 하나를 사용합니다. It performs the following steps when called:

  1. ctorTable 71에서 constructor name exemplar.[[TypedArrayName]]과 associated된 intrinsic object로 둔다.
  2. result를 ? TypedArrayCreateFromConstructor(ctor, « 𝔽(length) »)로 둔다.
  3. Assert: result[[TypedArrayName]][[ContentType]] internal slots를 가진다.
  4. Assert: result.[[ContentType]]exemplar.[[ContentType]]이다.
  5. result를 반환한다.

23.2.4.3 TypedArraySpeciesCreate ( exemplar, argList )

The abstract operation TypedArraySpeciesCreate takes arguments exemplar (a TypedArray) and argList (a List of ECMAScript language values) and returns either a normal completion containing a TypedArray or a throw completion. exemplar에서 derived된 constructor function을 사용한 new TypedArray의 creation을 specify하는 데 사용됩니다. %Symbol.species% 사용을 통해 non-Array objects를 create할 수 있는 ArraySpeciesCreate와 달리, 이 operation은 constructor function이 actual TypedArray를 create하도록 enforces합니다. It performs the following steps when called:

  1. defaultCtorTable 71에서 constructor name exemplar.[[TypedArrayName]]과 associated된 intrinsic object로 둔다.
  2. ctor를 ? SpeciesConstructor(exemplar, defaultCtor)로 둔다.
  3. result를 ? TypedArrayCreateFromConstructor(ctor, argList)로 둔다.
  4. result.[[ContentType]]exemplar.[[ContentType]]이 아니면, TypeError exception을 throw한다.
  5. result를 반환한다.

23.2.4.4 ValidateTypedArray ( obj, order )

The abstract operation ValidateTypedArray takes arguments obj (an ECMAScript language value) and order (seq-cst or unordered) and returns either a normal completion containing a TypedArray With Buffer Witness Record or a throw completion. It performs the following steps when called:

  1. RequireInternalSlot(obj, [[TypedArrayName]])를 수행한다.
  2. Assert: obj[[ViewedArrayBuffer]] internal slot을 가진다.
  3. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, order)로 둔다.
  4. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
  5. taRecord를 반환한다.

23.2.4.5 TypedArrayElementSize ( obj )

The abstract operation TypedArrayElementSize takes argument obj (a TypedArray) and returns a non-negative integer. It performs the following steps when called:

  1. obj.[[TypedArrayName]]에 대해 Table 71에 specified된 Element Size value를 반환한다.

23.2.4.6 TypedArrayElementType ( obj )

The abstract operation TypedArrayElementType takes argument obj (a TypedArray) and returns a TypedArray element type. It performs the following steps when called:

  1. obj.[[TypedArrayName]]에 대해 Table 71에 specified된 Element Type value를 반환한다.

23.2.4.7 CompareTypedArrayElements ( x, y, comparator )

The abstract operation CompareTypedArrayElements takes arguments x (a Number or a BigInt), y (a Number or a BigInt), and comparator (a function object or undefined) and returns either a normal completion containing a Number or an abrupt completion. It performs the following steps when called:

  1. Assert: xy는 모두 Number이거나, xy는 모두 BigInt이다.
  2. comparatorundefined가 아니면, 다음을 수행한다.
    1. result를 ? ToNumber(? Call(comparator, undefined, « x, y »))로 둔다.
    2. resultNaN이면, +0𝔽를 반환한다.
    3. result를 반환한다.
  3. xNaN이고 yNaN이면, +0𝔽를 반환한다.
  4. xNaN이면, 1𝔽를 반환한다.
  5. yNaN이면, -1𝔽를 반환한다.
  6. x < y이면, -1𝔽를 반환한다.
  7. x > y이면, 1𝔽를 반환한다.
  8. x-0𝔽이고 y+0𝔽이면, -1𝔽를 반환한다.
  9. x+0𝔽이고 y-0𝔽이면, 1𝔽를 반환한다.
  10. +0𝔽를 반환한다.
Note
이는 23.1.3.30.2에서 사용되는 string comparison이 아니라 numeric comparison을 수행합니다.

23.2.5 The TypedArray Constructors

TypedArray constructor는:

  • otherwise noted된 경우를 제외하고, Table 71에서 TypedArray 대신 constructor name으로 사용되는 name만 differing하며 below에 described된 structure를 가지는 intrinsic object입니다.
  • arguments의 number 및 types에 따라 behaviour가 달라지는 function입니다. TypedArray call의 actual behaviour는 pass된 arguments의 number 및 kind에 depends합니다.
  • function으로 called되도록 intended되지 않으며, such manner로 called될 때 exception을 throw합니다.
  • 클래스 정의의 extends 절의 값으로 사용될 수 있다. 지정된 TypedArray 동작을 상속하려는 서브클래스 생성자는 %TypedArray%.prototype의 내장 메서드를 지원하는 데 필요한 내부 상태로 서브클래스 인스턴스를 생성하고 초기화하기 위해 TypedArray 생성자에 대한 super 호출을 포함해야 한다.

23.2.5.1 TypedArray ( ...args )

TypedArray constructor는 called될 때 다음 steps를 수행합니다:

  1. NewTarget이 undefined이면, TypeError exception을 throw한다.
  2. ctorName을 이 TypedArray constructor에 대해 Table 71에 specified된 Constructor Name value의 String value로 둔다.
  3. proto"%TypedArray.prototype%"로 둔다.
  4. numberOfArgsargs 안의 elements 수로 둔다.
  5. numberOfArgs = 0이면, ? AllocateTypedArray(ctorName, NewTarget, proto, 0)를 반환한다.
  6. firstArgargs[0]으로 둔다.
  7. firstArg가 Object이면, 다음을 수행한다.
    1. obj를 ? AllocateTypedArray(ctorName, NewTarget, proto)로 둔다.
    2. firstArg[[TypedArrayName]] internal slot을 가지면, 다음을 수행한다.
      1. InitializeTypedArrayFromTypedArray(obj, firstArg)를 수행한다.
    3. Else if firstArg[[ArrayBufferData]] internal slot을 가지면, 다음을 수행한다.
      1. numberOfArgs > 1이면 byteOffsetargs[1]로 둔다; else byteOffsetundefined로 둔다.
      2. numberOfArgs > 2이면 lengthargs[2]로 둔다; else lengthundefined로 둔다.
      3. InitializeTypedArrayFromArrayBuffer(obj, firstArg, byteOffset, length)를 수행한다.
    4. Else,
      1. Assert: firstArg는 Object이고 firstArg[[TypedArrayName]] 또는 [[ArrayBufferData]] internal slot 어느 것도 가지지 않는다.
      2. usingIterator를 ? GetMethod(firstArg, %Symbol.iterator%)로 둔다.
      3. usingIteratorundefined가 아니면, 다음을 수행한다.
        1. values를 ? IteratorToList(? GetIteratorFromMethod(firstArg, usingIterator))로 둔다.
        2. InitializeTypedArrayFromList(obj, values)를 수행한다.
      4. Else,
        1. NOTE: firstArgiterable object가 아니므로, already array-like object라고 assume한다.
        2. InitializeTypedArrayFromArrayLike(obj, firstArg)를 수행한다.
    5. obj를 반환한다.
  8. Assert: firstArg는 Object가 아니다.
  9. elementLength를 ? ToIndex(firstArg)로 둔다.
  10. AllocateTypedArray(ctorName, NewTarget, proto, elementLength)를 반환한다.

23.2.5.1.1 AllocateTypedArray ( ctorName, newTarget, defaultProto [ , length ] )

The abstract operation AllocateTypedArray takes arguments ctorName (a String which is the name of a TypedArray constructor in Table 71), newTarget (a constructor), and defaultProto (a String) and optional argument length (a non-negative integer) and returns either a normal completion containing a TypedArray or a throw completion. TypedArray constructor의 instance를 validate하고 create하는 데 사용됩니다. length argument가 passed되면, that length의 ArrayBuffer도 allocated되고 new TypedArray instance와 associated됩니다. AllocateTypedArray는 TypedArray에 의해 사용되는 common semantics를 제공합니다. It performs the following steps when called:

  1. proto를 ? GetPrototypeFromConstructor(newTarget, defaultProto)로 둔다.
  2. objTypedArrayCreate(proto)로 둔다.
  3. Assert: obj.[[ViewedArrayBuffer]]undefined이다.
  4. obj.[[TypedArrayName]]ctorName으로 설정한다.
  5. ctorName"BigInt64Array" 또는 "BigUint64Array" 중 하나이면, obj.[[ContentType]]bigint로 설정한다.
  6. Else, obj.[[ContentType]]number로 설정한다.
  7. length가 present하지 않으면, 다음을 수행한다.
    1. obj.[[ByteLength]]를 0으로 설정한다.
    2. obj.[[ByteOffset]]을 0으로 설정한다.
    3. obj.[[ArrayLength]]를 0으로 설정한다.
  8. Else,
    1. AllocateTypedArrayBuffer(obj, length)를 수행한다.
  9. obj를 반환한다.

23.2.5.1.2 InitializeTypedArrayFromTypedArray ( obj, sourceArray )

The abstract operation InitializeTypedArrayFromTypedArray takes arguments obj (a TypedArray) and sourceArray (a TypedArray) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. sourceDatasourceArray.[[ViewedArrayBuffer]]로 둔다.
  2. elementTypeTypedArrayElementType(obj)로 둔다.
  3. elementSizeTypedArrayElementSize(obj)로 둔다.
  4. sourceTypeTypedArrayElementType(sourceArray)로 둔다.
  5. sourceElementSizeTypedArrayElementSize(sourceArray)로 둔다.
  6. sourceByteOffsetsourceArray.[[ByteOffset]]으로 둔다.
  7. sourceRecordMakeTypedArrayWithBufferWitnessRecord(sourceArray, seq-cst)로 둔다.
  8. IsTypedArrayOutOfBounds(sourceRecord)가 true이면, TypeError exception을 throw한다.
  9. elementLengthTypedArrayLength(sourceRecord)로 둔다.
  10. byteLengthelementSize × elementLength로 둔다.
  11. elementTypesourceType이면, 다음을 수행한다.
    1. data를 ? CloneArrayBuffer(sourceData, sourceByteOffset, byteLength)로 둔다.
  12. Else,
    1. data를 ? AllocateArrayBuffer(%ArrayBuffer%, byteLength)로 둔다.
    2. sourceArray.[[ContentType]]obj.[[ContentType]]이 아니면, TypeError exception을 throw한다.
    3. sourceByteIndexsourceByteOffset으로 둔다.
    4. targetByteIndex를 0으로 둔다.
    5. countelementLength로 둔다.
    6. Repeat, while count > 0,
      1. valueGetValueFromBuffer(sourceData, sourceByteIndex, sourceType, true, unordered)로 둔다.
      2. SetValueInBuffer(data, targetByteIndex, elementType, value, true, unordered)를 수행한다.
      3. sourceByteIndexsourceByteIndex + sourceElementSize로 설정한다.
      4. targetByteIndextargetByteIndex + elementSize로 설정한다.
      5. countcount - 1로 설정한다.
  13. obj.[[ViewedArrayBuffer]]data로 설정한다.
  14. obj.[[ByteLength]]byteLength로 설정한다.
  15. obj.[[ByteOffset]]을 0으로 설정한다.
  16. obj.[[ArrayLength]]elementLength로 설정한다.
  17. unused를 반환한다.

23.2.5.1.3 InitializeTypedArrayFromArrayBuffer ( obj, buffer, byteOffset, length )

The abstract operation InitializeTypedArrayFromArrayBuffer takes arguments obj (a TypedArray), buffer (an ArrayBuffer or a SharedArrayBuffer), byteOffset (an ECMAScript language value), and length (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. elementSizeTypedArrayElementSize(obj)로 둔다.
  2. offset을 ? ToIndex(byteOffset)으로 둔다.
  3. offset modulo elementSize ≠ 0이면, RangeError exception을 throw한다.
  4. bufferIsFixedLengthIsFixedLengthArrayBuffer(buffer)로 둔다.
  5. lengthundefined가 아니면, 다음을 수행한다.
    1. newLength를 ? ToIndex(length)로 둔다.
  6. IsDetachedBuffer(buffer)가 true이면, TypeError exception을 throw한다.
  7. bufferByteLengthArrayBufferByteLength(buffer, seq-cst)로 둔다.
  8. lengthundefined이고 bufferIsFixedLengthfalse이면, 다음을 수행한다.
    1. offset > bufferByteLength이면, RangeError exception을 throw한다.
    2. obj.[[ByteLength]]auto로 설정한다.
    3. obj.[[ArrayLength]]auto로 설정한다.
  9. Else,
    1. lengthundefined이면, 다음을 수행한다.
      1. bufferByteLength modulo elementSize ≠ 0이면, RangeError exception을 throw한다.
      2. newByteLengthbufferByteLength - offset으로 둔다.
      3. newByteLength < 0이면, RangeError exception을 throw한다.
    2. Else,
      1. newByteLengthnewLength × elementSize로 둔다.
      2. offset + newByteLength > bufferByteLength이면, RangeError exception을 throw한다.
    3. obj.[[ByteLength]]newByteLength로 설정한다.
    4. obj.[[ArrayLength]]newByteLength / elementSize로 설정한다.
  10. obj.[[ViewedArrayBuffer]]buffer로 설정한다.
  11. obj.[[ByteOffset]]offset으로 설정한다.
  12. unused를 반환한다.

23.2.5.1.4 InitializeTypedArrayFromList ( obj, values )

The abstract operation InitializeTypedArrayFromList takes arguments obj (a TypedArray) and values (a List of ECMAScript language values) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. lengthvalues 안의 elements 수로 둔다.
  2. AllocateTypedArrayBuffer(obj, length)를 수행한다.
  3. k를 0으로 둔다.
  4. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValuevalues의 first element로 둔다.
    3. values에서 first element를 remove한다.
    4. Set(obj, propertyKey, kValue, true)를 수행한다.
    5. kk + 1로 설정한다.
  5. Assert: values는 now empty List이다.
  6. unused를 반환한다.

23.2.5.1.5 InitializeTypedArrayFromArrayLike ( obj, arrayLike )

The abstract operation InitializeTypedArrayFromArrayLike takes arguments obj (a TypedArray) and arrayLike (an Object, but not a TypedArray or an ArrayBuffer) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. length를 ? LengthOfArrayLike(arrayLike)로 둔다.
  2. AllocateTypedArrayBuffer(obj, length)를 수행한다.
  3. k를 0으로 둔다.
  4. Repeat, while k < length,
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. kValue를 ? Get(arrayLike, propertyKey)로 둔다.
    3. Set(obj, propertyKey, kValue, true)를 수행한다.
    4. kk + 1로 설정한다.
  5. unused를 반환한다.

23.2.5.1.6 AllocateTypedArrayBuffer ( obj, length )

The abstract operation AllocateTypedArrayBuffer takes arguments obj (a TypedArray) and length (a non-negative integer) and returns either a normal completion containing unused or a throw completion. ArrayBuffer를 allocate하고 obj와 associate합니다. It performs the following steps when called:

  1. Assert: obj.[[ViewedArrayBuffer]]undefined이다.
  2. elementSizeTypedArrayElementSize(obj)로 둔다.
  3. byteLengthelementSize × length로 둔다.
  4. data를 ? AllocateArrayBuffer(%ArrayBuffer%, byteLength)로 둔다.
  5. obj.[[ViewedArrayBuffer]]data로 설정한다.
  6. obj.[[ByteLength]]byteLength로 설정한다.
  7. obj.[[ByteOffset]]을 0으로 설정한다.
  8. obj.[[ArrayLength]]length로 설정한다.
  9. unused를 반환한다.

23.2.6 Properties of the TypedArray Constructors

TypedArray constructor는:

  • value가 %TypedArray%[[Prototype]] internal slot을 가집니다.
  • value가 3𝔽"length" property를 가집니다.
  • Table 71에서 그것에 대해 specified된 constructor name의 String value인 "name" property를 가집니다.
  • 다음 properties를 가집니다:

23.2.6.1 TypedArray.BYTES_PER_ELEMENT

TypedArray.BYTES_PER_ELEMENT의 value는 TypedArray에 대해 Table 71에 specified된 Element Size value입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

23.2.6.2 TypedArray.prototype

TypedArray.prototype의 initial value는 corresponding TypedArray prototype intrinsic object(23.2.7)입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

23.2.7 Properties of the TypedArray Prototype Objects

TypedArray prototype object는:

  • value가 %TypedArray.prototype%[[Prototype]] internal slot을 가집니다.
  • ordinary object입니다.
  • [[ViewedArrayBuffer]] 또는 TypedArray instance objects에 specific한 any other internal slots를 가지지 않습니다.

23.2.7.1 TypedArray.prototype.BYTES_PER_ELEMENT

TypedArray.prototype.BYTES_PER_ELEMENT의 value는 TypedArray에 대해 Table 71에 specified된 Element Size value입니다.

이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

23.2.7.2 TypedArray.prototype.constructor

given TypedArray constructor에 대한 prototype의 "constructor" property의 initial value는 constructor itself입니다.

23.2.8 Properties of TypedArray Instances

TypedArray instances는 TypedArrays입니다. 각 TypedArray instance는 corresponding TypedArray prototype object로부터 properties를 inherit합니다. 각 TypedArray instance는 다음 internal slots를 가집니다: [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], 및 [[ArrayLength]].

23.3 Uint8Array Objects

Uint8Array는 위에 described된 TypedArray의 particular kind입니다. 또한 Uint8Array constructor(23.3.1)와 Uint8Array prototype object(23.3.2)에 additional methods가 있습니다.

23.3.1 Additional Properties of the Uint8Array Constructor

23.3.1.1 Uint8Array.fromBase64 ( string [ , options ] )

  1. string이 String이 아니면, TypeError exception을 throw한다.
  2. opts를 ? GetOptionsObject(options)로 둔다.
  3. alphabet을 ? Get(opts, "alphabet")으로 둔다.
  4. alphabetundefined이면, alphabet"base64"로 설정한다.
  5. alphabet"base64""base64url"도 아니면, TypeError exception을 throw한다.
  6. lastChunkHandling을 ? Get(opts, "lastChunkHandling")으로 둔다.
  7. lastChunkHandlingundefined이면, lastChunkHandling"loose"로 설정한다.
  8. lastChunkHandling"loose", "strict", 또는 "stop-before-partial" 중 하나가 아니면, TypeError exception을 throw한다.
  9. resultFromBase64(string, alphabet, lastChunkHandling)로 둔다.
  10. result.[[Error]]none이 아니면, 다음을 수행한다.
    1. result.[[Error]]를 Throw한다.
  11. resultLengthresult.[[Bytes]] 안의 elements 수로 둔다.
  12. ta를 ? AllocateTypedArray("Uint8Array", %Uint8Array%, "%Uint8Array.prototype%", resultLength)로 둔다.
  13. Assert: ta.[[ViewedArrayBuffer]].[[ArrayBufferByteLength]]result.[[Bytes]] 안의 elements 수이다.
  14. ta.[[ViewedArrayBuffer]].[[ArrayBufferData]]의 each index의 value를 result.[[Bytes]]의 corresponding index의 value로 설정한다.
  15. ta를 반환한다.

23.3.1.2 Uint8Array.fromHex ( string )

  1. string이 String이 아니면, TypeError exception을 throw한다.
  2. resultFromHex(string)로 둔다.
  3. result.[[Error]]none이 아니면, 다음을 수행한다.
    1. result.[[Error]]를 Throw한다.
  4. resultLengthresult.[[Bytes]] 안의 elements 수로 둔다.
  5. ta를 ? AllocateTypedArray("Uint8Array", %Uint8Array%, "%Uint8Array.prototype%", resultLength)로 둔다.
  6. Assert: ta.[[ViewedArrayBuffer]].[[ArrayBufferByteLength]]result.[[Bytes]] 안의 elements 수이다.
  7. ta.[[ViewedArrayBuffer]].[[ArrayBufferData]]의 each index의 value를 result.[[Bytes]]의 corresponding index의 value로 설정한다.
  8. ta를 반환한다.

23.3.2 Additional Properties of the Uint8Array Prototype Object

23.3.2.1 Uint8Array.prototype.setFromBase64 ( string [ , options ] )

  1. intothis value로 둔다.
  2. ValidateUint8Array(into)를 수행한다.
  3. string이 String이 아니면, TypeError exception을 throw한다.
  4. opts를 ? GetOptionsObject(options)로 둔다.
  5. alphabet을 ? Get(opts, "alphabet")으로 둔다.
  6. alphabetundefined이면, alphabet"base64"로 설정한다.
  7. alphabet"base64""base64url"도 아니면, TypeError exception을 throw한다.
  8. lastChunkHandling을 ? Get(opts, "lastChunkHandling")으로 둔다.
  9. lastChunkHandlingundefined이면, lastChunkHandling"loose"로 설정한다.
  10. lastChunkHandling"loose", "strict", 또는 "stop-before-partial" 중 하나가 아니면, TypeError exception을 throw한다.
  11. taRecordMakeTypedArrayWithBufferWitnessRecord(into, seq-cst)로 둔다.
  12. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
  13. byteLengthTypedArrayLength(taRecord)로 둔다.
  14. resultFromBase64(string, alphabet, lastChunkHandling, byteLength)로 둔다.
  15. bytesresult.[[Bytes]]로 둔다.
  16. writtenbytes 안의 elements 수로 둔다.
  17. NOTE: FromBase64는 any user code를 invoke하지 않으므로, into를 backing하는 ArrayBuffer는 detached되거나 shrunk되었을 수 없다.
  18. Assert: writtenbyteLength이다.
  19. SetUint8ArrayBytes(into, bytes)를 수행한다.
  20. result.[[Error]]none이 아니면, 다음을 수행한다.
    1. result.[[Error]]를 Throw한다.
  21. resultObjOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  22. CreateDataPropertyOrThrow(resultObj, "read", 𝔽(result.[[Read]]))를 수행한다.
  23. CreateDataPropertyOrThrow(resultObj, "written", 𝔽(written))를 수행한다.
  24. resultObj를 반환한다.

23.3.2.2 Uint8Array.prototype.setFromHex ( string )

  1. intothis value로 둔다.
  2. ValidateUint8Array(into)를 수행한다.
  3. string이 String이 아니면, TypeError exception을 throw한다.
  4. taRecordMakeTypedArrayWithBufferWitnessRecord(into, seq-cst)로 둔다.
  5. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
  6. byteLengthTypedArrayLength(taRecord)로 둔다.
  7. resultFromHex(string, byteLength)로 둔다.
  8. bytesresult.[[Bytes]]로 둔다.
  9. writtenbytes 안의 elements 수로 둔다.
  10. NOTE: FromHex는 any user code를 invoke하지 않으므로, into를 backing하는 ArrayBuffer는 detached되거나 shrunk되었을 수 없다.
  11. Assert: writtenbyteLength이다.
  12. SetUint8ArrayBytes(into, bytes)를 수행한다.
  13. result.[[Error]]none이 아니면, 다음을 수행한다.
    1. result.[[Error]]를 Throw한다.
  14. resultObjOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  15. CreateDataPropertyOrThrow(resultObj, "read", 𝔽(result.[[Read]]))를 수행한다.
  16. CreateDataPropertyOrThrow(resultObj, "written", 𝔽(written))를 수행한다.
  17. resultObj를 반환한다.

23.3.2.3 Uint8Array.prototype.toBase64 ( [ options ] )

  1. objthis value로 둔다.
  2. ValidateUint8Array(obj)를 수행한다.
  3. opts를 ? GetOptionsObject(options)로 둔다.
  4. alphabet을 ? Get(opts, "alphabet")으로 둔다.
  5. alphabetundefined이면, alphabet"base64"로 설정한다.
  6. alphabet"base64""base64url"도 아니면, TypeError exception을 throw한다.
  7. omitPaddingToBoolean(? Get(opts, "omitPadding")))으로 둔다.
  8. toEncode를 ? GetUint8ArrayBytes(obj)로 둔다.
  9. alphabet"base64"이면, 다음을 수행한다.
    1. outAsciiRFC 4648의 section 4에 specified된 base64 encoding에 따라 toEncode를 encoding한 결과인 code points의 sequence로 둔다. Padding은 omitPaddingfalse인 경우에만 included된다.
  10. Else,
    1. Assert: alphabet"base64url"이다.
    2. outAsciiRFC 4648의 section 5에 specified된 base64url encoding에 따라 toEncode를 encoding한 결과인 code points의 sequence로 둔다. Padding은 omitPaddingfalse인 경우에만 included된다.
  11. CodePointsToString(outAscii)를 반환한다.

23.3.2.4 Uint8Array.prototype.toHex ( )

  1. objthis value로 둔다.
  2. ValidateUint8Array(obj)를 수행한다.
  3. toEncode를 ? GetUint8ArrayBytes(obj)로 둔다.
  4. out을 empty String으로 둔다.
  5. toEncode의 각 byte byte에 대해, 다음을 수행한다.
    1. hexNumber::toString(𝔽(byte), 16)으로 둔다.
    2. hexStringPad(hex, 2, "0", start)로 설정한다.
    3. outouthexstring-concatenation으로 설정한다.
  6. out을 반환한다.

23.3.3 Uint8Array Objects용 Abstract Operations

23.3.3.1 ValidateUint8Array ( ta )

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

  1. RequireInternalSlot(ta, [[TypedArrayName]])를 수행한다.
  2. ta.[[TypedArrayName]]"Uint8Array"가 아니면, TypeError exception을 throw한다.
  3. unused를 반환한다.

23.3.3.2 GetUint8ArrayBytes ( ta )

The abstract operation GetUint8ArrayBytes takes argument ta (a Uint8Array) and returns either a normal completion containing a List of byte values or a throw completion. It performs the following steps when called:

  1. bufferta.[[ViewedArrayBuffer]]로 둔다.
  2. taRecordMakeTypedArrayWithBufferWitnessRecord(ta, seq-cst)로 둔다.
  3. IsTypedArrayOutOfBounds(taRecord)가 true이면, TypeError exception을 throw한다.
  4. lengthTypedArrayLength(taRecord)로 둔다.
  5. byteOffsetta.[[ByteOffset]]으로 둔다.
  6. bytes를 새 empty List로 둔다.
  7. index를 0으로 둔다.
  8. Repeat, while index < length,
    1. byteIndexbyteOffset + index로 둔다.
    2. byte(GetValueFromBuffer(buffer, byteIndex, uint8, true, unordered))로 둔다.
    3. bytebytes에 append한다.
    4. indexindex + 1로 설정한다.
  9. bytes를 반환한다.

23.3.3.3 SetUint8ArrayBytes ( into, bytes )

The abstract operation SetUint8ArrayBytes takes arguments into (a Uint8Array) and bytes (a List of byte values) and returns unused. It performs the following steps when called:

  1. offsetinto.[[ByteOffset]]으로 둔다.
  2. lengthbytes 안의 elements 수로 둔다.
  3. index를 0으로 둔다.
  4. Repeat, while index < length,
    1. bytebytes[index]로 둔다.
    2. byteIndexInBufferindex + offset으로 둔다.
    3. SetValueInBuffer(into.[[ViewedArrayBuffer]], byteIndexInBuffer, uint8, 𝔽(byte), true, unordered)를 수행한다.
    4. indexindex + 1로 설정한다.
  5. unused를 반환한다.

23.3.3.4 SkipAsciiWhitespace ( string, index )

The abstract operation SkipAsciiWhitespace takes arguments string (a String) and index (a non-negative integer) and returns a non-negative integer. It performs the following steps when called:

  1. lengthstring의 length로 둔다.
  2. Repeat, while index < length,
    1. charstring 내 index index의 code unit으로 둔다.
    2. char가 0x0009 (TAB), 0x000A (LF), 0x000C (FF), 0x000D (CR), 또는 0x0020 (SPACE) 중 하나가 아니면, 다음을 수행한다.
      1. index를 반환한다.
    3. indexindex + 1로 설정한다.
  3. index를 반환한다.

23.3.3.5 DecodeFinalBase64Chunk ( chunk, throwOnExtraBits )

The abstract operation DecodeFinalBase64Chunk takes arguments chunk (a String of length 2 or 3) and throwOnExtraBits (a Boolean) and returns either a normal completion containing a List of byte values, or a throw completion. It performs the following steps when called:

  1. chunkLengthchunk의 length로 둔다.
  2. chunkLength = 2이면, 다음을 수행한다.
    1. chunkchunk"AA"string-concatenation으로 설정한다.
  3. Else,
    1. Assert: chunkLength는 3이다.
    2. chunkchunk"A"string-concatenation으로 설정한다.
  4. bytesDecodeFullLengthBase64Chunk(chunk)로 둔다.
  5. chunkLength = 2이면, 다음을 수행한다.
    1. throwOnExtraBitstrue이고 bytes[1] ≠ 0이면, SyntaxError exception을 throw한다.
    2. « bytes[0] »를 반환한다.
  6. throwOnExtraBitstrue이고 bytes[2] ≠ 0이면, SyntaxError exception을 throw한다.
  7. « bytes[0], bytes[1] »를 반환한다.

23.3.3.6 DecodeFullLengthBase64Chunk ( chunk )

The abstract operation DecodeFullLengthBase64Chunk takes argument chunk (a String of length 4) and returns a List of byte values of length 3.

standard base64 alphabet"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"입니다. 즉, Unicode Basic Latin block 안의 every letter 및 number에 corresponding하는 code units와 "+""/"를 elements로 가지는 String입니다.

  1. byteSequencechunk를 base64로 decoding하여 resulting되는 unique sequence of 3 bytes로 둔다(즉, byteSequenceRFC 4648의 section 4에 specified된 base64 encoding을 applying하면 chunk를 produce하게 되는 sequence).
  2. elements가 byteSequence의 elements인 List를 order대로 반환한다.

23.3.3.7 FromBase64 ( string, alphabet, lastChunkHandling [ , maxLength ] )

The abstract operation FromBase64 takes arguments string (a String), alphabet ("base64" or "base64url"), and lastChunkHandling ("loose", "strict", or "stop-before-partial") and optional argument maxLength (a non-negative integer) and returns a Record with fields [[Read]] (an integer), [[Bytes]] (a List of byte values), and [[Error]] (a SyntaxError object or none). It performs the following steps when called:

  1. maxLength가 present하지 않으면, 다음을 수행한다.
    1. maxLength를 253 - 1로 설정한다.
    2. NOTE: input이 String이므로, Strings의 length는 253 - 1 characters로 limited되고, output은 input이 가진 characters보다 more bytes를 require하지 않으므로, 이 limit에는 never reached될 수 없다. However, maxLengthfinite value를 사용하는 것이 editorially convenient하다.
  2. NOTE: 아래 algorithm에서 validation 및 decoding의 order는 observable하지 않다. Implementations는 validation을 decoding과 interleaving할 수도 있으며, 가장 efficient한 any order로 them을 수행하도록 encouraged된다.
  3. maxLength = 0이면, 다음을 수행한다.
    1. Record { [[Read]]: 0, [[Bytes]]: « », [[Error]]: none }를 반환한다.
  4. read를 0으로 둔다.
  5. bytes를 새 empty List로 둔다.
  6. chunk를 empty String으로 둔다.
  7. chunkLength를 0으로 둔다.
  8. index를 0으로 둔다.
  9. lengthstring의 length로 둔다.
  10. Repeat,
    1. Assert: bytes 안의 elements 수는 3으로 evenly divisible된다.
    2. indexSkipAsciiWhitespace(string, index)로 설정한다.
    3. index = length이면, 다음을 수행한다.
      1. chunkLength > 0이면, 다음을 수행한다.
        1. lastChunkHandling"stop-before-partial"이면, 다음을 수행한다.
          1. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.
        2. lastChunkHandling"strict"이면, 다음을 수행한다.
          1. error를 newly created SyntaxError object로 둔다.
          2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
        3. Assert: lastChunkHandling"loose"이다.
        4. chunkLength = 1이면, 다음을 수행한다.
          1. error를 newly created SyntaxError object로 둔다.
          2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
        5. bytesbytes와 ! DecodeFinalBase64Chunk(chunk, false)의 list-concatenation으로 설정한다.
      2. Record { [[Read]]: length, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.
    4. charstringindex부터 index + 1까지의 substring으로 둔다.
    5. indexindex + 1로 설정한다.
    6. char"="이면, 다음을 수행한다.
      1. chunkLength < 2이면, 다음을 수행한다.
        1. error를 newly created SyntaxError object로 둔다.
        2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
      2. indexSkipAsciiWhitespace(string, index)로 설정한다.
      3. chunkLength = 2이면, 다음을 수행한다.
        1. index = length이면, 다음을 수행한다.
          1. lastChunkHandling"stop-before-partial"이면, 다음을 수행한다.
            1. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.
          2. error를 newly created SyntaxError object로 둔다.
          3. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
        2. charstringindex부터 index + 1까지의 substring으로 설정한다.
        3. char"="이면, 다음을 수행한다.
          1. indexSkipAsciiWhitespace(string, index + 1)로 설정한다.
      4. index < length이면, 다음을 수행한다.
        1. error를 newly created SyntaxError object로 둔다.
        2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
      5. lastChunkHandling"strict"이면 throwOnExtraBitstrue로 둔다; else throwOnExtraBitsfalse로 둔다.
      6. decodeResultCompletion(DecodeFinalBase64Chunk(chunk, throwOnExtraBits))로 둔다.
      7. decodeResultabrupt completion이면, 다음을 수행한다.
        1. errordecodeResult.[[Value]]로 둔다.
        2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
      8. bytesbytes와 ! decodeResultlist-concatenation으로 설정한다.
      9. Record { [[Read]]: length, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.
    7. alphabet"base64url"이면, 다음을 수행한다.
      1. char"+" 또는 "/" 중 하나이면, 다음을 수행한다.
        1. error를 newly created SyntaxError object로 둔다.
        2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
      2. Else if char"-"이면, 다음을 수행한다.
        1. char"+"로 설정한다.
      3. Else if char"_"이면, 다음을 수행한다.
        1. char"/"로 설정한다.
    8. char의 sole code unit이 standard base64 alphabet의 element가 아니면, 다음을 수행한다.
      1. error를 newly created SyntaxError object로 둔다.
      2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
    9. remainingmaxLength - bytes 안의 elements 수로 둔다.
    10. remaining = 1이고 chunkLength = 2이면, 또는 remaining = 2이고 chunkLength = 3이면, 다음을 수행한다.
      1. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.
    11. chunkchunkcharstring-concatenation으로 설정한다.
    12. chunkLengthchunk의 length로 설정한다.
    13. chunkLength = 4이면, 다음을 수행한다.
      1. bytesbytesDecodeFullLengthBase64Chunk(chunk)의 list-concatenation으로 설정한다.
      2. chunk를 empty String으로 설정한다.
      3. chunkLength를 0으로 설정한다.
      4. readindex로 설정한다.
      5. bytes 안의 elements 수 = maxLength이면, 다음을 수행한다.
        1. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.

23.3.3.8 FromHex ( string [ , maxLength ] )

The abstract operation FromHex takes argument string (a String) and optional argument maxLength (a non-negative integer) and returns a Record with fields [[Read]] (an integer), [[Bytes]] (a List of byte values), and [[Error]] (a SyntaxError object or none). It performs the following steps when called:

  1. maxLength가 present하지 않으면, maxLength를 253 - 1로 설정한다.
  2. lengthstring의 length로 둔다.
  3. bytes를 새 empty List로 둔다.
  4. read를 0으로 둔다.
  5. length modulo 2 ≠ 0이면, 다음을 수행한다.
    1. error를 newly created SyntaxError object로 둔다.
    2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
  6. Repeat, while read < length and the number of elements in bytes < maxLength,
    1. hexitsstringread부터 read + 2까지의 substring으로 둔다.
    2. hexits"0123456789abcdefABCDEF" 안에 있지 않은 any code units를 contain하면, 다음을 수행한다.
      1. error를 newly created SyntaxError object로 둔다.
      2. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: error }를 반환한다.
    3. readread + 2로 설정한다.
    4. byte를 values 10부터 15까지의 digits에 대해 letters A through Fa through f를 사용하여, base-16 notation에서 hexits가 represented하는 integer value로 둔다.
    5. bytebytes에 append한다.
  7. Record { [[Read]]: read, [[Bytes]]: bytes, [[Error]]: none }를 반환한다.