20 Fundamental Objects

20.1 Object Objects

20.1.1 The Object Constructor

Object constructor는:

  • %Object%입니다.
  • global object"Object" property의 initial value입니다.
  • constructor로 called될 때 new ordinary object를 create합니다.
  • constructor가 아니라 function으로 called될 때 type conversion을 수행합니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다.

20.1.1.1 Object ( value )

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

  1. NewTarget이 undefined도 아니고 active function object도 아니면, 다음을 수행한다.
    1. OrdinaryCreateFromConstructor(NewTarget, "%Object.prototype%")를 반환한다.
  2. valueundefined 또는 null 중 하나이면, OrdinaryObjectCreate(%Object.prototype%)를 반환한다.
  3. ToObject(value)를 반환한다.

20.1.2 Properties of the Object Constructor

Object constructor는:

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

20.1.2.1 Object.assign ( target, ...sources )

이 function은 one or more source object에서 target object로 모든 enumerable own property의 value를 copy합니다.

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

  1. targetObj를 ? ToObject(target)라고 하자.
  2. 인수가 하나만 전달되었으면 targetObj를 반환한다.
  3. sources의 각 요소 nextSource에 대해 다음을 수행한다.
    1. nextSourceundefinednull도 아니면,
      1. from을 ! ToObject(nextSource)라고 하자.
      2. keys를 ? from.[[OwnPropertyKeys]]()라고 하자.
      3. keys의 각 요소 nextKey에 대해 다음을 수행한다.
        1. propertyDesc를 ? from.[[GetOwnProperty]](nextKey)라고 하자.
        2. propertyDescundefined가 아니고 propertyDesc.[[Enumerable]]true이면,
          1. propertyValue를 ? Get(from, nextKey)라고 하자.
          2. Set(targetObj, nextKey, propertyValue, true)를 수행한다.
  4. targetObj를 반환한다.

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

20.1.2.2 Object.create ( proto, properties )

이 function은 specified prototype을 가진 new object를 create합니다.

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

  1. proto가 Object가 아니고 protonull도 아니면, TypeError exception을 throw한다.
  2. objOrdinaryObjectCreate(proto)로 둔다.
  3. propertiesundefined가 아니면, 다음을 수행한다.
    1. ObjectDefineProperties(obj, properties)를 반환한다.
  4. obj를 반환한다.

20.1.2.3 Object.defineProperties ( obj, properties )

이 function은 object의 own property를 add하거나 existing own property의 attribute를 update합니다.

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

  1. obj가 Object가 아니면, TypeError exception을 throw한다.
  2. ObjectDefineProperties(obj, properties)를 반환한다.

20.1.2.3.1 ObjectDefineProperties ( obj, properties )

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

  1. properties를 ? ToObject(properties)로 설정한다.
  2. keys를 ? properties.[[OwnPropertyKeys]]()로 둔다.
  3. propertyDescs를 새 empty List로 둔다.
  4. keys의 각 element nextKey에 대해, 다음을 수행한다.
    1. currentPropertyDesc를 ? properties.[[GetOwnProperty]](nextKey)로 둔다.
    2. currentPropertyDescundefined가 아니고 currentPropertyDesc.[[Enumerable]]true이면, 다음을 수행한다.
      1. propertyDescObj를 ? Get(properties, nextKey)로 둔다.
      2. propertyDesc를 ? ToPropertyDescriptor(propertyDescObj)로 둔다.
      3. Record { [[Key]]: nextKey, [[Descriptor]]: propertyDesc }를 propertyDescs에 append한다.
  5. propertyDescs의 각 element property에 대해, 다음을 수행한다.
    1. DefinePropertyOrThrow(obj, property.[[Key]], property.[[Descriptor]])를 수행한다.
  6. obj를 반환한다.

20.1.2.4 Object.defineProperty ( obj, key, attrs )

이 function은 object의 own property를 add하거나 existing own property의 attribute를 update합니다.

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

  1. obj가 Object가 아니면, TypeError exception을 throw한다.
  2. propertyKey를 ? ToPropertyKey(key)로 둔다.
  3. propertyDesc를 ? ToPropertyDescriptor(attrs)로 둔다.
  4. DefinePropertyOrThrow(obj, propertyKey, propertyDesc)를 수행한다.
  5. obj를 반환한다.

20.1.2.5 Object.entries ( obj )

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

  1. coerced를 ? ToObject(obj)로 둔다.
  2. entryList를 ? EnumerableOwnProperties(coerced, key+value)로 둔다.
  3. CreateArrayFromList(entryList)를 반환한다.

20.1.2.6 Object.freeze ( obj )

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

  1. obj가 Object가 아니면, obj를 반환한다.
  2. status를 ? SetIntegrityLevel(obj, frozen)로 둔다.
  3. statusfalse이면, TypeError exception을 throw한다.
  4. obj를 반환한다.

20.1.2.7 Object.fromEntries ( iterable )

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

  1. RequireObjectCoercible(iterable)를 수행한다.
  2. objOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  3. Assert: obj는 own property가 없는 extensible ordinary object이다.
  4. obj를 capture하고 called될 때 다음 step을 수행하는 parameters (key, value)를 가진 새 Abstract Closure closure를 둔다:
    1. propertyKey를 ? ToPropertyKey(key)로 둔다.
    2. CreateDataPropertyOrThrow(obj, propertyKey, value)를 수행한다.
    3. NormalCompletion(undefined)를 반환한다.
  5. adderCreateBuiltinFunction(closure, 2, "", « »)로 둔다.
  6. AddEntriesFromIterable(obj, iterable, adder)를 반환한다.
Note
adder를 위해 created된 function은 ECMAScript code에 의해 never directly accessible하지 않습니다.

20.1.2.8 Object.getOwnPropertyDescriptor ( obj, key )

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

  1. coerced를 ? ToObject(obj)로 둔다.
  2. propertyKey를 ? ToPropertyKey(key)로 둔다.
  3. propertyDesc를 ? coerced.[[GetOwnProperty]](propertyKey)로 둔다.
  4. FromPropertyDescriptor(propertyDesc)를 반환한다.

20.1.2.9 Object.getOwnPropertyDescriptors ( obj )

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

  1. coerced를 ? ToObject(obj)로 둔다.
  2. ownKeys를 ? coerced.[[OwnPropertyKeys]]()로 둔다.
  3. descsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. ownKeys의 각 element key에 대해, 다음을 수행한다.
    1. propertyDesc를 ? coerced.[[GetOwnProperty]](key)로 둔다.
    2. propertyDescObjFromPropertyDescriptor(propertyDesc)로 둔다.
    3. propertyDescObjundefined가 아니면, ! CreateDataPropertyOrThrow(descs, key, propertyDescObj)를 수행한다.
  5. descs를 반환한다.

20.1.2.10 Object.getOwnPropertyNames ( obj )

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

  1. CreateArrayFromList(? GetOwnPropertyKeys(obj, string))를 반환한다.

20.1.2.11 Object.getOwnPropertySymbols ( obj )

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

  1. CreateArrayFromList(? GetOwnPropertyKeys(obj, symbol))를 반환한다.

20.1.2.11.1 GetOwnPropertyKeys ( value, type )

The abstract operation GetOwnPropertyKeys takes arguments value (an ECMAScript language value) and type (string or symbol) and returns either a normal completion containing a List of property keys or a throw completion. It performs the following steps when called:

  1. obj를 ? ToObject(value)로 둔다.
  2. keys를 ? obj.[[OwnPropertyKeys]]()로 둔다.
  3. nameList를 새 empty List로 둔다.
  4. keys의 각 element nextKey에 대해, 다음을 수행한다.
    1. nextKey가 Symbol이고 typesymbol이거나, nextKey가 String이고 typestring이면, 다음을 수행한다.
      1. nextKeynameList에 append한다.
  5. nameList를 반환한다.

20.1.2.12 Object.getPrototypeOf ( obj )

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

  1. coerced를 ? ToObject(obj)로 둔다.
  2. coerced.[[GetPrototypeOf]]()를 반환한다.

20.1.2.13 Object.groupBy ( items, callback )

Note

callback은 two arguments를 accept하는 function이어야 합니다. groupByitems의 각 element에 대해 ascending order로 callback을 once call하고, new object를 construct합니다. callback에 의해 returned된 각 value는 property key로 coerced됩니다. such 각 property key에 대해, result object는 key가 해당 property key이고 value가 callback return value가 그 key로 coerced된 모든 element를 contain하는 array인 property를 가집니다.

callback은 two arguments, 즉 element의 value와 element의 index로 called됩니다.

groupBy의 return value는 %Object.prototype%에서 inherit하지 않는 object입니다.

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

  1. groups를 ? GroupBy(items, callback, property)라고 하자.
  2. objOrdinaryObjectCreate(null)라고 하자.
  3. groups의 각 Record { [[Key]], [[Elements]] } group에 대해 다음을 수행한다.
    1. elementsCreateArrayFromList(group.[[Elements]])라고 하자.
    2. CreateDataPropertyOrThrow(obj, group.[[Key]], elements)를 수행한다.
  4. obj를 반환한다.

20.1.2.14 Object.hasOwn ( obj, key )

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

  1. coerced를 ? ToObject(obj)로 둔다.
  2. propertyKey를 ? ToPropertyKey(key)로 둔다.
  3. HasOwnProperty(coerced, propertyKey)를 반환한다.

20.1.2.15 Object.is ( value1, value2 )

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

  1. SameValue(value1, value2)를 반환한다.

20.1.2.16 Object.isExtensible ( obj )

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

  1. obj가 Object가 아니면, false를 반환한다.
  2. IsExtensible(obj)를 반환한다.

20.1.2.17 Object.isFrozen ( obj )

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

  1. obj가 Object가 아니면, true를 반환한다.
  2. TestIntegrityLevel(obj, frozen)를 반환한다.

20.1.2.18 Object.isSealed ( obj )

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

  1. obj가 Object가 아니면, true를 반환한다.
  2. TestIntegrityLevel(obj, sealed)를 반환한다.

20.1.2.19 Object.keys ( obj )

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

  1. coerced를 ? ToObject(obj)로 둔다.
  2. keyList를 ? EnumerableOwnProperties(coerced, key)로 둔다.
  3. CreateArrayFromList(keyList)를 반환한다.

20.1.2.20 Object.preventExtensions ( obj )

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

  1. obj가 Object가 아니면, obj를 반환한다.
  2. status를 ? obj.[[PreventExtensions]]()로 둔다.
  3. statusfalse이면, TypeError exception을 throw한다.
  4. obj를 반환한다.

20.1.2.21 Object.prototype

Object.prototype의 initial value는 Object prototype object입니다.

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

20.1.2.22 Object.seal ( obj )

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

  1. obj가 Object가 아니면, obj를 반환한다.
  2. status를 ? SetIntegrityLevel(obj, sealed)로 둔다.
  3. statusfalse이면, TypeError exception을 throw한다.
  4. obj를 반환한다.

20.1.2.23 Object.setPrototypeOf ( obj, proto )

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

  1. RequireObjectCoercible(obj)를 수행한다.
  2. proto가 Object가 아니고 protonull도 아니면, TypeError exception을 throw한다.
  3. obj가 Object가 아니면, obj를 반환한다.
  4. status를 ? obj.[[SetPrototypeOf]](proto)로 둔다.
  5. statusfalse이면, TypeError exception을 throw한다.
  6. obj를 반환한다.

20.1.2.24 Object.values ( obj )

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

  1. coerced를 ? ToObject(obj)로 둔다.
  2. valueList를 ? EnumerableOwnProperties(coerced, value)로 둔다.
  3. CreateArrayFromList(valueList)를 반환한다.

20.1.3 Properties of the Object Prototype Object

Object prototype object는:

  • %Object.prototype%입니다.
  • value가 true[[Extensible]] internal slot을 가집니다.
  • 10.4.7.1에 defined된 것과 같은 [[SetPrototypeOf]] method를 제외하고 ordinary object에 defined된 internal method를 가집니다. (따라서 이는 immutable prototype exotic object입니다.)
  • value가 null[[Prototype]] internal slot을 가집니다.

20.1.3.1 Object.prototype.constructor

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

20.1.3.2 Object.prototype.hasOwnProperty ( value )

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

  1. propertyKey를 ? ToPropertyKey(value)로 둔다.
  2. obj를 ? ToObject(this value)로 둔다.
  3. HasOwnProperty(obj, propertyKey)를 반환한다.
Note

step 12의 ordering은, this value가 undefined 또는 null인 경우에도 이 specification의 previous edition에서 step 1에 의해 thrown되었을 any exception이 계속 thrown되도록 ensure하기 위해 chosen되었습니다.

20.1.3.3 Object.prototype.isPrototypeOf ( value )

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

  1. value가 Object가 아니면, false를 반환한다.
  2. obj를 ? ToObject(this value)로 둔다.
  3. Repeat,
    1. value를 ? value.[[GetPrototypeOf]]()로 설정한다.
    2. valuenull이면, false를 반환한다.
    3. SameValue(obj, value)가 true이면, true를 반환한다.
Note

step 12의 ordering은, value가 object가 아니고 this value가 undefined 또는 null인 경우에 대해 이 specification의 previous edition에서 specified된 behaviour를 preserves합니다.

20.1.3.4 Object.prototype.propertyIsEnumerable ( value )

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

  1. propertyKey를 ? ToPropertyKey(value)로 둔다.
  2. obj를 ? ToObject(this value)로 둔다.
  3. propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
  4. propertyDescundefined이면, false를 반환한다.
  5. propertyDesc.[[Enumerable]]을 반환한다.
Note 1

이 method는 prototype chain 안의 object를 consider하지 않습니다.

Note 2

step 12의 ordering은, this value가 undefined 또는 null인 경우에도 이 specification의 previous edition에서 step 1에 의해 thrown되었을 any exception이 계속 thrown되도록 ensure하기 위해 chosen되었습니다.

20.1.3.5 Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )

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

  1. thisValuethis value로 둔다.
  2. Invoke(thisValue, "toString")를 반환한다.

이 method의 optional parameter는 사용되지 않지만, ECMA-402 toLocaleString method에서 사용되는 parameter pattern에 correspond하도록 intended됩니다. ECMA-402 support를 include하지 않는 implementation은 those parameter position을 other purpose에 사용해서는 안 됩니다.

Note 1

이 method는 locale-sensitive toString behaviour를 가지지 않는 object를 위한 generic toLocaleString implementation을 제공합니다. Array, Number, Date, 및 %TypedArray%는 own locale-sensitive toLocaleString method를 provide합니다.

Note 2

ECMA-402는 intentionally 이 default implementation에 대한 alternative를 provide하지 않습니다.

20.1.3.6 Object.prototype.toString ( )

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

  1. this value가 undefined이면, "[object Undefined]"를 반환한다.
  2. this value가 null이면, "[object Null]"을 반환한다.
  3. obj를 ! ToObject(this value)로 둔다.
  4. isArray를 ? IsArray(obj)로 둔다.
  5. isArraytrue이면, builtinTag"Array"로 둔다.
  6. 그렇지 않고 obj[[ParameterMap]] internal slot을 가지면, builtinTag"Arguments"로 둔다.
  7. 그렇지 않고 obj[[Call]] internal method를 가지면, builtinTag"Function"으로 둔다.
  8. 그렇지 않고 obj[[ErrorData]] internal slot을 가지면, builtinTag"Error"로 둔다.
  9. 그렇지 않고 obj[[BooleanData]] internal slot을 가지면, builtinTag"Boolean"으로 둔다.
  10. 그렇지 않고 obj[[NumberData]] internal slot을 가지면, builtinTag"Number"로 둔다.
  11. 그렇지 않고 obj[[StringData]] internal slot을 가지면, builtinTag"String"으로 둔다.
  12. 그렇지 않고 obj[[DateValue]] internal slot을 가지면, builtinTag"Date"로 둔다.
  13. 그렇지 않고 obj[[RegExpMatcher]] internal slot을 가지면, builtinTag"RegExp"로 둔다.
  14. 그렇지 않으면, builtinTag"Object"로 둔다.
  15. tag를 ? Get(obj, %Symbol.toStringTag%)로 둔다.
  16. tag가 String이 아니면, tagbuiltinTag로 설정한다.
  17. "[object ", tag, 및 "]"string-concatenation을 반환한다.
Note

Historically, 이 method는 this specification의 previous edition에서 various built-in object를 위한 nominal type tag로 사용되었던 [[Class]] internal slot의 String value에 access하기 위해 occasionally 사용되었습니다. toString의 above definition은 those specific kind of built-in object를 test하기 위해 toString을 사용하는 legacy code에 대한 compatibility를 preserves합니다. 이는 other kind의 built-in 또는 program defined object에 대한 reliable type testing mechanism을 provide하지 않습니다. In addition, program은 such legacy type test의 reliability를 invalidate할 ways로 %Symbol.toStringTag%를 사용할 수 있습니다.

20.1.3.7 Object.prototype.valueOf ( )

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

  1. ToObject(this value)를 반환한다.

20.1.3.8 Object.prototype.__proto__

Object.prototype.__proto__는 attributes { [[Enumerable]]: false, [[Configurable]]: true }를 가진 accessor property입니다. [[Get]][[Set]] attribute는 다음과 같이 defined됩니다:

20.1.3.8.1 get Object.prototype.__proto__

[[Get]] attribute의 value는 argument를 require하지 않는 built-in function입니다. called될 때 다음 step을 수행합니다:

  1. obj를 ? ToObject(this value)로 둔다.
  2. obj.[[GetPrototypeOf]]()를 반환한다.

20.1.3.8.2 set Object.prototype.__proto__

[[Set]] attribute의 value는 argument proto를 take하는 built-in function입니다. called될 때 다음 step을 수행합니다:

  1. thisValuethis value로 둔다.
  2. RequireObjectCoercible(thisValue)를 수행한다.
  3. proto가 Object가 아니고 protonull도 아니면, undefined를 반환한다.
  4. thisValue가 Object가 아니면, undefined를 반환한다.
  5. status를 ? thisValue.[[SetPrototypeOf]](proto)로 둔다.
  6. statusfalse이면, TypeError exception을 throw한다.
  7. undefined를 반환한다.

20.1.3.9 Legacy Object.prototype Accessor Methods

20.1.3.9.1 Object.prototype.__defineGetter__ ( key, getter )

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

  1. obj를 ? ToObject(this value)로 둔다.
  2. IsCallable(getter)가 false이면, TypeError exception을 throw한다.
  3. propertyDesc를 PropertyDescriptor { [[Get]]: getter, [[Enumerable]]: true, [[Configurable]]: true }로 둔다.
  4. propertyKey를 ? ToPropertyKey(key)로 둔다.
  5. DefinePropertyOrThrow(obj, propertyKey, propertyDesc)를 수행한다.
  6. undefined를 반환한다.

20.1.3.9.2 Object.prototype.__defineSetter__ ( key, setter )

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

  1. obj를 ? ToObject(this value)로 둔다.
  2. IsCallable(setter)가 false이면, TypeError exception을 throw한다.
  3. propertyDesc를 PropertyDescriptor { [[Set]]: setter, [[Enumerable]]: true, [[Configurable]]: true }로 둔다.
  4. propertyKey를 ? ToPropertyKey(key)로 둔다.
  5. DefinePropertyOrThrow(obj, propertyKey, propertyDesc)를 수행한다.
  6. undefined를 반환한다.

20.1.3.9.3 Object.prototype.__lookupGetter__ ( key )

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

  1. obj를 ? ToObject(this value)로 둔다.
  2. propertyKey를 ? ToPropertyKey(key)로 둔다.
  3. Repeat,
    1. propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
    2. propertyDescundefined가 아니면, 다음을 수행한다.
      1. IsAccessorDescriptor(propertyDesc)가 true이면, propertyDesc.[[Get]]을 반환한다.
      2. undefined를 반환한다.
    3. obj를 ? obj.[[GetPrototypeOf]]()로 설정한다.
    4. objnull이면, undefined를 반환한다.

20.1.3.9.4 Object.prototype.__lookupSetter__ ( key )

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

  1. obj를 ? ToObject(this value)로 둔다.
  2. propertyKey를 ? ToPropertyKey(key)로 둔다.
  3. Repeat,
    1. propertyDesc를 ? obj.[[GetOwnProperty]](propertyKey)로 둔다.
    2. propertyDescundefined가 아니면, 다음을 수행한다.
      1. IsAccessorDescriptor(propertyDesc)가 true이면, propertyDesc.[[Set]]을 반환한다.
      2. undefined를 반환한다.
    3. obj를 ? obj.[[GetPrototypeOf]]()로 설정한다.
    4. objnull이면, undefined를 반환한다.

20.1.4 Properties of Object Instances

Object instance는 Object prototype object에서 inherited되는 property 외에 special property를 가지지 않습니다.

20.2 Function Objects

20.2.1 The Function Constructor

Function constructor는:

  • %Function%입니다.
  • global object"Function" property의 initial value입니다.
  • constructor가 아니라 function으로 called될 때 new function object를 create하고 initialize합니다. 따라서 function call Function(…)은 same arguments를 가진 object creation expression new Function(…)과 equivalent합니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다. specified Function behaviour를 inherit하려는 subclass constructor는 built-in function behaviour에 necessary한 internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Function constructor에 대한 super call을 include해야 합니다. function object를 defining하기 위한 모든 ECMAScript syntactic form은 Function의 instance를 create합니다. built-in GeneratorFunction, AsyncFunction, 및 AsyncGeneratorFunction subclass를 제외하고 Function subclass의 instance를 create하는 syntactic means는 없습니다.

20.2.1.1 Function ( ...paramArgs, bodyArg )

last argument(있으면)는 function의 body(executable code)를 specify합니다; preceding argument는 formal parameter를 specify합니다.

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

  1. ctor를 active function object로 둔다.
  2. bodyArg가 present하지 않으면, bodyArg를 empty String으로 설정한다.
  3. CreateDynamicFunction(ctor, NewTarget, normal, paramArgs, bodyArg)를 반환한다.
Note

specified될 각 formal parameter에 대해 one argument를 가지는 것은 permissible하지만 necessary하지 않습니다. 예를 들어 다음 세 expression은 모두 same result를 produce합니다:

new Function("a", "b", "c", "return a+b+c")
new Function("a, b, c", "return a+b+c")
new Function("a,b", "c", "return a+b+c")

20.2.1.1.1 CreateDynamicFunction ( ctor, newTarget, kind, paramArgs, bodyArg )

The abstract operation CreateDynamicFunction takes arguments ctor (a constructor), newTarget (a constructor or undefined), kind (normal, generator, async, or async-generator), paramArgs (a List of ECMAScript language values), and bodyArg (an ECMAScript language value) and returns either a normal completion containing an ECMAScript function object or a throw completion. ctor는 이 action을 performing하는 constructor function입니다. newTargetnew가 initially applied된 constructor입니다. paramArgsbodyArgctor에 passed된 argument value를 reflect합니다. It performs the following steps when called:

  1. newTargetundefined이면, newTargetctor로 설정한다.
  2. kindnormal이면, 다음을 수행한다.
    1. prefix"function"으로 둔다.
    2. exprGrammar를 grammar symbol FunctionExpression으로 둔다.
    3. bodyGrammar를 grammar symbol FunctionBody[~Yield, ~Await]로 둔다.
    4. paramGrammar를 grammar symbol FormalParameters[~Yield, ~Await]로 둔다.
    5. fallbackProto"%Function.prototype%"로 둔다.
  3. 그렇지 않고 kindgenerator이면, 다음을 수행한다.
    1. prefix"function*"로 둔다.
    2. exprGrammar를 grammar symbol GeneratorExpression으로 둔다.
    3. bodyGrammar를 grammar symbol GeneratorBody로 둔다.
    4. paramGrammar를 grammar symbol FormalParameters[+Yield, ~Await]로 둔다.
    5. fallbackProto"%GeneratorFunction.prototype%"로 둔다.
  4. 그렇지 않고 kindasync이면, 다음을 수행한다.
    1. prefix"async function"으로 둔다.
    2. exprGrammar를 grammar symbol AsyncFunctionExpression으로 둔다.
    3. bodyGrammar를 grammar symbol AsyncFunctionBody로 둔다.
    4. paramGrammar를 grammar symbol FormalParameters[~Yield, +Await]로 둔다.
    5. fallbackProto"%AsyncFunction.prototype%"로 둔다.
  5. 그렇지 않으면,
    1. Assert: kindasync-generator이다.
    2. prefix"async function*"로 둔다.
    3. exprGrammar를 grammar symbol AsyncGeneratorExpression으로 둔다.
    4. bodyGrammar를 grammar symbol AsyncGeneratorBody로 둔다.
    5. paramGrammar를 grammar symbol FormalParameters[+Yield, +Await]로 둔다.
    6. fallbackProto"%AsyncGeneratorFunction.prototype%"로 둔다.
  6. argCountparamArgs 안의 element 수로 둔다.
  7. paramStrings를 새 empty List로 둔다.
  8. paramArgs의 각 element arg에 대해, 다음을 수행한다.
    1. ToString(arg)를 paramStrings에 append한다.
  9. bodyString을 ? ToString(bodyArg)로 둔다.
  10. currentRealm을 current Realm Record로 둔다.
  11. HostEnsureCanCompileStrings(currentRealm, paramStrings, bodyString, false)를 수행한다.
  12. paramString을 empty String으로 둔다.
  13. argCount > 0이면, 다음을 수행한다.
    1. paramStringparamStrings[0]으로 설정한다.
    2. k를 1로 둔다.
    3. Repeat, k < argCount인 동안,
      1. nextArgStringparamStrings[k]로 둔다.
      2. paramStringparamString, "," (comma), 및 nextArgStringstring-concatenation으로 설정한다.
      3. kk + 1로 설정한다.
  14. bodyParseString을 0x000A (LINE FEED), bodyString, 및 0x000A (LINE FEED)의 string-concatenation으로 둔다.
  15. sourceStringprefix, " anonymous(", paramString, 0x000A (LINE FEED), ") {", bodyParseString, 및 "}"string-concatenation으로 둔다.
  16. sourceTextStringToCodePoints(sourceString)로 둔다.
  17. paramsParseText(paramString, paramGrammar)로 둔다.
  18. params가 error의 List이면, SyntaxError exception을 throw한다.
  19. bodyParseText(bodyParseString, bodyGrammar)로 둔다.
  20. body가 error의 List이면, SyntaxError exception을 throw한다.
  21. NOTE: parameter와 body는 각각 alone valid함을 ensure하기 위해 separately parsed된다. 예를 들어 new Function("/*", "*/ ) {")는 function으로 evaluate되지 않는다.
  22. NOTE: 이 step에 reached했다면, sourceTextexprGrammar의 syntax를 가져야 한다(although reverse implication does not hold). 다음 두 step의 purpose는 exprGrammar에 directly apply되는 any Early Error rule을 enforce하는 것이다.
  23. exprParseText(sourceText, exprGrammar)로 둔다.
  24. expr가 error의 List이면, SyntaxError exception을 throw한다.
  25. funcProto를 ? GetPrototypeFromConstructor(newTarget, fallbackProto)로 둔다.
  26. envRecordcurrentRealm.[[GlobalEnv]]로 둔다.
  27. privateEnvnull로 둔다.
  28. funcOrdinaryFunctionCreate(funcProto, sourceText, params, body, non-lexical-this, envRecord, privateEnv)로 둔다.
  29. SetFunctionName(func, "anonymous")를 수행한다.
  30. kindgenerator이면, 다음을 수행한다.
    1. protoProtoOrdinaryObjectCreate(%GeneratorPrototype%)로 둔다.
    2. DefinePropertyOrThrow(func, "prototype", PropertyDescriptor { [[Value]]: protoProto, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
  31. 그렇지 않고 kindasync-generator이면, 다음을 수행한다.
    1. protoProtoOrdinaryObjectCreate(%AsyncGeneratorPrototype%)로 둔다.
    2. DefinePropertyOrThrow(func, "prototype", PropertyDescriptor { [[Value]]: protoProto, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
  32. 그렇지 않고 kindnormal이면, 다음을 수행한다.
    1. MakeConstructor(func)를 수행한다.
  33. NOTE: kindasync인 function은 constructable하지 않으며 [[Construct]] internal method 또는 "prototype" property를 가지지 않는다.
  34. func를 반환한다.
Note

CreateDynamicFunction은 created하는 any function 중 kindasync가 아닌 것에 대해 "prototype" property를 define하여, 해당 function이 constructor로 사용될 가능성에 대비합니다.

20.2.2 Properties of the Function Constructor

Function constructor는:

  • itself가 built-in function object입니다.
  • value가 %Function.prototype%[[Prototype]] internal slot을 가집니다.
  • value가 1𝔽"length" property를 가집니다.
  • 다음 property를 가집니다:

20.2.2.1 Function.prototype

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

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

20.2.3 Properties of the Function Prototype Object

Function prototype object는:

  • %Function.prototype%입니다.
  • itself가 built-in function object입니다.
  • any argument를 accept하고 invoked될 때 undefined를 반환합니다.
  • [[Construct]] internal method를 가지지 않습니다; new operator와 함께 constructor로 사용될 수 없습니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.
  • "prototype" property를 가지지 않습니다.
  • value가 +0𝔽"length" property를 가집니다.
  • value가 empty String인 "name" property를 가집니다.
Note

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

20.2.3.1 Function.prototype.apply ( thisArg, argArray )

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

  1. functhis value로 둔다.
  2. IsCallable(func)이 false이면, TypeError exception을 throw한다.
  3. argArrayundefined 또는 null 중 하나이면, 다음을 수행한다.
    1. PrepareForTailCall()을 수행한다.
    2. Call(func, thisArg)를 반환한다.
  4. argList를 ? CreateListFromArrayLike(argArray)로 둔다.
  5. PrepareForTailCall()을 수행한다.
  6. Call(func, thisArg, argList)를 반환한다.
Note 1

thisArg value는 modification 없이 this value로 passed됩니다. 이는 Edition 3에서 undefined 또는 null thisArgglobal object로 replaced되고, all other value에 ToObject가 applied되며 그 result가 this value로 passed되었던 것과 달라진 change입니다. thisArg가 modification 없이 passed되더라도, non-strict function은 function entry 시 여전히 these transformation을 수행합니다.

Note 2

func가 arrow function 또는 bound function exotic object 중 하나이면, thisArg는 step 6의 function [[Call]]에 의해 ignored될 것입니다.

20.2.3.2 Function.prototype.bind ( thisArg, ...args )

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

  1. targetthis value로 둔다.
  2. IsCallable(target)이 false이면, TypeError exception을 throw한다.
  3. boundFunc를 ? BoundFunctionCreate(target, thisArg, args)로 둔다.
  4. length를 0으로 둔다.
  5. targetHasLength를 ? HasOwnProperty(target, "length")로 둔다.
  6. targetHasLengthtrue이면, 다음을 수행한다.
    1. targetLength를 ? Get(target, "length")로 둔다.
    2. targetLength가 Number이면, 다음을 수행한다.
      1. targetLength+∞𝔽이면, 다음을 수행한다.
        1. length를 +∞로 설정한다.
      2. 그렇지 않고 targetLength-∞𝔽이면, 다음을 수행한다.
        1. length를 0으로 설정한다.
      3. 그렇지 않으면,
        1. targetLengthAsInt를 ! ToIntegerOrInfinity(targetLength)로 둔다.
        2. Assert: targetLengthAsIntfinite이다.
        3. argCountargs 안의 element 수로 둔다.
        4. lengthmax(targetLengthAsInt - argCount, 0)으로 설정한다.
  7. SetFunctionLength(boundFunc, length)를 수행한다.
  8. targetName을 ? Get(target, "name")로 둔다.
  9. targetName이 String이 아니면, targetName을 empty String으로 설정한다.
  10. SetFunctionName(boundFunc, targetName, "bound")를 수행한다.
  11. boundFunc를 반환한다.
Note 1

Function.prototype.bind를 사용하여 created된 Function objectexotic object입니다. 또한 "prototype" property를 가지지 않습니다.

Note 2

target이 arrow function 또는 bound function exotic object 중 하나이면, 이 method에 passed된 thisArgfunc에 대한 subsequent call에서 사용되지 않을 것입니다.

20.2.3.3 Function.prototype.call ( thisArg, ...args )

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

  1. functhis value로 둔다.
  2. IsCallable(func)이 false이면, TypeError exception을 throw한다.
  3. PrepareForTailCall()을 수행한다.
  4. Call(func, thisArg, args)를 반환한다.
Note 1

thisArg value는 modification 없이 this value로 passed됩니다. 이는 Edition 3에서 undefined 또는 null thisArgglobal object로 replaced되고, all other value에 ToObject가 applied되며 그 result가 this value로 passed되었던 것과 달라진 change입니다. thisArg가 modification 없이 passed되더라도, non-strict function은 function entry 시 여전히 these transformation을 수행합니다.

Note 2

func가 arrow function 또는 bound function exotic object 중 하나이면, thisArg는 step 4의 function [[Call]]에 의해 ignored될 것입니다.

20.2.3.4 Function.prototype.constructor

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

20.2.3.5 Function.prototype.toString ( )

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

  1. functhis value로 둔다.
  2. func가 Object이고, func[[SourceText]] internal slot을 가지며, func.[[SourceText]]가 Unicode code point의 sequence이고, HostHasSourceTextAvailable(func)가 true이면, 다음을 수행한다.
    1. CodePointsToString(func.[[SourceText]])를 반환한다.
  3. funcbuilt-in function object이면, funcimplementation-defined String source code representation을 반환한다. representation은 NativeFunction의 syntax를 가져야 합니다. Additionally, func[[InitialName]] internal slot을 가지고 func.[[InitialName]]이 String이면, returned String 중 NativeFunctionAccessoropt PropertyName에 의해 matched될 portion은 func.[[InitialName]]이어야 합니다.
  4. func가 Object이고 IsCallable(func)가 true이면, funcimplementation-defined String source code representation을 반환한다. representation은 NativeFunction의 syntax를 가져야 한다.
  5. TypeError exception을 throw한다.
NativeFunction : function NativeFunctionAccessoropt PropertyName[~Yield, ~Await]opt ( FormalParameters[~Yield, ~Await] ) { [ native code ] } NativeFunctionAccessor : get set

20.2.3.6 Function.prototype [ %Symbol.hasInstance% ] ( value )

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

  1. thisValuethis value로 둔다.
  2. OrdinaryHasInstance(thisValue, value)를 반환한다.

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

Note

이는 대부분의 function이 inherit하는 %Symbol.hasInstance%의 default implementation입니다. %Symbol.hasInstance%는 value가 specific constructor의 instance인지 determine하기 위해 instanceof operator에 의해 called됩니다. 다음과 같은 expression은

v instanceof F

다음처럼 evaluates됩니다

F[%Symbol.hasInstance%](v)

constructor function은 function에 different %Symbol.hasInstance% method를 exposing함으로써 instanceof에 의해 어떤 object가 its instance로 recognized되는지 control할 수 있습니다.

이 property는 bound function의 target function을 globally expose하는 데 used될 수 있는 tampering을 prevent하기 위해 non-writable 및 non-configurable입니다.

이 method의 "name" property의 value는 "[Symbol.hasInstance]"입니다.

20.2.4 Function Instances

Every Function instance는 ECMAScript function object이고 Table 26에 listed된 internal slot을 가집니다. Function.prototype.bind method(20.2.3.2)를 사용하여 created된 Function objectTable 27에 listed된 internal slot을 가집니다.

Function instance는 다음 property를 가집니다:

20.2.4.1 length

"length" property의 value는 function에 expected되는 typical number of arguments를 indicate하는 integral Number입니다. 그러나 language는 function이 some other number of arguments와 함께 invoked되는 것을 permit합니다. "length" property에 의해 specified된 number가 아닌 number of arguments로 invoked될 때의 function behaviour는 function에 depend합니다. 이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

20.2.4.2 name

"name" property의 value는 function을 descriptive하는 String입니다. name은 semantic significance를 가지지 않지만, typically ECMAScript source text 안에서 definition point에서 function을 refer하기 위해 사용되는 variable 또는 property name입니다. 이 property는 attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }를 가집니다.

이 specification에 의해 contextual name이 associated되지 않은 Anonymous function object"name" property의 value로 empty String을 사용합니다.

20.2.4.3 prototype

constructor로 사용될 수 있는 Function instance는 "prototype" property를 가집니다. such Function instance가 created될 때마다 another ordinary object도 created되고 function의 "prototype" property의 initial value가 됩니다. 달리 specified되지 않는 한, "prototype" property의 value는 해당 function이 constructor로 invoked될 때 created되는 object의 [[Prototype]] internal slot을 initialize하는 데 사용됩니다.

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

Note

Function.prototype.bind를 사용하여 created되거나, MethodDefinition(GeneratorMethod 또는 AsyncGeneratorMethod가 아닌 것) 또는 ArrowFunction을 evaluating하여 created된 Function object"prototype" property를 가지지 않습니다.

20.2.5 HostHasSourceTextAvailable ( func )

The host-defined abstract operation HostHasSourceTextAvailable takes argument func (a function object) and returns a Boolean. host environmentfunc에 대한 source text가 provided되는 것을 prevent할 수 있게 합니다.

HostHasSourceTextAvailable의 implementation은 다음 requirement에 conform해야 합니다:

  • parameter에 대해 deterministic이어야 합니다. 특정 func를 argument로 하여 called될 때마다, same result를 반환해야 합니다.

HostHasSourceTextAvailable의 default implementation은 true를 반환하는 것입니다.

20.3 Boolean Objects

20.3.1 The Boolean Constructor

Boolean constructor는:

  • %Boolean%입니다.
  • global object"Boolean" property의 initial value입니다.
  • constructor로 called될 때 new Boolean object를 create하고 initialize합니다.
  • constructor가 아니라 function으로 called될 때 type conversion을 수행합니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다. specified Boolean behaviour를 inherit하려는 subclass constructor[[BooleanData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Boolean constructor에 대한 super call을 include해야 합니다.

20.3.1.1 Boolean ( value )

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

  1. boolToBoolean(value)로 둔다.
  2. NewTarget이 undefined이면, bool을 반환한다.
  3. obj를 ? OrdinaryCreateFromConstructor(NewTarget, "%Boolean.prototype%", « [[BooleanData]] »)로 둔다.
  4. obj.[[BooleanData]]bool로 설정한다.
  5. obj를 반환한다.

20.3.2 Properties of the Boolean Constructor

Boolean constructor는:

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

20.3.2.1 Boolean.prototype

Boolean.prototype의 initial value는 Boolean prototype object입니다.

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

20.3.3 Properties of the Boolean Prototype Object

Boolean prototype object는:

  • %Boolean.prototype%입니다.
  • ordinary object입니다.
  • itself가 Boolean object입니다; value가 false[[BooleanData]] internal slot을 가집니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.

20.3.3.1 Boolean.prototype.constructor

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

20.3.3.2 Boolean.prototype.toString ( )

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

  1. bool을 ? ThisBooleanValue(this value)로 둔다.
  2. booltrue이면, "true"를 반환한다.
  3. "false"를 반환한다.

20.3.3.3 Boolean.prototype.valueOf ( )

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

  1. ThisBooleanValue(this value)를 반환한다.

20.3.3.3.1 ThisBooleanValue ( arg )

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

  1. arg가 Boolean이면, arg를 반환한다.
  2. arg가 Object이고 arg[[BooleanData]] internal slot을 가지면, 다음을 수행한다.
    1. boolarg.[[BooleanData]]로 둔다.
    2. Assert: bool은 Boolean이다.
    3. bool을 반환한다.
  3. TypeError exception을 throw한다.

20.3.4 Properties of Boolean Instances

Boolean instance는 Boolean prototype object에서 property를 inherit하는 ordinary object입니다. Boolean instance는 [[BooleanData]] internal slot을 가집니다. [[BooleanData]] internal slot은 이 Boolean object가 represented하는 Boolean value입니다.

20.4 Symbol Objects

20.4.1 The Symbol Constructor

Symbol constructor는:

  • %Symbol%입니다.
  • global object"Symbol" property의 initial value입니다.
  • function으로 called될 때 new Symbol value를 반환합니다.
  • new operator와 함께 사용되도록 intended되지 않습니다.
  • subclassed되도록 intended되지 않습니다.
  • class definition의 extends clause의 value로 사용될 수 있지만, 이에 대한 super call은 exception을 cause합니다.

20.4.1.1 Symbol ( [ description ] )

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

  1. NewTarget이 undefined가 아니면, TypeError exception을 throw한다.
  2. descriptionundefined이면, descStringundefined로 둔다.
  3. 그렇지 않으면, descString을 ? ToString(description)으로 둔다.
  4. ... [[Description]]descString인 new Symbol을 반환한다.

20.4.2 Properties of the Symbol Constructor

Symbol constructor는:

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

20.4.2.1 Symbol.asyncIterator

Symbol.asyncIterator의 initial value는 well-known symbol %Symbol.asyncIterator%입니다(Table 1).

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

20.4.2.2 Symbol.for ( key )

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

  1. stringKey를 ? ToString(key)이라고 하자.
  2. agentRecord를 둘러싸는 에이전트의 Agent Record라고 하자.
  3. globalSymbolRegistryagentRecord.[[GlobalSymbolRegistry]]라고 하자.
  4. globalSymbolRegistry의 각 요소 element에 대해, 다음을 수행한다.
    1. element.[[Key]]stringKey이면, element.[[Symbol]]을 반환한다.
  5. 단언: globalSymbolRegistry는 현재 stringKey에 대한 항목을 포함하지 않는다.
  6. newSymbol[[Description]]stringKey인 새 Symbol이라고 하자.
  7. GlobalSymbolRegistry Record { [[Key]]: stringKey, [[Symbol]]: newSymbol }를 globalSymbolRegistry에 추가한다.
  8. newSymbol을 반환한다.

20.4.2.3 Symbol.hasInstance

Symbol.hasInstance의 initial value는 well-known symbol %Symbol.hasInstance%입니다(Table 1).

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

20.4.2.4 Symbol.isConcatSpreadable

Symbol.isConcatSpreadable의 initial value는 well-known symbol %Symbol.isConcatSpreadable%입니다(Table 1).

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

20.4.2.5 Symbol.iterator

Symbol.iterator의 initial value는 well-known symbol %Symbol.iterator%입니다(Table 1).

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

20.4.2.6 Symbol.keyFor ( symbol )

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

  1. symbol이 Symbol이 아니면, TypeError exception을 throw한다.
  2. KeyForSymbol(symbol)을 반환한다.

20.4.2.7 Symbol.match

Symbol.match의 initial value는 well-known symbol %Symbol.match%입니다(Table 1).

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

20.4.2.8 Symbol.matchAll

Symbol.matchAll의 initial value는 well-known symbol %Symbol.matchAll%입니다(Table 1).

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

20.4.2.9 Symbol.prototype

Symbol.prototype의 initial value는 Symbol prototype object입니다.

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

20.4.2.10 Symbol.replace

Symbol.replace의 initial value는 well-known symbol %Symbol.replace%입니다(Table 1).

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

20.4.2.11 Symbol.search

Symbol.search의 initial value는 well-known symbol %Symbol.search%입니다(Table 1).

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

20.4.2.12 Symbol.species

Symbol.species의 initial value는 well-known symbol %Symbol.species%입니다(Table 1).

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

20.4.2.13 Symbol.split

Symbol.split의 initial value는 well-known symbol %Symbol.split%입니다(Table 1).

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

20.4.2.14 Symbol.toPrimitive

Symbol.toPrimitive의 initial value는 well-known symbol %Symbol.toPrimitive%입니다(Table 1).

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

20.4.2.15 Symbol.toStringTag

Symbol.toStringTag의 initial value는 well-known symbol %Symbol.toStringTag%입니다(Table 1).

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

20.4.2.16 Symbol.unscopables

Symbol.unscopables의 initial value는 well-known symbol %Symbol.unscopables%입니다(Table 1).

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

20.4.3 Properties of the Symbol Prototype Object

Symbol prototype object는:

  • %Symbol.prototype%입니다.
  • ordinary object입니다.
  • Symbol instance가 아니며 [[SymbolData]] internal slot을 가지지 않습니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.

20.4.3.1 Symbol.prototype.constructor

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

20.4.3.2 get Symbol.prototype.description

Symbol.prototype.description은 set accessor function이 undefinedaccessor property입니다. 그 get accessor function은 called될 때 다음 step을 수행합니다:

  1. symbol을 ? ThisSymbolValue(this value)로 둔다.
  2. symbol.[[Description]]을 반환한다.

20.4.3.3 Symbol.prototype.toString ( )

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

  1. symbol을 ? ThisSymbolValue(this value)로 둔다.
  2. SymbolDescriptiveString(symbol)을 반환한다.

20.4.3.3.1 SymbolDescriptiveString ( symbol )

The abstract operation SymbolDescriptiveString takes argument symbol (a Symbol) and returns a String. It performs the following steps when called:

  1. descriptionsymbol.[[Description]]이라고 하자.
  2. descriptionundefined이면, description을 빈 String으로 설정한다.
  3. Assert: description은 String이다.
  4. "Symbol(", description")"string-concatenation을 반환한다.

20.4.3.4 Symbol.prototype.valueOf ( )

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

  1. ThisSymbolValue(this value)를 반환한다.

20.4.3.4.1 ThisSymbolValue ( arg )

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

  1. arg가 Symbol이면, arg를 반환한다.
  2. arg가 Object이고 arg[[SymbolData]] internal slot을 가지면, 다음을 수행한다.
    1. symbolarg.[[SymbolData]]로 둔다.
    2. Assert: symbol은 Symbol이다.
    3. symbol을 반환한다.
  3. TypeError exception을 throw한다.

20.4.3.5 Symbol.prototype [ %Symbol.toPrimitive% ] ( hint )

이 method는 ECMAScript language operator가 Symbol object를 primitive value로 convert하기 위해 called합니다.

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

  1. ThisSymbolValue(this value)를 반환한다.
Note

argument는 ignored됩니다.

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

이 method의 "name" property의 value는 "[Symbol.toPrimitive]"입니다.

20.4.3.6 Symbol.prototype [ %Symbol.toStringTag% ]

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

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

20.4.4 Properties of Symbol Instances

Symbol instance는 Symbol prototype object에서 property를 inherit하는 ordinary object입니다. Symbol instance는 [[SymbolData]] internal slot을 가집니다. [[SymbolData]] internal slot은 이 Symbol object가 represented하는 Symbol value입니다.

20.4.5 Abstract Operations for Symbols

20.4.5.1 GlobalSymbolRegistry 레코드

GlobalSymbolRegistry RecordSymbol.for를 통해 등록된 Symbol 값과 String 키를 연결하는 데 사용되는 Record 값이다.

GlobalSymbolRegistry Records에는 Table 59에 나열된 필드가 있다.

Table 59: GlobalSymbolRegistry Record 필드
필드 이름 사용법
[[Key]] String Symbol을 전역적으로 식별하는 데 사용되는 문자열 키.
[[Symbol]] Symbol 어떤 realm에서도 가져올 수 있는 심벌.

20.4.5.2 KeyForSymbol ( symbol )

The abstract operation KeyForSymbol takes argument symbol (a Symbol) and returns a String or undefined. symbol이 둘러싸는 에이전트의 [[GlobalSymbolRegistry]] List 안에 있으면, symbol을 등록하는 데 사용된 String이 반환된다. It performs the following steps when called:

  1. agentRecord를 둘러싸는 에이전트의 Agent Record라고 하자.
  2. globalSymbolRegistryagentRecord.[[GlobalSymbolRegistry]]라고 하자.
  3. globalSymbolRegistry의 각 요소 element에 대해, 다음을 수행한다.
    1. SameValue(element.[[Symbol]], symbol)가 true이면, element.[[Key]]를 반환한다.
  4. 단언: globalSymbolRegistry는 현재 symbol에 대한 항목을 포함하지 않는다.
  5. undefined를 반환한다.

20.5 Error Objects

Error object의 instance는 runtime error가 occur할 때 exception으로 thrown됩니다. Error object는 user-defined exception class를 위한 base object로도 serve할 수 있습니다.

ECMAScript 구현이 런타임 오류를 감지하면, 20.5.5에 정의된 NativeError 객체 중 하나의 새 인스턴스, 또는 20.5.7에 정의된 AggregateError 객체나 20.5.8에 정의된 SuppressedError 객체 중 하나의 새 인스턴스를 던진다. 이러한 각 객체는 아래에 설명된 구조를 가지며, NativeError 대신 생성자 이름으로 사용되는 이름, 프로토타입 객체의 "name" 속성, 프로토타입 객체의 구현 정의 "message" 속성, 그리고 %AggregateError% 전용 "errors" 속성 또는 %SuppressedError% 전용 "error""suppressed" 속성의 존재 여부에서만 다르다.

20.5.1 The Error Constructor

Error constructor는:

  • %Error%입니다.
  • global object"Error" property의 initial value입니다.
  • constructor가 아니라 function으로 called될 때 new Error object를 create하고 initialize합니다. 따라서 function call Error(…)은 same arguments를 가진 object creation expression new Error(…)과 equivalent합니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다. specified Error behaviour를 inherit하려는 subclass constructor[[ErrorData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 Error constructor에 대한 super call을 include해야 합니다.

20.5.1.1 Error ( message [ , options ] )

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

  1. NewTarget이 undefined이면, newTarget을 active function object로 둔다; 그렇지 않으면 newTarget을 NewTarget으로 둔다.
  2. obj를 ? OrdinaryCreateFromConstructor(newTarget, "%Error.prototype%", « [[ErrorData]] »)로 둔다.
  3. messageundefined가 아니면, 다음을 수행한다.
    1. messageString을 ? ToString(message)로 둔다.
    2. CreateNonEnumerableDataPropertyOrThrow(obj, "message", messageString)을 수행한다.
  4. InstallErrorCause(obj, options)를 수행한다.
  5. obj를 반환한다.

20.5.2 Properties of the Error Constructor

Error constructor는:

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

20.5.2.1 Error.isError ( arg )

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

  1. arg가 Object가 아니면, false를 반환한다.
  2. arg[[ErrorData]] internal slot을 가지지 않으면, false를 반환한다.
  3. true를 반환한다.

20.5.2.2 Error.prototype

Error.prototype의 initial value는 Error prototype object입니다.

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

20.5.3 Properties of the Error Prototype Object

Error prototype object는:

  • %Error.prototype%입니다.
  • ordinary object입니다.
  • Error instance가 아니며 [[ErrorData]] internal slot을 가지지 않습니다.
  • value가 %Object.prototype%[[Prototype]] internal slot을 가집니다.

20.5.3.1 Error.prototype.constructor

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

20.5.3.2 Error.prototype.message

Error.prototype.message의 initial value는 empty String입니다.

20.5.3.3 Error.prototype.name

Error.prototype.name의 initial value는 "Error"입니다.

20.5.3.4 Error.prototype.toString ( )

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

  1. objthis value로 둔다.
  2. obj가 Object가 아니면, TypeError exception을 throw한다.
  3. name을 ? Get(obj, "name")로 둔다.
  4. nameundefined이면, name"Error"로 설정한다; 그렇지 않으면 name을 ? ToString(name)으로 설정한다.
  5. message를 ? Get(obj, "message")로 둔다.
  6. messageundefined이면, message를 empty String으로 설정한다; 그렇지 않으면 message를 ? ToString(message)로 설정한다.
  7. name이 empty String이면, message를 반환한다.
  8. message가 empty String이면, name을 반환한다.
  9. name, code unit 0x003A (COLON), code unit 0x0020 (SPACE), 및 messagestring-concatenation을 반환한다.

20.5.4 Properties of Error Instances

Error 인스턴스는 Error 프로토타입 객체에서 속성을 상속하고 값이 undefined[[ErrorData]] 내부 슬롯을 갖는 일반 객체이다. [[ErrorData]]의 유일하게 명세된 용도는 Object.prototype.toStringError.isError 안에서 Error, AggregateError, SuppressedError 및 NativeError 인스턴스를 Error 객체로 식별하는 것이다.

20.5.5 Native Error Types Used in This Standard

아래의 NativeError 객체 중 하나, 또는 AggregateError 객체나 SuppressedError 객체 중 하나의 새 인스턴스는 런타임 오류가 감지될 때 던져진다. 모든 NativeError 객체는 20.5.6에 설명된 것처럼 동일한 구조를 공유한다.

20.5.5.1 EvalError

EvalError constructor%EvalError%입니다.

이 exception은 currently 이 specification 안에서 used되지 않습니다. 이 object는 이 specification의 previous edition과의 compatibility를 위해 remains합니다.

20.5.5.2 RangeError

RangeError constructor%RangeError%입니다.

allowable value의 set 또는 range 안에 있지 않은 value를 indicates합니다.

20.5.5.3 ReferenceError

ReferenceError constructor%ReferenceError%입니다.

invalid reference가 detected되었음을 indicate합니다.

20.5.5.4 SyntaxError

SyntaxError constructor%SyntaxError%입니다.

parsing error가 occurred했음을 indicates합니다.

20.5.5.5 TypeError

TypeError constructor%TypeError%입니다.

TypeError는 other NativeError object 중 none이 failure cause의 appropriate indication이 아닐 때 unsuccessful operation을 indicate하는 데 사용됩니다.

20.5.5.6 URIError

URIError constructor%URIError%입니다.

global URI handling function 중 하나가 its definition과 incompatible한 way로 사용되었음을 indicates합니다.

20.5.6 NativeError Object Structure

이러한 object 각각은 below에 described된 structure를 가지며, constructor name으로 사용되는 name 및 prototype object의 "name" property만 다릅니다.

각 error object에 대해, definition 안의 NativeError에 대한 reference는 20.5.5의 appropriate error object name으로 replaced되어야 합니다.

20.5.6.1 The NativeError Constructors

NativeError constructor는:

  • constructor가 아니라 function으로 called될 때 new NativeError object를 create하고 initialize합니다. object를 function으로 call하는 것은 same arguments를 가지고 constructor로 call하는 것과 equivalent합니다. 따라서 function call NativeError(…)는 same arguments를 가진 object creation expression new NativeError(…)과 equivalent합니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다. specified NativeError behaviour를 inherit하려는 subclass constructor[[ErrorData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 NativeError constructor에 대한 super call을 include해야 합니다.

20.5.6.1.1 NativeError ( message [ , options ] )

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

  1. NewTarget이 undefined이면, newTarget을 active function object로 둔다; 그렇지 않으면 newTarget을 NewTarget으로 둔다.
  2. obj를 ? OrdinaryCreateFromConstructor(newTarget, "%NativeError.prototype%", « [[ErrorData]] »)로 둔다.
  3. messageundefined가 아니면, 다음을 수행한다.
    1. messageString을 ? ToString(message)으로 둔다.
    2. CreateNonEnumerableDataPropertyOrThrow(obj, "message", messageString)을 수행한다.
  4. InstallErrorCause(obj, options)를 수행한다.
  5. obj를 반환한다.

step 2에 passed되는 string의 actual value는 which NativeError constructor가 defined되는지에 corresponding하여 "%EvalError.prototype%", "%RangeError.prototype%", "%ReferenceError.prototype%", "%SyntaxError.prototype%", "%TypeError.prototype%", 또는 "%URIError.prototype%" 중 하나입니다.

20.5.6.2 Properties of the NativeError Constructors

NativeError constructor는:

  • value가 %Error%[[Prototype]] internal slot을 가집니다.
  • String value "NativeError"인 value를 가진 "name" property를 가집니다.
  • 다음 property를 가집니다:

20.5.6.2.1 NativeError.prototype

NativeError.prototype의 initial value는 NativeError prototype object(20.5.6.3)입니다. 각 NativeError constructor는 distinct prototype object를 가집니다.

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

20.5.6.3 Properties of the NativeError Prototype Objects

NativeError prototype object는:

  • ordinary object입니다.
  • Error instance가 아니며 [[ErrorData]] internal slot을 가지지 않습니다.
  • value가 %Error.prototype%[[Prototype]] internal slot을 가집니다.

20.5.6.3.1 NativeError.prototype.constructor

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

20.5.6.3.2 NativeError.prototype.message

given NativeError constructor에 대한 prototype의 "message" property의 initial value는 empty String입니다.

20.5.6.3.3 NativeError.prototype.name

given NativeError constructor에 대한 prototype의 "name" property의 initial value는 constructor의 name(NativeError 대신 사용된 name)으로 구성되는 String value입니다.

20.5.6.4 Properties of NativeError Instances

NativeError 인스턴스는 해당 NativeError 프로토타입 객체에서 속성을 상속하고 값이 undefined[[ErrorData]] 내부 슬롯을 갖는 일반 객체이다. [[ErrorData]]의 유일하게 명세된 용도는 Object.prototype.toString(20.1.3.6) 및 Error.isError(20.5.2.1)가 Error, AggregateError, SuppressedError 또는 NativeError 인스턴스를 식별하는 것이다.

20.5.7 AggregateError Objects

20.5.7.1 The AggregateError Constructor

AggregateError constructor는:

  • %AggregateError%입니다.
  • global object"AggregateError" property의 initial value입니다.
  • constructor가 아니라 function으로 called될 때 new AggregateError object를 create하고 initialize합니다. 따라서 function call AggregateError(…)은 same arguments를 가진 object creation expression new AggregateError(…)과 equivalent합니다.
  • class definition의 extends clause의 value로 사용될 수 있습니다. specified AggregateError behaviour를 inherit하려는 subclass constructor[[ErrorData]] internal slot을 가진 subclass instance를 create하고 initialize하기 위해 AggregateError constructor에 대한 super call을 include해야 합니다.

20.5.7.1.1 AggregateError ( errors, message [ , options ] )

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

  1. NewTarget이 undefined이면, newTarget을 active function object로 둔다; 그렇지 않으면 newTarget을 NewTarget으로 둔다.
  2. obj를 ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]] »)로 둔다.
  3. messageundefined가 아니면, 다음을 수행한다.
    1. messageString을 ? ToString(message)으로 둔다.
    2. CreateNonEnumerableDataPropertyOrThrow(obj, "message", messageString)을 수행한다.
  4. InstallErrorCause(obj, options)를 수행한다.
  5. errorsList를 ? IteratorToList(? GetIterator(errors, sync))로 둔다.
  6. DefinePropertyOrThrow(obj, "errors", PropertyDescriptor { [[Configurable]]: true, [[Enumerable]]: false, [[Writable]]: true, [[Value]]: CreateArrayFromList(errorsList) })를 수행한다.
  7. obj를 반환한다.

20.5.7.2 Properties of the AggregateError Constructor

AggregateError constructor는:

  • value가 %Error%[[Prototype]] internal slot을 가집니다.
  • 다음 property를 가집니다:

20.5.7.2.1 AggregateError.prototype

AggregateError.prototype의 initial value는 %AggregateError.prototype%입니다.

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

20.5.7.3 Properties of the AggregateError Prototype Object

AggregateError prototype object는:

  • %AggregateError.prototype%입니다.
  • ordinary object입니다.
  • Error instance도 AggregateError instance도 아니며 [[ErrorData]] internal slot을 가지지 않습니다.
  • value가 %Error.prototype%[[Prototype]] internal slot을 가집니다.

20.5.7.3.1 AggregateError.prototype.constructor

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

20.5.7.3.2 AggregateError.prototype.message

AggregateError.prototype.message의 initial value는 empty String입니다.

20.5.7.3.3 AggregateError.prototype.name

AggregateError.prototype.name의 initial value는 "AggregateError"입니다.

20.5.7.4 AggregateError 인스턴스의 속성

AggregateError 인스턴스는 해당 AggregateError 프로토타입 객체에서 속성을 상속하고 값이 undefined[[ErrorData]] 내부 슬롯을 갖는 일반 객체이다. [[ErrorData]]의 유일하게 명세된 용도는 Object.prototype.toString(20.1.3.6) 및 Error.isError(20.5.2.1)가 Error, AggregateError, SuppressedError 또는 NativeError 인스턴스를 식별하는 것이다.

20.5.8 SuppressedError 객체

20.5.8.1 SuppressedError 생성자

SuppressedError 생성자는 다음과 같다:

  • %SuppressedError%이다.
  • 전역 객체의 "SuppressedError" 속성의 초기값이다.
  • 생성자가 아니라 함수로 호출될 때 새 SuppressedError 객체를 생성하고 초기화한다. 따라서 함수 호출 SuppressedError(…)는 같은 인수를 사용하는 객체 생성 표현식 new SuppressedError(…)와 동등하다.
  • 클래스 정의의 extends 절 값으로 사용할 수 있다. 지정된 SuppressedError 동작을 상속하려는 하위 클래스 생성자는 [[ErrorData]] 내부 슬롯을 갖는 하위 클래스 인스턴스를 생성하고 초기화하기 위해 SuppressedError 생성자에 대한 super 호출을 포함해야 한다.

20.5.8.1.1 SuppressedError ( error, suppressed, message )

이 함수는 호출될 때 다음 단계를 수행한다:

  1. NewTarget이 undefined이면 newTarget활성 함수 객체로 둔다. 그렇지 않으면 newTarget을 NewTarget으로 둔다.
  2. obj를 ? OrdinaryCreateFromConstructor(newTarget, "%SuppressedError.prototype%", « [[ErrorData]] »)로 둔다.
  3. messageundefined가 아니면,
    1. messageString을 ? ToString(message)로 둔다.
    2. CreateNonEnumerableDataPropertyOrThrow(obj, "message", messageString)를 수행한다.
  4. CreateNonEnumerableDataPropertyOrThrow(obj, "error", error)를 수행한다.
  5. CreateNonEnumerableDataPropertyOrThrow(obj, "suppressed", suppressed)를 수행한다.
  6. obj를 반환한다.

20.5.8.2 SuppressedError 생성자의 속성

SuppressedError 생성자는 다음과 같다:

  • 값이 %Error%[[Prototype]] 내부 슬롯을 갖는다.
  • 다음 속성을 갖는다:

20.5.8.2.1 SuppressedError.prototype

SuppressedError.prototype의 초기값은 SuppressedError 프로토타입 객체이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 속성을 갖는다.

20.5.8.3 SuppressedError 프로토타입 객체의 속성

SuppressedError 프로토타입 객체는 다음과 같다:

  • %SuppressedError.prototype%이다.
  • 일반 객체이다.
  • Error 인스턴스 또는 SuppressedError 인스턴스가 아니며 [[ErrorData]] 내부 슬롯을 갖지 않는다.
  • 값이 %Error.prototype%[[Prototype]] 내부 슬롯을 갖는다.

20.5.8.3.1 SuppressedError.prototype.constructor

SuppressedError.prototype.constructor의 초기값은 %SuppressedError%이다.

20.5.8.3.2 SuppressedError.prototype.message

SuppressedError.prototype.message의 초기값은 빈 String이다.

20.5.8.3.3 SuppressedError.prototype.name

SuppressedError.prototype.name의 초기값은 "SuppressedError"이다.

20.5.8.4 SuppressedError 인스턴스의 속성

SuppressedError 인스턴스는 해당 SuppressedError 프로토타입 객체에서 속성을 상속하고 값이 undefined[[ErrorData]] 내부 슬롯을 갖는 일반 객체이다. [[ErrorData]]의 유일하게 명세된 용도는 Object.prototype.toStringError.isError 안에서 Error, AggregateError, SuppressedError 및 NativeError 인스턴스를 Error 객체로 식별하는 것이다.

20.5.9 Abstract Operations for Error Objects

20.5.9.1 InstallErrorCause ( obj, options )

The abstract operation InstallErrorCause takes arguments obj (an Object) and options (an ECMAScript language value) and returns either a normal completion containing unused or a throw completion. options"cause" property가 present할 때 obj"cause" property를 create하는 데 사용됩니다. It performs the following steps when called:

  1. options가 Object이고 ? HasProperty(options, "cause")가 true이면, 다음을 수행한다.
    1. cause를 ? Get(options, "cause")로 둔다.
    2. CreateNonEnumerableDataPropertyOrThrow(obj, "cause", cause)를 수행한다.
  2. unused를 반환한다.