페이지 표시 설정

10 일반 객체와 특수 객체의 동작

10.1 일반 객체 내부 메서드와 내부 슬롯

모든 일반 객체에는 [[Prototype]]이라는 내부 슬롯이 있습니다. 이 내부 슬롯의 값은 null 또는 객체이며 상속을 구현하는 데 사용됩니다. propertyKey라는 이름의 프로퍼티가 일반 객체 obj에는 없지만 해당 [[Prototype]] 객체에는 존재한다고 가정합니다. propertyKey가 [[Prototype]] 객체의 데이터 프로퍼티를 참조하면 obj는 get 접근을 위해 이를 상속하며, propertyKey가 obj의 프로퍼티인 것처럼 동작합니다. propertyKey가 [[Prototype]] 객체의 쓰기 가능한 데이터 프로퍼티를 참조하면 obj에서 propertyKey에 대한 set 접근은 obj에 propertyKey라는 이름의 새로운 데이터 프로퍼티를 생성합니다. propertyKey가 [[Prototype]] 객체의 쓰기 불가능한 데이터 프로퍼티를 참조하면 obj에서 propertyKey에 대한 set 접근은 실패합니다. propertyKey가 [[Prototype]] 객체의 접근자 프로퍼티를 참조하면 해당 접근자는 get 접근과 set 접근 모두에 대해 obj에 상속됩니다.

모든 일반 객체에는 Boolean 값을 갖는 [[Extensible]] 내부 슬롯이 있으며, 이는 6.1.7.3에 명시된 확장 가능성과 관련된 내부 메서드 불변 조건을 충족하는 데 사용됩니다. 즉, 객체의 [[Extensible]] 내부 슬롯 값이 false로 설정되고 나면 더 이상 객체에 프로퍼티를 추가하거나, 객체의 [[Prototype]] 내부 슬롯 값을 수정하거나, 이후 [[Extensible]] 값을 true로 변경할 수 없습니다.

다음 알고리즘 설명에서는 obj가 일반 객체이고, propertyKey가 프로퍼티 키 값이며, value가 임의의 ECMAScript 언어 값이고, propertyDesc가 Property Descriptor Record라고 가정합니다.

각 일반 객체 내부 메서드는 이름이 유사한 추상 연산에 위임합니다. 그러한 추상 연산이 다른 내부 메서드에 의존하면 이름이 유사한 추상 연산을 직접 호출하는 대신 obj에서 내부 메서드를 호출합니다. 이러한 의미론은 일반 객체 내부 메서드가 특수 객체에 적용될 때 해당 특수 객체에서 재정의된 내부 메서드가 호출되도록 보장합니다.

10.1.1 [[GetPrototypeOf]] ( )

an ordinary object obj의 내부 메서드 [[GetPrototypeOf]]. 인수 없음. 반환값: 정상 완료 (값: (Object 또는 null)). 호출되면 다음 단계를 수행한다.

  1. OrdinaryGetPrototypeOf(obj)를 반환합니다.

10.1.1.1 OrdinaryGetPrototypeOf ( obj )

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

  1. obj.[[Prototype]]을 반환합니다.

10.1.2 [[SetPrototypeOf]] ( proto )

an ordinary object obj의 내부 메서드 [[SetPrototypeOf]]. 인수 proto ((Object 또는 null)). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. OrdinarySetPrototypeOf(obj, proto)를 반환합니다.

10.1.2.1 OrdinarySetPrototypeOf ( obj, proto )

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

  1. current를 obj.[[Prototype]]으로 둡니다.
  2. SameValue(proto, current)가 true이면, true를 반환합니다.
  3. extensible을 obj.[[Extensible]]로 둡니다.
  4. extensible이 false이면, false를 반환합니다.
  5. cursor를 proto로 둡니다.
  6. done을 false로 둡니다.
  7. done이 false인 동안 다음을 반복합니다.
    1. cursor가 null이면, 다음을 수행합니다.
      1. done을 true로 설정합니다.
    2. 그렇지 않고 SameValue(cursor, obj)가 true이면, 다음을 수행합니다.
      1. false를 반환합니다.
    3. 그렇지 않으면,
      1. cursor.[[GetPrototypeOf]]가 10.1.1에 정의된 일반 객체 내부 메서드가 아니면 done을 true로 설정합니다.
      2. 그렇지 않으면 cursor를 cursor.[[Prototype]]으로 설정합니다.
  8. obj.[[Prototype]]을 proto로 설정합니다.
  9. true를 반환합니다.
참고

7 단계의 반복은 [[GetPrototypeOf]] 및 [[SetPrototypeOf]]에 일반 객체 정의만 사용하는 객체로 이루어진 모든 프로토타입 체인에 순환이 생기지 않도록 보장합니다.

10.1.3 [[IsExtensible]] ( )

an ordinary object obj의 내부 메서드 [[IsExtensible]]. 인수 없음. 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. OrdinaryIsExtensible(obj)를 반환합니다.

10.1.3.1 OrdinaryIsExtensible ( obj )

추상 연산 OrdinaryIsExtensible. 인수 obj (Object). 반환값: Boolean. 호출되면 다음 단계를 수행한다.

  1. obj.[[Extensible]]을 반환합니다.

10.1.4 [[PreventExtensions]] ( )

an ordinary object obj의 내부 메서드 [[PreventExtensions]]. 인수 없음. 반환값: 정상 완료 (값: true). 호출되면 다음 단계를 수행한다.

  1. OrdinaryPreventExtensions(obj)를 반환합니다.

10.1.4.1 OrdinaryPreventExtensions ( obj )

추상 연산 OrdinaryPreventExtensions. 인수 obj (Object). 반환값: true. 호출되면 다음 단계를 수행한다.

  1. obj.[[Extensible]]을 false로 설정합니다.
  2. true를 반환합니다.

10.1.5 [[GetOwnProperty]] ( propertyKey )

an ordinary object obj의 내부 메서드 [[GetOwnProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: 정상 완료 (값: (프로퍼티 서술자 또는 undefined)). 호출되면 다음 단계를 수행한다.

  1. OrdinaryGetOwnProperty(obj, propertyKey)를 반환합니다.

10.1.5.1 OrdinaryGetOwnProperty ( obj, propertyKey )

추상 연산 OrdinaryGetOwnProperty. 인수 obj (Object) 및 propertyKey (프로퍼티 키). 반환값: (프로퍼티 서술자 또는 undefined). 호출되면 다음 단계를 수행한다.

  1. obj에 키가 propertyKey인 자체 프로퍼티가 없으면, undefined를 반환합니다.
  2. propertyDesc를 필드가 없는 새로 생성된 Property Descriptor로 둡니다.
  3. ownProperty를 키가 propertyKey인 obj의 자체 프로퍼티로 둡니다.
  4. ownProperty가 데이터 프로퍼티이면, 다음을 수행합니다.
    1. propertyDesc.[[Value]]를 ownProperty의 [[Value]] 속성 값으로 설정합니다.
    2. propertyDesc.[[Writable]]을 ownProperty의 [[Writable]] 속성 값으로 설정합니다.
  5. 그렇지 않으면,
    1. 단언: ownProperty는 접근자 프로퍼티입니다.
    2. propertyDesc.[[Getter]]를 ownProperty의 [[Getter]] 속성 값으로 설정합니다.
    3. propertyDesc.[[Setter]]를 ownProperty의 [[Setter]] 속성 값으로 설정합니다.
  6. propertyDesc.[[Enumerable]]을 ownProperty의 [[Enumerable]] 속성 값으로 설정합니다.
  7. propertyDesc.[[Configurable]]을 ownProperty의 [[Configurable]] 속성 값으로 설정합니다.
  8. propertyDesc를 반환합니다.

10.1.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

an ordinary object obj의 내부 메서드 [[DefineOwnProperty]]. 인수 propertyKey (프로퍼티 키) 및 propertyDesc (프로퍼티 서술자). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? OrdinaryDefineOwnProperty(obj, propertyKey, propertyDesc)를 반환합니다.

10.1.6.1 OrdinaryDefineOwnProperty ( obj, propertyKey, propertyDesc )

추상 연산 OrdinaryDefineOwnProperty. 인수 obj (Object), propertyKey (프로퍼티 키) 및 propertyDesc (프로퍼티 서술자). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. current를 ? obj.[[GetOwnProperty]](propertyKey)로 둡니다.
  2. extensible을 ? IsExtensible(obj)로 둡니다.
  3. ValidateAndApplyPropertyDescriptor(obj, propertyKey, extensible, propertyDesc, current)를 반환합니다.

10.1.6.2 IsCompatiblePropertyDescriptor ( extensible, propertyDesc, current )

추상 연산 IsCompatiblePropertyDescriptor. 인수 extensible (Boolean), propertyDesc (프로퍼티 서술자) 및 current ((프로퍼티 서술자 또는 undefined)). 반환값: Boolean. 호출되면 다음 단계를 수행한다.

  1. ValidateAndApplyPropertyDescriptor(undefined, "", extensible, propertyDesc, current)를 반환합니다.

10.1.6.3 ValidateAndApplyPropertyDescriptor ( obj, propertyKey, extensible, propertyDesc, current )

추상 연산 ValidateAndApplyPropertyDescriptor. 인수 obj ((Object 또는 undefined)), propertyKey (프로퍼티 키), extensible (Boolean), propertyDesc (프로퍼티 서술자) 및 current ((프로퍼티 서술자 또는 undefined)). 반환값: Boolean. 지정된 extensibility와 현재 프로퍼티 current를 갖는 객체의 프로퍼티로 propertyDesc를 적용하면서 불변 조건을 유지할 수 있는 경우에만 true를 반환합니다. 이러한 적용이 가능하고 obj가 undefined가 아니면 propertyKey라는 이름의 프로퍼티에 적용하며, 필요한 경우 해당 프로퍼티를 생성합니다. 호출되면 다음 단계를 수행한다.

  1. 단언: propertyKey는 프로퍼티 키입니다.
  2. current가 undefined이면, 다음을 수행합니다.
    1. extensible이 false이면, false를 반환합니다.
    2. obj가 undefined이면, true를 반환합니다.
    3. IsAccessorDescriptor(propertyDesc)가 true이면, 다음을 수행합니다.
      1. 객체 obj에 propertyKey라는 이름의 자체 접근자 프로퍼티를 생성합니다. 해당 프로퍼티의 [[Getter]], [[Setter]], [[Enumerable]] 및 [[Configurable]] 속성은 propertyDesc에 대응하는 필드가 있으면 해당 필드 값으로 설정하고, 그렇지 않으면 해당 속성의 기본값으로 설정합니다.
    4. 그렇지 않으면,
      1. 객체 obj에 propertyKey라는 이름의 자체 데이터 프로퍼티를 생성합니다. 해당 프로퍼티의 [[Value]], [[Writable]], [[Enumerable]] 및 [[Configurable]] 속성은 propertyDesc에 대응하는 필드가 있으면 해당 필드 값으로 설정하고, 그렇지 않으면 해당 속성의 기본값으로 설정합니다.
    5. true를 반환합니다.
  3. 단언: current는 모든 필드가 채워진 Property Descriptor입니다.
  4. propertyDesc에 필드가 하나도 없으면, true를 반환합니다.
  5. current.[[Configurable]]이 false이면, 다음을 수행합니다.
    1. propertyDesc에 [[Configurable]] 필드가 있고 propertyDesc.[[Configurable]]이 true이면, false를 반환합니다.
    2. propertyDesc에 [[Enumerable]] 필드가 있고 propertyDesc.[[Enumerable]]이 current.[[Enumerable]]과 다르면, false를 반환합니다.
    3. IsGenericDescriptor(propertyDesc)가 false이고 IsAccessorDescriptor(propertyDesc)가 IsAccessorDescriptor(current)와 다르면, false를 반환합니다.
    4. IsAccessorDescriptor(current)가 true이면, 다음을 수행합니다.
      1. propertyDesc에 [[Getter]] 필드가 있고 SameValue(propertyDesc.[[Getter]], current.[[Getter]])가 false이면, false를 반환합니다.
      2. propertyDesc에 [[Setter]] 필드가 있고 SameValue(propertyDesc.[[Setter]], current.[[Setter]])가 false이면, false를 반환합니다.
    5. 그렇지 않고 current.[[Writable]]이 false이면, 다음을 수행합니다.
      1. propertyDesc에 [[Writable]] 필드가 있고 propertyDesc.[[Writable]]이 true이면, false를 반환합니다.
      2. 참고: SameValue는 다른 방법으로 구별될 수 있는 NaN 값에 대해 true를 반환합니다. 여기에서 반환하면 obj의 기존 프로퍼티가 수정되지 않도록 보장합니다.
      3. propertyDesc에 [[Value]] 필드가 있으면, SameValue(propertyDesc.[[Value]], current.[[Value]])를 반환합니다.
  6. obj가 undefined가 아니면, 다음을 수행합니다.
    1. IsDataDescriptor(current)가 true이고 IsAccessorDescriptor(propertyDesc)가 true이면, 다음을 수행합니다.
      1. propertyDesc에 [[Configurable]] 필드가 있으면 configurable을 propertyDesc.[[Configurable]]로 둡니다. 그렇지 않으면 configurable을 current.[[Configurable]]로 둡니다.
      2. propertyDesc에 [[Enumerable]] 필드가 있으면 enumerable을 propertyDesc.[[Enumerable]]로 둡니다. 그렇지 않으면 enumerable을 current.[[Enumerable]]로 둡니다.
      3. 객체 obj에서 propertyKey라는 이름의 프로퍼티를 접근자 프로퍼티로 교체합니다. 해당 프로퍼티의 [[Configurable]] 및 [[Enumerable]] 속성은 각각 configurable 및 enumerable로 설정하고, [[Getter]] 및 [[Setter]] 속성은 propertyDesc에 대응하는 필드가 있으면 해당 필드 값으로 설정하며, 그렇지 않으면 해당 속성의 기본값으로 설정합니다.
    2. 그렇지 않고 IsAccessorDescriptor(current)가 true이고 IsDataDescriptor(propertyDesc)가 true이면, 다음을 수행합니다.
      1. propertyDesc에 [[Configurable]] 필드가 있으면 configurable을 propertyDesc.[[Configurable]]로 둡니다. 그렇지 않으면 configurable을 current.[[Configurable]]로 둡니다.
      2. propertyDesc에 [[Enumerable]] 필드가 있으면 enumerable을 propertyDesc.[[Enumerable]]로 둡니다. 그렇지 않으면 enumerable을 current.[[Enumerable]]로 둡니다.
      3. 객체 obj에서 propertyKey라는 이름의 프로퍼티를 데이터 프로퍼티로 교체합니다. 해당 프로퍼티의 [[Configurable]] 및 [[Enumerable]] 속성은 각각 configurable 및 enumerable로 설정하고, [[Value]] 및 [[Writable]] 속성은 propertyDesc에 대응하는 필드가 있으면 해당 필드 값으로 설정하며, 그렇지 않으면 해당 속성의 기본값으로 설정합니다.
    3. 그렇지 않으면,
      1. propertyDesc의 각 필드 이름 fieldName에 대해 객체 obj에서 propertyKey라는 이름의 프로퍼티에 있는 fieldName이라는 이름의 속성을 propertyDesc의 fieldName 필드 값으로 설정합니다.
  7. true를 반환합니다.

10.1.7 [[HasProperty]] ( propertyKey )

an ordinary object obj의 내부 메서드 [[HasProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? OrdinaryHasProperty(obj, propertyKey)를 반환합니다.

10.1.7.1 OrdinaryHasProperty ( obj, propertyKey )

추상 연산 OrdinaryHasProperty. 인수 obj (Object) 및 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. hasOwn을 ? obj.[[GetOwnProperty]](propertyKey)로 둡니다.
  2. hasOwn이 undefined가 아니면, true를 반환합니다.
  3. parent를 ? obj.[[GetPrototypeOf]]()로 둡니다.
  4. parent가 null이 아니면, 다음을 수행합니다.
    1. ? parent.[[HasProperty]](propertyKey)를 반환합니다.
  5. false를 반환합니다.

10.1.8 [[Get]] ( propertyKey, receiver )

an ordinary object obj의 내부 메서드 [[Get]]. 인수 propertyKey (프로퍼티 키) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? OrdinaryGet(obj, propertyKey, receiver)를 반환합니다.

10.1.8.1 OrdinaryGet ( obj, propertyKey, receiver )

추상 연산 OrdinaryGet. 인수 obj (Object), propertyKey (프로퍼티 키) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둡니다.
  2. propertyDesc가 undefined이면, 다음을 수행합니다.
    1. parent를 ? obj.[[GetPrototypeOf]]()로 둡니다.
    2. parent가 null이면, undefined를 반환합니다.
    3. ? parent.[[Get]](propertyKey, receiver)를 반환합니다.
  3. IsDataDescriptor(propertyDesc)가 true이면, propertyDesc.[[Value]]를 반환합니다.
  4. 단언: IsAccessorDescriptor(propertyDesc)는 true입니다.
  5. getter를 propertyDesc.[[Getter]]로 둡니다.
  6. getter가 undefined이면, undefined를 반환합니다.
  7. ? Call(getter, receiver)를 반환합니다.

10.1.9 [[Set]] ( propertyKey, value, receiver )

an ordinary object obj의 내부 메서드 [[Set]]. 인수 propertyKey (프로퍼티 키), value (ECMAScript 언어 값) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? OrdinarySet(obj, propertyKey, value, receiver)를 반환합니다.

10.1.9.1 OrdinarySet ( obj, propertyKey, value, receiver )

추상 연산 OrdinarySet. 인수 obj (Object), propertyKey (프로퍼티 키), value (ECMAScript 언어 값) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ownDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둡니다.
  2. ? OrdinarySetWithOwnDescriptor(obj, propertyKey, value, receiver, ownDesc)를 반환합니다.

10.1.9.2 OrdinarySetWithOwnDescriptor ( obj, propertyKey, value, receiver, ownDesc )

추상 연산 OrdinarySetWithOwnDescriptor. 인수 obj (Object), propertyKey (프로퍼티 키), value (ECMAScript 언어 값), receiver (ECMAScript 언어 값) 및 ownDesc ((프로퍼티 서술자 또는 undefined)). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ownDesc가 undefined이면, 다음을 수행합니다.
    1. parent를 ? obj.[[GetPrototypeOf]]()로 둡니다.
    2. parent가 null이 아니면, ? parent.[[Set]](propertyKey, value, receiver)를 반환합니다.
    3. ownDesc를 PropertyDescriptor { [[Value]]: undefined, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }로 설정합니다.
  2. IsDataDescriptor(ownDesc)가 true이면, 다음을 수행합니다.
    1. ownDesc.[[Writable]]이 false이면, false를 반환합니다.
    2. receiver가 Object가 아니면, false를 반환합니다.
    3. existingDesc를 ? receiver.[[GetOwnProperty]](propertyKey)로 둡니다.
    4. existingDesc가 undefined이면, 다음을 수행합니다.
      1. 단언: receiver에는 현재 프로퍼티 propertyKey가 없습니다.
      2. ? CreateDataProperty(receiver, propertyKey, value)를 반환합니다.
    5. IsAccessorDescriptor(existingDesc)가 true이면, false를 반환합니다.
    6. existingDesc.[[Writable]]이 false이면, false를 반환합니다.
    7. valueDesc를 PropertyDescriptor { [[Value]]: value }로 둡니다.
    8. ? receiver.[[DefineOwnProperty]](propertyKey, valueDesc)를 반환합니다.
  3. 단언: IsAccessorDescriptor(ownDesc)는 true입니다.
  4. setter를 ownDesc.[[Setter]]로 둡니다.
  5. setter가 undefined이면, false를 반환합니다.
  6. ? Call(setter, receiver, « value »)를 수행합니다.
  7. true를 반환합니다.

10.1.10 [[Delete]] ( propertyKey )

an ordinary object obj의 내부 메서드 [[Delete]]. 인수 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? OrdinaryDelete(obj, propertyKey)를 반환합니다.

10.1.10.1 OrdinaryDelete ( obj, propertyKey )

추상 연산 OrdinaryDelete. 인수 obj (Object) 및 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둡니다.
  2. propertyDesc가 undefined이면, true를 반환합니다.
  3. propertyDesc.[[Configurable]]이 true이면, 다음을 수행합니다.
    1. obj에서 이름이 propertyKey인 자체 프로퍼티를 제거합니다.
    2. true를 반환합니다.
  4. false를 반환합니다.

10.1.11 [[OwnPropertyKeys]] ( )

an ordinary object obj의 내부 메서드 [[OwnPropertyKeys]]. 인수 없음. 반환값: 정상 완료 (값: 리스트 (요소: 프로퍼티 키)). 호출되면 다음 단계를 수행한다.

  1. OrdinaryOwnPropertyKeys(obj)를 반환합니다.

10.1.11.1 OrdinaryOwnPropertyKeys ( obj )

추상 연산 OrdinaryOwnPropertyKeys. 인수 obj (Object). 반환값: 리스트 (요소: 프로퍼티 키). 호출되면 다음 단계를 수행한다.

  1. keys를 새로운 빈 List로 둡니다.
  2. 배열 인덱스인 obj의 각 자체 프로퍼티 키 propertyKey에 대해 숫자 인덱스 오름차순으로 다음을 수행합니다.
    1. propertyKey를 keys에 추가합니다.
  3. String이고 배열 인덱스가 아닌 obj의 각 자체 프로퍼티 키 propertyKey에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.
    1. propertyKey를 keys에 추가합니다.
  4. Symbol인 obj의 각 자체 프로퍼티 키 propertyKey에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.
    1. propertyKey를 keys에 추가합니다.
  5. keys를 반환합니다.

10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] )

추상 연산 OrdinaryObjectCreate. 인수 proto ((Object 또는 null)) 및 선택적 인수 additionalInternalSlotsList (리스트 (요소: 내부 슬롯 이름)). 반환값: Object. 새로운 일반 객체의 런타임 생성을 명시하는 데 사용됩니다. additionalInternalSlotsList에는 [[Prototype]] 및 [[Extensible]] 외에 객체의 일부로 정의해야 하는 추가 내부 슬롯의 이름이 포함됩니다. additionalInternalSlotsList가 제공되지 않으면 새로운 빈 List를 사용합니다. 호출되면 다음 단계를 수행한다.

  1. internalSlotsList를 « [[Prototype]], [[Extensible]] »로 둡니다.
  2. additionalInternalSlotsList가 존재하면 internalSlotsList를 internalSlotsList와 additionalInternalSlotsList의 목록 연결로 설정합니다.
  3. obj를 MakeBasicObject(internalSlotsList)로 둡니다.
  4. obj.[[Prototype]]을 proto로 설정합니다.
  5. obj를 반환합니다.
참고

OrdinaryObjectCreate는 MakeBasicObject를 호출하는 것 이상을 거의 수행하지 않지만, 이를 사용하면 특수 객체가 아니라 일반 객체를 생성하려는 의도가 전달됩니다. 따라서 이 명세에서는 이후 객체의 내부 메서드를 결과가 일반 객체가 아니게 되는 방식으로 수정하는 알고리즘에서 이를 호출하지 않습니다. 특수 객체를 생성하는 연산은 MakeBasicObject를 직접 호출합니다.

10.1.13 OrdinaryCreateFromConstructor ( ctor, intrinsicDefaultProto [ , internalSlotsList ] )

추상 연산 OrdinaryCreateFromConstructor. 인수 ctor (함수 객체) 및 intrinsicDefaultProto (String) 및 선택적 인수 internalSlotsList (리스트 (요소: 내부 슬롯 이름)). 반환값: (정상 완료 (값: Object) 또는 throw 완료). 생성자의 "prototype" 속성이 존재하면 해당 속성에서 [[Prototype]] 값을 가져오고, 그렇지 않으면 생성자의 영역에서 intrinsicDefaultProto로 지정된 내장 객체를 [[Prototype]] 값으로 사용하는 일반 객체를 생성합니다. internalSlotsList에는 해당 객체의 일부로 정의해야 하는 추가 내부 슬롯의 이름이 포함됩니다. 호출되면 다음 단계를 수행한다.

  1. 단언: intrinsicDefaultProto는 이 명세에서 내재 객체에 사용하는 이름입니다. 대응하는 객체는 객체의 [[Prototype]] 값으로 사용하도록 의도된 내재 객체여야 합니다.
  2. proto를 ? GetPrototypeFromConstructor(ctor, intrinsicDefaultProto)로 둡니다.
  3. internalSlotsList가 존재하면 slots를 internalSlotsList로 둡니다.
  4. 그렇지 않으면 slots를 새로운 빈 List로 둡니다.
  5. OrdinaryObjectCreate(proto, slots)를 반환합니다.

10.1.14 GetPrototypeFromConstructor ( ctor, intrinsicDefaultProto )

추상 연산 GetPrototypeFromConstructor. 인수 ctor (함수 객체) 및 intrinsicDefaultProto (String). 반환값: (정상 완료 (값: Object) 또는 throw 완료). 특정 생성자를 사용하여 생성된 객체에 사용해야 하는 [[Prototype]] 값을 결정합니다. 생성자의 "prototype" 속성이 존재하면 해당 속성에서 값을 가져옵니다. 그렇지 않으면 생성자의 영역에서 intrinsicDefaultProto로 지정된 내장 객체를 사용합니다. 호출되면 다음 단계를 수행한다.

  1. 단언: intrinsicDefaultProto는 이 명세에서 정의한 내장 객체의 이름입니다. 해당 객체는 객체의 [[Prototype]] 값으로 사용하도록 의도된 내장 객체여야 합니다.
  2. proto를 ? Get(ctor, "prototype")으로 설정합니다.
  3. proto가 Object이면 proto를 반환합니다.
  4. 참고: ctor의 영역에서 가져온 대체 값은 현재 실행 중인 실행 컨텍스트와 무관합니다.
  5. realm을 ? GetFunctionRealm(ctor)으로 설정합니다.
  6. realm.[[Intrinsics]]에서 intrinsicDefaultProto로 식별되는 필드의 값을 반환합니다.

10.1.15 RequireInternalSlot ( obj, internalSlot )

추상 연산 RequireInternalSlot. 인수 obj (ECMAScript 언어 값) 및 internalSlot (내부 슬롯 이름). 반환값: (정상 완료 (값: unused) 또는 throw 완료). obj가 Object이고 주어진 내부 슬롯을 갖는 경우가 아니면 예외를 던집니다. 호출되면 다음 단계를 수행한다.

  1. obj가 Object가 아니면, TypeError 예외를 던집니다.
  2. obj에 internalSlot 내부 슬롯이 없으면, TypeError 예외를 던집니다.
  3. unused를 반환합니다.

10.2 ECMAScript 함수 객체

ECMAScript 함수 객체는 렉시컬 환경을 클로저로 캡처한 매개변수화된 ECMAScript 코드를 캡슐화하고 해당 코드의 동적 평가를 지원합니다. ECMAScript 함수 객체는 일반 객체이며 다른 일반 객체와 동일한 내부 슬롯과 내부 메서드를 갖습니다. ECMAScript 함수 객체의 코드는 엄격 모드 코드(11.2.2)이거나 비엄격 코드일 수 있습니다. 코드가 엄격 모드 코드인 ECMAScript 함수 객체를 엄격 함수라고 합니다. 코드가 엄격 모드 코드가 아닌 함수 객체를 비엄격 함수라고 합니다.

[[Extensible]] 및 [[Prototype]] 외에도 ECMAScript 함수 객체에는 표 26에 나열된 내부 슬롯이 있습니다.

표 26: ECMAScript 함수 객체의 내부 슬롯
내부 슬롯 타입 설명
[[Environment]] Environment Record 함수가 클로저로 캡처한 Environment Record입니다. 함수 코드를 평가할 때 바깥쪽 환경으로 사용됩니다.
[[PrivateEnvironment]] PrivateEnvironment Record 또는 null 함수가 클로저로 캡처한 Private Name에 대한 PrivateEnvironment Record입니다. 이 함수가 구문상 클래스 내부에 포함되지 않으면 null입니다. 함수 코드를 평가할 때 내부 클래스의 바깥쪽 PrivateEnvironment로 사용됩니다.
[[FormalParameters]] Parse Node 함수의 형식 매개변수 목록을 정의하는 소스 텍스트의 루트 Parse Node입니다.
[[ECMAScriptCode]] Parse Node 함수 본문을 정의하는 소스 텍스트의 루트 Parse Node입니다.
[[ConstructorKind]] base 또는 derived 함수가 파생 클래스 생성자인지를 나타냅니다.
[[Realm]] Realm Record 함수가 생성된 realm이며 함수 평가 중 접근하는 모든 내재 객체를 제공합니다.
[[ScriptOrModule]] Script Record 또는 Module Record 함수가 생성된 스크립트 또는 모듈입니다.
[[ThisMode]] lexical, strict 또는 global 함수의 형식 매개변수와 코드 본문 내에서 this 참조를 해석하는 방법을 정의합니다. lexical은 this가 렉시컬하게 둘러싸는 함수의 this 값을 참조함을 의미합니다. strict는 함수 호출에서 제공된 this 값을 정확히 그대로 사용함을 의미합니다. global은 undefined 또는 null인 this 값을 전역 객체에 대한 참조로 해석하고, 그 밖의 모든 this 값은 먼저 ToObject에 전달함을 의미합니다.
[[Strict]] Boolean 엄격 함수이면 true, 비엄격 함수이면 false입니다.
[[HomeObject]] Object 또는 undefined 함수가 super를 사용하면 이는 [[GetPrototypeOf]]가 super 프로퍼티 조회를 시작할 객체를 제공하는 객체입니다.
[[SourceText]] 유니코드 코드 포인트 시퀀스 함수를 정의하는 소스 텍스트입니다.
[[Fields]] ClassFieldDefinition Record의 List 함수가 클래스이면 클래스의 비정적 필드와 대응하는 이니셜라이저를 나타내는 Record의 목록입니다.
[[PrivateMethods]] PrivateElement의 List 함수가 클래스이면 클래스의 비정적 비공개 메서드와 접근자를 나타내는 목록입니다.
[[ClassFieldInitializerName]] String, Symbol, Private Name 또는 empty 함수가 클래스 필드의 이니셜라이저로 생성되었으면 해당 필드의 NamedEvaluation에 사용할 이름이고, 그렇지 않으면 empty입니다.
[[IsClassConstructor]] Boolean 함수가 클래스 생성자인지를 나타냅니다. (true이면 함수의 [[Call]]을 호출하면 즉시 TypeError 예외를 던집니다.)

모든 ECMAScript 함수 객체에는 여기에 정의된 [[Call]] 내부 메서드가 있습니다. 생성자이기도 한 ECMAScript 함수에는 추가로 [[Construct]] 내부 메서드가 있습니다.

10.2.1 [[Call]] ( thisArg, argList )

an ECMAScript function object func의 내부 메서드 [[Call]]. 인수 thisArg (ECMAScript 언어 값) 및 argList (리스트 (요소: ECMAScript 언어 값)). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. callerContext를 실행 중인 실행 컨텍스트로 둡니다.
  2. calleeContext를 PrepareForOrdinaryCall(func, undefined)로 둡니다.
  3. 단언: 이제 calleeContext가 실행 중인 실행 컨텍스트입니다.
  4. func.[[IsClassConstructor]]가 true이면, 다음을 수행합니다.
    1. error를 새로 생성된 TypeError 객체로 둡니다.
    2. 참고: error는 func와 연결된 Realm Record를 사용하여 calleeContext에서 생성됩니다.
    3. 실행 컨텍스트 스택에서 calleeContext를 제거하고 callerContext를 실행 중인 실행 컨텍스트로 복원합니다.
    4. error를 던집니다.
  5. OrdinaryCallBindThis(func, calleeContext, thisArg)를 수행합니다.
  6. result를 Completion(OrdinaryCallEvaluateBody(func, argList))로 둡니다.
  7. 실행 컨텍스트 스택에서 calleeContext를 제거하고 callerContext를 실행 중인 실행 컨텍스트로 복원합니다.
  8. result가 throw 완료이면, ? result를 반환합니다.
  9. 단언: result는 return 완료입니다.
  10. result.[[Value]]를 반환합니다.
참고

7 단계에서 calleeContext가 실행 컨텍스트 스택에서 제거될 때, 접근 가능한 Generator에 의해 일시 중단되고 이후 재개를 위해 유지되고 있다면 파기해서는 안 됩니다.

10.2.1.1 PrepareForOrdinaryCall ( func, newTarget )

추상 연산 PrepareForOrdinaryCall. 인수 func (ECMAScript 함수 객체) 및 newTarget ((Object 또는 undefined)). 반환값: 실행 컨텍스트. 호출되면 다음 단계를 수행한다.

  1. callerContext를 실행 중인 실행 컨텍스트로 둡니다.
  2. calleeContext를 새로운 ECMAScript 코드 실행 컨텍스트로 둡니다.
  3. calleeContext의 Function을 func로 설정합니다.
  4. calleeRealm을 func.[[Realm]]로 둡니다.
  5. calleeContext의 Realm을 calleeRealm로 설정합니다.
  6. calleeContext의 ScriptOrModule을 func.[[ScriptOrModule]]로 설정합니다.
  7. localEnv를 NewFunctionEnvironment(func, newTarget)으로 둡니다.
  8. calleeContext의 LexicalEnvironment를 localEnv로 설정합니다.
  9. calleeContext의 VariableEnvironment를 localEnv로 설정합니다.
  10. calleeContext의 PrivateEnvironment를 func.[[PrivateEnvironment]]로 설정합니다.
  11. callerContext가 아직 일시 중단되지 않았으면 callerContext를 일시 중단합니다.
  12. calleeContext를 실행 컨텍스트 스택에 푸시합니다. 이제 calleeContext가 실행 중인 실행 컨텍스트입니다.
  13. 참고: 이 시점 이후 생성되는 모든 예외 객체는 calleeRealm과 연결됩니다.
  14. calleeContext를 반환합니다.

10.2.1.2 OrdinaryCallBindThis ( func, calleeContext, thisArg )

추상 연산 OrdinaryCallBindThis. 인수 func (ECMAScript 함수 객체), calleeContext (실행 컨텍스트) 및 thisArg (ECMAScript 언어 값). 반환값: unused. 호출되면 다음 단계를 수행한다.

  1. thisMode를 func.[[ThisMode]]로 둡니다.
  2. thisMode가 lexical이면, unused를 반환합니다.
  3. calleeRealm을 func.[[Realm]]로 둡니다.
  4. localEnv를 calleeContext의 LexicalEnvironment로 둡니다.
  5. thisMode가 strict이면, 다음을 수행합니다.
    1. thisValue를 thisArg로 둡니다.
  6. 그렇지 않으면,
    1. thisArg가 undefined 또는 null이면, 다음을 수행합니다.
      1. globalEnv를 calleeRealm.[[GlobalEnv]]로 둡니다.
      2. 단언: globalEnv는 Global Environment Record입니다.
      3. thisValue를 globalEnv.[[GlobalThisValue]]로 둡니다.
    2. 그렇지 않으면,
      1. thisValue를 ! ToObject(thisArg)로 둡니다.
      2. 참고: ToObject는 calleeRealm을 사용하여 래퍼 객체를 생성합니다.
  7. 단언: localEnv는 Function Environment Record입니다.
  8. 단언: localEnv.[[ThisBindingStatus]]가 initialized가 아니므로 다음 단계는 절대로 비정상 완료를 반환하지 않습니다.
  9. ! BindThisValue(localEnv, thisValue)를 수행합니다.
  10. unused를 반환합니다.

10.2.1.3 Runtime Semantics: EvaluateBody

구문 지향 연산 EvaluateBody. 인수 func (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값)). 반환값: (return 완료 또는 throw 완료). 다음 생성 규칙별로 정의된다.

FunctionBody : FunctionStatementList
  1. 인수 func 및 argList를 사용한 FunctionBody의 ? EvaluateFunctionBody를 반환합니다.
ConciseBody : ExpressionBody
  1. 인수 func 및 argList를 사용한 ConciseBody의 ? EvaluateConciseBody를 반환합니다.
GeneratorBody : FunctionBody
  1. 인수 func 및 argList를 사용한 GeneratorBody의 ? EvaluateGeneratorBody를 반환합니다.
AsyncGeneratorBody : FunctionBody
  1. 인수 func 및 argList를 사용한 AsyncGeneratorBody의 ? EvaluateAsyncGeneratorBody를 반환합니다.
AsyncFunctionBody : FunctionBody
  1. 인수 func 및 argList를 사용한 AsyncFunctionBody의 ? EvaluateAsyncFunctionBody를 반환합니다.
AsyncConciseBody : ExpressionBody
  1. 인수 func 및 argList를 사용한 AsyncConciseBody의 ? EvaluateAsyncConciseBody를 반환합니다.
Initializer : = AssignmentExpression
  1. 단언: argList는 비어 있습니다.
  2. 단언: func.[[ClassFieldInitializerName]]은 empty가 아닙니다.
  3. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이면, 다음을 수행합니다.
    1. value를 인수 func.[[ClassFieldInitializerName]]을 사용한 Initializer의 ? NamedEvaluation으로 둡니다.
  4. 그렇지 않으면,
    1. rhs를 AssignmentExpression의 ? Evaluation으로 둡니다.
    2. value를 ? GetValue(rhs)로 둡니다.
  5. ReturnCompletion(value)을 반환합니다.
참고

필드 이니셜라이저가 함수 경계를 구성하더라도 FunctionDeclarationInstantiation을 호출하는 것은 관찰 가능한 효과가 없으므로 생략합니다.

ClassStaticBlockBody : ClassStaticBlockStatementList
  1. 단언: argList는 비어 있습니다.
  2. 인수 func를 사용한 ClassStaticBlockBody의 ? EvaluateClassStaticBlockBody를 반환합니다.

10.2.1.4 OrdinaryCallEvaluateBody ( func, argList )

추상 연산 OrdinaryCallEvaluateBody. 인수 func (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값)). 반환값: (return 완료 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. 인수 func 및 argList를 사용한 func.[[ECMAScriptCode]]의 ? EvaluateBody를 반환합니다.

10.2.2 [[Construct]] ( argList, newTarget )

an ECMAScript function object func의 내부 메서드 [[Construct]]. 인수 argList (리스트 (요소: ECMAScript 언어 값)) 및 newTarget (생성자). 반환값: (정상 완료 (값: Object) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. callerContext를 실행 중인 실행 컨텍스트로 둡니다.
  2. kind를 func.[[ConstructorKind]]로 둡니다.
  3. kind가 base이면, 다음을 수행합니다.
    1. thisArg를 ? OrdinaryCreateFromConstructor(newTarget, "%Object.prototype%")로 둡니다.
  4. calleeContext를 PrepareForOrdinaryCall(func, newTarget)로 둡니다.
  5. 단언: 이제 calleeContext가 실행 중인 실행 컨텍스트입니다.
  6. kind가 base이면, 다음을 수행합니다.
    1. OrdinaryCallBindThis(func, calleeContext, thisArg)를 수행합니다.
    2. initializeResult를 Completion(InitializeInstanceElements(thisArg, func))로 둡니다.
    3. initializeResult가 비정상 완료이면, 다음을 수행합니다.
      1. 실행 컨텍스트 스택에서 calleeContext를 제거하고 callerContext를 실행 중인 실행 컨텍스트로 복원합니다.
      2. ? initializeResult를 반환합니다.
  7. ctorEnv를 calleeContext의 LexicalEnvironment로 둡니다.
  8. result를 Completion(OrdinaryCallEvaluateBody(func, argList))로 둡니다.
  9. 실행 컨텍스트 스택에서 calleeContext를 제거하고 callerContext를 실행 중인 실행 컨텍스트로 복원합니다.
  10. result가 throw 완료이면, ? result를 반환합니다.
  11. 단언: result는 return 완료입니다.
  12. result.[[Value]]가 Object이면, result.[[Value]]를 반환합니다.
  13. kind가 base이면, thisArg를 반환합니다.
  14. result.[[Value]]가 undefined가 아니면, TypeError 예외를 던집니다.
  15. thisBinding을 ? ctorEnv.GetThisBinding()으로 둡니다.
  16. 단언: thisBinding은 Object입니다.
  17. thisBinding을 반환합니다.

10.2.3 OrdinaryFunctionCreate ( proto, sourceText, paramList, body, thisMode, envRecord, privateEnv )

추상 연산 OrdinaryFunctionCreate. 인수 proto (Object), sourceText (a sequence of Unicode code points), paramList (구문 분석 노드), body (구문 분석 노드), thisMode ((lexical-this 또는 non-lexical-this)), envRecord (Environment 레코드) 및 privateEnv ((PrivateEnvironment 레코드 또는 null)). 반환값: ECMAScript 함수 객체. 기본 [[Call]] 내부 메서드를 갖고 [[Construct]] 내부 메서드는 없는 새로운 함수의 런타임 생성을 명시하는 데 사용됩니다(다만 MakeConstructor와 같은 연산에 의해 이후 [[Construct]]가 추가될 수 있습니다). sourceText는 생성할 함수의 구문 정의에 해당하는 소스 텍스트입니다. 호출되면 다음 단계를 수행한다.

  1. internalSlotsList를 표 26에 나열된 내부 슬롯으로 둡니다.
  2. func를 OrdinaryObjectCreate(proto, internalSlotsList)로 둡니다.
  3. func.[[Call]]을 10.2.1에 명시된 정의로 설정합니다.
  4. func.[[SourceText]]를 sourceText로 설정합니다.
  5. func.[[FormalParameters]]를 paramList로 설정합니다.
  6. func.[[ECMAScriptCode]]를 body로 설정합니다.
  7. strict를 IsStrict(body)로 둡니다.
  8. func.[[Strict]]을 strict로 설정합니다.
  9. thisMode가 lexical-this이면 func.[[ThisMode]]를 lexical로 설정합니다.
  10. 그렇지 않고 strict가 true이면 func.[[ThisMode]]를 strict로 설정합니다.
  11. 그렇지 않으면 func.[[ThisMode]]를 global로 설정합니다.
  12. func.[[IsClassConstructor]]를 false로 설정합니다.
  13. func.[[Environment]]을 envRecord로 설정합니다.
  14. func.[[PrivateEnvironment]]을 privateEnv로 설정합니다.
  15. func.[[ScriptOrModule]]을 GetActiveScriptOrModule()로 설정합니다.
  16. func.[[Realm]]을 현재 Realm Record로 설정합니다.
  17. func.[[HomeObject]]을 undefined로 설정합니다.
  18. func.[[Fields]]를 새로운 빈 List로 설정합니다.
  19. func.[[PrivateMethods]]를 새로운 빈 List로 설정합니다.
  20. func.[[ClassFieldInitializerName]]을 empty로 설정합니다.
  21. length를 paramList의 ExpectedArgumentCount로 둡니다.
  22. SetFunctionLength(func, length)를 수행합니다.
  23. func를 반환합니다.

10.2.4 AddRestrictedFunctionProperties ( func, realm )

추상 연산 AddRestrictedFunctionProperties. 인수 func (함수 객체) 및 realm (Realm 레코드). 반환값: unused. 호출되면 다음 단계를 수행한다.

  1. 단언: realm.[[Intrinsics]].[[%ThrowTypeError%]]가 존재하며 초기화되어 있습니다.
  2. thrower를 realm.[[Intrinsics]].[[%ThrowTypeError%]]로 둡니다.
  3. ! DefinePropertyOrThrow(func, "caller", PropertyDescriptor { [[Getter]]: thrower, [[Setter]]: thrower, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  4. ! DefinePropertyOrThrow(func, "arguments", PropertyDescriptor { [[Getter]]: thrower, [[Setter]]: thrower, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  5. unused를 반환합니다.

10.2.4.1 %ThrowTypeError% ( )

이 함수는 %ThrowTypeError% 내재 객체입니다.

각 realm마다 한 번 정의되는 익명 내장 함수 객체입니다.

호출되면 다음 단계를 수행합니다:

  1. TypeError 예외를 던집니다.

이 함수의 [[Extensible]] 내부 슬롯 값은 false입니다.

이 함수의 "length" 프로퍼티는 속성 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 갖습니다.

이 함수의 "name" 프로퍼티는 속성 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 갖습니다.

10.2.5 MakeConstructor ( func [ , writableProto [ , proto ] ] )

추상 연산 MakeConstructor. 인수 func ((ECMAScript 함수 객체 또는 내장 함수 객체)) 및 선택적 인수 writableProto (Boolean) 및 proto (Object). 반환값: unused. func를 생성자로 변환합니다. 호출되면 다음 단계를 수행한다.

  1. func가 ECMAScript 함수 객체이면, 다음을 수행합니다.
    1. 단언: IsConstructor(func)는 false입니다.
    2. 단언: func는 "prototype" 자체 프로퍼티를 갖지 않는 확장 가능한 객체입니다.
    3. func.[[Construct]]를 10.2.2에 명시된 정의로 설정합니다.
  2. 그렇지 않으면,
    1. func.[[Construct]]를 10.3.2에 명시된 정의로 설정합니다.
  3. func.[[ConstructorKind]]를 base로 설정합니다.
  4. writableProto가 존재하지 않으면 writableProto를 true로 설정합니다.
  5. proto가 존재하지 않으면, 다음을 수행합니다.
    1. proto를 OrdinaryObjectCreate(%Object.prototype%)로 설정합니다.
    2. ! DefinePropertyOrThrow(proto, "constructor", PropertyDescriptor { [[Value]]: func, [[Writable]]: writableProto, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  6. ! DefinePropertyOrThrow(func, "prototype", PropertyDescriptor { [[Value]]: proto, [[Writable]]: writableProto, [[Enumerable]]: false, [[Configurable]]: false })를 수행합니다.
  7. unused를 반환합니다.

10.2.6 MakeClassConstructor ( func )

추상 연산 MakeClassConstructor. 인수 func (ECMAScript 함수 객체). 반환값: unused. 호출되면 다음 단계를 수행한다.

  1. 단언: func.[[IsClassConstructor]]는 false입니다.
  2. func.[[IsClassConstructor]]를 true로 설정합니다.
  3. unused를 반환합니다.

10.2.7 MakeMethod ( func, homeObj )

추상 연산 MakeMethod. 인수 func (ECMAScript 함수 객체) 및 homeObj (Object). 반환값: unused. func를 메서드로 구성합니다. 호출되면 다음 단계를 수행한다.

  1. 단언: homeObj는 일반 객체입니다.
  2. func.[[HomeObject]]을 homeObj로 설정합니다.
  3. unused를 반환합니다.

10.2.8 DefineMethodProperty ( homeObj, name, closure, enumerable )

추상 연산 DefineMethodProperty. 인수 homeObj (Object), name ((프로퍼티 키 또는 비공개 이름)), closure (함수 객체) 및 enumerable (Boolean). 반환값: (정상 완료 (값: (PrivateElement 또는 empty)) 또는 중도 완료). 호출되면 다음 단계를 수행한다.

  1. 단언: homeObj는 일반 확장 가능 객체입니다.
  2. name이 Private Name이면, PrivateElement { [[Key]]: name, [[Kind]]: method, [[Value]]: closure }를 반환합니다.
  3. propertyDesc를 PropertyDescriptor { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true }로 둡니다.
  4. ? DefinePropertyOrThrow(homeObj, name, propertyDesc)를 수행합니다.
  5. 참고: DefinePropertyOrThrow는 name이 "prototype"인 클래스 정적 메서드를 정의하려고 할 때만 비정상 완료를 반환합니다.
  6. empty를 반환합니다.

10.2.9 SetFunctionName ( func, name [ , prefix ] )

추상 연산 SetFunctionName. 인수 func (함수 객체) 및 name ((프로퍼티 키 또는 비공개 이름)) 및 선택적 인수 prefix (String). 반환값: unused. func에 "name" 프로퍼티를 추가합니다. 호출되면 다음 단계를 수행한다.

  1. 단언: func는 "name" 자체 프로퍼티를 갖지 않는 확장 가능한 객체입니다.
  2. name이 Symbol이면, 다음을 수행합니다.
    1. description을 name.[[Description]]으로 둡니다.
    2. description이 undefined이면 name을 빈 String으로 설정합니다.
    3. 그렇지 않으면 name을 "[", description 및 "]"의 문자열 연결로 설정합니다.
  3. 그렇지 않고 name이 Private Name이면, 다음을 수행합니다.
    1. name을 name.[[Description]]으로 설정합니다.
  4. initialName을 name으로 둡니다.
  5. prefix가 존재하면, 다음을 수행합니다.
    1. prefixedName을 prefix, 코드 단위 0x0020 (SPACE) 및 name의 문자열 연결로 둡니다.
    2. initialName을 prefixedName으로 설정합니다.
    3. Normative Optional, Legacy
      initialName을 name 또는 prefixedName 중 구현체 정의 방식으로 선택한 값으로 설정합니다.
    4. name을 prefixedName으로 설정합니다.
  6. func에 [[InitialName]] 내부 슬롯이 있으면 func.[[InitialName]]을 initialName으로 설정합니다.
  7. ! DefinePropertyOrThrow(func, "name", PropertyDescriptor { [[Value]]: name, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  8. unused를 반환합니다.
참고

func.[[InitialName]]에 prefixedName을 사용할지 여부에 대한 선택은 Function.prototype.toString ( )의 출력에 영향을 줍니다. 5.c 단계에서 서로 다른 내장 함수에 대해 서로 다른 선택을 하는 것은 권장되지 않는 레거시 동작입니다.

10.2.10 SetFunctionLength ( func, length )

추상 연산 SetFunctionLength. 인수 func (함수 객체) 및 length ((음이 아닌 정수 또는 +∞)). 반환값: unused. func에 "length" 프로퍼티를 추가합니다. 호출되면 다음 단계를 수행한다.

  1. 단언: func는 "length" 자체 프로퍼티를 갖지 않는 확장 가능한 객체입니다.
  2. ! DefinePropertyOrThrow(func, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  3. unused를 반환합니다.

10.2.11 FunctionDeclarationInstantiation ( func, argList )

추상 연산 FunctionDeclarationInstantiation. 인수 func (ECMAScript 함수 객체) 및 argList (리스트 (요소: ECMAScript 언어 값)). 반환값: (정상 완료 (값: unused) 또는 throw 완료). func는 실행 컨텍스트를 설정하는 대상 함수 객체입니다.

참고

ECMAScript 함수를 평가하기 위한 실행 컨텍스트를 설정하면 새로운 Function Environment Record가 생성되고 각 형식 매개변수에 대한 바인딩이 해당 Environment Record에서 인스턴스화됩니다. 함수 본문의 각 선언도 인스턴스화됩니다. 함수의 형식 매개변수에 기본값 이니셜라이저가 포함되지 않으면 본문 선언은 매개변수와 동일한 Environment Record에서 인스턴스화됩니다. 기본값 매개변수 이니셜라이저가 존재하면 본문 선언을 위해 두 번째 Environment Record가 생성됩니다. 형식 매개변수와 함수는 FunctionDeclarationInstantiation의 일부로 초기화됩니다. 그 밖의 모든 바인딩은 함수 본문 평가 중에 초기화됩니다.

호출되면 다음 단계를 수행합니다:

  1. calleeContext를 실행 중인 실행 컨텍스트로 둡니다.
  2. code를 func.[[ECMAScriptCode]]로 둡니다.
  3. strict를 func.[[Strict]]로 둡니다.
  4. formals를 func.[[FormalParameters]]로 둡니다.
  5. paramNames를 formals의 BoundNames로 둡니다.
  6. paramNames에 중복 항목이 있으면 hasDuplicates를 true로 둡니다. 그렇지 않으면 hasDuplicates를 false로 둡니다.
  7. simpleParamList를 formals의 IsSimpleParameterList로 둡니다.
  8. hasParamExprs를 formals의 ContainsExpression으로 둡니다.
  9. variableNames를 code의 VarDeclaredNames로 둡니다.
  10. variableDecls를 code의 VarScopedDeclarations로 둡니다.
  11. lexicalNames를 code의 LexicallyDeclaredNames로 둡니다.
  12. funcNames를 새로운 빈 List로 둡니다.
  13. funcsToInitialize를 새로운 빈 List로 둡니다.
  14. variableDecls의 각 요소 variableDecl에 대해 List 역순으로 다음을 수행합니다.
    1. variableDecl이 VariableDeclaration도 ForBinding도 BindingIdentifier도 아니면, 다음을 수행합니다.
      1. 단언: variableDecl은 FunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나입니다.
      2. funcName을 variableDecl의 BoundNames의 유일한 요소로 둡니다.
      3. funcNames에 funcName이 포함되어 있지 않으면, 다음을 수행합니다.
        1. funcName을 funcNames의 첫 번째 요소로 삽입합니다.
        2. 참고: 동일한 이름의 함수 선언이 여러 개 있으면 마지막 선언을 사용합니다.
        3. variableDecl을 funcsToInitialize의 첫 번째 요소로 삽입합니다.
  15. argumentsObjNeeded를 true로 둡니다.
  16. func.[[ThisMode]]가 lexical이면, 다음을 수행합니다.
    1. 참고: 화살표 함수에는 arguments 객체가 없습니다.
    2. argumentsObjNeeded를 false로 설정합니다.
  17. 그렇지 않고 paramNames에 "arguments"가 포함되어 있으면, 다음을 수행합니다.
    1. argumentsObjNeeded를 false로 설정합니다.
  18. 그렇지 않고 hasParamExprs가 false이면, 다음을 수행합니다.
    1. funcNames에 "arguments"가 포함되어 있거나 lexicalNames에 "arguments"가 포함되어 있으면, 다음을 수행합니다.
      1. argumentsObjNeeded를 false로 설정합니다.
  19. strict가 true이거나 hasParamExprs가 false이면, 다음을 수행합니다.
    1. 참고: 엄격 모드 코드의 eval 호출은 eval 외부에서 볼 수 있는 새로운 바인딩을 생성할 수 없으므로 매개변수에는 하나의 Environment Record만 필요합니다.
    2. envRecord를 calleeContext의 LexicalEnvironment로 둡니다.
  20. 그렇지 않으면,
    1. 참고: 형식 매개변수 목록에서 직접 eval 호출로 생성된 바인딩이 매개변수가 선언되는 환경 바깥에 있도록 보장하기 위해 별도의 Environment Record가 필요합니다.
    2. calleeEnv를 calleeContext의 LexicalEnvironment로 둡니다.
    3. envRecord를 NewDeclarativeEnvironment(calleeEnv)로 둡니다.
    4. 단언: calleeContext의 VariableEnvironment와 calleeEnv는 같은 Environment Record입니다.
    5. calleeContext의 LexicalEnvironment를 envRecord로 설정합니다.
  21. paramNames의 각 String paramName에 대해 다음을 수행합니다.
    1. alreadyDeclared를 ! envRecord.HasBinding(paramName)으로 둡니다.
    2. 참고: 조기 오류는 중복 매개변수 이름이 매개변수 기본값이나 나머지 매개변수를 갖지 않는 비엄격 함수에서만 나타날 수 있도록 보장합니다.
    3. alreadyDeclared가 false이면, 다음을 수행합니다.
      1. ! envRecord.CreateMutableBinding(paramName, false)를 수행합니다.
      2. hasDuplicates가 true이면, 다음을 수행합니다.
        1. ! envRecord.InitializeBinding(paramName, undefined)를 수행합니다.
  22. argumentsObjNeeded가 true이면, 다음을 수행합니다.
    1. strict가 true이거나 simpleParamList가 false이면, 다음을 수행합니다.
      1. argumentsObj를 CreateUnmappedArgumentsObject(argList)로 둡니다.
    2. 그렇지 않으면,
      1. 참고: 매핑된 arguments 객체는 나머지 매개변수, 매개변수 기본값 이니셜라이저 또는 구조 분해 매개변수가 없는 비엄격 함수에만 제공됩니다.
      2. argumentsObj를 CreateMappedArgumentsObject(func, formals, argList, envRecord)로 둡니다.
    3. strict가 true이면, 다음을 수행합니다.
      1. ! envRecord.CreateImmutableBinding("arguments", false)를 수행합니다.
      2. 참고: 엄격 모드 코드에서는 조기 오류가 이 바인딩에 할당하려는 시도를 방지하므로 변경 가능 여부를 관찰할 수 없습니다.
    4. 그렇지 않으면,
      1. ! envRecord.CreateMutableBinding("arguments", false)를 수행합니다.
    5. ! envRecord.InitializeBinding("arguments", argumentsObj)를 수행합니다.
    6. paramBindings를 paramNames와 « "arguments" »의 목록 연결로 둡니다.
  23. 그렇지 않으면,
    1. paramBindings를 paramNames로 둡니다.
  24. iteratorRecord를 CreateListIteratorRecord(argList)로 둡니다.
  25. hasDuplicates가 true이면, 다음을 수행합니다.
    1. usedEnv를 undefined로 둡니다.
  26. 그렇지 않으면,
    1. usedEnv를 envRecord로 둡니다.
  27. 참고: 다음 단계는 ReturnCompletion을 반환할 수 없습니다. 표현식 위치에서 그러한 완료가 발생할 수 있는 유일한 방법은 YieldExpression을 사용하는 것이지만, 이는 15.5.1 및 15.6.1의 조기 오류 규칙에 의해 매개변수 목록에서 금지됩니다.
  28. 인수 iteratorRecord 및 usedEnv를 사용한 formals의 ? IteratorBindingInitialization을 수행합니다.
  29. hasParamExprs가 false이면, 다음을 수행합니다.
    1. 참고: 매개변수와 최상위 var에는 하나의 Environment Record만 필요합니다.
    2. instantiatedVariableNames를 List paramBindings의 복사본으로 둡니다.
    3. variableNames의 각 요소 name에 대해 다음을 수행합니다.
      1. instantiatedVariableNames에 name이 포함되어 있지 않으면, 다음을 수행합니다.
        1. name을 instantiatedVariableNames에 추가합니다.
        2. ! envRecord.CreateMutableBinding(name, false)를 수행합니다.
        3. ! envRecord.InitializeBinding(name, undefined)를 수행합니다.
    4. variableEnv를 envRecord로 둡니다.
  30. 그렇지 않으면,
    1. 참고: 형식 매개변수 목록의 표현식에서 생성된 클로저가 함수 본문의 선언을 볼 수 없도록 별도의 Environment Record가 필요합니다.
    2. variableEnv를 NewDeclarativeEnvironment(envRecord)로 둡니다.
    3. calleeContext의 VariableEnvironment를 variableEnv로 설정합니다.
    4. instantiatedVariableNames를 새로운 빈 List로 둡니다.
    5. variableNames의 각 요소 name에 대해 다음을 수행합니다.
      1. instantiatedVariableNames에 name이 포함되어 있지 않으면, 다음을 수행합니다.
        1. name을 instantiatedVariableNames에 추가합니다.
        2. ! variableEnv.CreateMutableBinding(name, false)를 수행합니다.
        3. paramBindings에 name이 포함되어 있지 않거나 funcNames에 name이 포함되어 있으면, 다음을 수행합니다.
          1. initialValue를 undefined로 둡니다.
        4. 그렇지 않으면,
          1. initialValue를 ! envRecord.GetBindingValue(name, false)로 둡니다.
        5. ! variableEnv.InitializeBinding(name, initialValue)을 수행합니다.
        6. 참고: 형식 매개변수와 같은 이름의 var는 처음에는 대응하는 초기화된 매개변수와 같은 값을 갖습니다.
  31. strict가 true이면, 다음을 수행합니다.
    1. lexicalEnv를 variableEnv로 둡니다.
  32. 그렇지 않으면,
    1. Normative Optional
      호스트가 웹 브라우저이거나 그 밖의 방식으로 블록 수준 함수 선언의 웹 레거시 호환성 의미론을 지원하면, 다음을 수행합니다.
      1. code Contains x가 true인 Block, CaseClause 또는 DefaultClause x의 StatementList에 직접 포함된 각 FunctionDeclaration funcDecl에 대해 다음을 수행합니다.
        1. funcName을 funcDecl의 BindingIdentifier의 StringValue로 둡니다.
        2. FunctionDeclaration funcDecl을 funcName을 BindingIdentifier로 갖는 VariableStatement로 교체해도 func에 대한 조기 오류가 발생하지 않고 paramNames에 funcName이 포함되어 있지 않으면, 다음을 수행합니다.
          1. 참고: funcName에 대한 var 바인딩은 여기에서 funcName이 VarDeclaredName도, 형식 매개변수 이름도, 다른 FunctionDeclaration도 아닌 경우에만 인스턴스화됩니다.
          2. instantiatedVariableNames에 funcName이 포함되어 있지 않고 funcName이 "arguments"가 아니면, 다음을 수행합니다.
            1. ! variableEnv.CreateMutableBinding(funcName, false)를 수행합니다.
            2. ! variableEnv.InitializeBinding(funcName, undefined)를 수행합니다.
            3. funcName을 instantiatedVariableNames에 추가합니다.
          3. FunctionDeclaration funcDecl이 평가될 때 15.2.6에 제공된 FunctionDeclaration Evaluation 알고리즘 대신 다음 단계를 수행합니다.
            1. funcEnv를 실행 중인 실행 컨텍스트의 VariableEnvironment로 둡니다.
            2. blockEnv를 실행 중인 실행 컨텍스트의 LexicalEnvironment로 둡니다.
            3. funcObj를 ! blockEnv.GetBindingValue(funcName, false)로 둡니다.
            4. ! funcEnv.SetMutableBinding(funcName, funcObj, false)를 수행합니다.
            5. unused를 반환합니다.
    2. lexicalEnv를 NewDeclarativeEnvironment(variableEnv)로 둡니다.
    3. 참고: 비엄격 함수는 최상위 렉시컬 선언에 별도의 Environment Record를 사용하여 직접 eval이 eval 코드에서 도입한 var 스코프 선언과 기존 최상위 렉시컬 스코프 선언 사이의 충돌 여부를 결정할 수 있도록 합니다. 엄격 직접 eval은 항상 모든 선언을 새로운 Environment Record에 배치하므로 엄격 함수에는 이것이 필요하지 않습니다.
  33. calleeContext의 LexicalEnvironment를 lexicalEnv로 설정합니다.
  34. lexicalDecls를 code의 LexicallyScopedDeclarations로 둡니다.
  35. lexicalDecls의 각 요소 lexicalDecl에 대해 다음을 수행합니다.
    1. 참고: 렉시컬하게 선언된 이름은 함수/제너레이터 선언, 형식 매개변수 또는 var 이름과 같을 수 없습니다. 렉시컬하게 선언된 이름은 여기에서 인스턴스화만 되고 초기화되지는 않습니다.
    2. lexicalDecl의 BoundNames의 각 요소 name에 대해 다음을 수행합니다.
      1. lexicalDecl의 IsConstantDeclaration이 true이면, 다음을 수행합니다.
        1. ! lexicalEnv.CreateImmutableBinding(name, true)를 수행합니다.
      2. 그렇지 않으면,
        1. ! lexicalEnv.CreateMutableBinding(name, false)를 수행합니다.
  36. privateEnv를 calleeContext의 PrivateEnvironment로 둡니다.
  37. funcsToInitialize의 각 Parse Node funcDecl에 대해 다음을 수행합니다.
    1. funcName을 funcDecl의 BoundNames의 유일한 요소로 둡니다.
    2. funcObj를 인수 lexicalEnv 및 privateEnv를 사용한 funcDecl의 InstantiateFunctionObject로 둡니다.
    3. ! variableEnv.SetMutableBinding(funcName, funcObj, false)를 수행합니다.
  38. unused를 반환합니다.

10.3 내장 함수 객체

내장 함수 객체는 일반 객체이며 10.1에 명시된 일반 객체에 대한 요구 사항을 충족해야 합니다.

모든 일반 객체에 필요한 내부 슬롯(10.1 참조) 외에도 내장 함수 객체에는 다음 내부 슬롯이 있어야 합니다:

  • [[Realm]]은 함수가 생성된 realm을 나타내는 Realm Record입니다.
  • [[InitialName]]은 함수의 초기 이름인 String입니다. 20.2.3.5에서 사용됩니다.
  • [[Async]]는 BuiltinCallOrConstruct에서 함수가 async 함수 호출 및 생성 동작을 갖는지를 나타내는 Boolean입니다.

달리 명시되지 않는 한 내장 함수 객체의 [[Prototype]] 내부 슬롯 초기값은 %Function.prototype%입니다.

내장 함수 객체에는 10.3.1의 정의를 따르는 [[Call]] 내부 메서드가 있어야 합니다.

내장 함수 객체가 “constructor”로 설명되어 있거나 이 명세의 어떤 알고리즘이 해당 [[Construct]] 내부 메서드를 명시적으로 설정하는 경우에만 [[Construct]] 내부 메서드를 갖습니다. 이러한 [[Construct]] 내부 메서드는 10.3.2의 정의를 따라야 합니다.

구현체는 이 명세에 정의되지 않은 추가 내장 함수 객체를 제공할 수 있습니다.

10.3.1 [[Call]] ( thisArg, argList )

a built-in function object func의 내부 메서드 [[Call]]. 인수 thisArg (ECMAScript 언어 값) 및 argList (리스트 (요소: ECMAScript 언어 값)). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? BuiltinCallOrConstruct(func, thisArg, argList, undefined)를 반환합니다.

10.3.2 [[Construct]] ( argList, newTarget )

a built-in function object func (when the method is present)의 내부 메서드 [[Construct]]. 인수 argList (리스트 (요소: ECMAScript 언어 값)) 및 newTarget (생성자). 반환값: (정상 완료 (값: Object) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. result를 ? BuiltinCallOrConstruct(func, uninitialized, argList, newTarget)로 둡니다.
  2. 단언: result는 Object입니다.
  3. result를 반환합니다.

10.3.3 BuiltinCallOrConstruct ( func, thisArg, argList, newTarget )

추상 연산 BuiltinCallOrConstruct. 인수 func (내장 함수 객체), thisArg ((ECMAScript 언어 값 또는 uninitialized)), argList (리스트 (요소: ECMAScript 언어 값)) 및 newTarget ((생성자 또는 undefined)). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. callerContext를 실행 중인 실행 컨텍스트로 둡니다.
  2. callerContext가 아직 일시 중단되지 않았으면 callerContext를 일시 중단합니다.
  3. calleeContext를 새로운 실행 컨텍스트로 둡니다.
  4. calleeContext의 Function을 func로 설정합니다.
  5. calleeRealm을 func.[[Realm]]로 둡니다.
  6. calleeContext의 Realm을 calleeRealm으로 설정합니다.
  7. calleeContext의 ScriptOrModule을 null로 설정합니다.
  8. calleeContext에 필요한 구현체 정의 초기화를 수행합니다.
  9. calleeContext를 실행 컨텍스트 스택에 푸시합니다. 이제 calleeContext가 실행 중인 실행 컨텍스트입니다.
  10. func.[[Async]]가 true이면, 다음을 수행합니다.
    1. promiseCapability를 ! NewPromiseCapability(%Promise%)로 둡니다.
    2. resultsClosure를 매개변수가 없고 func, thisArg, argList 및 newTarget을 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure로 둡니다:
      1. result를 func의 명세에 부합하는 방식으로 func를 평가한 결과인 Completion Record로 둡니다. thisArg가 uninitialized이면 this 값은 초기화되지 않습니다. 그렇지 않으면 thisArg가 this 값을 제공합니다. argList는 이름 있는 매개변수를 제공합니다. newTarget은 NewTarget 값을 제공합니다.
      2. 참고: func가 이 문서에 정의되어 있으면 “func의 명세”는 알고리즘 단계 또는 다른 수단으로 해당 함수에 대해 명시된 동작입니다.
      3. Completion(result)를 반환합니다.
    3. AsyncFunctionStart(promiseCapability, resultsClosure)를 수행합니다.
    4. 실행 컨텍스트 스택에서 calleeContext를 제거하고 callerContext를 실행 중인 실행 컨텍스트로 복원합니다.
    5. promiseCapability.[[Promise]]를 반환합니다.
  11. result를 func의 명세에 부합하는 방식으로 func를 평가한 결과인 Completion Record로 둡니다. thisArg가 uninitialized이면 this 값은 초기화되지 않습니다. 그렇지 않으면 thisArg가 this 값을 제공합니다. argList는 이름 있는 매개변수를 제공합니다. newTarget은 NewTarget 값을 제공합니다.
  12. 참고: func가 이 문서에 정의되어 있으면 “func의 명세”는 알고리즘 단계 또는 다른 수단으로 해당 함수에 대해 명시된 동작입니다.
  13. 실행 컨텍스트 스택에서 calleeContext를 제거하고 callerContext를 실행 중인 실행 컨텍스트로 복원합니다.
  14. ? result를 반환합니다.
참고

calleeContext가 일시 중단되어 접근 가능한 Generator에 의해 이후 재개를 위해 유지되고 있다면 실행 컨텍스트 스택에서 제거될 때 파기해서는 안 됩니다.

10.3.4 CreateBuiltinFunction ( behaviour, length, name, additionalInternalSlotsList [ , realm [ , proto [ , prefix [ , async ] ] ] ] )

추상 연산 CreateBuiltinFunction. 인수 behaviour ((추상 클로저, a set of algorithm steps 또는 some other definition of a function's behaviour provided in this specification)), length ((음이 아닌 정수 또는 +∞)), name ((프로퍼티 키 또는 비공개 이름)) 및 additionalInternalSlotsList (리스트 (요소: 내부 슬롯 이름)) 및 선택적 인수 realm (Realm 레코드), proto ((Object 또는 null)), prefix (String) 및 async (Boolean). 반환값: 내장 함수 객체. additionalInternalSlotsList에는 객체의 일부로 정의해야 하는 추가 내부 슬롯의 이름이 포함됩니다. 이 연산은 내장 함수 객체를 생성합니다. 호출되면 다음 단계를 수행한다.

  1. realm이 존재하지 않으면 realm을 현재 Realm Record로 설정합니다.
  2. proto가 존재하지 않으면 proto를 realm.[[Intrinsics]].[[%Function.prototype%]]로 설정합니다.
  3. async가 존재하지 않으면 async를 false로 설정합니다.
  4. internalSlotsList를 10.3가 생성하려는 내장 함수 객체에 요구하는 모든 내부 슬롯의 이름을 포함하는 List로 둡니다.
  5. additionalInternalSlotsList의 요소를 internalSlotsList에 추가합니다.
  6. func를 호출될 때 behaviour가 지정한 대응 매개변수의 값으로 제공된 인수를 사용하여 behaviour가 설명하는 동작을 수행하는 새로운 내장 함수 객체로 둡니다. 새로운 함수 객체에는 이름이 internalSlotsList의 요소인 내부 슬롯과 [[InitialName]] 내부 슬롯이 있습니다.
  7. func.[[Async]]를 async로 설정합니다.
  8. func.[[Prototype]]을 proto로 설정합니다.
  9. func.[[Extensible]]을 true로 설정합니다.
  10. func.[[Realm]]을 realm으로 설정합니다.
  11. func.[[InitialName]]을 null로 설정합니다.
  12. SetFunctionLength(func, length)를 수행합니다.
  13. prefix가 존재하지 않으면, 다음을 수행합니다.
    1. SetFunctionName(func, name)을 수행합니다.
  14. 그렇지 않으면,
    1. SetFunctionName(func, name, prefix)을 수행합니다.
  15. func를 반환합니다.

이 명세에 정의된 각 내장 함수는 CreateBuiltinFunction 추상 연산을 호출하여 생성됩니다.

10.4 내장 특수 객체의 내부 메서드와 슬롯

이 명세에서는 여러 종류의 내장 특수 객체를 정의합니다. 이러한 객체는 일반적으로 몇몇 특정 상황을 제외하면 일반 객체와 유사하게 동작합니다. 다음 특수 객체는 아래에서 명시적으로 달리 지정한 경우를 제외하고 일반 객체 내부 메서드를 사용합니다:

10.4.1 바인딩된 함수 특수 객체

바인딩된 함수 특수 객체는 다른 함수 객체를 래핑하는 특수 객체입니다. 바인딩된 함수 특수 객체는 호출 가능합니다([[Call]] 내부 메서드를 가지며 [[Construct]] 내부 메서드를 가질 수도 있습니다). 바인딩된 함수 특수 객체를 호출하면 일반적으로 래핑된 함수가 호출됩니다.

객체의 [[Call]] 및 (해당하는 경우) [[Construct]] 내부 메서드가 다음 구현을 사용하고, 그 밖의 필수 내부 메서드가 10.1에 있는 정의를 사용하면 해당 객체는 바인딩된 함수 특수 객체입니다. 이러한 메서드는 BoundFunctionCreate에서 설치됩니다.

바인딩된 함수 특수 객체에는 표 26에 나열된 ECMAScript 함수 객체의 내부 슬롯이 없습니다. 대신 [[Prototype]] 및 [[Extensible]] 외에도 표 27에 나열된 내부 슬롯이 있습니다.

표 27: 바인딩된 함수 특수 객체의 내부 슬롯
내부 슬롯 타입 설명
[[BoundTargetFunction]] 호출 가능한 Object 래핑된 함수 객체입니다.
[[BoundThis]] ECMAScript 언어 값 래핑된 함수를 호출할 때 항상 this 값으로 전달되는 값입니다.
[[BoundArguments]] ECMAScript 언어 값의 List 래핑된 함수를 호출할 때마다 첫 번째 인수로 사용되는 요소를 갖는 값의 목록입니다.

10.4.1.1 [[Call]] ( thisArg, argList )

a bound function exotic object func의 내부 메서드 [[Call]]. 인수 thisArg (ECMAScript 언어 값) 및 argList (리스트 (요소: ECMAScript 언어 값)). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. target을 func.[[BoundTargetFunction]]으로 둡니다.
  2. boundThis를 func.[[BoundThis]]로 둡니다.
  3. boundArgs를 func.[[BoundArguments]]로 둡니다.
  4. args를 boundArgs와 argList의 목록 연결로 둡니다.
  5. ? Call(target, boundThis, args)를 반환합니다.

10.4.1.2 [[Construct]] ( argList, newTarget )

a bound function exotic object func의 내부 메서드 [[Construct]]. 인수 argList (리스트 (요소: ECMAScript 언어 값)) 및 newTarget (생성자). 반환값: (정상 완료 (값: Object) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. target을 func.[[BoundTargetFunction]]으로 둡니다.
  2. 단언: IsConstructor(target)은 true입니다.
  3. boundArgs를 func.[[BoundArguments]]로 둡니다.
  4. args를 boundArgs와 argList의 목록 연결로 둡니다.
  5. SameValue(func, newTarget)가 true이면 newTarget을 target으로 설정합니다.
  6. ? Construct(target, args, newTarget)를 반환합니다.

10.4.1.3 BoundFunctionCreate ( targetFunc, boundThis, boundArgs )

추상 연산 BoundFunctionCreate. 인수 targetFunc (함수 객체), boundThis (ECMAScript 언어 값) 및 boundArgs (리스트 (요소: ECMAScript 언어 값)). 반환값: (정상 완료 (값: 함수 객체) 또는 throw 완료). 새로운 바인딩된 함수 특수 객체의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.

  1. proto를 ? targetFunc.[[GetPrototypeOf]]()로 둡니다.
  2. internalSlotsList를 « [[Prototype]], [[Extensible]] »과 표 27에 나열된 내부 슬롯의 목록 연결로 둡니다.
  3. obj를 MakeBasicObject(internalSlotsList)로 둡니다.
  4. obj.[[Prototype]]을 proto로 설정합니다.
  5. obj.[[Call]]을 10.4.1.1에 명시된 대로 설정합니다.
  6. IsConstructor(targetFunc)가 true이면, 다음을 수행합니다.
    1. obj.[[Construct]]를 10.4.1.2에 명시된 대로 설정합니다.
  7. obj.[[BoundTargetFunction]]을 targetFunc로 설정합니다.
  8. obj.[[BoundThis]]를 boundThis로 설정합니다.
  9. obj.[[BoundArguments]]를 boundArgs로 설정합니다.
  10. obj를 반환합니다.

10.4.2 Array 특수 객체

Array는 배열 인덱스 프로퍼티 키를 특별하게 처리하는 특수 객체입니다(6.1.7 참조). 프로퍼티 이름이 배열 인덱스인 프로퍼티를 요소라고도 합니다. 모든 Array에는 구성 불가능한 "length" 프로퍼티가 있으며, 그 값은 수학적 값이 232보다 엄격히 작은 음이 아닌 정수 Number입니다. "length" 프로퍼티의 값은 이름이 배열 인덱스인 모든 자체 프로퍼티 이름의 숫자 값보다 큽니다. Array의 자체 프로퍼티가 생성되거나 변경될 때마다 이 불변 조건을 유지하기 위해 필요에 따라 다른 프로퍼티를 조정합니다. 구체적으로 이름이 배열 인덱스인 자체 프로퍼티가 추가될 때마다 필요한 경우 "length" 프로퍼티 값을 해당 배열 인덱스의 숫자 값보다 1 큰 값으로 변경합니다. 또한 "length" 프로퍼티 값이 변경될 때마다 배열 인덱스 이름의 값이 새로운 길이보다 작지 않은 모든 자체 프로퍼티를 삭제합니다. 이 제약 조건은 Array의 자체 프로퍼티에만 적용되며 프로토타입에서 상속될 수 있는 "length" 또는 배열 인덱스 프로퍼티의 영향을 받지 않습니다.

객체의 [[DefineOwnProperty]] 내부 메서드가 다음 구현을 사용하고 그 밖의 필수 내부 메서드가 10.1에 있는 정의를 사용하면 해당 객체는 Array 특수 객체(또는 간단히 Array)입니다. 이러한 메서드는 ArrayCreate에서 설치됩니다.

10.4.2.1 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

an Array exotic object array의 내부 메서드 [[DefineOwnProperty]]. 인수 propertyKey (프로퍼티 키) 및 propertyDesc (프로퍼티 서술자). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 "length"이면, ? ArraySetLength(array, propertyDesc)를 반환합니다.
  2. propertyKey가 배열 인덱스이면, 다음을 수행합니다.
    1. lengthDesc를 OrdinaryGetOwnProperty(array, "length")로 둡니다.
    2. 단언: lengthDesc는 undefined가 아닙니다.
    3. 단언: IsDataDescriptor(lengthDesc)는 true입니다.
    4. 단언: lengthDesc.[[Configurable]]은 false입니다.
    5. length를 lengthDesc.[[Value]]로 둡니다.
    6. 단언: length는 음이 아닌 정수 Number입니다.
    7. index를 ! ToUint32(propertyKey)로 둡니다.
    8. index ≥ length이고 lengthDesc.[[Writable]]이 false이면, false를 반환합니다.
    9. succeeded를 ! OrdinaryDefineOwnProperty(array, propertyKey, propertyDesc)로 둡니다.
    10. succeeded가 false이면, false를 반환합니다.
    11. index ≥ length이면, 다음을 수행합니다.
      1. lengthDesc.[[Value]]를 index + 1𝔽로 설정합니다.
      2. succeeded를 ! OrdinaryDefineOwnProperty(array, "length", lengthDesc)로 설정합니다.
      3. 단언: succeeded는 true입니다.
    12. true를 반환합니다.
  3. ? OrdinaryDefineOwnProperty(array, propertyKey, propertyDesc)를 반환합니다.

10.4.2.2 ArrayCreate ( length [ , proto ] )

추상 연산 ArrayCreate. 인수 length (음이 아닌 정수) 및 선택적 인수 proto (Object). 반환값: (정상 완료 (값: Array 특수 객체) 또는 throw 완료). 새로운 Array의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.

  1. length > 232 - 1이면, RangeError 예외를 던집니다.
  2. proto가 존재하지 않으면 proto를 %Array.prototype%로 설정합니다.
  3. array를 MakeBasicObject(« [[Prototype]], [[Extensible]] »)로 둡니다.
  4. array.[[Prototype]]을 proto로 설정합니다.
  5. array.[[DefineOwnProperty]]를 10.4.2.1에 명시된 대로 설정합니다.
  6. ! OrdinaryDefineOwnProperty(array, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false })를 수행합니다.
  7. array를 반환합니다.

10.4.2.3 ArraySpeciesCreate ( originalArray, length )

추상 연산 ArraySpeciesCreate. 인수 originalArray (Object) 및 length (음이 아닌 정수). 반환값: (정상 완료 (값: Object) 또는 throw 완료). originalArray에서 파생된 생성자 함수를 사용하여 새로운 Array 또는 유사한 객체의 생성을 명시하는 데 사용됩니다. 생성자 함수가 반드시 Array를 반환하도록 강제하지는 않습니다. 호출되면 다음 단계를 수행한다.

  1. isArray를 ? IsArray(originalArray)로 둡니다.
  2. isArray가 false이면, ? ArrayCreate(length)를 반환합니다.
  3. ctor를 ? Get(originalArray, "constructor")로 둡니다.
  4. IsConstructor(ctor)가 true이면, 다음을 수행합니다.
    1. thisRealm을 현재 Realm Record로 둡니다.
    2. ctorRealm을 ? GetFunctionRealm(ctor)로 둡니다.
    3. thisRealm과 ctorRealm이 같은 Realm Record가 아니면, 다음을 수행합니다.
      1. SameValue(ctor, ctorRealm.[[Intrinsics]].[[%Array%]])가 true이면 ctor를 undefined로 설정합니다.
  5. ctor가 Object이면, 다음을 수행합니다.
    1. ctor를 ? Get(ctor, %Symbol.species%)로 설정합니다.
    2. ctor가 null이면 ctor를 undefined로 설정합니다.
  6. ctor가 undefined이면, ? ArrayCreate(length)를 반환합니다.
  7. IsConstructor(ctor)가 false이면, TypeError 예외를 던집니다.
  8. ? Construct(ctor, « 𝔽(length) »)를 반환합니다.
참고

originalArray가 실행 중인 실행 컨텍스트의 realm이 아닌 realm의 표준 내장 Array 생성자를 사용하여 생성되었다면, 실행 중인 실행 컨텍스트의 realm을 사용하여 새로운 Array를 생성합니다. 이는 현재 ArraySpeciesCreate를 사용하여 정의된 Array.prototype 메서드에 대해 역사적으로 이러한 동작을 해 온 웹 브라우저와의 호환성을 유지합니다.

10.4.2.4 ArraySetLength ( array, propertyDesc )

추상 연산 ArraySetLength. 인수 array (Array) 및 propertyDesc (프로퍼티 서술자). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyDesc에 [[Value]] 필드가 없으면, 다음을 수행합니다.
    1. ! OrdinaryDefineOwnProperty(array, "length", propertyDesc)를 반환합니다.
  2. newLengthDesc를 propertyDesc의 복사본으로 둡니다.
  3. newLength를 ? ToUint32(propertyDesc.[[Value]])로 둡니다.
  4. numberLength를 ? ToNumber(propertyDesc.[[Value]])로 둡니다.
  5. SameValueZero(newLength, numberLength)가 false이면, RangeError 예외를 던집니다.
  6. newLengthDesc.[[Value]]를 newLength로 설정합니다.
  7. oldLengthDesc를 OrdinaryGetOwnProperty(array, "length")로 둡니다.
  8. 단언: oldLengthDesc는 undefined가 아닙니다.
  9. 단언: IsDataDescriptor(oldLengthDesc)는 true입니다.
  10. 단언: oldLengthDesc.[[Configurable]]은 false입니다.
  11. oldLength를 oldLengthDesc.[[Value]]로 둡니다.
  12. newLength ≥ oldLength이면, 다음을 수행합니다.
    1. ! OrdinaryDefineOwnProperty(array, "length", newLengthDesc)를 반환합니다.
  13. oldLengthDesc.[[Writable]]이 false이면, false를 반환합니다.
  14. newLengthDesc에 [[Writable]] 필드가 없거나 newLengthDesc.[[Writable]]이 true이면, 다음을 수행합니다.
    1. newWritable을 true로 둡니다.
  15. 그렇지 않으면,
    1. 참고: 일부 요소를 삭제할 수 없는 경우를 대비하여 [[Writable]] 속성을 false로 설정하는 작업을 연기합니다.
    2. newWritable을 false로 둡니다.
    3. newLengthDesc.[[Writable]]을 true로 설정합니다.
  16. succeeded를 ! OrdinaryDefineOwnProperty(array, "length", newLengthDesc)로 둡니다.
  17. succeeded가 false이면, false를 반환합니다.
  18. 배열 인덱스이고 ! ToUint32(propertyKey) ≥ newLength인 array의 각 자체 프로퍼티 키 propertyKey에 대해 숫자 인덱스 내림차순으로 다음을 수행합니다.
    1. deleteSucceeded를 ! array.[[Delete]](propertyKey)로 둡니다.
    2. deleteSucceeded가 false이면, 다음을 수행합니다.
      1. newLengthDesc.[[Value]]를 ! ToUint32(propertyKey) + 1𝔽로 설정합니다.
      2. newWritable이 false이면 newLengthDesc.[[Writable]]을 false로 설정합니다.
      3. ! OrdinaryDefineOwnProperty(array, "length", newLengthDesc)를 수행합니다.
      4. false를 반환합니다.
  19. newWritable이 false이면, 다음을 수행합니다.
    1. succeeded를 ! OrdinaryDefineOwnProperty(array, "length", PropertyDescriptor { [[Writable]]: false })로 설정합니다.
    2. 단언: succeeded는 true입니다.
  20. true를 반환합니다.
참고

3 및 4 단계에서 propertyDesc.[[Value]]가 객체이면 해당 valueOf 메서드를 두 번 호출합니다. 이는 이 명세 제2판부터 이러한 효과로 명시된 레거시 동작입니다.

10.4.3 String 특수 객체

String 객체는 String 값을 캡슐화하고 해당 String 값의 개별 코드 단위 요소에 대응하는 가상 정수 인덱스 데이터 프로퍼티를 노출하는 특수 객체입니다. String 특수 객체에는 항상 "length"라는 데이터 프로퍼티가 있으며, 그 값은 캡슐화된 String 값의 길이입니다. 코드 단위 데이터 프로퍼티와 "length" 프로퍼티는 모두 쓰기 불가능하고 구성 불가능합니다.

객체의 [[GetOwnProperty]], [[DefineOwnProperty]] 및 [[OwnPropertyKeys]] 내부 메서드가 다음 구현을 사용하고, 그 밖의 필수 내부 메서드가 10.1에 있는 정의를 사용하면 해당 객체는 String 특수 객체(또는 간단히 String 객체)입니다. 이러한 메서드는 StringCreate에서 설치됩니다.

String 특수 객체에는 일반 객체와 동일한 내부 슬롯이 있습니다. 또한 [[StringData]] 내부 슬롯도 있습니다.

10.4.3.1 [[GetOwnProperty]] ( propertyKey )

a String exotic object string의 내부 메서드 [[GetOwnProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: 정상 완료 (값: (프로퍼티 서술자 또는 undefined)). 호출되면 다음 단계를 수행한다.

  1. propertyDesc를 OrdinaryGetOwnProperty(string, propertyKey)로 둡니다.
  2. propertyDesc가 undefined가 아니면, propertyDesc를 반환합니다.
  3. StringGetOwnProperty(string, propertyKey)를 반환합니다.

10.4.3.2 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

a String exotic object string의 내부 메서드 [[DefineOwnProperty]]. 인수 propertyKey (프로퍼티 키) 및 propertyDesc (프로퍼티 서술자). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. stringDesc를 StringGetOwnProperty(string, propertyKey)로 둡니다.
  2. stringDesc가 undefined가 아니면, 다음을 수행합니다.
    1. extensible을 string.[[Extensible]]로 둡니다.
    2. IsCompatiblePropertyDescriptor(extensible, propertyDesc, stringDesc)를 반환합니다.
  3. ! OrdinaryDefineOwnProperty(string, propertyKey, propertyDesc)를 반환합니다.

10.4.3.3 [[OwnPropertyKeys]] ( )

a String exotic object obj의 내부 메서드 [[OwnPropertyKeys]]. 인수 없음. 반환값: 정상 완료 (값: 리스트 (요소: 프로퍼티 키)). 호출되면 다음 단계를 수행한다.

  1. keys를 새로운 빈 List로 둡니다.
  2. string을 obj.[[StringData]]로 둡니다.
  3. 단언: string은 String입니다.
  4. length를 string의 길이로 둡니다.
  5. 0 ≤ i < length를 만족하는 각 정수 i에 대해 오름차순으로 다음을 수행합니다.
    1. ! ToString(𝔽(i))을 keys에 추가합니다.
  6. 배열 인덱스이고 ! ToIntegerOrInfinity(propertyKey) ≥ length인 obj의 각 자체 프로퍼티 키 propertyKey에 대해 숫자 인덱스 오름차순으로 다음을 수행합니다.
    1. propertyKey를 keys에 추가합니다.
  7. String이고 배열 인덱스가 아닌 obj의 각 자체 프로퍼티 키 propertyKey에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.
    1. propertyKey를 keys에 추가합니다.
  8. Symbol인 obj의 각 자체 프로퍼티 키 propertyKey에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.
    1. propertyKey를 keys에 추가합니다.
  9. keys를 반환합니다.

10.4.3.4 StringCreate ( value, proto )

추상 연산 StringCreate. 인수 value (String) 및 proto (Object). 반환값: String 특수 객체. 새로운 String 특수 객체의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.

  1. string을 MakeBasicObject(« [[Prototype]], [[Extensible]], [[StringData]] »)로 둡니다.
  2. string.[[Prototype]]을 proto로 설정합니다.
  3. string.[[StringData]]를 value로 설정합니다.
  4. string.[[GetOwnProperty]]을 10.4.3.1에 명시된 대로 설정합니다.
  5. string.[[DefineOwnProperty]]을 10.4.3.2에 명시된 대로 설정합니다.
  6. string.[[OwnPropertyKeys]]를 10.4.3.3에 명시된 대로 설정합니다.
  7. length를 value의 길이로 둡니다.
  8. ! DefinePropertyOrThrow(string, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false })를 수행합니다.
  9. string을 반환합니다.

10.4.3.5 StringGetOwnProperty ( string, propertyKey )

추상 연산 StringGetOwnProperty. 인수 string (String 특수 객체) 및 propertyKey (프로퍼티 키). 반환값: (프로퍼티 서술자 또는 undefined). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 String이 아니면, undefined를 반환합니다.
  2. numericIndex를 CanonicalNumericIndexString(propertyKey)으로 둡니다.
  3. numericIndex가 정수 Number가 아니면, undefined를 반환합니다.
  4. numericIndex가 -0𝔽이거나 numericIndex < -0𝔽이면, undefined를 반환합니다.
  5. stringData를 string.[[StringData]]로 둡니다.
  6. 단언: stringData는 String입니다.
  7. length를 stringData의 길이로 둡니다.
  8. ℝ(numericIndex) ≥ length이면, undefined를 반환합니다.
  9. resultString을 stringData의 ℝ(numericIndex)부터 ℝ(numericIndex) + 1까지의 부분 문자열로 둡니다.
  10. PropertyDescriptor { [[Value]]: resultString, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false }를 반환합니다.

10.4.4 arguments 특수 객체

대부분의 ECMAScript 함수는 자신의 코드에서 arguments 객체를 사용할 수 있도록 합니다. 함수 정의의 특성에 따라 해당 arguments 객체는 일반 객체 또는 arguments 특수 객체입니다. arguments 특수 객체는 배열 인덱스 프로퍼티가 연결된 ECMAScript 함수 호출의 형식 매개변수 바인딩에 매핑되는 특수 객체입니다.

객체의 내부 메서드가 다음 구현을 사용하고 여기에서 명시되지 않은 메서드는 10.1에 있는 정의를 사용하면 해당 객체는 arguments 특수 객체입니다. 이러한 메서드는 CreateMappedArgumentsObject에서 설치됩니다.

참고 1

CreateUnmappedArgumentsObject는 이 절에 포함되어 있지만 arguments 특수 객체가 아니라 일반 객체를 생성합니다.

arguments 특수 객체에는 일반 객체와 동일한 내부 슬롯이 있습니다. 또한 [[ParameterMap]] 내부 슬롯도 있습니다. 일반 arguments 객체에도 [[ParameterMap]] 내부 슬롯이 있으며 그 값은 항상 undefined입니다. 일반 arguments 객체에서 [[ParameterMap]] 내부 슬롯은 Object.prototype.toString(20.1.3.6)이 이를 arguments 객체로 식별하기 위해서만 사용합니다.

참고 2

arguments 특수 객체에서 숫자 이름 값이 대응하는 함수 객체의 형식 매개변수 수보다 작은 정수 인덱스 데이터 프로퍼티는 처음에는 함수 실행 컨텍스트의 대응하는 인수 바인딩과 값을 공유합니다. 이는 프로퍼티를 변경하면 대응하는 인수 바인딩의 값도 변경되고 그 반대도 성립함을 의미합니다. 이러한 프로퍼티를 삭제한 다음 다시 정의하거나 프로퍼티를 접근자 프로퍼티로 변경하면 이 대응 관계가 끊어집니다. arguments 객체가 일반 객체이면 해당 프로퍼티 값은 단순히 함수에 전달된 인수의 복사본이며 프로퍼티 값과 형식 매개변수 값 사이에 동적인 연결이 없습니다.

참고 3

ParameterMap 객체와 그 프로퍼티 값은 arguments 객체와 인수 바인딩 사이의 대응 관계를 명시하기 위한 장치로 사용됩니다. ParameterMap 객체와 그 프로퍼티 값인 객체는 ECMAScript 코드에서 직접 관찰할 수 없습니다. ECMAScript 구현체는 명시된 의미론을 구현하기 위해 이러한 객체를 실제로 생성하거나 사용할 필요가 없습니다.

참고 4

일반 arguments 객체는 접근 시 TypeError 예외를 던지는 "callee"라는 이름의 구성 불가능한 접근자 프로퍼티를 정의합니다. "callee" 프로퍼티는 일부 종류의 비엄격 함수에 대해서만 생성되는 arguments 특수 객체에서는 더 구체적인 의미를 갖습니다. 일반 변형에서 이 프로퍼티를 정의하는 이유는 적합한 ECMAScript 구현체가 다른 방식으로 이를 정의하지 않도록 보장하기 위해서입니다.

참고 5

arguments 특수 객체의 ECMAScript 구현체에는 역사적으로 "caller"라는 이름의 접근자 프로퍼티가 포함되어 있었습니다. ECMAScript 2017 이전에는 이 명세가 일반 arguments 객체에서 예외를 던지는 "caller" 프로퍼티의 정의를 포함했습니다. 구현체가 더 이상 이 확장을 포함하지 않으므로 ECMAScript 2017에서는 예외를 던지는 "caller" 접근자에 대한 요구 사항을 삭제했습니다.

10.4.4.1 [[GetOwnProperty]] ( propertyKey )

an arguments exotic object args의 내부 메서드 [[GetOwnProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: 정상 완료 (값: (프로퍼티 서술자 또는 undefined)). 호출되면 다음 단계를 수행한다.

  1. propertyDesc를 OrdinaryGetOwnProperty(args, propertyKey)로 둡니다.
  2. propertyDesc가 undefined이면, undefined를 반환합니다.
  3. map을 args.[[ParameterMap]]으로 둡니다.
  4. isMapped를 ! HasOwnProperty(map, propertyKey)로 둡니다.
  5. isMapped가 true이면, 다음을 수행합니다.
    1. propertyDesc.[[Value]]를 ! Get(map, propertyKey)으로 설정합니다.
  6. propertyDesc를 반환합니다.

10.4.4.2 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

an arguments exotic object args의 내부 메서드 [[DefineOwnProperty]]. 인수 propertyKey (프로퍼티 키) 및 propertyDesc (프로퍼티 서술자). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. map을 args.[[ParameterMap]]으로 둡니다.
  2. isMapped를 ! HasOwnProperty(map, propertyKey)로 둡니다.
  3. newArgDesc를 propertyDesc로 둡니다.
  4. isMapped가 true이고 IsDataDescriptor(propertyDesc)가 true이면, 다음을 수행합니다.
    1. propertyDesc에 [[Value]] 필드가 없고, propertyDesc에 [[Writable]] 필드가 있으며, propertyDesc.[[Writable]]이 false이면, 다음을 수행합니다.
      1. newArgDesc를 propertyDesc의 복사본으로 설정합니다.
      2. newArgDesc.[[Value]]를 ! Get(map, propertyKey)으로 설정합니다.
  5. allowed를 ! OrdinaryDefineOwnProperty(args, propertyKey, newArgDesc)로 둡니다.
  6. allowed가 false이면, false를 반환합니다.
  7. isMapped가 true이면, 다음을 수행합니다.
    1. IsAccessorDescriptor(propertyDesc)가 true이면, 다음을 수행합니다.
      1. ! map.[[Delete]](propertyKey)를 수행합니다.
    2. 그렇지 않으면,
      1. propertyDesc에 [[Value]] 필드가 있으면, 다음을 수행합니다.
        1. 단언: arguments 객체가 매핑하는 형식 매개변수는 항상 쓰기 가능하므로 다음 Set은 성공합니다.
        2. ! Set(map, propertyKey, propertyDesc.[[Value]], false)를 수행합니다.
      2. propertyDesc에 [[Writable]] 필드가 있고 propertyDesc.[[Writable]]이 false이면, 다음을 수행합니다.
        1. ! map.[[Delete]](propertyKey)를 수행합니다.
  8. true를 반환합니다.

10.4.4.3 [[Get]] ( propertyKey, receiver )

an arguments exotic object args의 내부 메서드 [[Get]]. 인수 propertyKey (프로퍼티 키) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. map을 args.[[ParameterMap]]으로 둡니다.
  2. isMapped를 ! HasOwnProperty(map, propertyKey)로 둡니다.
  3. isMapped가 false이면, ? OrdinaryGet(args, propertyKey, receiver)를 반환합니다.
  4. 단언: map에는 propertyKey에 대한 형식 매개변수 매핑이 포함되어 있습니다.
  5. ! Get(map, propertyKey)을 반환합니다.

10.4.4.4 [[Set]] ( propertyKey, value, receiver )

an arguments exotic object args의 내부 메서드 [[Set]]. 인수 propertyKey (프로퍼티 키), value (ECMAScript 언어 값) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. SameValue(args, receiver)가 false이면, 다음을 수행합니다.
    1. isMapped를 false로 둡니다.
  2. 그렇지 않으면,
    1. map을 args.[[ParameterMap]]으로 둡니다.
    2. isMapped를 ! HasOwnProperty(map, propertyKey)로 둡니다.
  3. isMapped가 true이면, 다음을 수행합니다.
    1. 단언: arguments 객체가 매핑하는 형식 매개변수는 항상 쓰기 가능하므로 다음 Set은 성공합니다.
    2. ! Set(map, propertyKey, value, false)를 수행합니다.
  4. ? OrdinarySet(args, propertyKey, value, receiver)를 반환합니다.

10.4.4.5 [[Delete]] ( propertyKey )

an arguments exotic object args의 내부 메서드 [[Delete]]. 인수 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. map을 args.[[ParameterMap]]으로 둡니다.
  2. isMapped를 ! HasOwnProperty(map, propertyKey)로 둡니다.
  3. result를 ? OrdinaryDelete(args, propertyKey)로 둡니다.
  4. result가 true이고 isMapped가 true이면, 다음을 수행합니다.
    1. ! map.[[Delete]](propertyKey)를 수행합니다.
  5. result를 반환합니다.

10.4.4.6 CreateUnmappedArgumentsObject ( argList )

추상 연산 CreateUnmappedArgumentsObject. 인수 argList (리스트 (요소: ECMAScript 언어 값)). 반환값: 일반 객체. 호출되면 다음 단계를 수행한다.

  1. length를 argList의 요소 수로 둡니다.
  2. obj를 OrdinaryObjectCreate(%Object.prototype%, « [[ParameterMap]] »)로 둡니다.
  3. obj.[[ParameterMap]]을 undefined로 설정합니다.
  4. ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  5. index를 0으로 둡니다.
  6. index < length인 동안 다음을 반복합니다.
    1. value를 argList[index]로 둡니다.
    2. ! CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), value)를 수행합니다.
    3. index를 index + 1로 설정합니다.
  7. ! DefinePropertyOrThrow(obj, %Symbol.iterator%, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  8. ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Getter]]: %ThrowTypeError%, [[Setter]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]: false })를 수행합니다.
  9. obj를 반환합니다.

10.4.4.7 CreateMappedArgumentsObject ( func, formals, argList, envRecord )

추상 연산 CreateMappedArgumentsObject. 인수 func (ECMAScript 함수 객체), formals (구문 분석 노드), argList (리스트 (요소: ECMAScript 언어 값)) 및 envRecord (Environment 레코드). 반환값: arguments 특수 객체. 호출되면 다음 단계를 수행한다.

  1. 단언: formals에는 나머지 매개변수, 바인딩 패턴 또는 이니셜라이저가 포함되어 있지 않습니다. 중복 식별자는 포함할 수 있습니다.
  2. length를 argList의 요소 수로 둡니다.
  3. obj를 MakeBasicObject(« [[Prototype]], [[Extensible]], [[ParameterMap]] »)로 둡니다.
  4. obj.[[GetOwnProperty]]을 10.4.4.1에 명시된 대로 설정합니다.
  5. obj.[[DefineOwnProperty]]을 10.4.4.2에 명시된 대로 설정합니다.
  6. obj.[[Get]]을 10.4.4.3에 명시된 대로 설정합니다.
  7. obj.[[Set]]을 10.4.4.4에 명시된 대로 설정합니다.
  8. obj.[[Delete]]를 10.4.4.5에 명시된 대로 설정합니다.
  9. obj.[[Prototype]]을 %Object.prototype%로 설정합니다.
  10. map을 OrdinaryObjectCreate(null)로 둡니다.
  11. obj.[[ParameterMap]]을 map으로 설정합니다.
  12. paramNames를 formals의 BoundNames로 둡니다.
  13. paramCount를 paramNames의 요소 수로 둡니다.
  14. index를 0으로 둡니다.
  15. index < length인 동안 다음을 반복합니다.
    1. value를 argList[index]로 둡니다.
    2. ! CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), value)를 수행합니다.
    3. index를 index + 1로 설정합니다.
  16. ! DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  17. mappedNames를 새로운 빈 List로 둡니다.
  18. index를 paramCount - 1로 설정합니다.
  19. index ≥ 0인 동안 다음을 반복합니다.
    1. name을 paramNames[index]로 둡니다.
    2. mappedNames에 name이 포함되어 있지 않으면, 다음을 수행합니다.
      1. name을 mappedNames에 추가합니다.
      2. index < length이면, 다음을 수행합니다.
        1. getter를 MakeArgGetter(name, envRecord)로 둡니다.
        2. setter를 MakeArgSetter(name, envRecord)로 둡니다.
        3. ! map.[[DefineOwnProperty]](! ToString(𝔽(index)), PropertyDescriptor { [[Setter]]: setter, [[Getter]]: getter, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
    3. index를 index - 1로 설정합니다.
  20. ! DefinePropertyOrThrow(obj, %Symbol.iterator%, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  21. ! DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Value]]: func, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })를 수행합니다.
  22. obj를 반환합니다.

10.4.4.7.1 MakeArgGetter ( name, envRecord )

추상 연산 MakeArgGetter. 인수 name (String) 및 envRecord (Environment 레코드). 반환값: 함수 객체. 실행될 때 envRecord에서 name에 바인딩된 값을 반환하는 내장 함수 객체를 생성합니다. 호출되면 다음 단계를 수행한다.

  1. getterClosure를 매개변수가 없고 name 및 envRecord를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure로 둡니다:
    1. NormalCompletion(! envRecord.GetBindingValue(name, false))을 반환합니다.
  2. getter를 CreateBuiltinFunction(getterClosure, 0, "", « »)로 둡니다.
  3. 참고: ECMAScript 코드에서 getter에 직접 접근할 수는 없습니다.
  4. getter를 반환합니다.

10.4.4.7.2 MakeArgSetter ( name, envRecord )

추상 연산 MakeArgSetter. 인수 name (String) 및 envRecord (Environment 레코드). 반환값: 함수 객체. 실행될 때 envRecord에서 name에 바인딩된 값을 설정하는 내장 함수 객체를 생성합니다. 호출되면 다음 단계를 수행한다.

  1. setterClosure를 매개변수 (value)를 갖고 name 및 envRecord를 캡처하며 호출될 때 다음 단계를 수행하는 새로운 Abstract Closure로 둡니다:
    1. NormalCompletion(! envRecord.SetMutableBinding(name, value, false))을 반환합니다.
  2. setter를 CreateBuiltinFunction(setterClosure, 1, "", « »)로 둡니다.
  3. 참고: ECMAScript 코드에서 setter에 직접 접근할 수는 없습니다.
  4. setter를 반환합니다.

10.4.5 TypedArray 특수 객체

TypedArray는 정규 숫자 문자열인 프로퍼티 키를 특별하게 처리하는 특수 객체입니다. 범위 내의 정수 인덱스인 부분집합을 사용하여 균일한 타입의 요소를 인덱싱하고, 나머지는 프로토타입 체인을 순회하지 않고 존재하지 않도록 하는 불변 조건을 강제합니다.

참고

임의의 Number n에 대한 ToString(n)이 정규 숫자 문자열이므로 구현체는 실제로 문자열 변환을 수행하지 않고 Number를 TypedArray의 프로퍼티 키로 취급할 수 있습니다.

TypedArray에는 일반 객체와 동일한 내부 슬롯이 있으며 추가로 [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]] 및 [[ArrayLength]] 내부 슬롯이 있습니다.

객체의 [[PreventExtensions]], [[GetOwnProperty]], [[HasProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]] 및 [[OwnPropertyKeys]] 내부 메서드가 이 절의 정의를 사용하고, 그 밖의 필수 내부 메서드가 10.1에 있는 정의를 사용하면 해당 객체는 TypedArray입니다. 이러한 메서드는 TypedArrayCreate에서 설치됩니다.

10.4.5.1 [[PreventExtensions]] ( )

a TypedArray obj의 내부 메서드 [[PreventExtensions]]. 인수 없음. 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. 참고: 6.1.7.3에 명시된 확장 가능성과 관련된 불변 조건은 obj가 프로퍼티를 얻을 수 있거나(또는 잃었다가 다시 얻을 수 있으면) 이 메서드가 true를 반환하는 것을 허용하지 않습니다. 이러한 상황은 기반 버퍼의 크기가 조정될 때 정수 인덱스 이름의 프로퍼티에서 발생할 수 있습니다.
  2. IsTypedArrayFixedLength(obj)가 false이면, false를 반환합니다.
  3. OrdinaryPreventExtensions(obj)를 반환합니다.

10.4.5.2 [[GetOwnProperty]] ( propertyKey )

a TypedArray obj의 내부 메서드 [[GetOwnProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: 정상 완료 (값: (프로퍼티 서술자 또는 undefined)). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 String이면, 다음을 수행합니다.
    1. numericIndex를 CanonicalNumericIndexString(propertyKey)으로 둡니다.
    2. numericIndex가 undefined가 아니면, 다음을 수행합니다.
      1. value를 TypedArrayGetElement(obj, numericIndex)로 둡니다.
      2. value가 undefined이면, undefined를 반환합니다.
      3. PropertyDescriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true }를 반환합니다.
  2. OrdinaryGetOwnProperty(obj, propertyKey)를 반환합니다.

10.4.5.3 [[HasProperty]] ( propertyKey )

a TypedArray obj의 내부 메서드 [[HasProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 String이면, 다음을 수행합니다.
    1. numericIndex를 CanonicalNumericIndexString(propertyKey)으로 둡니다.
    2. numericIndex가 undefined가 아니면, IsValidIntegerIndex(obj, numericIndex)를 반환합니다.
  2. ? OrdinaryHasProperty(obj, propertyKey)를 반환합니다.

10.4.5.4 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

a TypedArray obj의 내부 메서드 [[DefineOwnProperty]]. 인수 propertyKey (프로퍼티 키) 및 propertyDesc (프로퍼티 서술자). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 String이면, 다음을 수행합니다.
    1. numericIndex를 CanonicalNumericIndexString(propertyKey)으로 둡니다.
    2. numericIndex가 undefined가 아니면, 다음을 수행합니다.
      1. IsValidIntegerIndex(obj, numericIndex)가 false이면, false를 반환합니다.
      2. propertyDesc에 [[Configurable]] 필드가 있고 propertyDesc.[[Configurable]]이 false이면, false를 반환합니다.
      3. propertyDesc에 [[Enumerable]] 필드가 있고 propertyDesc.[[Enumerable]]이 false이면, false를 반환합니다.
      4. IsAccessorDescriptor(propertyDesc)가 true이면, false를 반환합니다.
      5. propertyDesc에 [[Writable]] 필드가 있고 propertyDesc.[[Writable]]이 false이면, false를 반환합니다.
      6. propertyDesc에 [[Value]] 필드가 있으면 ? TypedArraySetElement(obj, numericIndex, propertyDesc.[[Value]])를 수행합니다.
      7. true를 반환합니다.
  2. ! OrdinaryDefineOwnProperty(obj, propertyKey, propertyDesc)를 반환합니다.

10.4.5.5 [[Get]] ( propertyKey, receiver )

a TypedArray obj의 내부 메서드 [[Get]]. 인수 propertyKey (프로퍼티 키) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 String이면, 다음을 수행합니다.
    1. numericIndex를 CanonicalNumericIndexString(propertyKey)으로 둡니다.
    2. numericIndex가 undefined가 아니면, 다음을 수행합니다.
      1. TypedArrayGetElement(obj, numericIndex)를 반환합니다.
  2. ? OrdinaryGet(obj, propertyKey, receiver)를 반환합니다.

10.4.5.6 [[Set]] ( propertyKey, value, receiver )

a TypedArray obj의 내부 메서드 [[Set]]. 인수 propertyKey (프로퍼티 키), value (ECMAScript 언어 값) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 String이면, 다음을 수행합니다.
    1. numericIndex를 CanonicalNumericIndexString(propertyKey)으로 둡니다.
    2. numericIndex가 undefined가 아니면, 다음을 수행합니다.
      1. SameValue(obj, receiver)가 true이면, 다음을 수행합니다.
        1. ? TypedArraySetElement(obj, numericIndex, value)를 수행합니다.
        2. true를 반환합니다.
      2. IsValidIntegerIndex(obj, numericIndex)가 false이면, true를 반환합니다.
  2. ? OrdinarySet(obj, propertyKey, value, receiver)를 반환합니다.

10.4.5.7 [[Delete]] ( propertyKey )

a TypedArray obj의 내부 메서드 [[Delete]]. 인수 propertyKey (프로퍼티 키). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 String이면, 다음을 수행합니다.
    1. numericIndex를 CanonicalNumericIndexString(propertyKey)으로 둡니다.
    2. numericIndex가 undefined가 아니면, 다음을 수행합니다.
      1. IsValidIntegerIndex(obj, numericIndex)가 false이면, true를 반환합니다.
      2. false를 반환합니다.
  2. ! OrdinaryDelete(obj, propertyKey)를 반환합니다.

10.4.5.8 [[OwnPropertyKeys]] ( )

a TypedArray obj의 내부 메서드 [[OwnPropertyKeys]]. 인수 없음. 반환값: 정상 완료 (값: 리스트 (요소: 프로퍼티 키)). 호출되면 다음 단계를 수행한다.

  1. taRecord를 MakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 둡니다.
  2. keys를 새로운 빈 List로 둡니다.
  3. IsTypedArrayOutOfBounds(taRecord)가 false이면, 다음을 수행합니다.
    1. length를 TypedArrayLength(taRecord)로 둡니다.
    2. 0 ≤ i < length를 만족하는 각 정수 i에 대해 오름차순으로 다음을 수행합니다.
      1. ! ToString(𝔽(i))을 keys에 추가합니다.
  4. String이고 정수 인덱스가 아닌 obj의 각 자체 프로퍼티 키 propertyKey에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.
    1. propertyKey를 keys에 추가합니다.
  5. Symbol인 obj의 각 자체 프로퍼티 키 propertyKey에 대해 프로퍼티 생성 시간 오름차순으로 다음을 수행합니다.
    1. propertyKey를 keys에 추가합니다.
  6. keys를 반환합니다.

10.4.5.9 버퍼 감시 Record가 있는 TypedArray

TypedArray With Buffer Witness Record는 TypedArray와 조회하는 버퍼의 캐시된 바이트 길이를 함께 캡슐화하는 데 사용하는 Record입니다. 조회하는 버퍼가 확장 가능한 SharedArrayBuffer인 경우 바이트 길이 데이터 블록에 대해 하나의 ReadSharedMemory 이벤트만 발생하도록 보장하는 데 사용됩니다.

TypedArray With Buffer Witness Record에는 표 28에 나열된 필드가 있습니다.

표 28: TypedArray With Buffer Witness Record 필드
필드 이름 값 의미
[[Object]] TypedArray 버퍼의 바이트 길이가 로드되는 TypedArray입니다.
[[CachedBufferByteLength]] 음이 아닌 정수 또는 detached Record가 생성될 당시 객체의 [[ViewedArrayBuffer]] 바이트 길이입니다.

10.4.5.10 MakeTypedArrayWithBufferWitnessRecord ( obj, order )

추상 연산 MakeTypedArrayWithBufferWitnessRecord. 인수 obj (TypedArray) 및 order ((seq-cst 또는 unordered)). 반환값: TypedArray With Buffer Witness 레코드. 호출되면 다음 단계를 수행한다.

  1. buffer를 obj.[[ViewedArrayBuffer]]로 둡니다.
  2. IsDetachedBuffer(buffer)가 true이면, 다음을 수행합니다.
    1. byteLength를 detached로 둡니다.
  3. 그렇지 않으면,
    1. byteLength를 ArrayBufferByteLength(buffer, order)로 둡니다.
  4. TypedArray With Buffer Witness Record { [[Object]]: obj, [[CachedBufferByteLength]]: byteLength }를 반환합니다.

10.4.5.11 TypedArrayCreate ( proto )

추상 연산 TypedArrayCreate. 인수 proto (Object). 반환값: TypedArray. 새로운 TypedArray의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.

  1. internalSlotsList를 « [[Prototype]], [[Extensible]], [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »로 둡니다.
  2. ta를 MakeBasicObject(internalSlotsList)로 둡니다.
  3. ta.[[PreventExtensions]]를 10.4.5.1에 명시된 대로 설정합니다.
  4. ta.[[GetOwnProperty]]을 10.4.5.2에 명시된 대로 설정합니다.
  5. ta.[[HasProperty]]를 10.4.5.3에 명시된 대로 설정합니다.
  6. ta.[[DefineOwnProperty]]을 10.4.5.4에 명시된 대로 설정합니다.
  7. ta.[[Get]]을 10.4.5.5에 명시된 대로 설정합니다.
  8. ta.[[Set]]을 10.4.5.6에 명시된 대로 설정합니다.
  9. ta.[[Delete]]를 10.4.5.7에 명시된 대로 설정합니다.
  10. ta.[[OwnPropertyKeys]]를 10.4.5.8에 명시된 대로 설정합니다.
  11. ta.[[Prototype]]을 proto로 설정합니다.
  12. ta를 반환합니다.

10.4.5.12 TypedArrayByteLength ( taRecord )

추상 연산 TypedArrayByteLength. 인수 taRecord (TypedArray With Buffer Witness 레코드). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.

  1. 단언: IsTypedArrayOutOfBounds(taRecord)는 false입니다.
  2. obj를 taRecord.[[Object]]로 둡니다.
  3. obj.[[ByteLength]]가 auto가 아니면, obj.[[ByteLength]]를 반환합니다.
  4. length를 TypedArrayLength(taRecord)로 둡니다.
  5. elementSize를 TypedArrayElementSize(obj)로 둡니다.
  6. 참고: 기반 버퍼가 정수 배수가 아닌 크기로 조정된 경우에도 반환되는 바이트 길이는 항상 elementSize의 정수 배수입니다.
  7. length × elementSize를 반환합니다.

10.4.5.13 TypedArrayLength ( taRecord )

추상 연산 TypedArrayLength. 인수 taRecord (TypedArray With Buffer Witness 레코드). 반환값: 음이 아닌 정수. 호출되면 다음 단계를 수행한다.

  1. 단언: IsTypedArrayOutOfBounds(taRecord)는 false입니다.
  2. obj를 taRecord.[[Object]]로 둡니다.
  3. obj.[[ArrayLength]]가 auto가 아니면, obj.[[ArrayLength]]를 반환합니다.
  4. 단언: IsFixedLengthArrayBuffer(obj.[[ViewedArrayBuffer]])는 false입니다.
  5. byteOffset을 obj.[[ByteOffset]]으로 둡니다.
  6. elementSize를 TypedArrayElementSize(obj)로 둡니다.
  7. byteLength를 taRecord.[[CachedBufferByteLength]]로 둡니다.
  8. 단언: byteLength는 detached가 아닙니다.
  9. floor((byteLength - byteOffset) / elementSize)를 반환합니다.

10.4.5.14 IsTypedArrayOutOfBounds ( taRecord )

추상 연산 IsTypedArrayOutOfBounds. 인수 taRecord (TypedArray With Buffer Witness 레코드). 반환값: Boolean. 객체의 숫자 프로퍼티 중 하나라도 기반 버퍼의 범위에 포함되지 않는 인덱스의 값을 참조하는지 검사합니다. 호출되면 다음 단계를 수행한다.

  1. obj를 taRecord.[[Object]]로 둡니다.
  2. bufferByteLength를 taRecord.[[CachedBufferByteLength]]로 둡니다.
  3. IsDetachedBuffer(obj.[[ViewedArrayBuffer]])가 true이면, 다음을 수행합니다.
    1. 단언: bufferByteLength는 detached입니다.
    2. true를 반환합니다.
  4. 단언: bufferByteLength는 음이 아닌 정수입니다.
  5. byteOffsetStart를 obj.[[ByteOffset]]으로 둡니다.
  6. obj.[[ArrayLength]]가 auto이면, 다음을 수행합니다.
    1. byteOffsetEnd를 bufferByteLength로 둡니다.
  7. 그렇지 않으면,
    1. elementSize를 TypedArrayElementSize(obj)로 둡니다.
    2. arrayByteLength를 obj.[[ArrayLength]] × elementSize로 둡니다.
    3. byteOffsetEnd를 byteOffsetStart + arrayByteLength로 둡니다.
  8. 참고: [[ByteOffset]]이 bufferByteLength인 길이 0의 TypedArray는 범위를 벗어난 것으로 간주하지 않습니다.
  9. byteOffsetStart > bufferByteLength이거나 byteOffsetEnd > bufferByteLength이면, true를 반환합니다.
  10. false를 반환합니다.

10.4.5.15 IsTypedArrayFixedLength ( obj )

추상 연산 IsTypedArrayFixedLength. 인수 obj (TypedArray). 반환값: Boolean. 호출되면 다음 단계를 수행한다.

  1. obj.[[ArrayLength]]가 auto이면, false를 반환합니다.
  2. buffer를 obj.[[ViewedArrayBuffer]]로 둡니다.
  3. IsFixedLengthArrayBuffer(buffer)가 false이고 IsSharedArrayBuffer(buffer)가 false이면, false를 반환합니다.
  4. true를 반환합니다.

10.4.5.16 IsValidIntegerIndex ( obj, index )

추상 연산 IsValidIntegerIndex. 인수 obj (TypedArray) 및 index (Number). 반환값: Boolean. 호출되면 다음 단계를 수행한다.

  1. IsDetachedBuffer(obj.[[ViewedArrayBuffer]])가 true이면, false를 반환합니다.
  2. index가 정수 Number가 아니면, false를 반환합니다.
  3. index가 -0𝔽이거나 index < -0𝔽이면, false를 반환합니다.
  4. taRecord를 MakeTypedArrayWithBufferWitnessRecord(obj, unordered)로 둡니다.
  5. 참고: obj의 기반 버퍼가 확장 가능한 SharedArrayBuffer인 경우 범위 검사는 동기화 연산이 아닙니다.
  6. IsTypedArrayOutOfBounds(taRecord)가 true이면, false를 반환합니다.
  7. length를 TypedArrayLength(taRecord)로 둡니다.
  8. ℝ(index) ≥ length이면, false를 반환합니다.
  9. true를 반환합니다.

10.4.5.17 TypedArrayGetElement ( obj, index )

추상 연산 TypedArrayGetElement. 인수 obj (TypedArray) 및 index (Number). 반환값: (Number, BigInt 또는 undefined). 호출되면 다음 단계를 수행한다.

  1. IsValidIntegerIndex(obj, index)가 false이면, undefined를 반환합니다.
  2. offset을 obj.[[ByteOffset]]으로 둡니다.
  3. elementSize를 TypedArrayElementSize(obj)로 둡니다.
  4. byteIndexInBuffer를 (ℝ(index) × elementSize) + offset으로 둡니다.
  5. elementType을 TypedArrayElementType(obj)으로 둡니다.
  6. GetValueFromBuffer(obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, true, unordered)를 반환합니다.

10.4.5.18 TypedArraySetElement ( obj, index, value )

추상 연산 TypedArraySetElement. 인수 obj (TypedArray), index (Number) 및 value (ECMAScript 언어 값). 반환값: (정상 완료 (값: unused) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. obj.[[ContentType]]이 bigint이면 number를 ? ToBigInt(value)로 둡니다.
  2. 그렇지 않으면 number를 ? ToNumber(value)로 둡니다.
  3. IsValidIntegerIndex(obj, index)가 true이면, 다음을 수행합니다.
    1. offset을 obj.[[ByteOffset]]으로 둡니다.
    2. elementSize를 TypedArrayElementSize(obj)로 둡니다.
    3. byteIndexInBuffer를 (ℝ(index) × elementSize) + offset으로 둡니다.
    4. elementType을 TypedArrayElementType(obj)으로 둡니다.
    5. SetValueInBuffer(obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, number, true, unordered)를 수행합니다.
  4. unused를 반환합니다.
참고

이 연산은 항상 성공하는 것처럼 보이지만 TypedArray 끝을 넘어 쓰려고 하거나 분리된 ArrayBuffer를 기반으로 하는 TypedArray에 쓰려고 하면 아무 효과도 없습니다.

10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )

추상 연산 IsArrayBufferViewOutOfBounds. 인수 obj ((TypedArray 또는 DataView)). 반환값: Boolean. TypedArray의 숫자 프로퍼티 중 하나 또는 DataView 객체의 메서드 중 하나가 기반 데이터 블록의 범위에 포함되지 않는 인덱스의 값을 참조할 수 있는지를 검사합니다. 이 추상 연산은 상위 명세의 편의를 위해 존재합니다. 호출되면 다음 단계를 수행한다.

  1. obj에 [[DataView]] 내부 슬롯이 있으면, 다음을 수행합니다.
    1. viewRecord를 MakeDataViewWithBufferWitnessRecord(obj, seq-cst)로 둡니다.
    2. IsViewOutOfBounds(viewRecord)를 반환합니다.
  2. taRecord를 MakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 둡니다.
  3. IsTypedArrayOutOfBounds(taRecord)를 반환합니다.

10.4.6 모듈 네임스페이스 특수 객체

모듈 네임스페이스 특수 객체는 ECMAScript Module에서 내보낸 바인딩을 노출하는 특수 객체입니다(16.2.3 참조). 모듈 네임스페이스 특수 객체의 String 키 자체 프로퍼티와 Module에서 내보낸 바인딩 이름 사이에는 일대일 대응 관계가 있습니다. 내보낸 바인딩에는 export * 내보내기 항목을 사용하여 간접적으로 내보낸 모든 바인딩이 포함됩니다. String 값을 갖는 각 자체 프로퍼티 키는 대응하는 내보낸 바인딩 이름의 StringValue입니다. 이것이 모듈 네임스페이스 특수 객체의 유일한 String 키 프로퍼티입니다. 이러한 각 프로퍼티는 속성 { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false }를 갖습니다. 모듈 네임스페이스 특수 객체는 확장 가능하지 않습니다.

객체의 [[GetPrototypeOf]], [[SetPrototypeOf]], [[IsExtensible]], [[PreventExtensions]], [[GetOwnProperty]], [[DefineOwnProperty]], [[HasProperty]], [[Get]], [[Set]], [[Delete]] 및 [[OwnPropertyKeys]] 내부 메서드가 이 절의 정의를 사용하고, 그 밖의 필수 내부 메서드가 10.1에 있는 정의를 사용하면 해당 객체는 모듈 네임스페이스 특수 객체입니다. 이러한 메서드는 ModuleNamespaceCreate에서 설치됩니다.

모듈 네임스페이스 특수 객체에는 표 29에 정의된 내부 슬롯이 있습니다.

표 29: 모듈 네임스페이스 특수 객체의 내부 슬롯
내부 슬롯 타입 설명
[[Module]] Module Record 이 네임스페이스가 내보내기를 노출하는 Module Record입니다.
[[Exports]] String의 List 이 객체의 자체 프로퍼티로 노출되는 내보낸 이름의 String 값을 요소로 갖는 List입니다. 목록은 사전식 코드 단위 순서에 따라 정렬됩니다.

10.4.6.1 [[GetPrototypeOf]] ( )

a module namespace exotic object의 내부 메서드 [[GetPrototypeOf]]. 인수 없음. 반환값: 정상 완료 (값: null). 호출되면 다음 단계를 수행한다.

  1. null을 반환합니다.

10.4.6.2 [[SetPrototypeOf]] ( proto )

a module namespace exotic object obj의 내부 메서드 [[SetPrototypeOf]]. 인수 proto ((Object 또는 null)). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. ! SetImmutablePrototype(obj, proto)를 반환합니다.

10.4.6.3 [[IsExtensible]] ( )

a module namespace exotic object의 내부 메서드 [[IsExtensible]]. 인수 없음. 반환값: 정상 완료 (값: false). 호출되면 다음 단계를 수행한다.

  1. false를 반환합니다.

10.4.6.4 [[PreventExtensions]] ( )

a module namespace exotic object의 내부 메서드 [[PreventExtensions]]. 인수 없음. 반환값: 정상 완료 (값: true). 호출되면 다음 단계를 수행한다.

  1. true를 반환합니다.

10.4.6.5 [[GetOwnProperty]] ( propertyKey )

a module namespace exotic object obj의 내부 메서드 [[GetOwnProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: (프로퍼티 서술자 또는 undefined)) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 Symbol이면, OrdinaryGetOwnProperty(obj, propertyKey)를 반환합니다.
  2. exports를 obj.[[Exports]]로 둡니다.
  3. exports에 propertyKey가 포함되어 있지 않으면, undefined를 반환합니다.
  4. value를 ? obj.[[Get]](propertyKey, obj)로 둡니다.
  5. PropertyDescriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false }를 반환합니다.

10.4.6.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

a module namespace exotic object obj의 내부 메서드 [[DefineOwnProperty]]. 인수 propertyKey (프로퍼티 키) 및 propertyDesc (프로퍼티 서술자). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 Symbol이면, ! OrdinaryDefineOwnProperty(obj, propertyKey, propertyDesc)를 반환합니다.
  2. current를 ? obj.[[GetOwnProperty]](propertyKey)로 둡니다.
  3. current가 undefined이면, false를 반환합니다.
  4. propertyDesc에 [[Configurable]] 필드가 있고 propertyDesc.[[Configurable]]이 true이면, false를 반환합니다.
  5. propertyDesc에 [[Enumerable]] 필드가 있고 propertyDesc.[[Enumerable]]이 false이면, false를 반환합니다.
  6. IsAccessorDescriptor(propertyDesc)가 true이면, false를 반환합니다.
  7. propertyDesc에 [[Writable]] 필드가 있고 propertyDesc.[[Writable]]이 false이면, false를 반환합니다.
  8. propertyDesc에 [[Value]] 필드가 있으면, SameValue(propertyDesc.[[Value]], current.[[Value]])를 반환합니다.
  9. true를 반환합니다.

10.4.6.7 [[HasProperty]] ( propertyKey )

a module namespace exotic object obj의 내부 메서드 [[HasProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 Symbol이면, ! OrdinaryHasProperty(obj, propertyKey)를 반환합니다.
  2. exports를 obj.[[Exports]]로 둡니다.
  3. exports에 propertyKey가 포함되어 있으면, true를 반환합니다.
  4. false를 반환합니다.

10.4.6.8 [[Get]] ( propertyKey, receiver )

a module namespace exotic object obj의 내부 메서드 [[Get]]. 인수 propertyKey (프로퍼티 키) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 Symbol이면, 다음을 수행합니다.
    1. ! OrdinaryGet(obj, propertyKey, receiver)를 반환합니다.
  2. exports를 obj.[[Exports]]로 둡니다.
  3. exports에 propertyKey가 포함되어 있지 않으면, undefined를 반환합니다.
  4. module을 obj.[[Module]]로 둡니다.
  5. binding을 module.ResolveExport(propertyKey)로 둡니다.
  6. 단언: binding은 ResolvedBinding Record입니다.
  7. targetModule을 binding.[[Module]]로 둡니다.
  8. 단언: targetModule은 undefined가 아닙니다.
  9. binding.[[BindingName]]이 namespace이면, 다음을 수행합니다.
    1. GetModuleNamespace(targetModule)를 반환합니다.
  10. targetEnv를 targetModule.[[Environment]]로 둡니다.
  11. targetEnv가 empty이면, ReferenceError 예외를 던집니다.
  12. ? targetEnv.GetBindingValue(binding.[[BindingName]], true)를 반환합니다.
참고

ResolveExport는 부작용이 없습니다. 이 연산을 특정 exportName, resolveSet 인수 쌍으로 호출할 때마다 동일한 결과를 반환해야 합니다. 구현체는 각 모듈 네임스페이스 특수 객체의 [[Exports]]에 대한 ResolveExport 결과를 미리 계산하거나 캐시하도록 선택할 수 있습니다.

10.4.6.9 [[Set]] ( propertyKey, value, receiver )

a module namespace exotic object의 내부 메서드 [[Set]]. 인수 propertyKey (프로퍼티 키), value (ECMAScript 언어 값) 및 receiver (ECMAScript 언어 값). 반환값: 정상 완료 (값: false). 호출되면 다음 단계를 수행한다.

  1. false를 반환합니다.

10.4.6.10 [[Delete]] ( propertyKey )

a module namespace exotic object obj의 내부 메서드 [[Delete]]. 인수 propertyKey (프로퍼티 키). 반환값: 정상 완료 (값: Boolean). 호출되면 다음 단계를 수행한다.

  1. propertyKey가 Symbol이면, 다음을 수행합니다.
    1. ! OrdinaryDelete(obj, propertyKey)를 반환합니다.
  2. exports를 obj.[[Exports]]로 둡니다.
  3. exports에 propertyKey가 포함되어 있으면, false를 반환합니다.
  4. true를 반환합니다.

10.4.6.11 [[OwnPropertyKeys]] ( )

a module namespace exotic object obj의 내부 메서드 [[OwnPropertyKeys]]. 인수 없음. 반환값: 정상 완료 (값: 리스트 (요소: 프로퍼티 키)). 호출되면 다음 단계를 수행한다.

  1. exports를 obj.[[Exports]]로 둡니다.
  2. symbolKeys를 OrdinaryOwnPropertyKeys(obj)로 둡니다.
  3. exports와 symbolKeys의 목록 연결을 반환합니다.

10.4.6.12 ModuleNamespaceCreate ( module, exports )

추상 연산 ModuleNamespaceCreate. 인수 module (Module 레코드) 및 exports (리스트 (요소: String)). 반환값: module namespace 특수 객체. 새로운 모듈 네임스페이스 특수 객체의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.

  1. 단언: module.[[Namespace]]는 empty입니다.
  2. internalSlotsList를 표 29에 나열된 내부 슬롯으로 둡니다.
  3. namespace를 MakeBasicObject(internalSlotsList)로 둡니다.
  4. namespace의 필수 내부 메서드를 10.4.6에 명시된 정의로 설정합니다.
  5. namespace.[[Module]]을 module로 설정합니다.
  6. sortedExports를 exports의 요소를 사전식 코드 단위 순서로 정렬한 요소를 갖는 List로 둡니다.
  7. namespace.[[Exports]]를 sortedExports로 설정합니다.
  8. 28.3의 정의에 대응하는 namespace의 자체 프로퍼티를 생성합니다.
  9. module.[[Namespace]]를 namespace로 설정합니다.
  10. namespace를 반환합니다.

10.4.7 변경 불가능한 프로토타입 특수 객체

변경 불가능한 프로토타입 특수 객체는 초기화된 후 변경되지 않는 [[Prototype]] 내부 슬롯을 갖는 특수 객체입니다.

객체의 [[SetPrototypeOf]] 내부 메서드가 다음 구현을 사용하면 해당 객체는 변경 불가능한 프로토타입 특수 객체입니다. (그 밖의 필수 내부 메서드는 해당 변경 불가능한 프로토타입 특수 객체의 구체적인 종류에 따라 어떤 구현이든 사용할 수 있습니다.)

참고

다른 특수 객체와 달리 변경 불가능한 프로토타입 특수 객체에는 전용 생성 추상 연산이 제공되지 않습니다. 이는 %Object.prototype%과 호스트 환경에서만 사용되며, 호스트 환경에서는 관련 객체가 다른 방식으로도 특수 객체일 수 있어 자체적인 전용 생성 연산이 필요하기 때문입니다.

10.4.7.1 [[SetPrototypeOf]] ( proto )

an immutable prototype exotic object obj의 내부 메서드 [[SetPrototypeOf]]. 인수 proto ((Object 또는 null)). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? SetImmutablePrototype(obj, proto)를 반환합니다.

10.4.7.2 SetImmutablePrototype ( obj, proto )

추상 연산 SetImmutablePrototype. 인수 obj (Object) 및 proto ((Object 또는 null)). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. current를 ? obj.[[GetPrototypeOf]]()로 둡니다.
  2. SameValue(proto, current)가 true이면, true를 반환합니다.
  3. false를 반환합니다.

10.5 Proxy 객체 내부 메서드와 내부 슬롯

Proxy 객체는 필수 내부 메서드의 일부가 ECMAScript 코드를 사용하여 구현되는 특수 객체입니다. 모든 Proxy 객체에는 [[ProxyHandler]]라는 내부 슬롯이 있습니다. [[ProxyHandler]]의 값은 프록시의 핸들러 객체라고 하는 객체 또는 null입니다. 핸들러 객체의 메서드(표 30 참조)는 Proxy 객체의 하나 이상의 내부 메서드 구현을 확장하는 데 사용할 수 있습니다. 모든 Proxy 객체에는 [[ProxyTarget]]이라는 내부 슬롯도 있으며, 그 값은 객체 또는 null입니다. 이 객체를 프록시의 대상 객체라고 합니다.

객체의 필수 내부 메서드(해당하는 경우 [[Call]] 및 [[Construct]] 포함)가 이 절의 정의를 사용하면 해당 객체는 Proxy 특수 객체입니다. 이러한 내부 메서드는 ProxyCreate에서 설치됩니다.

표 30: Proxy 핸들러 메서드
내부 메서드 핸들러 메서드
[[GetPrototypeOf]] getPrototypeOf
[[SetPrototypeOf]] setPrototypeOf
[[IsExtensible]] isExtensible
[[PreventExtensions]] preventExtensions
[[GetOwnProperty]] getOwnPropertyDescriptor
[[DefineOwnProperty]] defineProperty
[[HasProperty]] has
[[Get]] get
[[Set]] set
[[Delete]] deleteProperty
[[OwnPropertyKeys]] ownKeys
[[Call]] apply
[[Construct]] construct

Proxy 객체 내부 메서드의 구현을 제공하기 위해 핸들러 메서드를 호출하면 프록시의 대상 객체가 매개변수로 핸들러 메서드에 전달됩니다. 프록시의 핸들러 객체가 모든 필수 내부 메서드에 대응하는 메서드를 반드시 갖는 것은 아닙니다. 핸들러 객체에 내부 트랩에 대응하는 메서드가 없으면 프록시에서 내부 메서드를 호출할 때 프록시의 대상 객체에서 대응하는 내부 메서드를 호출합니다.

Proxy 객체의 [[ProxyHandler]] 및 [[ProxyTarget]] 내부 슬롯은 객체가 생성될 때 항상 초기화되며 일반적으로 수정할 수 없습니다. 일부 Proxy 객체는 나중에 해제할 수 있는 방식으로 생성됩니다. 프록시가 해제되면 [[ProxyHandler]] 및 [[ProxyTarget]] 내부 슬롯이 null로 설정되며, 이후 해당 Proxy 객체에서 내부 메서드를 호출하면 TypeError 예외가 던져집니다.

Proxy 객체는 임의의 ECMAScript 코드가 내부 메서드 구현을 제공할 수 있게 하므로, 핸들러 메서드가 6.1.7.3에 정의된 불변 조건을 위반하는 Proxy 객체를 정의할 수 있습니다. 6.1.7.3에 정의된 일부 내부 메서드 불변 조건은 필수 무결성 불변 조건입니다. 이러한 불변 조건은 이 절에 명시된 Proxy 객체 내부 메서드가 명시적으로 강제합니다. ECMAScript 구현체는 가능한 모든 불변 조건 위반 상황에서도 견고해야 합니다.

다음 알고리즘 설명에서는 obj가 ECMAScript Proxy 객체이고, propertyKey가 프로퍼티 키 값이며, value가 임의의 ECMAScript 언어 값이고, propertyDesc가 Property Descriptor Record라고 가정합니다.

10.5.1 [[GetPrototypeOf]] ( )

a Proxy exotic object obj의 내부 메서드 [[GetPrototypeOf]]. 인수 없음. 반환값: (정상 완료 (값: (Object 또는 null)) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "getPrototypeOf")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[GetPrototypeOf]]()를 반환합니다.
  7. handlerProto를 ? Call(trap, handler, « target »)로 둡니다.
  8. handlerProto가 Object도 아니고 null도 아니면, TypeError 예외를 던집니다.
  9. extensibleTarget을 ? IsExtensible(target)로 둡니다.
  10. extensibleTarget이 true이면, handlerProto를 반환합니다.
  11. targetProto를 ? target.[[GetPrototypeOf]]()로 둡니다.
  12. SameValue(handlerProto, targetProto)가 false이면, TypeError 예외를 던집니다.
  13. handlerProto를 반환합니다.
참고

Proxy 객체의 [[GetPrototypeOf]]는 다음 불변 조건을 강제합니다:

  • [[GetPrototypeOf]]의 결과는 Object 또는 null이어야 합니다.
  • 대상 객체가 확장 가능하지 않으면 Proxy 객체에 적용한 [[GetPrototypeOf]]는 Proxy 객체의 대상 객체에 적용한 [[GetPrototypeOf]]와 같은 값을 반환해야 합니다.

10.5.2 [[SetPrototypeOf]] ( proto )

a Proxy exotic object obj의 내부 메서드 [[SetPrototypeOf]]. 인수 proto ((Object 또는 null)). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "setPrototypeOf")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[SetPrototypeOf]](proto)를 반환합니다.
  7. boolTrapResult를 ToBoolean(? Call(trap, handler, « target, proto »))로 둡니다.
  8. boolTrapResult가 false이면, false를 반환합니다.
  9. extensibleTarget을 ? IsExtensible(target)로 둡니다.
  10. extensibleTarget이 true이면, true를 반환합니다.
  11. targetProto를 ? target.[[GetPrototypeOf]]()로 둡니다.
  12. SameValue(proto, targetProto)가 false이면, TypeError 예외를 던집니다.
  13. true를 반환합니다.
참고

Proxy 객체의 [[SetPrototypeOf]]는 다음 불변 조건을 강제합니다:

  • [[SetPrototypeOf]]의 결과는 Boolean 값입니다.
  • 대상 객체가 확장 가능하지 않으면 인수 값은 대상 객체에 적용한 [[GetPrototypeOf]]의 결과와 같아야 합니다.

10.5.3 [[IsExtensible]] ( )

a Proxy exotic object obj의 내부 메서드 [[IsExtensible]]. 인수 없음. 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "isExtensible")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? IsExtensible(target)을 반환합니다.
  7. boolTrapResult를 ToBoolean(? Call(trap, handler, « target »))로 둡니다.
  8. targetResult를 ? IsExtensible(target)로 둡니다.
  9. boolTrapResult가 targetResult와 다르면, TypeError 예외를 던집니다.
  10. boolTrapResult를 반환합니다.
참고

Proxy 객체의 [[IsExtensible]]은 다음 불변 조건을 강제합니다:

  • [[IsExtensible]]의 결과는 Boolean 값입니다.
  • Proxy 객체에 적용한 [[IsExtensible]]은 동일한 인수로 Proxy 객체의 대상 객체에 적용한 [[IsExtensible]]과 같은 값을 반환해야 합니다.

10.5.4 [[PreventExtensions]] ( )

a Proxy exotic object obj의 내부 메서드 [[PreventExtensions]]. 인수 없음. 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "preventExtensions")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[PreventExtensions]]()를 반환합니다.
  7. boolTrapResult를 ToBoolean(? Call(trap, handler, « target »))로 둡니다.
  8. boolTrapResult가 true이면, 다음을 수행합니다.
    1. extensibleTarget을 ? IsExtensible(target)로 둡니다.
    2. extensibleTarget이 true이면, TypeError 예외를 던집니다.
  9. boolTrapResult를 반환합니다.
참고

Proxy 객체의 [[PreventExtensions]]는 다음 불변 조건을 강제합니다:

  • [[PreventExtensions]]의 결과는 Boolean 값입니다.
  • Proxy 객체에 적용한 [[PreventExtensions]]는 Proxy 객체의 대상 객체에 적용한 [[IsExtensible]]이 false일 때만 true를 반환합니다.

10.5.5 [[GetOwnProperty]] ( propertyKey )

a Proxy exotic object obj의 내부 메서드 [[GetOwnProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: (프로퍼티 서술자 또는 undefined)) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "getOwnPropertyDescriptor")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[GetOwnProperty]](propertyKey)를 반환합니다.
  7. trapResultObj를 ? Call(trap, handler, « target, propertyKey »)로 둡니다.
  8. trapResultObj가 Object도 아니고 undefined도 아니면, TypeError 예외를 던집니다.
  9. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둡니다.
  10. trapResultObj가 undefined이면, 다음을 수행합니다.
    1. targetDesc가 undefined이면, undefined를 반환합니다.
    2. targetDesc.[[Configurable]]이 false이면, TypeError 예외를 던집니다.
    3. extensibleTarget을 ? IsExtensible(target)로 둡니다.
    4. extensibleTarget이 false이면, TypeError 예외를 던집니다.
    5. undefined를 반환합니다.
  11. extensibleTarget을 ? IsExtensible(target)로 둡니다.
  12. resultDesc를 ? ToPropertyDescriptor(trapResultObj)로 둡니다.
  13. CompletePropertyDescriptor(resultDesc)를 수행합니다.
  14. valid를 IsCompatiblePropertyDescriptor(extensibleTarget, resultDesc, targetDesc)로 둡니다.
  15. valid가 false이면, TypeError 예외를 던집니다.
  16. resultDesc.[[Configurable]]이 false이면, 다음을 수행합니다.
    1. targetDesc가 undefined이거나 targetDesc.[[Configurable]]이 true이면, 다음을 수행합니다.
      1. TypeError 예외를 던집니다.
    2. resultDesc에 [[Writable]] 필드가 있고 resultDesc.[[Writable]]이 false이면, 다음을 수행합니다.
      1. 단언: targetDesc에는 [[Writable]] 필드가 있습니다.
      2. targetDesc.[[Writable]]이 true이면, TypeError 예외를 던집니다.
  17. resultDesc를 반환합니다.
참고

Proxy 객체의 [[GetOwnProperty]]는 다음 불변 조건을 강제합니다:

  • [[GetOwnProperty]]의 결과는 Property Descriptor 또는 undefined여야 합니다.
  • 대상 객체의 구성 불가능한 자체 프로퍼티로 존재하는 프로퍼티를 존재하지 않는 것으로 보고할 수 없습니다.
  • 확장 불가능한 대상 객체의 자체 프로퍼티로 존재하는 프로퍼티를 존재하지 않는 것으로 보고할 수 없습니다.
  • 대상 객체의 자체 프로퍼티로 존재하지 않고 대상 객체가 확장 가능하지 않으면 프로퍼티를 존재하는 것으로 보고할 수 없습니다.
  • 대상 객체의 구성 불가능한 자체 프로퍼티로 존재하지 않는 한 프로퍼티를 구성 불가능한 것으로 보고할 수 없습니다.
  • 대상 객체의 구성 불가능하고 쓰기 불가능한 자체 프로퍼티로 존재하지 않는 한 프로퍼티를 구성 불가능하면서 동시에 쓰기 불가능한 것으로 보고할 수 없습니다.

10.5.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

a Proxy exotic object obj의 내부 메서드 [[DefineOwnProperty]]. 인수 propertyKey (프로퍼티 키) 및 propertyDesc (프로퍼티 서술자). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "defineProperty")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[DefineOwnProperty]](propertyKey, propertyDesc)를 반환합니다.
  7. propertyDescObj를 FromPropertyDescriptor(propertyDesc)로 둡니다.
  8. boolTrapResult를 ToBoolean(? Call(trap, handler, « target, propertyKey, propertyDescObj »))로 둡니다.
  9. boolTrapResult가 false이면, false를 반환합니다.
  10. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둡니다.
  11. extensibleTarget을 ? IsExtensible(target)로 둡니다.
  12. propertyDesc에 [[Configurable]] 필드가 있고 propertyDesc.[[Configurable]]이 false이면, 다음을 수행합니다.
    1. settingConfigurableFalse를 true로 둡니다.
  13. 그렇지 않으면,
    1. settingConfigurableFalse를 false로 둡니다.
  14. targetDesc가 undefined이면, 다음을 수행합니다.
    1. extensibleTarget이 false이면, TypeError 예외를 던집니다.
    2. settingConfigurableFalse가 true이면, TypeError 예외를 던집니다.
  15. 그렇지 않으면,
    1. IsCompatiblePropertyDescriptor(extensibleTarget, propertyDesc, targetDesc)가 false이면, TypeError 예외를 던집니다.
    2. settingConfigurableFalse가 true이고 targetDesc.[[Configurable]]이 true이면, TypeError 예외를 던집니다.
    3. IsDataDescriptor(targetDesc)가 true이고, targetDesc.[[Configurable]]이 false이며, targetDesc.[[Writable]]이 true이면, 다음을 수행합니다.
      1. propertyDesc에 [[Writable]] 필드가 있고 propertyDesc.[[Writable]]이 false이면, TypeError 예외를 던집니다.
  16. true를 반환합니다.
참고

Proxy 객체의 [[DefineOwnProperty]]는 다음 불변 조건을 강제합니다:

  • [[DefineOwnProperty]]의 결과는 Boolean 값입니다.
  • 대상 객체가 확장 가능하지 않으면 프로퍼티를 추가할 수 없습니다.
  • 대상 객체에 대응하는 구성 불가능한 자체 프로퍼티가 존재하지 않는 한 프로퍼티를 구성 불가능하게 만들 수 없습니다.
  • 대상 객체에 대응하는 구성 불가능하고 쓰기 불가능한 자체 프로퍼티가 존재하지 않는 한 구성 불가능한 프로퍼티를 쓰기 불가능하게 만들 수 없습니다.
  • 프로퍼티에 대응하는 대상 객체 프로퍼티가 있으면 해당 프로퍼티의 Property Descriptor를 [[DefineOwnProperty]]을 사용하여 대상 객체에 적용할 때 예외를 던지지 않습니다.

10.5.7 [[HasProperty]] ( propertyKey )

a Proxy exotic object obj의 내부 메서드 [[HasProperty]]. 인수 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "has")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[HasProperty]](propertyKey)를 반환합니다.
  7. boolTrapResult를 ToBoolean(? Call(trap, handler, « target, propertyKey »))로 둡니다.
  8. boolTrapResult가 false이면, 다음을 수행합니다.
    1. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둡니다.
    2. targetDesc가 undefined가 아니면, 다음을 수행합니다.
      1. targetDesc.[[Configurable]]이 false이면, TypeError 예외를 던집니다.
      2. extensibleTarget을 ? IsExtensible(target)로 둡니다.
      3. extensibleTarget이 false이면, TypeError 예외를 던집니다.
  9. boolTrapResult를 반환합니다.
참고

Proxy 객체의 [[HasProperty]]는 다음 불변 조건을 강제합니다:

  • [[HasProperty]]의 결과는 Boolean 값입니다.
  • 대상 객체의 구성 불가능한 자체 프로퍼티로 존재하는 프로퍼티를 존재하지 않는 것으로 보고할 수 없습니다.
  • 대상 객체의 자체 프로퍼티로 존재하고 대상 객체가 확장 가능하지 않으면 프로퍼티를 존재하지 않는 것으로 보고할 수 없습니다.

10.5.8 [[Get]] ( propertyKey, receiver )

a Proxy exotic object obj의 내부 메서드 [[Get]]. 인수 propertyKey (프로퍼티 키) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "get")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[Get]](propertyKey, receiver)를 반환합니다.
  7. trapResult를 ? Call(trap, handler, « target, propertyKey, receiver »)로 둡니다.
  8. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둡니다.
  9. targetDesc가 undefined가 아니고 targetDesc.[[Configurable]]이 false이면, 다음을 수행합니다.
    1. IsDataDescriptor(targetDesc)가 true이고 targetDesc.[[Writable]]이 false이면, 다음을 수행합니다.
      1. SameValue(trapResult, targetDesc.[[Value]])가 false이면, TypeError 예외를 던집니다.
    2. IsAccessorDescriptor(targetDesc)가 true이고 targetDesc.[[Getter]]가 undefined이면, 다음을 수행합니다.
      1. trapResult가 undefined가 아니면, TypeError 예외를 던집니다.
  10. trapResult를 반환합니다.
참고

Proxy 객체의 [[Get]]은 다음 불변 조건을 강제합니다:

  • 대상 객체의 대응하는 프로퍼티가 쓰기 불가능하고 구성 불가능한 자체 데이터 프로퍼티이면 프로퍼티에 대해 보고하는 값은 대상 객체의 대응하는 프로퍼티 값과 같아야 합니다.
  • 대상 객체의 대응하는 프로퍼티가 [[Getter]] 속성으로 undefined를 갖는 구성 불가능한 자체 접근자 프로퍼티이면 프로퍼티에 대해 보고하는 값은 undefined여야 합니다.

10.5.9 [[Set]] ( propertyKey, value, receiver )

a Proxy exotic object obj의 내부 메서드 [[Set]]. 인수 propertyKey (프로퍼티 키), value (ECMAScript 언어 값) 및 receiver (ECMAScript 언어 값). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "set")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[Set]](propertyKey, value, receiver)를 반환합니다.
  7. boolTrapResult를 ToBoolean(? Call(trap, handler, « target, propertyKey, value, receiver »))로 둡니다.
  8. boolTrapResult가 false이면, false를 반환합니다.
  9. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둡니다.
  10. targetDesc가 undefined가 아니고 targetDesc.[[Configurable]]이 false이면, 다음을 수행합니다.
    1. IsDataDescriptor(targetDesc)가 true이고 targetDesc.[[Writable]]이 false이면, 다음을 수행합니다.
      1. SameValue(value, targetDesc.[[Value]])가 false이면, TypeError 예외를 던집니다.
    2. IsAccessorDescriptor(targetDesc)가 true이면, 다음을 수행합니다.
      1. targetDesc.[[Setter]]가 undefined이면, TypeError 예외를 던집니다.
  11. true를 반환합니다.
참고

Proxy 객체의 [[Set]]은 다음 불변 조건을 강제합니다:

  • [[Set]]의 결과는 Boolean 값입니다.
  • 대응하는 대상 객체 프로퍼티가 쓰기 불가능하고 구성 불가능한 자체 데이터 프로퍼티이면 프로퍼티 값을 해당 대상 객체 프로퍼티의 값과 다른 값으로 변경할 수 없습니다.
  • 대응하는 대상 객체 프로퍼티가 [[Setter]] 속성으로 undefined를 갖는 구성 불가능한 자체 접근자 프로퍼티이면 프로퍼티 값을 설정할 수 없습니다.

10.5.10 [[Delete]] ( propertyKey )

a Proxy exotic object obj의 내부 메서드 [[Delete]]. 인수 propertyKey (프로퍼티 키). 반환값: (정상 완료 (값: Boolean) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "deleteProperty")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[Delete]](propertyKey)를 반환합니다.
  7. boolTrapResult를 ToBoolean(? Call(trap, handler, « target, propertyKey »))로 둡니다.
  8. boolTrapResult가 false이면, false를 반환합니다.
  9. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둡니다.
  10. targetDesc가 undefined이면, true를 반환합니다.
  11. targetDesc.[[Configurable]]이 false이면, TypeError 예외를 던집니다.
  12. extensibleTarget을 ? IsExtensible(target)로 둡니다.
  13. extensibleTarget이 false이면, TypeError 예외를 던집니다.
  14. true를 반환합니다.
참고

Proxy 객체의 [[Delete]]는 다음 불변 조건을 강제합니다:

  • [[Delete]]의 결과는 Boolean 값입니다.
  • 대상 객체의 구성 불가능한 자체 프로퍼티로 존재하는 프로퍼티를 삭제된 것으로 보고할 수 없습니다.
  • 대상 객체의 자체 프로퍼티로 존재하고 대상 객체가 확장 불가능하면 프로퍼티를 삭제된 것으로 보고할 수 없습니다.

10.5.11 [[OwnPropertyKeys]] ( )

a Proxy exotic object obj의 내부 메서드 [[OwnPropertyKeys]]. 인수 없음. 반환값: (정상 완료 (값: 리스트 (요소: 프로퍼티 키)) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "ownKeys")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? target.[[OwnPropertyKeys]]()를 반환합니다.
  7. trapResultArray를 ? Call(trap, handler, « target »)로 둡니다.
  8. trapResult를 ? CreateListFromArrayLike(trapResultArray, property-key)로 둡니다.
  9. trapResult에 중복 항목이 하나라도 있으면, TypeError 예외를 던집니다.
  10. extensibleTarget을 ? IsExtensible(target)로 둡니다.
  11. targetKeys를 ? target.[[OwnPropertyKeys]]()로 둡니다.
  12. 단언: targetKeys는 프로퍼티 키의 List입니다.
  13. 단언: targetKeys에는 중복 항목이 없습니다.
  14. targetConfigurableKeys를 새로운 빈 List로 둡니다.
  15. targetNonconfigurableKeys를 새로운 빈 List로 둡니다.
  16. targetKeys의 각 요소 key에 대해 다음을 수행합니다.
    1. propertyDesc를 ? target.[[GetOwnProperty]](key)로 둡니다.
    2. propertyDesc가 undefined가 아니고 propertyDesc.[[Configurable]]이 false이면, 다음을 수행합니다.
      1. key를 targetNonconfigurableKeys에 추가합니다.
    3. 그렇지 않으면,
      1. key를 targetConfigurableKeys에 추가합니다.
  17. extensibleTarget이 true이고 targetNonconfigurableKeys가 비어 있으면, 다음을 수행합니다.
    1. trapResult를 반환합니다.
  18. uncheckedResultKeys를 trapResult의 요소를 요소로 갖는 List로 둡니다.
  19. targetNonconfigurableKeys의 각 요소 key에 대해 다음을 수행합니다.
    1. uncheckedResultKeys에 key가 포함되어 있지 않으면, TypeError 예외를 던집니다.
    2. uncheckedResultKeys에서 key를 제거합니다.
  20. extensibleTarget이 true이면, trapResult를 반환합니다.
  21. targetConfigurableKeys의 각 요소 key에 대해 다음을 수행합니다.
    1. uncheckedResultKeys에 key가 포함되어 있지 않으면, TypeError 예외를 던집니다.
    2. uncheckedResultKeys에서 key를 제거합니다.
  22. uncheckedResultKeys가 비어 있지 않으면, TypeError 예외를 던집니다.
  23. trapResult를 반환합니다.
참고

Proxy 객체의 [[OwnPropertyKeys]]는 다음 불변 조건을 강제합니다:

  • [[OwnPropertyKeys]]의 결과는 List입니다.
  • 반환된 List에는 중복 항목이 없습니다.
  • 반환된 List의 각 요소는 프로퍼티 키입니다.
  • 결과 List에는 대상 객체의 모든 구성 불가능한 자체 프로퍼티 키가 포함되어야 합니다.
  • 대상 객체가 확장 가능하지 않으면 결과 List에는 대상 객체의 모든 자체 프로퍼티 키가 포함되어야 하며 다른 값은 포함되어서는 안 됩니다.

10.5.12 [[Call]] ( thisArg, argList )

a Proxy exotic object obj의 내부 메서드 [[Call]]. 인수 thisArg (ECMAScript 언어 값) 및 argList (리스트 (요소: ECMAScript 언어 값)). 반환값: (정상 완료 (값: ECMAScript 언어 값) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. handler를 obj.[[ProxyHandler]]로 둡니다.
  4. 단언: handler는 Object입니다.
  5. trap을 ? GetMethod(handler, "apply")로 둡니다.
  6. trap이 undefined이면, 다음을 수행합니다.
    1. ? Call(target, thisArg, argList)를 반환합니다.
  7. argArray를 CreateArrayFromList(argList)로 둡니다.
  8. ? Call(trap, handler, « target, thisArg, argArray »)를 반환합니다.
참고

Proxy 특수 객체는 [[ProxyTarget]] 내부 슬롯의 초기값이 [[Call]] 내부 메서드를 갖는 객체인 경우에만 [[Call]] 내부 메서드를 갖습니다.

10.5.13 [[Construct]] ( argList, newTarget )

a Proxy exotic object obj의 내부 메서드 [[Construct]]. 인수 argList (리스트 (요소: ECMAScript 언어 값)) 및 newTarget (생성자). 반환값: (정상 완료 (값: Object) 또는 throw 완료). 호출되면 다음 단계를 수행한다.

  1. ? ValidateNonRevokedProxy(obj)를 수행합니다.
  2. target을 obj.[[ProxyTarget]]으로 둡니다.
  3. 단언: IsConstructor(target)은 true입니다.
  4. handler를 obj.[[ProxyHandler]]로 둡니다.
  5. 단언: handler는 Object입니다.
  6. trap을 ? GetMethod(handler, "construct")로 둡니다.
  7. trap이 undefined이면, 다음을 수행합니다.
    1. ? Construct(target, argList, newTarget)를 반환합니다.
  8. argArray를 CreateArrayFromList(argList)로 둡니다.
  9. newObj를 ? Call(trap, handler, « target, argArray, newTarget »)로 둡니다.
  10. newObj가 Object가 아니면, TypeError 예외를 던집니다.
  11. newObj를 반환합니다.
참고 1

Proxy 특수 객체는 [[ProxyTarget]] 내부 슬롯의 초기값이 [[Construct]] 내부 메서드를 갖는 객체인 경우에만 [[Construct]] 내부 메서드를 갖습니다.

참고 2

Proxy 객체의 [[Construct]]는 다음 불변 조건을 강제합니다:

  • [[Construct]]의 결과는 Object여야 합니다.

10.5.14 ValidateNonRevokedProxy ( proxy )

추상 연산 ValidateNonRevokedProxy. 인수 proxy (Proxy 특수 객체). 반환값: (정상 완료 (값: unused) 또는 throw 완료). proxy가 해제된 경우 TypeError 예외를 던집니다. 호출되면 다음 단계를 수행한다.

  1. proxy.[[ProxyTarget]]이 null이면, TypeError 예외를 던집니다.
  2. 단언: proxy.[[ProxyHandler]]는 null이 아닙니다.
  3. unused를 반환합니다.

10.5.15 ProxyCreate ( target, handler )

추상 연산 ProxyCreate. 인수 target (ECMAScript 언어 값) 및 handler (ECMAScript 언어 값). 반환값: (정상 완료 (값: Proxy 특수 객체) 또는 throw 완료). 새로운 Proxy 객체의 생성을 명시하는 데 사용됩니다. 호출되면 다음 단계를 수행한다.

  1. target이 Object가 아니면 TypeError 예외를 던집니다.
  2. handler가 Object가 아니면 TypeError 예외를 던집니다.
  3. proxy를 MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]] »)로 둡니다.
  4. proxy의 필수 내부 메서드 중 [[Call]] 및 [[Construct]]를 제외한 메서드를 10.5에 지정된 정의로 설정합니다.
  5. IsCallable(target)이 true이면, 다음을 수행합니다.
    1. proxy.[[Call]]을 10.5.12에 지정된 대로 설정합니다.
    2. IsConstructor(target)가 true이면, 다음을 수행합니다.
      1. proxy.[[Construct]]를 10.5.13에 지정된 대로 설정합니다.
  6. proxy.[[ProxyTarget]]을 target으로 설정합니다.
  7. proxy.[[ProxyHandler]]를 handler로 설정합니다.
  8. proxy를 반환합니다.