10 Ordinary 및 Exotic Objects Behaviours

10.1 Ordinary Object Internal Methods and Internal Slots

모든 ordinary object[[Prototype]]이라는 internal slot을 가집니다. 이 internal slot의 value는 null 또는 object이며 inheritance를 implementing하는 데 사용됩니다. propertyKey라는 property가 ordinary object obj에는 missing이지만 그 [[Prototype]] object에는 존재한다고 가정합니다. propertyKey[[Prototype]] object 위의 data property를 refer하면, obj는 get access에 대해 이를 inherit하여 propertyKeyobj의 property인 것처럼 behave하게 합니다. propertyKey[[Prototype]] object 위의 writable data property를 refer하면, obj 위의 propertyKey의 set access는 obj 위에 propertyKey라는 새 data property를 create합니다. propertyKey[[Prototype]] object 위의 non-writable data property를 refer하면, obj 위의 propertyKey의 set access는 fail합니다. propertyKey[[Prototype]] object 위의 accessor property를 refer하면, accessor는 get access와 set access 모두에 대해 obj에 inherited됩니다.

모든 ordinary object는 Boolean-valued [[Extensible]] internal slot을 가지며, 이는 6.1.7.3에 specified된 extensibility-related internal method invariant를 fulfill하는 데 사용됩니다. 즉, object의 [[Extensible]] internal slot의 value가 일단 false로 set되면, 그 object에 property를 add하거나, object의 [[Prototype]] internal slot의 value를 modify하거나, 이후 [[Extensible]]의 value를 true로 change하는 것은 더 이상 possible하지 않습니다.

다음 algorithm description에서, objordinary object, propertyKeyproperty key value, value는 임의의 ECMAScript language value, propertyDescProperty Descriptor record라고 가정합니다.

ordinary object internal method는 similarly-named abstract operation에 delegate합니다. 그러한 abstract operation이 다른 internal method에 depend하면, similarly-named abstract operation을 직접 calling하는 대신 obj 위에서 internal method가 invoked됩니다. 이러한 semantics는 ordinary object internal method가 exotic object에 applied될 때 그 overridden internal method가 invoked되도록 ensure합니다.

10.1.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing either an Object or null. It performs the following steps when called:

  1. OrdinaryGetPrototypeOf(obj)를 반환한다.

10.1.1.1 OrdinaryGetPrototypeOf ( obj )

The abstract operation OrdinaryGetPrototypeOf takes argument obj (an Object) and returns an Object or null. It performs the following steps when called:

  1. obj.[[Prototype]]을 반환한다.

10.1.2 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of an ordinary object obj takes argument proto (an Object or null) and returns a normal completion containing a Boolean. It performs the following steps when called:

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

10.1.2.1 OrdinarySetPrototypeOf ( obj, proto )

The abstract operation OrdinarySetPrototypeOf takes arguments obj (an Object) and proto (an Object or null) and returns a Boolean. It performs the following steps when called:

  1. currentobj.[[Prototype]]으로 둔다.
  2. SameValue(proto, current)가 true이면, true를 반환한다.
  3. extensibleobj.[[Extensible]]로 둔다.
  4. extensiblefalse이면, false를 반환한다.
  5. cursorproto로 둔다.
  6. donefalse로 둔다.
  7. donefalse인 동안 Repeat,
    1. cursornull이면, 다음을 수행한다.
      1. donetrue로 설정한다.
    2. 그렇지 않고 SameValue(cursor, obj)가 true이면, 다음을 수행한다.
      1. false를 반환한다.
    3. 그렇지 않으면,
      1. cursor.[[GetPrototypeOf]]10.1.1에 정의된 ordinary object internal method가 아니면, donetrue로 설정한다.
      2. 그렇지 않으면, cursorcursor.[[Prototype]]으로 설정한다.
  8. obj.[[Prototype]]proto로 설정한다.
  9. true를 반환한다.
Note

step 7의 loop는 [[GetPrototypeOf]][[SetPrototypeOf]]에 대해 ordinary object definition을 사용하는 object만 포함하는 prototype chain 안에는 cycle이 없음을 guarantee합니다.

10.1.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. OrdinaryIsExtensible(obj)를 반환한다.

10.1.3.1 OrdinaryIsExtensible ( obj )

The abstract operation OrdinaryIsExtensible takes argument obj (an Object) and returns a Boolean. It performs the following steps when called:

  1. obj.[[Extensible]]을 반환한다.

10.1.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing true. It performs the following steps when called:

  1. OrdinaryPreventExtensions(obj)를 반환한다.

10.1.4.1 OrdinaryPreventExtensions ( obj )

The abstract operation OrdinaryPreventExtensions takes argument obj (an Object) and returns true. It performs the following steps when called:

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

10.1.5 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of an ordinary object obj takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

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

10.1.5.1 OrdinaryGetOwnProperty ( obj, propertyKey )

The abstract operation OrdinaryGetOwnProperty takes arguments obj (an Object) and propertyKey (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:

  1. obj가 key가 propertyKey인 own property를 가지지 않으면, undefined를 반환한다.
  2. propertyDesc를 field가 없는 newly created Property Descriptor로 둔다.
  3. ownProperty를 key가 propertyKeyobj의 own property로 둔다.
  4. ownPropertydata property이면, 다음을 수행한다.
    1. propertyDesc.[[Value]]ownProperty[[Value]] attribute의 value로 설정한다.
    2. propertyDesc.[[Writable]]ownProperty[[Writable]] attribute의 value로 설정한다.
  5. 그렇지 않으면,
    1. Assert: ownPropertyaccessor property이다.
    2. propertyDesc.[[Get]]ownProperty[[Get]] attribute의 value로 설정한다.
    3. propertyDesc.[[Set]]ownProperty[[Set]] attribute의 value로 설정한다.
  6. propertyDesc.[[Enumerable]]ownProperty[[Enumerable]] attribute의 value로 설정한다.
  7. propertyDesc.[[Configurable]]ownProperty[[Configurable]] attribute의 value로 설정한다.
  8. propertyDesc를 반환한다.

10.1.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of an ordinary object obj takes arguments propertyKey (a property key) and propertyDesc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. OrdinaryDefineOwnProperty(obj, propertyKey, propertyDesc)를 반환한다.

10.1.6.1 OrdinaryDefineOwnProperty ( obj, propertyKey, propertyDesc )

The abstract operation OrdinaryDefineOwnProperty takes arguments obj (an Object), propertyKey (a property key), and propertyDesc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

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

10.1.6.2 IsCompatiblePropertyDescriptor ( extensible, propertyDesc, current )

The abstract operation IsCompatiblePropertyDescriptor takes arguments extensible (a Boolean), propertyDesc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. It performs the following steps when called:

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

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

The abstract operation ValidateAndApplyPropertyDescriptor takes arguments obj (an Object or undefined), propertyKey (a property key), extensible (a Boolean), propertyDesc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. specified extensibility와 current property current를 가진 object의 property로 propertyDescinvariant를 uphold하면서 apply할 수 있으면 and only if true를 반환합니다. 그러한 application이 possible하고 objundefined가 아니면, propertyKey라는 name의 property에 대해 performed됩니다(필요하면 created됩니다). It performs the following steps when called:

  1. Assert: propertyKeyproperty key이다.
  2. currentundefined이면, 다음을 수행한다.
    1. extensiblefalse이면, false를 반환한다.
    2. objundefined이면, true를 반환한다.
    3. IsAccessorDescriptor(propertyDesc)가 true이면, 다음을 수행한다.
      1. object obj 위에 propertyKey라는 own accessor property를 create하되, 그 [[Get]], [[Set]], [[Enumerable]], [[Configurable]] attribute는 propertyDesc가 해당 field를 가지면 propertyDesc 안의 corresponding field의 value로, 그렇지 않으면 attribute의 default value로 설정한다.
    4. 그렇지 않으면,
      1. object obj 위에 propertyKey라는 own data property를 create하되, 그 [[Value]], [[Writable]], [[Enumerable]], [[Configurable]] attribute는 propertyDesc가 해당 field를 가지면 propertyDesc 안의 corresponding field의 value로, 그렇지 않으면 attribute의 default value로 설정한다.
    5. true를 반환한다.
  3. Assert: currentfully populated Property Descriptor이다.
  4. propertyDesc가 어떤 field도 가지지 않으면, true를 반환한다.
  5. current.[[Configurable]]false이면, 다음을 수행한다.
    1. propertyDesc[[Configurable]] field를 가지고 propertyDesc.[[Configurable]]true이면, false를 반환한다.
    2. propertyDesc[[Enumerable]] field를 가지고 propertyDesc.[[Enumerable]]current.[[Enumerable]]이 아니면, false를 반환한다.
    3. IsGenericDescriptor(propertyDesc)가 false이고 IsAccessorDescriptor(propertyDesc)가 IsAccessorDescriptor(current)가 아니면, false를 반환한다.
    4. IsAccessorDescriptor(current)가 true이면, 다음을 수행한다.
      1. propertyDesc[[Get]] field를 가지고 SameValue(propertyDesc.[[Get]], current.[[Get]])이 false이면, false를 반환한다.
      2. propertyDesc[[Set]] field를 가지고 SameValue(propertyDesc.[[Set]], current.[[Set]])이 false이면, false를 반환한다.
    5. 그렇지 않고 current.[[Writable]]false이면, 다음을 수행한다.
      1. propertyDesc[[Writable]] field를 가지고 propertyDesc.[[Writable]]true이면, false를 반환한다.
      2. NOTE: SameValue는 다른 means로 distinguishable할 수 있는 NaN value에 대해 true를 반환합니다. 여기서 return하면 obj의 existing property가 unmodified로 남도록 ensure합니다.
      3. propertyDesc[[Value]] field를 가지면, SameValue(propertyDesc.[[Value]], current.[[Value]])를 반환한다.
  6. objundefined가 아니면, 다음을 수행한다.
    1. IsDataDescriptor(current)가 true이고 IsAccessorDescriptor(propertyDesc)가 true이면, 다음을 수행한다.
      1. propertyDesc[[Configurable]] field를 가지면, configurablepropertyDesc.[[Configurable]]로 둔다; 그렇지 않으면 configurablecurrent.[[Configurable]]로 둔다.
      2. propertyDesc[[Enumerable]] field를 가지면, enumerablepropertyDesc.[[Enumerable]]로 둔다; 그렇지 않으면 enumerablecurrent.[[Enumerable]]으로 둔다.
      3. object objpropertyKey라는 property를 accessor property로 replace하되, 그 [[Configurable]][[Enumerable]] attribute는 각각 configurableenumerable로 설정하고, [[Get]][[Set]] attribute는 propertyDesc가 해당 field를 가지면 propertyDesc 안의 corresponding field의 value로, 그렇지 않으면 attribute의 default value로 설정한다.
    2. 그렇지 않고 IsAccessorDescriptor(current)가 true이고 IsDataDescriptor(propertyDesc)가 true이면, 다음을 수행한다.
      1. propertyDesc[[Configurable]] field를 가지면, configurablepropertyDesc.[[Configurable]]로 둔다; 그렇지 않으면 configurablecurrent.[[Configurable]]로 둔다.
      2. propertyDesc[[Enumerable]] field를 가지면, enumerablepropertyDesc.[[Enumerable]]로 둔다; 그렇지 않으면 enumerablecurrent.[[Enumerable]]으로 둔다.
      3. object objpropertyKey라는 property를 data property로 replace하되, 그 [[Configurable]][[Enumerable]] attribute는 각각 configurableenumerable로 설정하고, [[Value]][[Writable]] attribute는 propertyDesc가 해당 field를 가지면 propertyDesc 안의 corresponding field의 value로, 그렇지 않으면 attribute의 default value로 설정한다.
    3. 그렇지 않으면,
      1. propertyDesc의 각 field name fieldName에 대해, object objpropertyKey라는 property의 fieldName이라는 attribute를 propertyDescfieldName field의 value로 설정한다.
  7. true를 반환한다.

10.1.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of an ordinary object obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. OrdinaryHasProperty(obj, propertyKey)를 반환한다.

10.1.7.1 OrdinaryHasProperty ( obj, propertyKey )

The abstract operation OrdinaryHasProperty takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

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

10.1.8 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of an ordinary object obj takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. OrdinaryGet(obj, propertyKey, receiver)를 반환한다.

10.1.8.1 OrdinaryGet ( obj, propertyKey, receiver )

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

  1. propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
  2. propertyDescundefined이면, 다음을 수행한다.
    1. parent를 ? obj.[[GetPrototypeOf]]()로 둔다.
    2. parentnull이면, undefined를 반환한다.
    3. parent.[[Get]](propertyKey, receiver)를 반환한다.
  3. IsDataDescriptor(propertyDesc)가 true이면, propertyDesc.[[Value]]를 반환한다.
  4. Assert: IsAccessorDescriptor(propertyDesc)는 true이다.
  5. getterpropertyDesc.[[Get]]으로 둔다.
  6. getterundefined이면, undefined를 반환한다.
  7. Call(getter, receiver)를 반환한다.

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

The [[Set]] internal method of an ordinary object obj takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. OrdinarySet(obj, propertyKey, value, receiver)를 반환한다.

10.1.9.1 OrdinarySet ( obj, propertyKey, value, receiver )

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

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

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

The abstract operation OrdinarySetWithOwnDescriptor takes arguments obj (an Object), propertyKey (a property key), value (an ECMAScript language value), receiver (an ECMAScript language value), and ownDesc (a Property Descriptor or undefined) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ownDescundefined이면, 다음을 수행한다.
    1. parent를 ? obj.[[GetPrototypeOf]]()로 둔다.
    2. parentnull이 아니면, ? 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. existingDescundefined이면, 다음을 수행한다.
      1. Assert: receiver는 currently property 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. Assert: IsAccessorDescriptor(ownDesc)는 true이다.
  4. setterownDesc.[[Set]]으로 둔다.
  5. setterundefined이면, false를 반환한다.
  6. Call(setter, receiver, « value »)를 수행한다.
  7. true를 반환한다.

10.1.10 [[Delete]] ( propertyKey )

The [[Delete]] internal method of an ordinary object obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. OrdinaryDelete(obj, propertyKey)를 반환한다.

10.1.10.1 OrdinaryDelete ( obj, propertyKey )

The abstract operation OrdinaryDelete takes arguments obj (an Object) and propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
  2. propertyDescundefined이면, true를 반환한다.
  3. propertyDesc.[[Configurable]]true이면, 다음을 수행한다.
    1. obj에서 name이 propertyKey인 own property를 remove한다.
    2. true를 반환한다.
  4. false를 반환한다.

10.1.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of an ordinary object obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:

  1. OrdinaryOwnPropertyKeys(obj)를 반환한다.

10.1.11.1 OrdinaryOwnPropertyKeys ( obj )

The abstract operation OrdinaryOwnPropertyKeys takes argument obj (an Object) and returns a List of property keys. It performs the following steps when called:

  1. keys를 새 empty List로 둔다.
  2. obj의 각 own property key propertyKeypropertyKeyarray index인 것에 대해, ascending numeric index order로 다음을 수행한다.
    1. propertyKeykeys에 append한다.
  3. obj의 각 own property key propertyKeypropertyKey가 String이고 propertyKeyarray index가 아닌 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
    1. propertyKeykeys에 append한다.
  4. obj의 각 own property key propertyKeypropertyKey가 Symbol인 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
    1. propertyKeykeys에 append한다.
  5. keys를 반환한다.

10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] )

The abstract operation OrdinaryObjectCreate takes argument proto (an Object or null) and optional argument additionalInternalSlotsList (a List of names of internal slots) and returns an Object. 새 ordinary object의 runtime creation을 specify하는 데 사용됩니다. additionalInternalSlotsList[[Prototype]][[Extensible]]을 넘어 object의 part로 define되어야 하는 additional internal slot의 name을 contain합니다. additionalInternalSlotsList가 provided되지 않으면, 새 empty List가 사용됩니다. It performs the following steps when called:

  1. internalSlotsList를 « [[Prototype]], [[Extensible]] »로 둔다.
  2. additionalInternalSlotsList가 present하면, internalSlotsListinternalSlotsListadditionalInternalSlotsListlist-concatenation으로 설정한다.
  3. objMakeBasicObject(internalSlotsList)로 둔다.
  4. obj.[[Prototype]]proto로 설정한다.
  5. obj를 반환한다.
Note

OrdinaryObjectCreate는 MakeBasicObject를 call하는 것 이상의 일을 거의 하지 않지만, 그 use는 exotic object가 아니라 ordinary object를 create하려는 intention을 communicate합니다. 따라서 이 명세 안에서는 result가 non-ordinary가 되도록 object의 internal method를 subsequently modify하는 algorithm에 의해 called되지 않습니다. exotic object를 create하는 operation은 MakeBasicObject를 직접 invoke합니다.

10.1.13 OrdinaryCreateFromConstructor ( ctor, intrinsicDefaultProto [ , internalSlotsList ] )

The abstract operation OrdinaryCreateFromConstructor takes arguments ctor (a function object) and intrinsicDefaultProto (a String) and optional argument internalSlotsList (a List of names of internal slots) and returns either a normal completion containing an Object or a throw completion. constructor"prototype" property가 존재하면 그 property에서 retrieved된 [[Prototype]] value를 가지는 ordinary object를 create합니다. 그렇지 않으면 intrinsicDefaultProto가 naming하는 intrinsic이 [[Prototype]]에 사용됩니다. internalSlotsList는 object의 part로 define되어야 하는 additional internal slot의 name을 contain합니다. internalSlotsList가 provided되지 않으면, 새 empty List가 사용됩니다. It performs the following steps when called:

  1. Assert: intrinsicDefaultProto는 이 명세의 intrinsic object name이다. corresponding object는 object의 [[Prototype]] value로 사용되도록 intended된 intrinsic이어야 한다.
  2. proto를 ? GetPrototypeFromConstructor(ctor, intrinsicDefaultProto)로 둔다.
  3. internalSlotsList가 present하면, slotsinternalSlotsList로 둔다.
  4. 그렇지 않으면, slots를 새 empty List로 둔다.
  5. OrdinaryObjectCreate(proto, slots)를 반환한다.

10.1.14 GetPrototypeFromConstructor ( ctor, intrinsicDefaultProto )

The abstract operation GetPrototypeFromConstructor takes arguments ctor (a function object) and intrinsicDefaultProto (a String) and returns either a normal completion containing an Object or a throw completion. specific constructor에 corresponding하는 object를 create하는 데 사용해야 하는 [[Prototype]] value를 determine합니다. value는 constructor"prototype" property가 존재하면 그 property에서 retrieved됩니다. 그렇지 않으면 intrinsicDefaultProto가 naming하는 intrinsic이 [[Prototype]]에 사용됩니다. It performs the following steps when called:

  1. Assert: intrinsicDefaultProto는 이 명세의 intrinsic object name이다. corresponding object는 object의 [[Prototype]] value로 사용되도록 intended된 intrinsic이어야 한다.
  2. proto를 ? Get(ctor, "prototype")로 둔다.
  3. proto가 Object가 아니면, 다음을 수행한다.
    1. realm을 ? GetFunctionRealm(ctor)으로 둔다.
    2. protorealmintrinsicDefaultProto라는 name의 intrinsic object로 설정한다.
  4. proto를 반환한다.
Note

ctor[[Prototype]] value를 supply하지 않으면, 사용되는 default value는 running execution context가 아니라 ctor function의 realm에서 obtained됩니다.

10.1.15 RequireInternalSlot ( obj, internalSlot )

The abstract operation RequireInternalSlot takes arguments obj (an ECMAScript language value) and internalSlot (an internal slot name) and returns either a normal completion containing unused or a throw completion. obj가 Object이고 given internal slot을 가지지 않는 한 exception을 throw합니다. It performs the following steps when called:

  1. obj가 Object가 아니면, TypeError exception을 throw한다.
  2. objinternalSlot internal slot을 가지지 않으면, TypeError exception을 throw한다.
  3. unused를 반환한다.

10.2 ECMAScript Function Objects

ECMAScript function object는 lexical environment 위에 closed된 parameterized ECMAScript code를 encapsulate하고 그 code의 dynamic evaluation을 support합니다. ECMAScript function objectordinary object이며 다른 ordinary object와 같은 internal slot과 같은 internal method를 가집니다. ECMAScript function object의 code는 strict mode code(11.2.2)이거나 non-strict code일 수 있습니다. code가 strict mode code인 ECMAScript function objectstrict function이라고 합니다. code가 strict mode code가 아닌 것은 non-strict function이라고 합니다.

[[Extensible]][[Prototype]] 외에도, ECMAScript function objectTable 26에 listed된 internal slot도 가집니다.

Table 26: Internal Slots of ECMAScript Function Objects
Internal Slot Type Description
[[Environment]] an Environment Record function이 closed over된 Environment Record입니다. function의 code를 evaluating할 때 outer environment로 사용됩니다.
[[PrivateEnvironment]] a PrivateEnvironment Record or null function이 closed over된 Private Name에 대한 PrivateEnvironment Record입니다. 이 function이 syntactically class 안에 contained되어 있지 않으면 null입니다. function의 code를 evaluating할 때 inner class를 위한 outer PrivateEnvironment로 사용됩니다.
[[FormalParameters]] a Parse Node function의 formal parameter list를 define하는 source text의 root parse node입니다.
[[ECMAScriptCode]] a Parse Node function의 body를 define하는 source text의 root parse node입니다.
[[ConstructorKind]] base or derived function이 derived class constructor인지 여부입니다.
[[Realm]] a Realm Record function이 created된 realm이며, function을 evaluating할 때 accessed되는 intrinsic object를 제공합니다.
[[ScriptOrModule]] a Script Record or a Module Record function이 created된 script 또는 module입니다.
[[ThisMode]] lexical, strict, or global function의 formal parameter와 code body 안에서 this reference가 어떻게 interpreted되는지 define합니다. lexicalthis가 lexically enclosing function의 this value를 refer함을 의미합니다. strictthis value가 function invocation에 의해 provided된 그대로 사용됨을 의미합니다. globalundefined 또는 nullthis value가 global object에 대한 reference로 interpreted되고, 그 밖의 this value는 먼저 ToObject에 passed됨을 의미합니다.
[[Strict]] a Boolean 이것이 strict function이면 true, non-strict function이면 false입니다.
[[HomeObject]] an Object or undefined function이 super를 사용하면, 이는 그 [[GetPrototypeOf]]super property lookup이 시작되는 object를 제공하는 object입니다.
[[SourceText]] a sequence of Unicode code points function을 define하는 source text입니다.
[[Fields]] a List of ClassFieldDefinition Records function이 class이면, 이는 class의 non-static field와 corresponding initializer를 represent하는 Record의 list입니다.
[[PrivateMethods]] a List of PrivateElements function이 class이면, 이는 class의 non-static private method와 accessor를 represent하는 list입니다.
[[ClassFieldInitializerName]] a String, a Symbol, a Private Name, or empty function이 class field의 initializer로 created되면, field의 NamedEvaluation에 사용할 name입니다. 그렇지 않으면 empty입니다.
[[IsClassConstructor]] a Boolean function이 class constructor인지 여부를 나타냅니다. (true이면, function의 [[Call]]을 invoking하는 즉시 TypeError exception을 throw합니다.)

모든 ECMAScript function object는 여기서 정의된 [[Call]] internal method를 가집니다. 또한 constructor이기도 한 ECMAScript function은 [[Construct]] internal method를 가집니다.

10.2.1 [[Call]] ( thisArg, argList )

The [[Call]] internal method of an ECMAScript function object func takes arguments thisArg (an ECMAScript language value) and argList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. callerContextrunning execution context로 둔다.
  2. calleeContextPrepareForOrdinaryCall(func, undefined)로 둔다.
  3. Assert: calleeContext는 이제 running execution context이다.
  4. func.[[IsClassConstructor]]true이면, 다음을 수행한다.
    1. error를 newly created TypeError object로 둔다.
    2. NOTE: errorfunc의 associated Realm Record를 가진 calleeContext 안에서 created됩니다.
    3. execution context stack에서 calleeContext를 remove하고 callerContextrunning execution context로 restore한다.
    4. error를 throw한다.
  5. OrdinaryCallBindThis(func, calleeContext, thisArg)를 수행한다.
  6. resultCompletion(OrdinaryCallEvaluateBody(func, argList))로 둔다.
  7. execution context stack에서 calleeContext를 remove하고 callerContextrunning execution context로 restore한다.
  8. resultreturn completion이면, result.[[Value]]를 반환한다.
  9. Assert: resultthrow completion이다.
  10. result를 반환한다.
Note

step 7에서 calleeContextexecution context stack에서 removed될 때, accessible Generator에 의해 later resumption을 위해 suspended되고 retained되어 있다면 destroyed되어서는 안 됩니다.

10.2.1.1 PrepareForOrdinaryCall ( func, newTarget )

The abstract operation PrepareForOrdinaryCall takes arguments func (an ECMAScript function object) and newTarget (an Object or undefined) and returns an execution context. It performs the following steps when called:

  1. callerContextrunning execution context로 둔다.
  2. calleeContext를 새 ECMAScript code execution context로 둔다.
  3. calleeContext의 Function을 func로 설정한다.
  4. calleeRealmfunc.[[Realm]]으로 둔다.
  5. calleeContextRealmcalleeRealm으로 설정한다.
  6. calleeContext의 ScriptOrModule을 func.[[ScriptOrModule]]으로 설정한다.
  7. localEnvNewFunctionEnvironment(func, newTarget)으로 둔다.
  8. calleeContext의 LexicalEnvironment를 localEnv로 설정한다.
  9. calleeContext의 VariableEnvironment를 localEnv로 설정한다.
  10. calleeContext의 PrivateEnvironment를 func.[[PrivateEnvironment]]로 설정한다.
  11. callerContext가 already suspended가 아니면, callerContext를 suspend한다.
  12. calleeContextexecution context stack 위로 push한다; calleeContext는 이제 running execution context이다.
  13. NOTE: 이 point 이후 produced되는 모든 exception object는 calleeRealm과 associated됩니다.
  14. calleeContext를 반환한다.

10.2.1.2 OrdinaryCallBindThis ( func, calleeContext, thisArg )

The abstract operation OrdinaryCallBindThis takes arguments func (an ECMAScript function object), calleeContext (an execution context), and thisArg (an ECMAScript language value) and returns unused. It performs the following steps when called:

  1. thisModefunc.[[ThisMode]]로 둔다.
  2. thisModelexical이면, unused를 반환한다.
  3. calleeRealmfunc.[[Realm]]으로 둔다.
  4. localEnvcalleeContext의 LexicalEnvironment로 둔다.
  5. thisModestrict이면, 다음을 수행한다.
    1. thisValuethisArg로 둔다.
  6. 그렇지 않으면,
    1. thisArgundefined 또는 null이면, 다음을 수행한다.
      1. globalEnvcalleeRealm.[[GlobalEnv]]로 둔다.
      2. Assert: globalEnvGlobal Environment Record이다.
      3. thisValueglobalEnv.[[GlobalThisValue]]로 둔다.
    2. 그렇지 않으면,
      1. thisValue를 ! ToObject(thisArg)로 둔다.
      2. NOTE: ToObjectcalleeRealm을 사용하여 wrapper object를 produce합니다.
  7. Assert: localEnvFunction Environment Record이다.
  8. Assert: localEnv.[[ThisBindingStatus]]initialized가 아니므로 다음 step은 결코 abrupt completion을 반환하지 않는다.
  9. BindThisValue(localEnv, thisValue)를 수행한다.
  10. unused를 반환한다.

10.2.1.3 Runtime Semantics: EvaluateBody

The syntax-directed operation EvaluateBody takes arguments func (an ECMAScript function object) and argList (a List of ECMAScript language values) and returns a return completion or a throw completion. It is defined piecewise over the following productions:

FunctionBody : FunctionStatementList
  1. arguments funcargList를 가진 FunctionBodyEvaluateFunctionBody를 ? 반환한다.
ConciseBody : ExpressionBody
  1. arguments funcargList를 가진 ConciseBodyEvaluateConciseBody를 ? 반환한다.
GeneratorBody : FunctionBody
  1. arguments funcargList를 가진 GeneratorBodyEvaluateGeneratorBody를 ? 반환한다.
AsyncGeneratorBody : FunctionBody
  1. arguments funcargList를 가진 AsyncGeneratorBodyEvaluateAsyncGeneratorBody를 ? 반환한다.
AsyncFunctionBody : FunctionBody
  1. arguments funcargList를 가진 AsyncFunctionBodyEvaluateAsyncFunctionBody를 ? 반환한다.
AsyncConciseBody : ExpressionBody
  1. arguments funcargList를 가진 AsyncConciseBodyEvaluateAsyncConciseBody를 ? 반환한다.
Initializer : = AssignmentExpression
  1. Assert: argList는 empty이다.
  2. Assert: func.[[ClassFieldInitializerName]]empty가 아니다.
  3. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이면, 다음을 수행한다.
    1. value를 argument func.[[ClassFieldInitializerName]]을 가진 InitializerNamedEvaluation으로 ? 둔다.
  4. 그렇지 않으면,
    1. rhsAssignmentExpressionEvaluation으로 ? 둔다.
    2. value를 ? GetValue(rhs)로 둔다.
  5. ReturnCompletion(value)를 반환한다.
Note

field initializer가 function boundary를 constitute하더라도, FunctionDeclarationInstantiation을 calling하는 것은 observable effect가 없으므로 omitted됩니다.

ClassStaticBlockBody : ClassStaticBlockStatementList
  1. Assert: argList는 empty이다.
  2. argument func를 가진 ClassStaticBlockBodyEvaluateClassStaticBlockBody를 ? 반환한다.

10.2.1.4 OrdinaryCallEvaluateBody ( func, argList )

The abstract operation OrdinaryCallEvaluateBody takes arguments func (an ECMAScript function object) and argList (a List of ECMAScript language values) and returns a return completion or a throw completion. It performs the following steps when called:

  1. arguments funcargList를 가진 func.[[ECMAScriptCode]]EvaluateBody를 ? 반환한다.

10.2.2 [[Construct]] ( argList, newTarget )

The [[Construct]] internal method of an ECMAScript function object func takes arguments argList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. callerContextrunning execution context로 둔다.
  2. kindfunc.[[ConstructorKind]]로 둔다.
  3. kindbase이면, 다음을 수행한다.
    1. thisArg를 ? OrdinaryCreateFromConstructor(newTarget, "%Object.prototype%")로 둔다.
  4. calleeContextPrepareForOrdinaryCall(func, newTarget)으로 둔다.
  5. Assert: calleeContext는 이제 running execution context이다.
  6. kindbase이면, 다음을 수행한다.
    1. OrdinaryCallBindThis(func, calleeContext, thisArg)를 수행한다.
    2. initializeResultCompletion(InitializeInstanceElements(thisArg, func))로 둔다.
    3. initializeResultabrupt completion이면, 다음을 수행한다.
      1. execution context stack에서 calleeContext를 remove하고 callerContextrunning execution context로 restore한다.
      2. initializeResult를 반환한다.
  7. ctorEnvcalleeContext의 LexicalEnvironment로 둔다.
  8. resultCompletion(OrdinaryCallEvaluateBody(func, argList))로 둔다.
  9. execution context stack에서 calleeContext를 remove하고 callerContextrunning execution context로 restore한다.
  10. resultthrow completion이면, 다음을 수행한다.
    1. result를 반환한다.
  11. Assert: resultreturn completion이다.
  12. result.[[Value]]가 Object이면, result.[[Value]]를 반환한다.
  13. kindbase이면, thisArg를 반환한다.
  14. result.[[Value]]undefined가 아니면, TypeError exception을 throw한다.
  15. thisBinding을 ? ctorEnv.GetThisBinding()으로 둔다.
  16. Assert: thisBinding은 Object이다.
  17. thisBinding을 반환한다.

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

The abstract operation OrdinaryFunctionCreate takes arguments proto (an Object), sourceText (a sequence of Unicode code points), paramList (a Parse Node), body (a Parse Node), thisMode (lexical-this or non-lexical-this), envRecord (an Environment Record), and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. default [[Call]] internal method를 가지며 [[Construct]] internal method는 없는 새 function의 runtime creation을 specify하는 데 사용됩니다(단, MakeConstructor 같은 operation에 의해 subsequently added될 수 있습니다). sourceText는 created될 function의 syntactic definition의 source text입니다. It performs the following steps when called:

  1. internalSlotsListTable 26에 listed된 internal slot으로 둔다.
  2. funcOrdinaryObjectCreate(proto, internalSlotsList)로 둔다.
  3. func.[[Call]]10.2.1에 specified된 definition으로 설정한다.
  4. func.[[SourceText]]sourceText로 설정한다.
  5. func.[[FormalParameters]]paramList로 설정한다.
  6. func.[[ECMAScriptCode]]body로 설정한다.
  7. strictIsStrict(body)로 둔다.
  8. func.[[Strict]]strict로 설정한다.
  9. thisModelexical-this이면, func.[[ThisMode]]lexical로 설정한다.
  10. 그렇지 않고 stricttrue이면, 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]]을 current Realm Record로 설정한다.
  17. func.[[HomeObject]]undefined로 설정한다.
  18. func.[[Fields]]를 새 empty List로 설정한다.
  19. func.[[PrivateMethods]]를 새 empty List로 설정한다.
  20. func.[[ClassFieldInitializerName]]empty로 설정한다.
  21. lengthparamListExpectedArgumentCount로 둔다.
  22. SetFunctionLength(func, length)를 수행한다.
  23. func를 반환한다.

10.2.4 AddRestrictedFunctionProperties ( func, realm )

The abstract operation AddRestrictedFunctionProperties takes arguments func (a function object) and realm (a Realm Record) and returns unused. It performs the following steps when called:

  1. Assert: realm.[[Intrinsics]].[[%ThrowTypeError%]]는 존재하고 initialized되어 있다.
  2. throwerrealm.[[Intrinsics]].[[%ThrowTypeError%]]로 둔다.
  3. DefinePropertyOrThrow(func, "caller", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true })를 수행한다.
  4. DefinePropertyOrThrow(func, "arguments", PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: true })를 수행한다.
  5. unused를 반환한다.

10.2.4.1 %ThrowTypeError% ( )

이 function은 %ThrowTypeError% intrinsic object입니다.

이는 각 realm마다 한 번 정의되는 anonymous built-in function object입니다.

called될 때 다음 step을 수행합니다:

  1. TypeError exception을 throw한다.

이 function의 [[Extensible]] internal slot의 value는 false입니다.

이 function의 "length" property는 attribute { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

이 function의 "name" property는 attribute { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }를 가집니다.

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

The abstract operation MakeConstructor takes argument func (an ECMAScript function object or a built-in function object) and optional arguments writableProto (a Boolean) and proto (an Object) and returns unused. funcconstructor로 convert합니다. It performs the following steps when called:

  1. func가 ECMAScript function object이면, 다음을 수행한다.
    1. Assert: IsConstructor(func)는 false이다.
    2. Assert: func"prototype" own property를 가지지 않는 extensible object이다.
    3. func.[[Construct]]10.2.2에 specified된 definition으로 설정한다.
  2. 그렇지 않으면,
    1. func.[[Construct]]10.3.2에 specified된 definition으로 설정한다.
  3. func.[[ConstructorKind]]base로 설정한다.
  4. writableProto가 present하지 않으면, writablePrototrue로 설정한다.
  5. proto가 present하지 않으면, 다음을 수행한다.
    1. protoOrdinaryObjectCreate(%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 )

The abstract operation MakeClassConstructor takes argument func (an ECMAScript function object) and returns unused. It performs the following steps when called:

  1. Assert: func.[[IsClassConstructor]]false이다.
  2. func.[[IsClassConstructor]]true로 설정한다.
  3. unused를 반환한다.

10.2.7 MakeMethod ( func, homeObj )

The abstract operation MakeMethod takes arguments func (an ECMAScript function object) and homeObj (an Object) and returns unused. func를 method로 configure합니다. It performs the following steps when called:

  1. Assert: homeObjordinary object이다.
  2. func.[[HomeObject]]homeObj로 설정한다.
  3. unused를 반환한다.

10.2.8 DefineMethodProperty ( homeObj, name, closure, enumerable )

The abstract operation DefineMethodProperty takes arguments homeObj (an Object), name (a property key or Private Name), closure (a function object), and enumerable (a Boolean) and returns either a normal completion containing either a PrivateElement or unused, or an abrupt completion. It performs the following steps when called:

  1. Assert: homeObj는 ordinary, extensible object이다.
  2. namePrivate 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. NOTE: DefinePropertyOrThrowname"prototype"인 class static method를 define하려고 attempt할 때만 abrupt completion을 반환합니다.
  6. unused를 반환한다.

10.2.9 SetFunctionName ( func, name [ , prefix ] )

The abstract operation SetFunctionName takes arguments func (a function object) and name (a property key or Private Name) and optional argument prefix (a String) and returns unused. func"name" property를 add합니다. It performs the following steps when called:

  1. Assert: func"name" own property를 가지지 않는 extensible object이다.
  2. name이 Symbol이면, 다음을 수행한다.
    1. descriptionname.[[Description]]으로 둔다.
    2. descriptionundefined이면, name을 empty String으로 설정한다.
    3. 그렇지 않으면, name"[", description, "]"string-concatenation으로 설정한다.
  3. 그렇지 않고 namePrivate Name이면, 다음을 수행한다.
    1. namename.[[Description]]으로 설정한다.
  4. func[[InitialName]] internal slot을 가지면, 다음을 수행한다.
    1. func.[[InitialName]]name으로 설정한다.
  5. prefix가 present하면, 다음을 수행한다.
    1. prefixedNameprefix, code unit 0x0020 (SPACE), namestring-concatenation으로 둔다.
    2. func[[InitialName]] internal slot을 가지면, 다음을 수행한다.
      1. NOTE: 다음 step의 choice는 이 Abstract Operation이 invoked될 때마다 independently made됩니다.
      2. func.[[InitialName]]name 또는 prefixedNameimplementation-defined choice로 설정한다.
    3. nameprefixedName으로 설정한다.
  6. DefinePropertyOrThrow(func, "name", PropertyDescriptor { [[Value]]: name, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true })를 수행한다.
  7. unused를 반환한다.

10.2.10 SetFunctionLength ( func, length )

The abstract operation SetFunctionLength takes arguments func (a function object) and length (a non-negative integer or +∞) and returns unused. func"length" property를 add합니다. It performs the following steps when called:

  1. Assert: func"length" own property를 가지지 않는 extensible object이다.
  2. DefinePropertyOrThrow(func, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true })를 수행한다.
  3. unused를 반환한다.

10.2.11 FunctionDeclarationInstantiation ( func, argList )

The abstract operation FunctionDeclarationInstantiation takes arguments func (an ECMAScript function object) and argList (a List of ECMAScript language values) and returns either a normal completion containing unused or a throw completion. funcexecution context가 established되고 있는 대상 function object입니다.

Note

ECMAScript function을 evaluating하기 위해 execution context가 established될 때 새 Function Environment Record가 created되고 각 formal parameter에 대한 binding이 그 Environment Record 안에 instantiated됩니다. function body 안의 각 declaration도 instantiated됩니다. function의 formal parameter가 default value initializer를 포함하지 않으면 body declaration은 parameter와 같은 Environment Record 안에 instantiated됩니다. default value parameter initializer가 존재하면 body declaration을 위해 두 번째 Environment Record가 created됩니다. Formal parameter와 function은 FunctionDeclarationInstantiation의 일부로 initialized됩니다. 다른 모든 binding은 function body의 evaluation 중에 initialized됩니다.

called될 때 다음 step을 수행합니다:

  1. calleeContext를 실행 중인 실행 컨텍스트라고 하자.
  2. codefunc.[[ECMAScriptCode]]라고 하자.
  3. strictfunc.[[Strict]]라고 하자.
  4. formalsfunc.[[FormalParameters]]라고 하자.
  5. paramNamesformalsBoundNames라고 하자.
  6. paramNames에 중복 항목이 있으면 hasDuplicatestrue라고 하고, 그렇지 않으면 hasDuplicatesfalse라고 하자.
  7. simpleParamListformalsIsSimpleParameterList라고 하자.
  8. hasParamExprsformalsContainsExpression이라고 하자.
  9. variableNamescodeVarDeclaredNames라고 하자.
  10. variableDeclscodeVarScopedDeclarations라고 하자.
  11. lexicalNamescodeLexicallyDeclaredNames라고 하자.
  12. funcNames를 새로운 빈 List라고 하자.
  13. funcsToInitialize를 새로운 빈 List라고 하자.
  14. variableDecls의 각 요소 variableDecl에 대해, List의 역순으로 다음을 수행한다.
    1. variableDeclVariableDeclarationForBindingBindingIdentifier도 아니면,
      1. Assert: variableDeclFunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나이다.
      2. funcNamevariableDeclBoundNames의 유일한 요소라고 하자.
      3. funcNamesfuncName을 포함하지 않으면,
        1. funcNamefuncNames의 첫 번째 요소로 삽입한다.
        2. NOTE: 같은 이름에 대해 여러 함수 선언이 있으면, 마지막 선언이 사용된다.
        3. variableDeclfuncsToInitialize의 첫 번째 요소로 삽입한다.
  15. argumentsObjNeededtrue라고 하자.
  16. func.[[ThisMode]]lexical이면,
    1. NOTE: 화살표 함수는 arguments 객체를 갖지 않는다.
    2. argumentsObjNeededfalse로 설정한다.
  17. 그렇지 않고 paramNames"arguments"를 포함하면,
    1. argumentsObjNeededfalse로 설정한다.
  18. 그렇지 않고 hasParamExprsfalse이면,
    1. funcNames"arguments"를 포함하거나 lexicalNames"arguments"를 포함하면,
      1. argumentsObjNeededfalse로 설정한다.
  19. stricttrue이거나 hasParamExprsfalse이면,
    1. NOTE: 매개변수에는 단일 Environment Record만 필요하다. strict mode 코드의 eval 호출은 eval 밖에서 보이는 새 바인딩을 만들 수 없기 때문이다.
    2. envRecordcalleeContext의 LexicalEnvironment라고 하자.
  20. 그렇지 않으면,
    1. NOTE: formal parameter list 안의 direct eval 호출로 생성된 바인딩이 매개변수가 선언된 환경 밖에 있도록 보장하기 위해 별도의 Environment Record가 필요하다.
    2. calleeEnvcalleeContext의 LexicalEnvironment라고 하자.
    3. envRecordNewDeclarativeEnvironment(calleeEnv)라고 하자.
    4. Assert: calleeContext의 VariableEnvironment와 calleeEnv는 같은 Environment Record이다.
    5. calleeContext의 LexicalEnvironment를 envRecord로 설정한다.
  21. paramNames의 각 String paramName에 대해 다음을 수행한다.
    1. alreadyDeclared를 ! envRecord.HasBinding(paramName)이라고 하자.
    2. NOTE: Early errors는 중복 매개변수 이름이 기본 매개변수 값이나 rest 매개변수가 없는 non-strict 함수에서만 발생할 수 있음을 보장한다.
    3. alreadyDeclaredfalse이면,
      1. envRecord.CreateMutableBinding(paramName, false)를 수행한다.
      2. hasDuplicatestrue이면,
        1. envRecord.InitializeBinding(paramName, undefined)를 수행한다.
  22. argumentsObjNeededtrue이면,
    1. stricttrue이거나 simpleParamListfalse이면,
      1. argumentsObjCreateUnmappedArgumentsObject(argList)라고 하자.
    2. 그렇지 않으면,
      1. NOTE: mapped argument object는 rest 매개변수, 매개변수 기본값 초기화자, 구조 분해 매개변수가 없는 non-strict 함수에만 제공된다.
      2. argumentsObjCreateMappedArgumentsObject(func, formals, argList, envRecord)라고 하자.
    3. stricttrue이면,
      1. envRecord.CreateImmutableBinding("arguments", false)를 수행한다.
      2. NOTE: strict mode 코드에서는 Early Errors가 이 바인딩에 할당하려는 시도를 방지하므로, 그 가변성은 관찰 가능하지 않다.
    4. 그렇지 않으면,
      1. envRecord.CreateMutableBinding("arguments", false)를 수행한다.
    5. envRecord.InitializeBinding("arguments", argumentsObj)를 수행한다.
    6. paramBindingsparamNames와 « "arguments" »의 list-concatenation이라고 하자.
  23. 그렇지 않으면,
    1. paramBindingsparamNames라고 하자.
  24. iteratorRecordCreateListIteratorRecord(argList)라고 하자.
  25. hasDuplicatestrue이면,
    1. usedEnvundefined라고 하자.
  26. 그렇지 않으면,
    1. usedEnvenvRecord라고 하자.
  27. NOTE: 다음 단계는 ReturnCompletion을 반환할 수 없다. 그러한 completion이 expression 위치에서 발생할 수 있는 유일한 방법은 YieldExpression 사용뿐인데, 이는 15.5.115.6.1의 Early Error 규칙에 의해 parameter list에서 금지되기 때문이다.
  28. formalsIteratorBindingInitialization을 인수 iteratorRecordusedEnv와 함께 수행한다. 완료가 갑작스러운 완료이면 전파한다.
  29. hasParamExprsfalse이면,
    1. NOTE: 매개변수와 최상위 vars에는 단일 Environment Record만 필요하다.
    2. instantiatedVariableNamesList paramBindings의 복사본이라고 하자.
    3. variableNames의 각 요소 name에 대해 다음을 수행한다.
      1. instantiatedVariableNamesname을 포함하지 않으면,
        1. nameinstantiatedVariableNames에 추가한다.
        2. envRecord.CreateMutableBinding(name, false)를 수행한다.
        3. envRecord.InitializeBinding(name, undefined)를 수행한다.
    4. variableEnvenvRecord라고 하자.
  30. 그렇지 않으면,
    1. NOTE: formal parameter list 안의 표현식으로 생성된 클로저가 함수 본문의 선언을 볼 수 없도록 보장하기 위해 별도의 Environment Record가 필요하다.
    2. variableEnvNewDeclarativeEnvironment(envRecord)라고 하자.
    3. calleeContext의 VariableEnvironment를 variableEnv로 설정한다.
    4. instantiatedVariableNames를 새로운 빈 List라고 하자.
    5. variableNames의 각 요소 name에 대해 다음을 수행한다.
      1. instantiatedVariableNamesname을 포함하지 않으면,
        1. nameinstantiatedVariableNames에 추가한다.
        2. variableEnv.CreateMutableBinding(name, false)를 수행한다.
        3. paramBindingsname을 포함하지 않거나 funcNamesname을 포함하면,
          1. initialValueundefined라고 하자.
        4. 그렇지 않으면,
          1. initialValue를 ! envRecord.GetBindingValue(name, false)라고 하자.
        5. variableEnv.InitializeBinding(name, initialValue)를 수행한다.
        6. NOTE: formal parameter와 같은 이름의 var는 처음에 해당 초기화된 매개변수와 같은 값을 갖는다.
  31. stricttrue이면,
    1. lexicalEnvvariableEnv라고 하자.
  32. 그렇지 않으면,
    1. host가 web browser이거나 그 밖에 Block-Level Function Declarations Web Legacy Compatibility Semantics를 지원하면,
      1. code Contains xtrueBlock, CaseClause 또는 DefaultClause xStatementList에 직접 포함된 각 FunctionDeclaration funcDecl에 대해 다음을 수행한다.
        1. funcNamefuncDeclBindingIdentifierStringValue라고 하자.
        2. FunctionDeclaration funcDeclfuncNameBindingIdentifier로 갖는 VariableStatement로 대체해도 func에 대한 Early Errors가 생성되지 않고 paramNamesfuncName을 포함하지 않으면,
          1. NOTE: funcName에 대한 var 바인딩은 그것이 VarDeclaredName, formal parameter의 이름 또는 다른 FunctionDeclaration이 아닐 때에만 여기서 인스턴스화된다.
          2. instantiatedVariableNamesfuncName을 포함하지 않고 funcName"arguments"가 아니면,
            1. variableEnv.CreateMutableBinding(funcName, false)를 수행한다.
            2. variableEnv.InitializeBinding(funcName, undefined)를 수행한다.
            3. funcNameinstantiatedVariableNames에 추가한다.
          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. lexicalEnvNewDeclarativeEnvironment(variableEnv)라고 하자.
    3. NOTE: non-strict 함수는 최상위 lexical 선언에 대해 별도의 Environment Record를 사용하므로, direct eval은 eval 코드가 도입한 var scoped 선언이 기존의 최상위 lexically scoped 선언과 충돌하는지 판단할 수 있다. strict 함수에는 이것이 필요하지 않다. strict direct eval은 항상 모든 선언을 새로운 Environment Record에 두기 때문이다.
  33. calleeContext의 LexicalEnvironment를 lexicalEnv로 설정한다.
  34. lexicalDeclscodeLexicallyScopedDeclarations라고 하자.
  35. lexicalDecls의 각 요소 lexicalDecl에 대해 다음을 수행한다.
    1. NOTE: lexically declared name은 function/generator 선언, formal parameter 또는 var 이름과 같을 수 없다. Lexically declared name은 여기서 인스턴스화만 되고 초기화되지는 않는다.
    2. lexicalDeclBoundNames의 각 요소 name에 대해 다음을 수행한다.
      1. lexicalDeclIsConstantDeclarationtrue이면,
        1. lexicalEnv.CreateImmutableBinding(name, true)를 수행한다.
      2. 그렇지 않으면,
        1. lexicalEnv.CreateMutableBinding(name, false)를 수행한다.
  36. privateEnvcalleeContext의 PrivateEnvironment라고 하자.
  37. funcsToInitialize의 각 Parse Node funcDecl에 대해 다음을 수행한다.
    1. funcNamefuncDeclBoundNames의 유일한 요소라고 하자.
    2. funcObjfuncDeclInstantiateFunctionObject에 인수 lexicalEnvprivateEnv를 전달한 결과라고 하자.
    3. variableEnv.SetMutableBinding(funcName, funcObj, false)를 수행한다.
  38. unused를 반환한다.

10.3 Built-in Function Objects

built-in function objectordinary object입니다; 이는 10.1에 set out된 ordinary object에 대한 requirement를 satisfy해야 합니다.

모든 ordinary object에 required되는 internal slot(10.1 참조) 외에도, built-in function object는 다음 internal slot도 가져야 합니다:

  • [[Realm]], function이 created된 realm을 represent하는 Realm Record.
  • [[InitialName]], function의 initial name인 String. 이는 20.2.3.5에 의해 사용됩니다.
  • [[Async]], function이 BuiltinCallOrConstruct 안에서 async function call 및 construct behaviour를 가지는지 여부를 나타내는 Boolean.

달리 specified되지 않는 한, built-in function object's [[Prototype]] internal slot의 initial value는 %Function.prototype%입니다.

built-in function object10.3.1의 definition을 conform하는 [[Call]] internal method를 가져야 합니다.

built-in function object는 “constructor”로 described되거나 이 명세의 어떤 algorithm이 그 [[Construct]] internal method를 explicit하게 set하는 경우에 and only if [[Construct]] internal method를 가집니다. 그러한 [[Construct]] internal method는 10.3.2의 definition을 conform해야 합니다.

implementation은 이 명세에 정의되지 않은 additional built-in function object를 provide할 수 있습니다.

10.3.1 [[Call]] ( thisArg, argList )

The [[Call]] internal method of a built-in function object func takes arguments thisArg (an ECMAScript language value) and argList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. BuiltinCallOrConstruct(func, thisArg, argList, undefined)를 반환한다.

10.3.2 [[Construct]] ( argList, newTarget )

The [[Construct]] internal method of a built-in function object func (when the method is present) takes arguments argList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. result를 ? BuiltinCallOrConstruct(func, uninitialized, argList, newTarget)로 둔다.
  2. Assert: result는 Object이다.
  3. result를 반환한다.

10.3.3 BuiltinCallOrConstruct ( func, thisArg, argList, newTarget )

The abstract operation BuiltinCallOrConstruct takes arguments func (a built-in function object), thisArg (an ECMAScript language value or uninitialized), argList (a List of ECMAScript language values), and newTarget (a constructor or undefined) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. callerContextrunning execution context로 둔다.
  2. callerContext가 already suspended가 아니면, callerContext를 suspend한다.
  3. calleeContext를 새 execution context로 둔다.
  4. calleeContext의 Function을 func로 설정한다.
  5. calleeRealmfunc.[[Realm]]으로 둔다.
  6. calleeContextRealmcalleeRealm으로 설정한다.
  7. calleeContext의 ScriptOrModule을 null로 설정한다.
  8. calleeContext의 necessary implementation-defined initialization을 수행한다.
  9. calleeContextexecution context stack 위로 push한다; calleeContext는 이제 running execution context이다.
  10. func.[[Async]]true이면, 다음을 수행한다.
    1. promiseCapability를 ! NewPromiseCapability(%Promise%)로 둔다.
    2. resultsClosurefunc, thisArg, argList, newTarget을 capture하고 called될 때 다음 step을 수행하는, parameter가 없는 새 Abstract Closure로 둔다:
      1. resultfunc의 specification을 conform하는 manner로 funcevaluating한 resultCompletion Record로 둔다. thisArguninitialized이면, this value는 uninitialized입니다; 그렇지 않으면 thisArgthis value를 제공합니다. argList는 named parameter를 제공합니다. newTarget은 NewTarget value를 제공합니다.
      2. NOTE: func가 이 document에 defined되어 있으면, “func의 specification”은 algorithm step 또는 기타 means를 통해 그것에 대해 specified된 behaviour입니다.
      3. Completion(result)을 반환한다.
    3. AsyncFunctionStart(promiseCapability, resultsClosure)를 수행한다.
    4. execution context stack에서 calleeContext를 remove하고 callerContextrunning execution context로 restore한다.
    5. promiseCapability.[[Promise]]를 반환한다.
  11. resultfunc의 specification을 conform하는 manner로 funcevaluating한 resultCompletion Record로 둔다. thisArguninitialized이면, this value는 uninitialized입니다; 그렇지 않으면 thisArgthis value를 제공합니다. argList는 named parameter를 제공합니다. newTarget은 NewTarget value를 제공합니다.
  12. NOTE: func가 이 document에 defined되어 있으면, “func의 specification”은 algorithm step 또는 기타 means를 통해 그것에 대해 specified된 behaviour입니다.
  13. execution context stack에서 calleeContext를 remove하고 callerContextrunning execution context로 restore한다.
  14. result를 반환한다.
Note

calleeContextexecution context stack에서 removed될 때, accessible Generator에 의해 later resumption을 위해 suspended되고 retained되어 있다면 destroyed되어서는 안 됩니다.

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

The abstract operation CreateBuiltinFunction takes arguments behaviour (an Abstract Closure, a set of algorithm steps, or some other definition of a function's behaviour provided in this specification), length (a non-negative integer or +∞), name (a property key or a Private Name), and additionalInternalSlotsList (a List of names of internal slots) and optional arguments realm (a Realm Record), proto (an Object or null), prefix (a String), and async (a Boolean) and returns a built-in function object. additionalInternalSlotsList는 object의 part로 define되어야 하는 additional internal slot의 name을 contain합니다. 이 operation은 built-in function object를 create합니다. It performs the following steps when called:

  1. realm이 present하지 않으면, realm을 current Realm Record로 설정한다.
  2. proto가 present하지 않으면, protorealm.[[Intrinsics]].[[%Function.prototype%]]로 설정한다.
  3. async가 present하지 않으면, asyncfalse로 설정한다.
  4. internalSlotsList를, create하려는 built-in function object에 대해 10.3가 require하는 모든 internal slot의 name을 contain하는 List로 둔다.
  5. additionalInternalSlotsList의 element를 internalSlotsList에 append한다.
  6. func를 called될 때 behaviour에 의해 specified된 corresponding parameter의 value로 provided argument를 사용하여 behaviour가 describe한 action을 수행하는 새 built-in function object로 둔다. 새 function object는 name이 internalSlotsList의 element인 internal slot과 [[InitialName]] internal slot을 가진다.
  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가 present하지 않으면, 다음을 수행한다.
    1. SetFunctionName(func, name)을 수행한다.
  14. 그렇지 않으면,
    1. SetFunctionName(func, name, prefix)를 수행한다.
  15. func를 반환한다.

이 명세에 정의된 각 built-in function은 CreateBuiltinFunction abstract operation을 calling하여 created됩니다.

10.4 Built-in Exotic Object Internal Methods and Slots

이 명세는 여러 종류의 built-in exotic object를 정의합니다. 이러한 object는 일반적으로 몇몇 specific situation을 제외하면 ordinary object와 similar하게 behave합니다. 다음 exotic object는 아래에서 explicit하게 달리 specified된 곳을 제외하고 ordinary object internal method를 사용합니다:

10.4.1 Bound Function Exotic Objects

bound function exotic object는 다른 function object를 wrap하는 exotic object입니다. bound function exotic object는 callable입니다([[Call]] internal method를 가지며 [[Construct]] internal method를 가질 수 있습니다). bound function exotic object를 calling하면 일반적으로 그것의 wrapped function의 call이 result됩니다.

object의 [[Call]]과 (applicable하면) [[Construct]] internal method가 다음 implementation을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 bound function exotic object입니다. 이러한 method는 BoundFunctionCreate에서 installed됩니다.

Bound function exotic objectTable 26에 listed된 ECMAScript function object의 internal slot을 가지지 않습니다. 대신 [[Prototype]][[Extensible]]에 더해, Table 27에 listed된 internal slot을 가집니다.

Table 27: Internal Slots of Bound Function Exotic Objects
Internal Slot Type Description
[[BoundTargetFunction]] a callable Object wrapped function object입니다.
[[BoundThis]] an ECMAScript language value wrapped function을 calling할 때 항상 this value로 passed되는 value입니다.
[[BoundArguments]] a List of ECMAScript language values wrapped function에 대한 any call의 first arguments로 사용되는 element를 가진 value의 list입니다.

10.4.1.1 [[Call]] ( thisArg, argList )

The [[Call]] internal method of a bound function exotic object func takes arguments thisArg (an ECMAScript language value) and argList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. targetfunc.[[BoundTargetFunction]]으로 둔다.
  2. boundThisfunc.[[BoundThis]]로 둔다.
  3. boundArgsfunc.[[BoundArguments]]로 둔다.
  4. argsboundArgsargListlist-concatenation으로 둔다.
  5. Call(target, boundThis, args)를 반환한다.

10.4.1.2 [[Construct]] ( argList, newTarget )

The [[Construct]] internal method of a bound function exotic object func takes arguments argList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. targetfunc.[[BoundTargetFunction]]으로 둔다.
  2. Assert: IsConstructor(target)은 true이다.
  3. boundArgsfunc.[[BoundArguments]]로 둔다.
  4. argsboundArgsargListlist-concatenation으로 둔다.
  5. SameValue(func, newTarget)가 true이면, newTargettarget으로 설정한다.
  6. Construct(target, args, newTarget)을 반환한다.

10.4.1.3 BoundFunctionCreate ( targetFunc, boundThis, boundArgs )

The abstract operation BoundFunctionCreate takes arguments targetFunc (a function object), boundThis (an ECMAScript language value), and boundArgs (a List of ECMAScript language values) and returns either a normal completion containing a function object or a throw completion. 새 bound function exotic object의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:

  1. proto를 ? targetFunc.[[GetPrototypeOf]]()로 둔다.
  2. internalSlotsList를 « [[Prototype]], [[Extensible]] »와 Table 27에 listed된 internal slot의 list-concatenation으로 둔다.
  3. objMakeBasicObject(internalSlotsList)로 둔다.
  4. obj.[[Prototype]]proto로 설정한다.
  5. obj.[[Call]]10.4.1.1에 specified된 대로 설정한다.
  6. IsConstructor(targetFunc)가 true이면, 다음을 수행한다.
    1. obj.[[Construct]]10.4.1.2에 specified된 대로 설정한다.
  7. obj.[[BoundTargetFunction]]targetFunc로 설정한다.
  8. obj.[[BoundThis]]boundThis로 설정한다.
  9. obj.[[BoundArguments]]boundArgs로 설정한다.
  10. obj를 반환한다.

10.4.2 Array Exotic Objects

Array는 array index property key(6.1.7 참조)에 special treatment를 제공하는 exotic object입니다. property namearray index인 property는 element라고도 합니다. 모든 Array는 non-configurable "length" property를 가지며, 그 value는 항상 mathematical value가 232보다 strictly less인 non-negative integral Number입니다. "length" property의 value는 name이 array index인 모든 own property의 name보다 numerically greater합니다; Array의 own property가 created되거나 changed될 때마다, 이 invariant를 maintain하기 위해 other property가 necessary하게 adjusted됩니다. Specifically, name이 array index인 own property가 added될 때마다, "length" property의 value는 필요하면 그 array index의 numeric value보다 하나 큰 값으로 changed됩니다; 그리고 "length" property의 value가 changed될 때마다, name이 array index이고 value가 new length보다 작지 않은 모든 own property는 deleted됩니다. 이 constraint는 Array의 own property에만 apply되며, 그 prototype에서 inherited될 수 있는 "length" 또는 array index property의 영향을 받지 않습니다.

object의 [[DefineOwnProperty]] internal method가 다음 implementation을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 Array exotic object(또는 simply, Array)입니다. 이러한 method는 ArrayCreate에서 installed됩니다.

10.4.2.1 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of an Array exotic object array takes arguments propertyKey (a property key) and propertyDesc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey"length"이면, ? ArraySetLength(array, propertyDesc)를 반환한다.
  2. propertyKeyarray index이면, 다음을 수행한다.
    1. lengthDescOrdinaryGetOwnProperty(array, "length")로 둔다.
    2. Assert: lengthDescundefined가 아니다.
    3. Assert: IsDataDescriptor(lengthDesc)는 true이다.
    4. Assert: lengthDesc.[[Configurable]]false이다.
    5. lengthlengthDesc.[[Value]]로 둔다.
    6. Assert: length는 non-negative integral Number이다.
    7. index를 ! ToUint32(propertyKey)로 둔다.
    8. indexlength이고 lengthDesc.[[Writable]]false이면, false를 반환한다.
    9. succeeded를 ! OrdinaryDefineOwnProperty(array, propertyKey, propertyDesc)로 둔다.
    10. succeededfalse이면, false를 반환한다.
    11. indexlength이면, 다음을 수행한다.
      1. lengthDesc.[[Value]]index + 1𝔽로 설정한다.
      2. succeeded를 ! OrdinaryDefineOwnProperty(array, "length", lengthDesc)로 설정한다.
      3. Assert: succeededtrue이다.
    12. true를 반환한다.
  3. OrdinaryDefineOwnProperty(array, propertyKey, propertyDesc)를 반환한다.

10.4.2.2 ArrayCreate ( length [ , proto ] )

The abstract operation ArrayCreate takes argument length (a non-negative integer) and optional argument proto (an Object) and returns either a normal completion containing an Array exotic object or a throw completion. 새 Array의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:

  1. length > 232 - 1이면, RangeError exception을 throw한다.
  2. proto가 present하지 않으면, proto%Array.prototype%으로 설정한다.
  3. arrayMakeBasicObject[[Prototype]], [[Extensible]] »)로 둔다.
  4. array.[[Prototype]]proto로 설정한다.
  5. array.[[DefineOwnProperty]]10.4.2.1에 specified된 대로 설정한다.
  6. OrdinaryDefineOwnProperty(array, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
  7. array를 반환한다.

10.4.2.3 ArraySpeciesCreate ( originalArray, length )

The abstract operation ArraySpeciesCreate takes arguments originalArray (an Object) and length (a non-negative integer) and returns either a normal completion containing an Object or a throw completion. originalArray에서 derived된 constructor function을 사용하여 새 Array 또는 similar object의 creation을 specify하는 데 사용됩니다. constructor function이 Array를 return해야 한다고 enforce하지는 않습니다. It performs the following steps when called:

  1. isArray를 ? IsArray(originalArray)로 둔다.
  2. isArrayfalse이면, ? ArrayCreate(length)를 반환한다.
  3. ctor를 ? Get(originalArray, "constructor")로 둔다.
  4. IsConstructor(ctor)가 true이면, 다음을 수행한다.
    1. thisRealm을 current Realm Record로 둔다.
    2. ctorRealm을 ? GetFunctionRealm(ctor)으로 둔다.
    3. thisRealmctorRealm이 같은 Realm Record가 아니면, 다음을 수행한다.
      1. SameValue(ctor, ctorRealm.[[Intrinsics]].[[%Array%]])가 true이면, ctorundefined로 설정한다.
  5. ctor가 Object이면, 다음을 수행한다.
    1. ctor를 ? Get(ctor, %Symbol.species%)로 설정한다.
    2. ctornull이면, ctorundefined로 설정한다.
  6. ctorundefined이면, ? ArrayCreate(length)를 반환한다.
  7. IsConstructor(ctor)가 false이면, TypeError exception을 throw한다.
  8. Construct(ctor, « 𝔽(length) »)를 반환한다.
Note

originalArrayrunning execution contextrealm이 아닌 realm에 대한 standard built-in Array constructor를 사용하여 created되었다면, running execution contextrealm을 사용하여 새 Array가 created됩니다. 이는 역사적으로 ArraySpeciesCreate를 사용하여 now defined된 Array.prototype method에 대해 해당 behaviour를 가졌던 Web browser와의 compatibility를 maintain합니다.

10.4.2.4 ArraySetLength ( array, propertyDesc )

The abstract operation ArraySetLength takes arguments array (an Array) and propertyDesc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyDesc[[Value]] field를 가지지 않으면, 다음을 수행한다.
    1. OrdinaryDefineOwnProperty(array, "length", propertyDesc)를 반환한다.
  2. newLengthDescpropertyDesc의 copy로 둔다.
  3. newLength를 ? ToUint32(propertyDesc.[[Value]])로 둔다.
  4. numberLength를 ? ToNumber(propertyDesc.[[Value]])로 둔다.
  5. SameValueZero(newLength, numberLength)가 false이면, RangeError exception을 throw한다.
  6. newLengthDesc.[[Value]]newLength로 설정한다.
  7. oldLengthDescOrdinaryGetOwnProperty(array, "length")로 둔다.
  8. Assert: oldLengthDescundefined가 아니다.
  9. Assert: IsDataDescriptor(oldLengthDesc)는 true이다.
  10. Assert: oldLengthDesc.[[Configurable]]false이다.
  11. oldLengtholdLengthDesc.[[Value]]로 둔다.
  12. newLengtholdLength이면, 다음을 수행한다.
    1. OrdinaryDefineOwnProperty(array, "length", newLengthDesc)를 반환한다.
  13. oldLengthDesc.[[Writable]]false이면, false를 반환한다.
  14. newLengthDesc[[Writable]] field를 가지지 않거나 newLengthDesc.[[Writable]]true이면, 다음을 수행한다.
    1. newWritabletrue로 둔다.
  15. 그렇지 않으면,
    1. NOTE: 어떤 element가 deleted될 수 없는 경우를 대비하여 [[Writable]] attribute를 false로 setting하는 것은 deferred됩니다.
    2. newWritablefalse로 둔다.
    3. newLengthDesc.[[Writable]]true로 설정한다.
  16. succeeded를 ! OrdinaryDefineOwnProperty(array, "length", newLengthDesc)로 둔다.
  17. succeededfalse이면, false를 반환한다.
  18. array의 각 own property key propertyKeypropertyKeyarray index이고 ! ToUint32(propertyKey) ≥ newLength인 것에 대해, descending numeric index order로 다음을 수행한다.
    1. deleteSucceeded를 ! array.[[Delete]](propertyKey)로 둔다.
    2. deleteSucceededfalse이면, 다음을 수행한다.
      1. newLengthDesc.[[Value]]를 ! ToUint32(propertyKey) + 1𝔽로 설정한다.
      2. newWritablefalse이면, newLengthDesc.[[Writable]]false로 설정한다.
      3. OrdinaryDefineOwnProperty(array, "length", newLengthDesc)를 수행한다.
      4. false를 반환한다.
  19. newWritablefalse이면, 다음을 수행한다.
    1. succeeded를 ! OrdinaryDefineOwnProperty(array, "length", PropertyDescriptor { [[Writable]]: false })로 설정한다.
    2. Assert: succeededtrue이다.
  20. true를 반환한다.
Note

step 34에서, propertyDesc.[[Value]]가 object이면 그 valueOf method가 두 번 called됩니다. 이는 이 명세의 2nd Edition부터 이 effect로 specified된 legacy behaviour입니다.

10.4.3 String Exotic Objects

String object는 String value를 encapsulate하고 String value의 individual code unit element에 corresponding하는 virtual integer-indexed data property를 expose하는 exotic object입니다. String exotic object는 항상 "length"라는 data property를 가지며, 그 value는 encapsulated String value의 length입니다. code unit data property"length" property는 모두 non-writable 및 non-configurable입니다.

object의 [[GetOwnProperty]], [[DefineOwnProperty]], [[OwnPropertyKeys]] internal method가 다음 implementation을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 String exotic object(또는 simply, String object)입니다. 이러한 method는 StringCreate에서 installed됩니다.

String exotic objectordinary object와 같은 internal slot을 가집니다. 또한 [[StringData]] internal slot을 가집니다.

10.4.3.1 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of a String exotic object string takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

  1. propertyDescOrdinaryGetOwnProperty(string, propertyKey)로 둔다.
  2. propertyDescundefined가 아니면, propertyDesc를 반환한다.
  3. StringGetOwnProperty(string, propertyKey)를 반환한다.

10.4.3.2 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of a String exotic object string takes arguments propertyKey (a property key) and propertyDesc (a Property Descriptor) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. stringDescStringGetOwnProperty(string, propertyKey)로 둔다.
  2. stringDescundefined가 아니면, 다음을 수행한다.
    1. extensiblestring.[[Extensible]]로 둔다.
    2. IsCompatiblePropertyDescriptor(extensible, propertyDesc, stringDesc)를 반환한다.
  3. OrdinaryDefineOwnProperty(string, propertyKey, propertyDesc)를 반환한다.

10.4.3.3 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a String exotic object obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:

  1. keys를 새 empty List로 둔다.
  2. stringobj.[[StringData]]로 둔다.
  3. Assert: string은 String이다.
  4. lengthstring의 length로 둔다.
  5. 0 ≤ i < length인 각 integer i에 대해, ascending order로 다음을 수행한다.
    1. ToString(𝔽(i))를 keys에 append한다.
  6. obj의 각 own property key propertyKeypropertyKeyarray index이고 ! ToIntegerOrInfinity(propertyKey) ≥ length인 것에 대해, ascending numeric index order로 다음을 수행한다.
    1. propertyKeykeys에 append한다.
  7. obj의 각 own property key propertyKeypropertyKey가 String이고 propertyKeyarray index가 아닌 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
    1. propertyKeykeys에 append한다.
  8. obj의 각 own property key propertyKeypropertyKey가 Symbol인 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
    1. propertyKeykeys에 append한다.
  9. keys를 반환한다.

10.4.3.4 StringCreate ( value, proto )

The abstract operation StringCreate takes arguments value (a String) and proto (an Object) and returns a String exotic object. 새 String exotic object의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:

  1. stringMakeBasicObject[[Prototype]], [[Extensible]], [[StringData]] »)로 둔다.
  2. string.[[Prototype]]proto로 설정한다.
  3. string.[[StringData]]value로 설정한다.
  4. string.[[GetOwnProperty]]10.4.3.1에 specified된 대로 설정한다.
  5. string.[[DefineOwnProperty]]10.4.3.2에 specified된 대로 설정한다.
  6. string.[[OwnPropertyKeys]]10.4.3.3에 specified된 대로 설정한다.
  7. lengthvalue의 length로 둔다.
  8. DefinePropertyOrThrow(string, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
  9. string을 반환한다.

10.4.3.5 StringGetOwnProperty ( string, propertyKey )

The abstract operation StringGetOwnProperty takes arguments string (an Object that has a [[StringData]] internal slot) and propertyKey (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:

  1. propertyKey가 String이 아니면, undefined를 반환한다.
  2. numericIndexCanonicalNumericIndexString(propertyKey)로 둔다.
  3. numericIndexintegral Number가 아니면, undefined를 반환한다.
  4. numericIndex-0𝔽이거나 numericIndex < -0𝔽이면, undefined를 반환한다.
  5. stringDatastring.[[StringData]]로 둔다.
  6. Assert: stringData는 String이다.
  7. lengthstringData의 length로 둔다.
  8. (numericIndex) ≥ length이면, undefined를 반환한다.
  9. resultString(numericIndex)부터 (numericIndex) + 1까지의 stringData substring으로 둔다.
  10. PropertyDescriptor { [[Value]]: resultString, [[Writable]]: false, [[Enumerable]]: true, [[Configurable]]: false }를 반환한다.

10.4.4 Arguments Exotic Objects

대부분의 ECMAScript function은 그 code에서 arguments object를 available하게 합니다. function definition의 characteristic에 따라, 그 arguments object는 ordinary object이거나 arguments exotic object입니다. arguments exotic objectarray index property가 associated ECMAScript function의 invocation의 formal parameter binding에 map되는 exotic object입니다.

object의 internal method가 다음 implementation을 사용하고, 여기서 specified되지 않은 것은 10.1에 있는 것을 사용하면, 그 object는 arguments exotic object입니다. 이러한 method는 CreateMappedArgumentsObject에서 installed됩니다.

Note 1

CreateUnmappedArgumentsObject는 이 clause 안에 grouped되어 있지만, arguments exotic object가 아니라 ordinary object를 create합니다.

Arguments exotic objectordinary object와 같은 internal slot을 가집니다. 또한 [[ParameterMap]] internal slot을 가집니다. Ordinary arguments object도 value가 항상 undefined[[ParameterMap]] internal slot을 가집니다. ordinary argument object의 경우 [[ParameterMap]] internal slot은 Object.prototype.toString(20.1.3.6)에 의해 그것을 그렇게 identify하는 데만 사용됩니다.

Note 2

numeric name value가 corresponding function object의 formal parameter 수보다 작은 arguments exotic objectinteger-indexed data property는 initially function의 execution context 안의 corresponding argument binding과 그 value를 share합니다. 이는 property를 changing하면 corresponding argument binding의 value가 changed되고 그 반대도 성립함을 의미합니다. 그러한 property가 deleted된 다음 redefined되거나 property가 accessor property로 changed되면 이 correspondence는 broken됩니다. arguments object가 ordinary object이면, 그 property의 value는 단순히 function에 passed된 argument의 copy이며, property value와 formal parameter value 사이에 dynamic linkage는 없습니다.

Note 3

ParameterMap object와 그 property value는 arguments object correspondence to argument binding을 specifying하는 device로 사용됩니다. ParameterMap object와 그 property의 value인 object는 ECMAScript code에서 directly observable하지 않습니다. ECMAScript implementation은 specified semantics를 implement하기 위해 실제로 그러한 object를 create하거나 사용할 필요가 없습니다.

Note 4

Ordinary arguments object는 access 시 TypeError exception을 throw하는 "callee"라는 non-configurable accessor property를 define합니다. "callee" property는 일부 class의 non-strict function에 대해서만 created되는 arguments exotic object에 대해 더 specific한 meaning을 가집니다. ordinary variant에서 이 property의 definition은 conforming ECMAScript implementation이 다른 manner로 define하지 않도록 ensure하기 위해 존재합니다.

Note 5

arguments exotic object의 ECMAScript implementation은 역사적으로 "caller"라는 accessor property를 contained했습니다. ECMAScript 2017 이전에는, 이 명세가 ordinary arguments object 위의 throwing "caller" property의 definition을 포함했습니다. implementation이 더 이상 이 extension을 contain하지 않으므로, ECMAScript 2017은 throwing "caller" accessor에 대한 requirement를 dropped했습니다.

10.4.4.1 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of an arguments exotic object args takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

  1. propertyDescOrdinaryGetOwnProperty(args, propertyKey)로 둔다.
  2. propertyDescundefined이면, undefined를 반환한다.
  3. mapargs.[[ParameterMap]]으로 둔다.
  4. isMapped를 ! HasOwnProperty(map, propertyKey)로 둔다.
  5. isMappedtrue이면, 다음을 수행한다.
    1. propertyDesc.[[Value]]를 ! Get(map, propertyKey)로 설정한다.
  6. propertyDesc를 반환한다.

10.4.4.2 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of an arguments exotic object args takes arguments propertyKey (a property key) and propertyDesc (a Property Descriptor) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. mapargs.[[ParameterMap]]으로 둔다.
  2. isMapped를 ! HasOwnProperty(map, propertyKey)로 둔다.
  3. newArgDescpropertyDesc로 둔다.
  4. isMappedtrue이고 IsDataDescriptor(propertyDesc)가 true이면, 다음을 수행한다.
    1. propertyDesc[[Value]] field를 가지지 않고, propertyDesc[[Writable]] field를 가지며, propertyDesc.[[Writable]]false이면, 다음을 수행한다.
      1. newArgDescpropertyDesc의 copy로 설정한다.
      2. newArgDesc.[[Value]]를 ! Get(map, propertyKey)로 설정한다.
  5. allowed를 ! OrdinaryDefineOwnProperty(args, propertyKey, newArgDesc)로 둔다.
  6. allowedfalse이면, false를 반환한다.
  7. isMappedtrue이면, 다음을 수행한다.
    1. IsAccessorDescriptor(propertyDesc)가 true이면, 다음을 수행한다.
      1. map.[[Delete]](propertyKey)를 수행한다.
    2. 그렇지 않으면,
      1. propertyDesc[[Value]] field를 가지면, 다음을 수행한다.
        1. Assert: arguments object가 map한 formal parameter는 항상 writable이므로 다음 Set은 succeed할 것이다.
        2. Set(map, propertyKey, propertyDesc.[[Value]], false)를 수행한다.
      2. propertyDesc[[Writable]] field를 가지고 propertyDesc.[[Writable]]false이면, 다음을 수행한다.
        1. map.[[Delete]](propertyKey)를 수행한다.
  8. true를 반환한다.

10.4.4.3 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of an arguments exotic object args takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. mapargs.[[ParameterMap]]으로 둔다.
  2. isMapped를 ! HasOwnProperty(map, propertyKey)로 둔다.
  3. isMappedfalse이면, ? OrdinaryGet(args, propertyKey, receiver)를 반환한다.
  4. Assert: mappropertyKey에 대한 formal parameter mapping을 contain한다.
  5. Get(map, propertyKey)를 반환한다.

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

The [[Set]] internal method of an arguments exotic object args takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. SameValue(args, receiver)가 false이면, 다음을 수행한다.
    1. isMappedfalse로 둔다.
  2. 그렇지 않으면,
    1. mapargs.[[ParameterMap]]으로 둔다.
    2. isMapped를 ! HasOwnProperty(map, propertyKey)로 둔다.
  3. isMappedtrue이면, 다음을 수행한다.
    1. Assert: arguments object가 map한 formal parameter는 항상 writable이므로 다음 Set은 succeed할 것이다.
    2. Set(map, propertyKey, value, false)를 수행한다.
  4. OrdinarySet(args, propertyKey, value, receiver)를 반환한다.

10.4.4.5 [[Delete]] ( propertyKey )

The [[Delete]] internal method of an arguments exotic object args takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. mapargs.[[ParameterMap]]으로 둔다.
  2. isMapped를 ! HasOwnProperty(map, propertyKey)로 둔다.
  3. result를 ? OrdinaryDelete(args, propertyKey)로 둔다.
  4. resulttrue이고 isMappedtrue이면, 다음을 수행한다.
    1. map.[[Delete]](propertyKey)를 수행한다.
  5. result를 반환한다.

10.4.4.6 CreateUnmappedArgumentsObject ( argList )

The abstract operation CreateUnmappedArgumentsObject takes argument argList (a List of ECMAScript language values) and returns an ordinary object. It performs the following steps when called:

  1. lengthargList 안의 element 수로 둔다.
  2. objOrdinaryObjectCreate(%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인 동안 Repeat,
    1. valueargList[index]로 둔다.
    2. CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), value)를 수행한다.
    3. indexindex + 1로 설정한다.
  7. DefinePropertyOrThrow(obj, %Symbol.iterator%, PropertyDescriptor { [[Value]]: %Array.prototype.values%, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })를 수행한다.
  8. DefinePropertyOrThrow(obj, "callee", PropertyDescriptor { [[Get]]: %ThrowTypeError%, [[Set]]: %ThrowTypeError%, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
  9. obj를 반환한다.

10.4.4.7 CreateMappedArgumentsObject ( func, formals, argList, envRecord )

The abstract operation CreateMappedArgumentsObject takes arguments func (an ECMAScript function object), formals (a Parse Node), argList (a List of ECMAScript language values), and envRecord (an Environment Record) and returns an arguments exotic object. It performs the following steps when called:

  1. Assert: formals는 rest parameter, binding pattern 또는 initializer를 contain하지 않는다. 이는 duplicate identifier를 contain할 수 있다.
  2. lengthargList 안의 element 수로 둔다.
  3. objMakeBasicObject[[Prototype]], [[Extensible]], [[ParameterMap]] »)로 둔다.
  4. obj.[[GetOwnProperty]]10.4.4.1에 specified된 대로 설정한다.
  5. obj.[[DefineOwnProperty]]10.4.4.2에 specified된 대로 설정한다.
  6. obj.[[Get]]10.4.4.3에 specified된 대로 설정한다.
  7. obj.[[Set]]10.4.4.4에 specified된 대로 설정한다.
  8. obj.[[Delete]]10.4.4.5에 specified된 대로 설정한다.
  9. obj.[[Prototype]]%Object.prototype%으로 설정한다.
  10. mapOrdinaryObjectCreate(null)로 둔다.
  11. obj.[[ParameterMap]]map으로 설정한다.
  12. paramNamesformalsBoundNames로 둔다.
  13. paramCountparamNames 안의 element 수로 둔다.
  14. index를 0으로 둔다.
  15. index < length인 동안 Repeat,
    1. valueargList[index]로 둔다.
    2. CreateDataPropertyOrThrow(obj, ! ToString(𝔽(index)), value)를 수행한다.
    3. indexindex + 1로 설정한다.
  16. DefinePropertyOrThrow(obj, "length", PropertyDescriptor { [[Value]]: 𝔽(length), [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true })를 수행한다.
  17. mappedNames를 새 empty List로 둔다.
  18. indexparamCount - 1로 설정한다.
  19. index ≥ 0인 동안 Repeat,
    1. nameparamNames[index]로 둔다.
    2. mappedNamesname을 contain하지 않으면, 다음을 수행한다.
      1. namemappedNames에 append한다.
      2. index < length이면, 다음을 수행한다.
        1. getterMakeArgGetter(name, envRecord)로 둔다.
        2. setterMakeArgSetter(name, envRecord)로 둔다.
        3. map.[[DefineOwnProperty]](! ToString(𝔽(index)), PropertyDescriptor { [[Set]]: setter, [[Get]]: getter, [[Enumerable]]: false, [[Configurable]]: true })를 수행한다.
    3. indexindex - 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 )

The abstract operation MakeArgGetter takes arguments name (a String) and envRecord (an Environment Record) and returns a function object. executed될 때 envRecord 안에서 name에 bound된 value를 반환하는 built-in function object를 create합니다. It performs the following steps when called:

  1. getterClosurenameenvRecord를 capture하고 called될 때 다음 step을 수행하는, parameter가 없는 새 Abstract Closure로 둔다:
    1. NormalCompletion(! envRecord.GetBindingValue(name, false))를 반환한다.
  2. getterCreateBuiltinFunction(getterClosure, 0, "", « »)로 둔다.
  3. NOTE: getter는 ECMAScript code에서 결코 directly accessible하지 않습니다.
  4. getter를 반환한다.

10.4.4.7.2 MakeArgSetter ( name, envRecord )

The abstract operation MakeArgSetter takes arguments name (a String) and envRecord (an Environment Record) and returns a function object. executed될 때 envRecord 안에서 name에 bound된 value를 set하는 built-in function object를 create합니다. It performs the following steps when called:

  1. setterClosurenameenvRecord를 capture하고 called될 때 다음 step을 수행하는, parameter (value)를 가진 새 Abstract Closure로 둔다:
    1. NormalCompletion(! envRecord.SetMutableBinding(name, value, false))를 반환한다.
  2. setterCreateBuiltinFunction(setterClosure, 1, "", « »)로 둔다.
  3. NOTE: setter는 ECMAScript code에서 결코 directly accessible하지 않습니다.
  4. setter를 반환한다.

10.4.5 TypedArray Exotic Objects

TypedArraycanonical numeric stringproperty key에 대해 special handling을 수행하는 exotic object입니다. uniform type의 element를 index하기 위해 in-bounds integer index인 subset을 사용하고, 나머지는 prototype chain traversal을 incur하지 않고 absent임을 enforce합니다.

Note

어떤 Number n에 대해서도 ToString(n)은 canonical numeric string이므로, implementation은 실제 string conversion을 수행하지 않고도 Number를 TypedArrayproperty key로 treat할 수 있습니다.

TypedArrayordinary object와 같은 internal slot을 가지며, 추가로 [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] internal slot을 가집니다.

object의 [[PreventExtensions]], [[GetOwnProperty]], [[HasProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]], [[OwnPropertyKeys]] internal method가 이 section의 definition을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 TypedArray입니다. 이러한 method는 TypedArrayCreate에 의해 installed됩니다.

10.4.5.1 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of a TypedArray obj takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. NOTE: 6.1.7.3에 specified된 extensibility-related invariant는 obj가 property를 gain할 수 있을 때(또는 lose한 후 regain할 수 있을 때) 이 method가 true를 return하는 것을 allow하지 않습니다. 이는 underlying buffer가 resized될 때 integer index name을 가진 property에 대해 occur할 수 있습니다.
  2. IsTypedArrayFixedLength(obj)가 false이면, false를 반환한다.
  3. OrdinaryPreventExtensions(obj)를 반환한다.

10.4.5.2 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of a TypedArray obj takes argument propertyKey (a property key) and returns a normal completion containing either a Property Descriptor or undefined. It performs the following steps when called:

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

10.4.5.3 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of a TypedArray obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey가 String이면, 다음을 수행한다.
    1. numericIndexCanonicalNumericIndexString(propertyKey)으로 둔다.
    2. numericIndexundefined가 아니면, IsValidIntegerIndex(obj, numericIndex)를 반환한다.
  2. OrdinaryHasProperty(obj, propertyKey)를 반환한다.

10.4.5.4 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of a TypedArray obj takes arguments propertyKey (a property key) and propertyDesc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey가 String이면, 다음을 수행한다.
    1. numericIndexCanonicalNumericIndexString(propertyKey)으로 둔다.
    2. numericIndexundefined가 아니면, 다음을 수행한다.
      1. IsValidIntegerIndex(obj, numericIndex)가 false이면, false를 반환한다.
      2. propertyDesc[[Configurable]] field를 가지고 propertyDesc.[[Configurable]]false이면, false를 반환한다.
      3. propertyDesc[[Enumerable]] field를 가지고 propertyDesc.[[Enumerable]]false이면, false를 반환한다.
      4. IsAccessorDescriptor(propertyDesc)가 true이면, false를 반환한다.
      5. propertyDesc[[Writable]] field를 가지고 propertyDesc.[[Writable]]false이면, false를 반환한다.
      6. propertyDesc[[Value]] field를 가지면, ? TypedArraySetElement(obj, numericIndex, propertyDesc.[[Value]])를 수행한다.
      7. true를 반환한다.
  2. OrdinaryDefineOwnProperty(obj, propertyKey, propertyDesc)를 반환한다.

10.4.5.5 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of a TypedArray obj takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. propertyKey가 String이면, 다음을 수행한다.
    1. numericIndexCanonicalNumericIndexString(propertyKey)으로 둔다.
    2. numericIndexundefined가 아니면, 다음을 수행한다.
      1. TypedArrayGetElement(obj, numericIndex)를 반환한다.
  2. OrdinaryGet(obj, propertyKey, receiver)를 반환한다.

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

The [[Set]] internal method of a TypedArray obj takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey가 String이면, 다음을 수행한다.
    1. numericIndexCanonicalNumericIndexString(propertyKey)으로 둔다.
    2. numericIndexundefined가 아니면, 다음을 수행한다.
      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 )

The [[Delete]] internal method of a TypedArray obj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. propertyKey가 String이면, 다음을 수행한다.
    1. numericIndexCanonicalNumericIndexString(propertyKey)으로 둔다.
    2. numericIndexundefined가 아니면, 다음을 수행한다.
      1. IsValidIntegerIndex(obj, numericIndex)가 false이면, true를 반환한다.
      2. false를 반환한다.
  2. OrdinaryDelete(obj, propertyKey)를 반환한다.

10.4.5.8 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a TypedArray obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:

  1. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 둔다.
  2. keys를 새 empty List로 둔다.
  3. IsTypedArrayOutOfBounds(taRecord)가 false이면, 다음을 수행한다.
    1. lengthTypedArrayLength(taRecord)로 둔다.
    2. 0 ≤ i < length인 각 integer i에 대해, ascending order로 다음을 수행한다.
      1. ToString(𝔽(i))를 keys에 append한다.
  4. obj의 각 own property key propertyKeypropertyKey가 String이고 propertyKeyinteger index가 아닌 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
    1. propertyKeykeys에 append한다.
  5. obj의 각 own property key propertyKeypropertyKey가 Symbol인 것에 대해, property creation의 ascending chronological order로 다음을 수행한다.
    1. propertyKeykeys에 append한다.
  6. keys를 반환한다.

10.4.5.9 TypedArray With Buffer Witness Records

TypedArray With Buffer Witness Record는 viewed buffer의 cached byte length와 함께 TypedArray를 encapsulate하는 데 사용되는 Record value입니다. 이는 viewed buffer가 growable SharedArrayBuffer일 때 byte length data block의 single ReadSharedMemory event가 있음을 ensure하는 데 help하기 위해 사용됩니다.

TypedArray With Buffer Witness Record는 Table 28에 listed된 field를 가집니다.

Table 28: TypedArray With Buffer Witness Record Fields
Field Name Value Meaning
[[Object]] a TypedArray buffer의 byte length가 loaded되는 TypedArray입니다.
[[CachedBufferByteLength]] a non-negative integer or detached Record가 created되었을 때 object의 [[ViewedArrayBuffer]]의 byte length입니다.

10.4.5.10 MakeTypedArrayWithBufferWitnessRecord ( obj, order )

The abstract operation MakeTypedArrayWithBufferWitnessRecord takes arguments obj (a TypedArray) and order (seq-cst or unordered) and returns a TypedArray With Buffer Witness Record. It performs the following steps when called:

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

10.4.5.11 TypedArrayCreate ( proto )

The abstract operation TypedArrayCreate takes argument proto (an Object) and returns a TypedArray. 새 TypedArray의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:

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

10.4.5.12 TypedArrayByteLength ( taRecord )

The abstract operation TypedArrayByteLength takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:

  1. Assert: IsTypedArrayOutOfBounds(taRecord)는 false이다.
  2. objtaRecord.[[Object]]로 둔다.
  3. obj.[[ByteLength]]auto가 아니면, obj.[[ByteLength]]를 반환한다.
  4. lengthTypedArrayLength(taRecord)로 둔다.
  5. elementSizeTypedArrayElementSize(obj)로 둔다.
  6. NOTE: underlying buffer가 non-integer multiple로 resized되었을 때도 returned byte length는 항상 elementSizeinteger multiple입니다.
  7. length × elementSize를 반환한다.

10.4.5.13 TypedArrayLength ( taRecord )

The abstract operation TypedArrayLength takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a non-negative integer. It performs the following steps when called:

  1. Assert: IsTypedArrayOutOfBounds(taRecord)는 false이다.
  2. objtaRecord.[[Object]]로 둔다.
  3. obj.[[ArrayLength]]auto가 아니면, obj.[[ArrayLength]]를 반환한다.
  4. Assert: IsFixedLengthArrayBuffer(obj.[[ViewedArrayBuffer]])는 false이다.
  5. byteOffsetobj.[[ByteOffset]]로 둔다.
  6. elementSizeTypedArrayElementSize(obj)로 둔다.
  7. byteLengthtaRecord.[[CachedBufferByteLength]]로 둔다.
  8. Assert: byteLengthdetached가 아니다.
  9. floor((byteLength - byteOffset) / elementSize)를 반환한다.

10.4.5.14 IsTypedArrayOutOfBounds ( taRecord )

The abstract operation IsTypedArrayOutOfBounds takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a Boolean. object의 numeric property 중 어떤 것이 underlying buffer's bounds 안에 contained되지 않은 index의 value를 reference하는지 check합니다. It performs the following steps when called:

  1. objtaRecord.[[Object]]로 둔다.
  2. bufferByteLengthtaRecord.[[CachedBufferByteLength]]로 둔다.
  3. IsDetachedBuffer(obj.[[ViewedArrayBuffer]])가 true이면, 다음을 수행한다.
    1. Assert: bufferByteLengthdetached이다.
    2. true를 반환한다.
  4. Assert: bufferByteLength는 non-negative integer이다.
  5. byteOffsetStartobj.[[ByteOffset]]로 둔다.
  6. obj.[[ArrayLength]]auto이면, 다음을 수행한다.
    1. byteOffsetEndbufferByteLength로 둔다.
  7. 그렇지 않으면,
    1. elementSizeTypedArrayElementSize(obj)로 둔다.
    2. arrayByteLengthobj.[[ArrayLength]] × elementSize로 둔다.
    3. byteOffsetEndbyteOffsetStart + arrayByteLength로 둔다.
  8. NOTE: [[ByteOffset]]bufferByteLength인 0-length TypedArray는 out-of-bounds로 considered되지 않습니다.
  9. byteOffsetStart > bufferByteLength이거나 byteOffsetEnd > bufferByteLength이면, true를 반환한다.
  10. false를 반환한다.

10.4.5.15 IsTypedArrayFixedLength ( obj )

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

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

10.4.5.16 IsValidIntegerIndex ( obj, index )

The abstract operation IsValidIntegerIndex takes arguments obj (a TypedArray) and index (a Number) and returns a Boolean. It performs the following steps when called:

  1. IsDetachedBuffer(obj.[[ViewedArrayBuffer]])가 true이면, false를 반환한다.
  2. indexintegral Number가 아니면, false를 반환한다.
  3. index-0𝔽이거나 index < -0𝔽이면, false를 반환한다.
  4. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, unordered)로 둔다.
  5. NOTE: obj의 backing buffer가 growable SharedArrayBuffer일 때 bounds checking은 synchronizing operation이 아닙니다.
  6. IsTypedArrayOutOfBounds(taRecord)가 true이면, false를 반환한다.
  7. lengthTypedArrayLength(taRecord)로 둔다.
  8. (index) ≥ length이면, false를 반환한다.
  9. true를 반환한다.

10.4.5.17 TypedArrayGetElement ( obj, index )

The abstract operation TypedArrayGetElement takes arguments obj (a TypedArray) and index (a Number) and returns a Number, a BigInt, or undefined. It performs the following steps when called:

  1. IsValidIntegerIndex(obj, index)가 false이면, undefined를 반환한다.
  2. offsetobj.[[ByteOffset]]로 둔다.
  3. elementSizeTypedArrayElementSize(obj)로 둔다.
  4. byteIndexInBuffer를 ((index) × elementSize) + offset으로 둔다.
  5. elementTypeTypedArrayElementType(obj)으로 둔다.
  6. GetValueFromBuffer(obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, true, unordered)를 반환한다.

10.4.5.18 TypedArraySetElement ( obj, index, value )

The abstract operation TypedArraySetElement takes arguments obj (a TypedArray), index (a Number), and value (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. obj.[[ContentType]]bigint이면, number를 ? ToBigInt(value)로 둔다.
  2. 그렇지 않으면, number를 ? ToNumber(value)로 둔다.
  3. IsValidIntegerIndex(obj, index)가 true이면, 다음을 수행한다.
    1. offsetobj.[[ByteOffset]]로 둔다.
    2. elementSizeTypedArrayElementSize(obj)로 둔다.
    3. byteIndexInBuffer를 ((index) × elementSize) + offset으로 둔다.
    4. elementTypeTypedArrayElementType(obj)로 둔다.
    5. SetValueInBuffer(obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, number, true, unordered)를 수행한다.
  4. unused를 반환한다.
Note

이 operation은 항상 succeed하는 것처럼 보이지만, TypedArray의 end를 지나서 write하려고 하거나 detached ArrayBuffer가 backing하는 TypedArray에 write하려고 할 때는 effect가 없습니다.

10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )

The abstract operation IsArrayBufferViewOutOfBounds takes argument obj (a TypedArray or a DataView) and returns a Boolean. TypedArray의 numeric property 중 어떤 것이나 DataView object의 method가 underlying data block's bounds 안에 contained되지 않은 index의 value를 reference할 수 있는지 check합니다. 이 abstract operation은 upstream specification을 위한 convenience로 존재합니다. It performs the following steps when called:

  1. obj[[DataView]] internal slot을 가지면, 다음을 수행한다.
    1. viewRecordMakeDataViewWithBufferWitnessRecord(obj, seq-cst)로 둔다.
    2. IsViewOutOfBounds(viewRecord)를 반환한다.
  2. taRecordMakeTypedArrayWithBufferWitnessRecord(obj, seq-cst)로 둔다.
  3. IsTypedArrayOutOfBounds(taRecord)를 반환한다.

10.4.6 Module Namespace Exotic Objects

module namespace exotic object는 ECMAScript Module에서 exported된 binding을 expose하는 exotic object입니다(16.2.3 참조). module namespace exotic object의 String-keyed own property와 Module이 exported한 binding name 사이에는 one-to-one correspondence가 있습니다. exported binding에는 export * export item을 사용하여 indirectly exported된 binding도 포함됩니다. 각 String-valued own property key는 corresponding exported binding name의 StringValue입니다. 이들은 module namespace exotic object의 유일한 String-keyed property입니다. 그러한 각 property는 attribute { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false }를 가집니다. Module namespace exotic object는 extensible이 아닙니다.

object의 [[GetPrototypeOf]], [[SetPrototypeOf]], [[IsExtensible]], [[PreventExtensions]], [[GetOwnProperty]], [[DefineOwnProperty]], [[HasProperty]], [[Get]], [[Set]], [[Delete]], [[OwnPropertyKeys]] internal method가 이 section의 definition을 사용하고, 그 other essential internal method가 10.1에 있는 definition을 사용하면, 그 object는 module namespace exotic object입니다. 이러한 method는 ModuleNamespaceCreate에 의해 installed됩니다.

Module namespace exotic objectTable 29에 정의된 internal slot을 가집니다.

Table 29: Internal Slots of Module Namespace Exotic Objects
Internal Slot Type Description
[[Module]] a Module Record 이 namespace가 expose하는 export를 가진 Module Record입니다.
[[Exports]] a List of Strings 이 object의 own property로 exposed되는 exported name의 String value를 element로 가지는 List입니다. list는 lexicographic code unit order에 따라 sorted됩니다.

10.4.6.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing null. It performs the following steps when called:

  1. null을 반환한다.

10.4.6.2 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of a module namespace exotic object obj takes argument proto (an Object or null) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. SetImmutablePrototype(obj, proto)를 반환한다.

10.4.6.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing false. It performs the following steps when called:

  1. false를 반환한다.

10.4.6.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of a module namespace exotic object takes no arguments and returns a normal completion containing true. It performs the following steps when called:

  1. true를 반환한다.

10.4.6.5 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key) and returns either a normal completion containing either a Property Descriptor or undefined, or a throw completion. It performs the following steps when called:

  1. propertyKey가 Symbol이면, OrdinaryGetOwnProperty(obj, propertyKey)를 반환한다.
  2. exportsobj.[[Exports]]로 둔다.
  3. exportspropertyKey를 contain하지 않으면, undefined를 반환한다.
  4. value를 ? obj.[[Get]](propertyKey, obj)로 둔다.
  5. PropertyDescriptor { [[Value]]: value, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false }를 반환한다.

10.4.6.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of a module namespace exotic object obj takes arguments propertyKey (a property key) and propertyDesc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. propertyKey가 Symbol이면, ! OrdinaryDefineOwnProperty(obj, propertyKey, propertyDesc)를 반환한다.
  2. current를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
  3. currentundefined이면, false를 반환한다.
  4. propertyDesc[[Configurable]] field를 가지고 propertyDesc.[[Configurable]]true이면, false를 반환한다.
  5. propertyDesc[[Enumerable]] field를 가지고 propertyDesc.[[Enumerable]]false이면, false를 반환한다.
  6. IsAccessorDescriptor(propertyDesc)가 true이면, false를 반환한다.
  7. propertyDesc[[Writable]] field를 가지고 propertyDesc.[[Writable]]false이면, false를 반환한다.
  8. propertyDesc[[Value]] field를 가지면, SameValue(propertyDesc.[[Value]], current.[[Value]])를 반환한다.
  9. true를 반환한다.

10.4.6.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. propertyKey가 Symbol이면, ! OrdinaryHasProperty(obj, propertyKey)를 반환한다.
  2. exportsobj.[[Exports]]로 둔다.
  3. exportspropertyKey를 contain하면, true를 반환한다.
  4. false를 반환한다.

10.4.6.8 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of a module namespace exotic object obj takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. propertyKey가 Symbol이면, 다음을 수행한다.
    1. OrdinaryGet(obj, propertyKey, receiver)를 반환한다.
  2. exportsobj.[[Exports]]로 둔다.
  3. exportspropertyKey를 contain하지 않으면, undefined를 반환한다.
  4. moduleobj.[[Module]]로 둔다.
  5. bindingmodule.ResolveExport(propertyKey)로 둔다.
  6. Assert: bindingResolvedBinding Record이다.
  7. targetModulebinding.[[Module]]로 둔다.
  8. Assert: targetModuleundefined가 아니다.
  9. binding.[[BindingName]]namespace이면, 다음을 수행한다.
    1. GetModuleNamespace(targetModule)를 반환한다.
  10. targetEnvtargetModule.[[Environment]]로 둔다.
  11. targetEnvempty이면, ReferenceError exception을 throw한다.
  12. targetEnv.GetBindingValue(binding.[[BindingName]], true)를 반환한다.
Note

ResolveExport는 side-effect free입니다. 이 operation이 specific exportName, resolveSet pair를 argument로 called될 때마다 같은 result를 반환해야 합니다. implementation은 각 module namespace exotic object[[Exports]]에 대한 ResolveExport result를 pre-compute하거나 cache하도록 choose할 수 있습니다.

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

The [[Set]] internal method of a module namespace exotic object takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns a normal completion containing false. It performs the following steps when called:

  1. false를 반환한다.

10.4.6.10 [[Delete]] ( propertyKey )

The [[Delete]] internal method of a module namespace exotic object obj takes argument propertyKey (a property key) and returns a normal completion containing a Boolean. It performs the following steps when called:

  1. propertyKey가 Symbol이면, 다음을 수행한다.
    1. OrdinaryDelete(obj, propertyKey)를 반환한다.
  2. exportsobj.[[Exports]]로 둔다.
  3. exportspropertyKey를 contain하면, false를 반환한다.
  4. true를 반환한다.

10.4.6.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a module namespace exotic object obj takes no arguments and returns a normal completion containing a List of property keys. It performs the following steps when called:

  1. exportsobj.[[Exports]]로 둔다.
  2. symbolKeysOrdinaryOwnPropertyKeys(obj)로 둔다.
  3. exportssymbolKeyslist-concatenation을 반환한다.

10.4.6.12 ModuleNamespaceCreate ( module, exports )

The abstract operation ModuleNamespaceCreate takes arguments module (a Module Record) and exports (a List of Strings) and returns a module namespace exotic object. 새 module namespace exotic object의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:

  1. Assert: module.[[Namespace]]empty이다.
  2. internalSlotsListTable 29에 listed된 internal slot으로 둔다.
  3. namespaceMakeBasicObject(internalSlotsList)로 둔다.
  4. namespace의 essential internal method를 10.4.6에 specified된 definition으로 설정한다.
  5. namespace.[[Module]]module로 설정한다.
  6. sortedExportsexports의 element를 element로 가지고 lexicographic code unit order에 따라 sorted된 List로 둔다.
  7. namespace.[[Exports]]sortedExports로 설정한다.
  8. 28.3의 definition에 corresponding하는 namespace의 own property를 create한다.
  9. module.[[Namespace]]namespace로 설정한다.
  10. namespace를 반환한다.

10.4.7 Immutable Prototype Exotic Objects

immutable prototype exotic object는 initialized된 후 change되지 않는 [[Prototype]] internal slot을 가지는 exotic object입니다.

object의 [[SetPrototypeOf]] internal method가 다음 implementation을 사용하면, 그 object는 immutable prototype exotic object입니다. (그 other essential internal method는 문제의 specific immutable prototype exotic object에 따라 어떤 implementation이든 사용할 수 있습니다.)

Note

다른 exotic object와 달리, immutable prototype exotic object를 위해 provided된 dedicated creation abstract operation은 없습니다. 이는 그것들이 %Object.prototype%host environment에서만 사용되며, host environment에서는 relevant object가 potentially 다른 방식으로도 exotic이므로 자체 dedicated creation operation이 필요하기 때문입니다.

10.4.7.1 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of an immutable prototype exotic object obj takes argument proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. SetImmutablePrototype(obj, proto)를 반환한다.

10.4.7.2 SetImmutablePrototype ( obj, proto )

The abstract operation SetImmutablePrototype takes arguments obj (an Object) and proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

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

10.5 Proxy Object Internal Methods and Internal Slots

Proxy object는 essential internal method가 ECMAScript code를 사용하여 partially implemented되는 exotic object입니다. 모든 Proxy object는 [[ProxyHandler]]라는 internal slot을 가집니다. [[ProxyHandler]]의 value는 proxy의 handler object라고 불리는 object 또는 null입니다. handler object의 method(Table 30 참조)는 Proxy object's internal method 중 하나 이상에 대한 implementation을 augment하는 데 사용될 수 있습니다. 모든 Proxy object는 또한 [[ProxyTarget]]이라는 internal slot을 가지며, 그 value는 object 또는 null입니다. 이 object를 proxy의 target object라고 합니다.

object의 essential internal method(applicable하면 [[Call]][[Construct]] 포함)가 이 section의 definition을 사용하면, 그 object는 Proxy exotic object입니다. 이러한 internal method는 ProxyCreate에서 installed됩니다.

Table 30: Proxy Handler Methods
Internal Method Handler Method
[[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 object internal method의 implementation을 provide하기 위해 handler method가 called될 때, handler method에는 proxy의 target object가 parameter로 passed됩니다. proxy의 handler object가 모든 essential internal method에 corresponding하는 method를 반드시 가지는 것은 아닙니다. proxy 위에서 internal method를 invoking하면 handler object가 internal trap에 corresponding하는 method를 가지지 않는 경우 proxy의 target object 위의 corresponding internal method가 invoked됩니다.

Proxy object의 [[ProxyHandler]][[ProxyTarget]] internal slot은 object가 created될 때 항상 initialized되며 일반적으로 modified될 수 없습니다. 일부 Proxy object는 subsequently revoked될 수 있도록 허용하는 manner로 created됩니다. proxy가 revoked되면, 그 [[ProxyHandler]][[ProxyTarget]] internal slot은 null로 set되어 이후 그 Proxy object 위의 internal method invocation이 TypeError exception을 throw하게 합니다.

Proxy object는 internal method의 implementation이 arbitrary ECMAScript code에 의해 provided되는 것을 permit하므로, handler method가 6.1.7.3에 정의된 invariant를 violate하는 Proxy object를 define하는 것이 가능합니다. 6.1.7.3에 정의된 internal method invariant 중 일부는 essential integrity invariant입니다. 이러한 invariant는 이 section에 specified된 Proxy object internal method에 의해 explicitly enforced됩니다. ECMAScript implementation은 가능한 모든 invariant violation이 presence하더라도 robust해야 합니다.

다음 algorithm description에서, obj는 ECMAScript Proxy object, propertyKeyproperty key value, value는 임의의 ECMAScript language value, propertyDescProperty Descriptor record라고 가정합니다.

10.5.1 [[GetPrototypeOf]] ( )

The [[GetPrototypeOf]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing either an Object or null, or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "getPrototypeOf")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[GetPrototypeOf]]()를 반환한다.
  7. handlerProto를 ? Call(trap, handler, « target »)로 둔다.
  8. handlerProto가 Object도 아니고 null도 아니면, TypeError exception을 throw한다.
  9. extensibleTarget을 ? IsExtensible(target)으로 둔다.
  10. extensibleTargettrue이면, handlerProto를 반환한다.
  11. targetProto를 ? target.[[GetPrototypeOf]]()로 둔다.
  12. SameValue(handlerProto, targetProto)가 false이면, TypeError exception을 throw한다.
  13. handlerProto를 반환한다.
Note

Proxy object의 [[GetPrototypeOf]]는 다음 invariant를 enforce합니다:

  • [[GetPrototypeOf]]의 result는 Object 또는 null이어야 합니다.
  • target object가 extensible이 아니면, Proxy object에 applied된 [[GetPrototypeOf]]는 Proxy object's target object에 applied된 [[GetPrototypeOf]]와 같은 value를 반환해야 합니다.

10.5.2 [[SetPrototypeOf]] ( proto )

The [[SetPrototypeOf]] internal method of a Proxy exotic object obj takes argument proto (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "setPrototypeOf")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[SetPrototypeOf]](proto)를 반환한다.
  7. boolTrapResultToBoolean(? Call(trap, handler, « target, proto »))로 둔다.
  8. boolTrapResultfalse이면, false를 반환한다.
  9. extensibleTarget을 ? IsExtensible(target)으로 둔다.
  10. extensibleTargettrue이면, true를 반환한다.
  11. targetProto를 ? target.[[GetPrototypeOf]]()로 둔다.
  12. SameValue(proto, targetProto)가 false이면, TypeError exception을 throw한다.
  13. true를 반환한다.
Note

Proxy object의 [[SetPrototypeOf]]는 다음 invariant를 enforce합니다:

  • [[SetPrototypeOf]]의 result는 Boolean value입니다.
  • target object가 extensible이 아니면, argument value는 target object에 applied된 [[GetPrototypeOf]]의 result와 같아야 합니다.

10.5.3 [[IsExtensible]] ( )

The [[IsExtensible]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "isExtensible")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. IsExtensible(target)을 반환한다.
  7. boolTrapResultToBoolean(? Call(trap, handler, « target »))로 둔다.
  8. targetResult를 ? IsExtensible(target)으로 둔다.
  9. boolTrapResulttargetResult가 아니면, TypeError exception을 throw한다.
  10. boolTrapResult를 반환한다.
Note

Proxy object의 [[IsExtensible]]는 다음 invariant를 enforce합니다:

  • [[IsExtensible]]의 result는 Boolean value입니다.
  • Proxy object에 applied된 [[IsExtensible]]는 같은 argument로 Proxy object's target object에 applied된 [[IsExtensible]]와 같은 value를 반환해야 합니다.

10.5.4 [[PreventExtensions]] ( )

The [[PreventExtensions]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "preventExtensions")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[PreventExtensions]]()를 반환한다.
  7. boolTrapResultToBoolean(? Call(trap, handler, « target »))로 둔다.
  8. boolTrapResulttrue이면, 다음을 수행한다.
    1. extensibleTarget을 ? IsExtensible(target)으로 둔다.
    2. extensibleTargettrue이면, TypeError exception을 throw한다.
  9. boolTrapResult를 반환한다.
Note

Proxy object의 [[PreventExtensions]]는 다음 invariant를 enforce합니다:

  • [[PreventExtensions]]의 result는 Boolean value입니다.
  • Proxy object에 applied된 [[PreventExtensions]]는 Proxy object's target object에 applied된 [[IsExtensible]]false인 경우에만 true를 반환합니다.

10.5.5 [[GetOwnProperty]] ( propertyKey )

The [[GetOwnProperty]] internal method of a Proxy exotic object obj takes argument propertyKey (a property key) and returns either a normal completion containing either a Property Descriptor or undefined, or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "getOwnPropertyDescriptor")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[GetOwnProperty]](propertyKey)를 반환한다.
  7. trapResultObj를 ? Call(trap, handler, « target, propertyKey »)로 둔다.
  8. trapResultObj가 Object도 아니고 undefined도 아니면, TypeError exception을 throw한다.
  9. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둔다.
  10. trapResultObjundefined이면, 다음을 수행한다.
    1. targetDescundefined이면, undefined를 반환한다.
    2. targetDesc.[[Configurable]]false이면, TypeError exception을 throw한다.
    3. extensibleTarget을 ? IsExtensible(target)으로 둔다.
    4. extensibleTargetfalse이면, TypeError exception을 throw한다.
    5. undefined를 반환한다.
  11. extensibleTarget을 ? IsExtensible(target)으로 둔다.
  12. resultDesc를 ? ToPropertyDescriptor(trapResultObj)로 둔다.
  13. CompletePropertyDescriptor(resultDesc)를 수행한다.
  14. validIsCompatiblePropertyDescriptor(extensibleTarget, resultDesc, targetDesc)로 둔다.
  15. validfalse이면, TypeError exception을 throw한다.
  16. resultDesc.[[Configurable]]false이면, 다음을 수행한다.
    1. targetDescundefined이거나 targetDesc.[[Configurable]]true이면, 다음을 수행한다.
      1. TypeError exception을 throw한다.
    2. resultDesc[[Writable]] field를 가지고 resultDesc.[[Writable]]false이면, 다음을 수행한다.
      1. Assert: targetDesc[[Writable]] field를 가진다.
      2. targetDesc.[[Writable]]true이면, TypeError exception을 throw한다.
  17. resultDesc를 반환한다.
Note

Proxy object의 [[GetOwnProperty]]는 다음 invariant를 enforce합니다:

  • [[GetOwnProperty]]의 result는 Property Descriptor 또는 undefined여야 합니다.
  • property가 target object의 non-configurable own property로 존재하면, 그 property를 non-existent로 report할 수 없습니다.
  • property가 non-extensible target object의 own property로 존재하면, 그 property를 non-existent로 report할 수 없습니다.
  • property가 target object의 own property로 존재하지 않고 target object가 extensible이 아니면, 그 property를 existent로 report할 수 없습니다.
  • target object의 non-configurable own property로 존재하지 않는 한, property를 non-configurable로 report할 수 없습니다.
  • target object의 non-configurable, non-writable own property로 존재하지 않는 한, property를 non-configurable이면서 non-writable로 report할 수 없습니다.

10.5.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )

The [[DefineOwnProperty]] internal method of a Proxy exotic object obj takes arguments propertyKey (a property key) and propertyDesc (a Property Descriptor) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "defineProperty")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[DefineOwnProperty]](propertyKey, propertyDesc)를 반환한다.
  7. propertyDescObjFromPropertyDescriptor(propertyDesc)로 둔다.
  8. boolTrapResultToBoolean(? Call(trap, handler, « target, propertyKey, propertyDescObj »))로 둔다.
  9. boolTrapResultfalse이면, false를 반환한다.
  10. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둔다.
  11. extensibleTarget을 ? IsExtensible(target)으로 둔다.
  12. propertyDesc[[Configurable]] field를 가지고 propertyDesc.[[Configurable]]false이면, 다음을 수행한다.
    1. settingConfigFalsetrue로 둔다.
  13. 그렇지 않으면,
    1. settingConfigFalsefalse로 둔다.
  14. targetDescundefined이면, 다음을 수행한다.
    1. extensibleTargetfalse이면, TypeError exception을 throw한다.
    2. settingConfigFalsetrue이면, TypeError exception을 throw한다.
  15. 그렇지 않으면,
    1. IsCompatiblePropertyDescriptor(extensibleTarget, propertyDesc, targetDesc)가 false이면, TypeError exception을 throw한다.
    2. settingConfigFalsetrue이고 targetDesc.[[Configurable]]true이면, TypeError exception을 throw한다.
    3. IsDataDescriptor(targetDesc)가 true이고, targetDesc.[[Configurable]]false이고, targetDesc.[[Writable]]true이면, 다음을 수행한다.
      1. propertyDesc[[Writable]] field를 가지고 propertyDesc.[[Writable]]false이면, TypeError exception을 throw한다.
  16. true를 반환한다.
Note

Proxy object의 [[DefineOwnProperty]]는 다음 invariant를 enforce합니다:

  • [[DefineOwnProperty]]의 result는 Boolean value입니다.
  • target object가 extensible이 아니면 property를 added할 수 없습니다.
  • target object의 corresponding non-configurable own property가 존재하지 않는 한 property는 non-configurable일 수 없습니다.
  • target object의 corresponding non-configurable, non-writable own property가 존재하지 않는 한 non-configurable property는 non-writable일 수 없습니다.
  • property가 corresponding target object property를 가지면, [[DefineOwnProperty]]를 사용하여 그 property의 Property Descriptor를 target object에 applying해도 exception을 throw하지 않습니다.

10.5.7 [[HasProperty]] ( propertyKey )

The [[HasProperty]] internal method of a Proxy exotic object obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "has")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[HasProperty]](propertyKey)를 반환한다.
  7. boolTrapResultToBoolean(? Call(trap, handler, « target, propertyKey »))로 둔다.
  8. boolTrapResultfalse이면, 다음을 수행한다.
    1. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둔다.
    2. targetDescundefined가 아니면, 다음을 수행한다.
      1. targetDesc.[[Configurable]]false이면, TypeError exception을 throw한다.
      2. extensibleTarget을 ? IsExtensible(target)으로 둔다.
      3. extensibleTargetfalse이면, TypeError exception을 throw한다.
  9. boolTrapResult를 반환한다.
Note

Proxy object의 [[HasProperty]]는 다음 invariant를 enforce합니다:

  • [[HasProperty]]의 result는 Boolean value입니다.
  • property가 target object의 non-configurable own property로 존재하면, 그 property를 non-existent로 report할 수 없습니다.
  • property가 target object의 own property로 존재하고 target object가 extensible이 아니면, 그 property를 non-existent로 report할 수 없습니다.

10.5.8 [[Get]] ( propertyKey, receiver )

The [[Get]] internal method of a Proxy exotic object obj takes arguments propertyKey (a property key) and receiver (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "get")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[Get]](propertyKey, receiver)를 반환한다.
  7. trapResult를 ? Call(trap, handler, « target, propertyKey, receiver »)로 둔다.
  8. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둔다.
  9. targetDescundefined가 아니고 targetDesc.[[Configurable]]false이면, 다음을 수행한다.
    1. IsDataDescriptor(targetDesc)가 true이고 targetDesc.[[Writable]]false이면, 다음을 수행한다.
      1. SameValue(trapResult, targetDesc.[[Value]])가 false이면, TypeError exception을 throw한다.
    2. IsAccessorDescriptor(targetDesc)가 true이고 targetDesc.[[Get]]undefined이면, 다음을 수행한다.
      1. trapResultundefined가 아니면, TypeError exception을 throw한다.
  10. trapResult를 반환한다.
Note

Proxy object의 [[Get]]은 다음 invariant를 enforce합니다:

  • target object property가 non-writable, non-configurable own data property이면, property에 대해 reported된 value는 corresponding target object property의 value와 같아야 합니다.
  • corresponding target object property가 [[Get]] attribute로 undefined를 가지는 non-configurable own accessor property이면, property에 대해 reported된 value는 undefined여야 합니다.

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

The [[Set]] internal method of a Proxy exotic object obj takes arguments propertyKey (a property key), value (an ECMAScript language value), and receiver (an ECMAScript language value) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "set")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[Set]](propertyKey, value, receiver)를 반환한다.
  7. boolTrapResultToBoolean(? Call(trap, handler, « target, propertyKey, value, receiver »))로 둔다.
  8. boolTrapResultfalse이면, false를 반환한다.
  9. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둔다.
  10. targetDescundefined가 아니고 targetDesc.[[Configurable]]false이면, 다음을 수행한다.
    1. IsDataDescriptor(targetDesc)가 true이고 targetDesc.[[Writable]]false이면, 다음을 수행한다.
      1. SameValue(value, targetDesc.[[Value]])가 false이면, TypeError exception을 throw한다.
    2. IsAccessorDescriptor(targetDesc)가 true이면, 다음을 수행한다.
      1. targetDesc.[[Set]]undefined이면, TypeError exception을 throw한다.
  11. true를 반환한다.
Note

Proxy object의 [[Set]]은 다음 invariant를 enforce합니다:

  • [[Set]]의 result는 Boolean value입니다.
  • corresponding target object property가 non-writable, non-configurable own data property이면, property의 value를 corresponding target object property의 value와 다르게 change할 수 없습니다.
  • corresponding target object property가 [[Set]] attribute로 undefined를 가지는 non-configurable own accessor property이면, property의 value를 set할 수 없습니다.

10.5.10 [[Delete]] ( propertyKey )

The [[Delete]] internal method of a Proxy exotic object obj takes argument propertyKey (a property key) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "deleteProperty")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[Delete]](propertyKey)를 반환한다.
  7. boolTrapResultToBoolean(? Call(trap, handler, « target, propertyKey »))로 둔다.
  8. boolTrapResultfalse이면, false를 반환한다.
  9. targetDesc를 ? target.[[GetOwnProperty]](propertyKey)로 둔다.
  10. targetDescundefined이면, true를 반환한다.
  11. targetDesc.[[Configurable]]false이면, TypeError exception을 throw한다.
  12. extensibleTarget을 ? IsExtensible(target)으로 둔다.
  13. extensibleTargetfalse이면, TypeError exception을 throw한다.
  14. true를 반환한다.
Note

Proxy object의 [[Delete]]는 다음 invariant를 enforce합니다:

  • [[Delete]]의 result는 Boolean value입니다.
  • property가 target object의 non-configurable own property로 존재하면, 그 property를 deleted된 것으로 report할 수 없습니다.
  • property가 target object의 own property로 존재하고 target object가 non-extensible이면, 그 property를 deleted된 것으로 report할 수 없습니다.

10.5.11 [[OwnPropertyKeys]] ( )

The [[OwnPropertyKeys]] internal method of a Proxy exotic object obj takes no arguments and returns either a normal completion containing a List of property keys or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "ownKeys")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. target.[[OwnPropertyKeys]]()를 반환한다.
  7. trapResultArray를 ? Call(trap, handler, « target »)로 둔다.
  8. trapResult를 ? CreateListFromArrayLike(trapResultArray, property-key)로 둔다.
  9. trapResult가 duplicate entry를 contain하면, TypeError exception을 throw한다.
  10. extensibleTarget을 ? IsExtensible(target)으로 둔다.
  11. targetKeys를 ? target.[[OwnPropertyKeys]]()로 둔다.
  12. Assert: targetKeysproperty keyList이다.
  13. Assert: targetKeys는 duplicate entry를 contain하지 않는다.
  14. targetConfigurableKeys를 새 empty List로 둔다.
  15. targetNonconfigurableKeys를 새 empty List로 둔다.
  16. targetKeys의 각 element key에 대해, 다음을 수행한다.
    1. propertyDesc를 ? target.[[GetOwnProperty]](key)로 둔다.
    2. propertyDescundefined가 아니고 propertyDesc.[[Configurable]]false이면, 다음을 수행한다.
      1. keytargetNonconfigurableKeys에 append한다.
    3. 그렇지 않으면,
      1. keytargetConfigurableKeys에 append한다.
  17. extensibleTargettrue이고 targetNonconfigurableKeys가 empty이면, 다음을 수행한다.
    1. trapResult를 반환한다.
  18. uncheckedResultKeys를 element가 trapResult의 element인 List로 둔다.
  19. targetNonconfigurableKeys의 각 element key에 대해, 다음을 수행한다.
    1. uncheckedResultKeyskey를 contain하지 않으면, TypeError exception을 throw한다.
    2. uncheckedResultKeys에서 key를 remove한다.
  20. extensibleTargettrue이면, trapResult를 반환한다.
  21. targetConfigurableKeys의 각 element key에 대해, 다음을 수행한다.
    1. uncheckedResultKeyskey를 contain하지 않으면, TypeError exception을 throw한다.
    2. uncheckedResultKeys에서 key를 remove한다.
  22. uncheckedResultKeys가 empty가 아니면, TypeError exception을 throw한다.
  23. trapResult를 반환한다.
Note

Proxy object의 [[OwnPropertyKeys]]는 다음 invariant를 enforce합니다:

  • [[OwnPropertyKeys]]의 result는 List입니다.
  • returned List는 duplicate entry를 contain하지 않습니다.
  • returned List의 각 element는 property key입니다.
  • result List는 target object의 모든 non-configurable own property의 key를 contain해야 합니다.
  • target object가 extensible이 아니면, result List는 target object의 own property의 모든 key를 contain해야 하며 다른 value는 contain하지 않아야 합니다.

10.5.12 [[Call]] ( thisArg, argList )

The [[Call]] internal method of a Proxy exotic object obj takes arguments thisArg (an ECMAScript language value) and argList (a List of ECMAScript language values) and returns either a normal completion containing an ECMAScript language value or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. handlerobj.[[ProxyHandler]]로 둔다.
  4. Assert: handler는 Object이다.
  5. trap을 ? GetMethod(handler, "apply")로 둔다.
  6. trapundefined이면, 다음을 수행한다.
    1. Call(target, thisArg, argList)를 반환한다.
  7. argArrayCreateArrayFromList(argList)로 둔다.
  8. Call(trap, handler, « target, thisArg, argArray »)를 반환한다.
Note

Proxy exotic object는 그 [[ProxyTarget]] internal slot의 initial value가 [[Call]] internal method를 가지는 object인 경우에만 [[Call]] internal method를 가집니다.

10.5.13 [[Construct]] ( argList, newTarget )

The [[Construct]] internal method of a Proxy exotic object obj takes arguments argList (a List of ECMAScript language values) and newTarget (a constructor) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

  1. ValidateNonRevokedProxy(obj)를 수행한다.
  2. targetobj.[[ProxyTarget]]으로 둔다.
  3. Assert: IsConstructor(target)은 true이다.
  4. handlerobj.[[ProxyHandler]]로 둔다.
  5. Assert: handler는 Object이다.
  6. trap을 ? GetMethod(handler, "construct")로 둔다.
  7. trapundefined이면, 다음을 수행한다.
    1. Construct(target, argList, newTarget)를 반환한다.
  8. argArrayCreateArrayFromList(argList)로 둔다.
  9. newObj를 ? Call(trap, handler, « target, argArray, newTarget »)로 둔다.
  10. newObj가 Object가 아니면, TypeError exception을 throw한다.
  11. newObj를 반환한다.
Note 1

Proxy exotic object는 그 [[ProxyTarget]] internal slot의 initial value가 [[Construct]] internal method를 가지는 object인 경우에만 [[Construct]] internal method를 가집니다.

Note 2

Proxy object의 [[Construct]]는 다음 invariant를 enforce합니다:

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

10.5.14 ValidateNonRevokedProxy ( proxy )

The abstract operation ValidateNonRevokedProxy takes argument proxy (a Proxy exotic object) and returns either a normal completion containing unused or a throw completion. proxy가 revoked되었으면 TypeError exception을 throw합니다. It performs the following steps when called:

  1. proxy.[[ProxyTarget]]null이면, TypeError exception을 throw한다.
  2. Assert: proxy.[[ProxyHandler]]null이 아니다.
  3. unused를 반환한다.

10.5.15 ProxyCreate ( target, handler )

The abstract operation ProxyCreate takes arguments target (an ECMAScript language value) and handler (an ECMAScript language value) and returns either a normal completion containing a Proxy exotic object or a throw completion. 새 Proxy object의 creation을 specify하는 데 사용됩니다. It performs the following steps when called:

  1. target이 Object가 아니면, TypeError 예외를 던진다.
  2. handler가 Object가 아니면, TypeError 예외를 던진다.
  3. proxyMakeBasicObject[[ProxyHandler]], [[ProxyTarget]] »)라고 하자.
  4. , [[Call]][[Construct]]를 제외한 proxy의 필수 내부 메서드를 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를 반환한다.