10.1 Ordinary Object Internal Methods and Internal Slots
All ordinary objects have an internal slot called [[Prototype]]. The value of this internal slot is either null or an object and is used for implementing inheritance. Assume a property named P is missing from an ordinary objectO but exists on its [[Prototype]] object. If P refers to a data property on the [[Prototype]] object, O inherits it for get access, making it behave as if P was a property of O. If P refers to a writable data property on the [[Prototype]] object, set access of P on O creates a new data property named P on O. If P refers to a non-writable data property on the [[Prototype]] object, set access of P on O fails. If P refers to an accessor property on the [[Prototype]] object, the accessor is inherited by O for both get access and set access.
Every ordinary object has a Boolean-valued [[Extensible]] internal slot which is used to fulfill the extensibility-related internal method invariants specified in 6.1.7.3. Namely, once the value of an object's [[Extensible]] internal slot has been set to false, it is no longer possible to add properties to the object, to modify the value of the object's [[Prototype]] internal slot, or to subsequently change the value of [[Extensible]] to true.
Each ordinary object internal method delegates to a similarly-named abstract operation. If such an abstract operation depends on another internal method, then the internal method is invoked on O rather than calling the similarly-named abstract operation directly. These semantics ensure that exotic objects have their overridden internal methods invoked when ordinary object internal methods are applied to them.
10.1.1[[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of an ordinary objectO takes no arguments and returns a normal completion containing either an Object or null. It performs the following steps when called:
The abstract operation OrdinaryGetPrototypeOf takes argument O (an Object) and returns an Object or null. It performs the following steps when called:
Return O.[[Prototype]].
10.1.2[[SetPrototypeOf]] ( V )
The [[SetPrototypeOf]] internal method of an ordinary objectO takes argument V (an Object or null) and returns a normal completion containing a Boolean. It performs the following steps when called:
The abstract operation OrdinarySetPrototypeOf takes arguments O (an Object) and V (an Object or null) and returns a Boolean. It performs the following steps when called:
If p.[[GetPrototypeOf]] is not the ordinary object internal method defined in 10.1.1, set done to true.
Else, set p to p.[[Prototype]].
Set O.[[Prototype]] to V.
Return true.
Note
The loop in step 7 guarantees that there will be no cycles in any prototype chain that only includes objects that use the ordinary object definitions for [[GetPrototypeOf]] and [[SetPrototypeOf]].
10.1.3[[IsExtensible]] ( )
The [[IsExtensible]] internal method of an ordinary objectO takes no arguments and returns a normal completion containing a Boolean. It performs the following steps when called:
The abstract operation OrdinaryIsExtensible takes argument O (an Object) and returns a Boolean. It performs the following steps when called:
Return O.[[Extensible]].
10.1.4[[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of an ordinary objectO takes no arguments and returns a normal completion containingtrue. It performs the following steps when called:
The abstract operation OrdinaryGetOwnProperty takes arguments O (an Object) and P (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:
If O does not have an own property with key P, return undefined.
10.1.6.2 IsCompatiblePropertyDescriptor ( Extensible, Desc, Current )
The abstract operation IsCompatiblePropertyDescriptor takes arguments Extensible (a Boolean), Desc (a Property Descriptor), and Current (a Property Descriptor or undefined) and returns a Boolean. It performs the following steps when called:
10.1.6.3 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )
The abstract operation ValidateAndApplyPropertyDescriptor takes arguments O (an Object or undefined), P (a property key), extensible (a Boolean), Desc (a Property Descriptor), and current (a Property Descriptor or undefined) and returns a Boolean. It returns true if and only if Desc can be applied as the property of an object with specified extensibility and current property current while upholding invariants. When such application is possible and O is not undefined, it is performed for the property named P (which is created if necessary). It performs the following steps when called:
Create an own accessor property named P of object O whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute's default value otherwise.
Else,
Create an own data property named P of object O whose [[Value]], [[Writable]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute's default value otherwise.
If Desc has a [[Get]] field and SameValue(Desc.[[Get]], current.[[Get]]) is false, return false.
If Desc has a [[Set]] field and SameValue(Desc.[[Set]], current.[[Set]]) is false, return false.
Else if current.[[Writable]] is false, then
If Desc has a [[Writable]] field and Desc.[[Writable]] is true, return false.
NOTE: SameValue returns true for NaN values which may be distinguishable by other means. Returning here ensures that any existing property of O remains unmodified.
If Desc has a [[Value]] field, return SameValue(Desc.[[Value]], current.[[Value]]).
If Desc has a [[Configurable]] field, let configurable be Desc.[[Configurable]]; else let configurable be current.[[Configurable]].
If Desc has a [[Enumerable]] field, let enumerable be Desc.[[Enumerable]]; else let enumerable be current.[[Enumerable]].
Replace the property named P of object O with an accessor property whose [[Configurable]] and [[Enumerable]] attributes are set to configurable and enumerable, respectively, and whose [[Get]] and [[Set]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute's default value otherwise.
If Desc has a [[Configurable]] field, let configurable be Desc.[[Configurable]]; else let configurable be current.[[Configurable]].
If Desc has a [[Enumerable]] field, let enumerable be Desc.[[Enumerable]]; else let enumerable be current.[[Enumerable]].
Replace the property named P of object O with a data property whose [[Configurable]] and [[Enumerable]] attributes are set to configurable and enumerable, respectively, and whose [[Value]] and [[Writable]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute's default value otherwise.
Else,
For each field of Desc, set the corresponding attribute of the property named P of object O to the value of the field.
The abstract operation OrdinaryOwnPropertyKeys takes argument O (an Object) and returns a List of property keys. It performs the following steps when called:
For each own property keyP of O such that P is an array index, in ascending numeric index order, do
Append P to keys.
For each own property keyP of O such that Pis a String and P is not an array index, in ascending chronological order of property creation, do
Append P to keys.
For each own property keyP of O such that Pis a Symbol, in ascending chronological order of property creation, do
Append P to keys.
Return 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. It is used to specify the runtime creation of new ordinary objects. additionalInternalSlotsList contains the names of additional internal slots that must be defined as part of the object, beyond [[Prototype]] and [[Extensible]]. If additionalInternalSlotsList is not provided, a new empty List is used. It performs the following steps when called:
Let internalSlotsList be « [[Prototype]], [[Extensible]] ».
If additionalInternalSlotsList is present, set internalSlotsList to the list-concatenation of internalSlotsList and additionalInternalSlotsList.
Although OrdinaryObjectCreate does little more than call MakeBasicObject, its use communicates the intention to create an ordinary object, and not an exotic one. Thus, within this specification, it is not called by any algorithm that subsequently modifies the internal methods of the object in ways that would make the result non-ordinary. Operations that create exotic objects invoke MakeBasicObject directly.
The abstract operation OrdinaryCreateFromConstructor takes arguments constructor (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. It creates an ordinary object whose [[Prototype]] value is retrieved from a constructor's "prototype" property, if it exists. Otherwise the intrinsic named by intrinsicDefaultProto is used for [[Prototype]]. internalSlotsList contains the names of additional internal slots that must be defined as part of the object. If internalSlotsList is not provided, a new empty List is used. It performs the following steps when called:
Assert: intrinsicDefaultProto is this specification's name of an intrinsic object. The corresponding object must be an intrinsic that is intended to be used as the [[Prototype]] value of an object.
The abstract operation GetPrototypeFromConstructor takes arguments constructor (a function object) and intrinsicDefaultProto (a String) and returns either a normal completion containing an Object or a throw completion. It determines the [[Prototype]] value that should be used to create an object corresponding to a specific constructor. The value is retrieved from the constructor's "prototype" property, if it exists. Otherwise the intrinsic named by intrinsicDefaultProto is used for [[Prototype]]. It performs the following steps when called:
Assert: intrinsicDefaultProto is this specification's name of an intrinsic object. The corresponding object must be an intrinsic that is intended to be used as the [[Prototype]] value of an object.
Set proto to realm's intrinsic object named intrinsicDefaultProto.
Return proto.
Note
If constructor does not supply a [[Prototype]] value, the default value that is used is obtained from the realm of the constructor function rather than from the running execution context.
10.1.15 RequireInternalSlot ( O, internalSlot )
The abstract operation RequireInternalSlot takes arguments O (an ECMAScript language value) and internalSlot (an internal slot name) and returns either a normal completion containingunused or a throw completion. It throws an exception unless Ois an Object and has the given internal slot. It performs the following steps when called:
The PrivateEnvironment Record for Private Names that the function was closed over. null if this function is not syntactically contained within a class. Used as the outer PrivateEnvironment for inner classes when evaluating the code of the function.
The script or module in which the function was created.
[[ThisMode]]
lexical, strict, or global
Defines how this references are interpreted within the formal parameters and code body of the function. lexical means that this refers to the this value of a lexically enclosing function. strict means that the this value is used exactly as provided by an invocation of the function. global means that a this value of undefined or null is interpreted as a reference to the global object, and any other this value is first passed to ToObject.
If the function is created as the initializer of a class field, the name to use for NamedEvaluation of the field; empty otherwise.
[[IsClassConstructor]]
a Boolean
Indicates whether the function is a class constructor. (If true, invoking the function's [[Call]] will immediately throw a TypeError exception.)
All ECMAScript function objects have the [[Call]] internal method defined here. ECMAScript functions that are also constructors in addition have the [[Construct]] internal method.
When calleeContext is removed from the execution context stack in step 7 it must not be destroyed if it is suspended and retained for later resumption by an accessible Generator.
10.2.1.1 PrepareForOrdinaryCall ( F, newTarget )
The abstract operation PrepareForOrdinaryCall takes arguments F (an ECMAScript function object) and newTarget (an Object or undefined) and returns an execution context. It performs the following steps when called:
The abstract operation OrdinaryCallBindThis takes arguments F (an ECMAScript function object), calleeContext (an execution context), and thisArgument (an ECMAScript language value) and returns unused. It performs the following steps when called:
Let thisMode be F.[[ThisMode]].
If thisMode is lexical, return unused.
Let calleeRealm be F.[[Realm]].
Let localEnv be the LexicalEnvironment of calleeContext.
Even though field initializers constitute a function boundary, calling FunctionDeclarationInstantiation does not have any observable effect and so is omitted.
The abstract operation OrdinaryFunctionCreate takes arguments functionPrototype (an Object), sourceText (a sequence of Unicode code points), ParameterList (a Parse Node), Body (a Parse Node), thisMode (lexical-this or non-lexical-this), env (an Environment Record), and privateEnv (a PrivateEnvironment Record or null) and returns an ECMAScript function object. It is used to specify the runtime creation of a new function with a default [[Call]] internal method and no [[Construct]] internal method (although one may be subsequently added by an operation such as MakeConstructor). sourceText is the source text of the syntactic definition of the function to be created. It performs the following steps when called:
Let internalSlotsList be the internal slots listed in Table 30.
The abstract operation AddRestrictedFunctionProperties takes arguments F (a function object) and realm (a Realm Record) and returns unused. It performs the following steps when called:
The abstract operation MakeConstructor takes argument F (an ECMAScript function object or a built-in function object) and optional arguments writablePrototype (a Boolean) and prototype (an Object) and returns unused. It converts F into a constructor. It performs the following steps when called:
The abstract operation MakeClassConstructor takes argument F (an ECMAScript function object) and returns unused. It performs the following steps when called:
The abstract operation MakeMethod takes arguments F (an ECMAScript function object) and homeObject (an Object) and returns unused. It configures F as a method. It performs the following steps when called:
The abstract operation SetFunctionName takes arguments F (a function object) and name (a property key or Private Name) and optional argument prefix (a String) and returns unused. It adds a "name" property to F. It performs the following steps when called:
Assert: F is an extensible object that does not have a "name" own property.
The abstract operation SetFunctionLength takes arguments F (a function object) and length (a non-negative integer or +∞) and returns unused. It adds a "length" property to F. It performs the following steps when called:
Assert: F is an extensible object that does not have a "length" own property.
When an execution context is established for evaluating an ECMAScript function a new Function Environment Record is created and bindings for each formal parameter are instantiated in that Environment Record. Each declaration in the function body is also instantiated. If the function's formal parameters do not include any default value initializers then the body declarations are instantiated in the same Environment Record as the parameters. If default value parameter initializers exist, a second Environment Record is created for the body declarations. Formal parameters and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.
Let fn be the sole element of the BoundNames of d.
If functionNames does not contain fn, then
Insert fn as the first element of functionNames.
NOTE: If there are multiple function declarations for the same name, the last declaration is used.
Insert d as the first element of functionsToInitialize.
Let argumentsObjectNeeded be true.
If func.[[ThisMode]] is lexical, then
NOTE: Arrow functions never have an arguments object.
Set argumentsObjectNeeded to false.
Else if parameterNames contains "arguments", then
Set argumentsObjectNeeded to false.
Else if hasParameterExpressions is false, then
If functionNames contains "arguments" or lexicalNames contains "arguments", then
Set argumentsObjectNeeded to false.
If strict is true or hasParameterExpressions is false, then
NOTE: Only a single Environment Record is needed for the parameters, since calls to eval in strict mode code cannot create new bindings which are visible outside of the eval.
Let env be the LexicalEnvironment of calleeContext.
Else,
NOTE: A separate Environment Record is needed to ensure that bindings created by direct eval calls in the formal parameter list are outside the environment where parameters are declared.
Let calleeEnv be the LexicalEnvironment of calleeContext.
Set the LexicalEnvironment of calleeContext to env.
For each String paramName of parameterNames, do
Let alreadyDeclared be ! env.HasBinding(paramName).
NOTE: Early errors ensure that duplicate parameter names can only occur in non-strict functions that do not have parameter default values or rest parameters.
NOTE: A mapped argument object is only provided for non-strict functions that don't have a rest parameter, any parameter default value initializers, or any destructured parameters.
NOTE: Only a single Environment Record is needed for the parameters and top-level vars.
Let instantiatedVarNames be a copy of the ListparameterBindings.
For each element n of varNames, do
If instantiatedVarNames does not contain n, then
Append n to instantiatedVarNames.
Perform ! env.CreateMutableBinding(n, false).
Perform ! env.InitializeBinding(n, undefined).
Let varEnv be env.
Else,
NOTE: A separate Environment Record is needed to ensure that closures created by expressions in the formal parameter list do not have visibility of declarations in the function body.
NOTE: Non-strict functions use a separate Environment Record for top-level lexical declarations so that a direct eval can determine whether any var scoped declarations introduced by the eval code conflict with pre-existing top-level lexically scoped declarations. This is not needed for strict functions because a strict direct eval always places all declarations into a new Environment Record.
Else,
Let lexEnv be varEnv.
Set the LexicalEnvironment of calleeContext to lexEnv.
NOTE: A lexically declared name cannot be the same as a function/generator declaration, formal parameter, or a var name. Lexically declared names are only instantiated here but not initialized.
B.3.2 provides an extension to the above algorithm that is necessary for backwards compatibility with web browser implementations of ECMAScript that predate ECMAScript 2015.
In addition to the internal slots required of every ordinary object (see 10.1), a built-in function object must also have the following internal slots:
[[Realm]], a Realm Record that represents the realm in which the function was created.
[[InitialName]], a String that is the initial name of the function. It is used by 20.2.3.5.
A built-in function object must have a [[Call]] internal method that conforms to the definition in 10.3.1.
A built-in function object has a [[Construct]] internal method if and only if it is described as a “constructor”, or some algorithm in this specification explicitly sets its [[Construct]] internal method. Such a [[Construct]] internal method must conform to the definition in 10.3.2.
An implementation may provide additional built-in function objects that are not defined in this specification.
Let result be the Completion Record that is the result of evaluatingF in a manner that conforms to the specification of F. If thisArgument is uninitialized, the this value is uninitialized; otherwise, thisArgument provides the this value. argumentsList provides the named parameters. newTarget provides the NewTarget value.
NOTE: If F is defined in this document, “the specification of F” is the behaviour specified for it via algorithm steps or other means.
When calleeContext is removed from the execution context stack it must not be destroyed if it has been suspended and retained by an accessible Generator for later resumption.
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), prototype (an Object or null), and prefix (a String) and returns a built-in function object. additionalInternalSlotsList contains the names of additional internal slots that must be defined as part of the object. This operation creates a built-in function object. It performs the following steps when called:
If prototype is not present, set prototype to realm.[[Intrinsics]].[[%Function.prototype%]].
Let internalSlotsList be a List containing the names of all the internal slots that 10.3 requires for the built-in function object that is about to be created.
Append to internalSlotsList the elements of additionalInternalSlotsList.
Let func be a new built-in function object that, when called, performs the action described by behaviour using the provided arguments as the values of the corresponding parameters specified by behaviour. The new function object has internal slots whose names are the elements of internalSlotsList, and an [[InitialName]] internal slot.
Each built-in function defined in this specification is created by calling the CreateBuiltinFunction abstract operation.
10.4 Built-in Exotic Object Internal Methods and Slots
This specification defines several kinds of built-in exotic objects. These objects generally behave similar to ordinary objects except for a few specific situations. The following exotic objects use the ordinary object internal methods except where it is explicitly specified otherwise below:
An object is a bound function exotic object if its [[Call]] and (if applicable) [[Construct]] internal methods use the following implementations, and its other essential internal methods use the definitions found in 10.1. These methods are installed in BoundFunctionCreate.
Set obj.[[BoundTargetFunction]] to targetFunction.
Set obj.[[BoundThis]] to boundThis.
Set obj.[[BoundArguments]] to boundArgs.
Return obj.
10.4.2 Array Exotic Objects
An Array is an exotic object that gives special treatment to array indexproperty keys (see 6.1.7). A property whose property name is an array index is also called an element. Every Array has a non-configurable "length" property whose value is always a non-negative integral Number whose mathematical value is strictly less than 232. The value of the "length" property is numerically greater than the name of every own property whose name is an array index; whenever an own property of an Array is created or changed, other properties are adjusted as necessary to maintain this invariant. Specifically, whenever an own property is added whose name is an array index, the value of the "length" property is changed, if necessary, to be one more than the numeric value of that array index; and whenever the value of the "length" property is changed, every own property whose name is an array index whose value is not smaller than the new length is deleted. This constraint applies only to own properties of an Array and is unaffected by "length" or array index properties that may be inherited from its prototypes.
An object is an Array exotic object (or simply, an Array) if its [[DefineOwnProperty]] internal method uses the following implementation, and its other essential internal methods use the definitions found in 10.1. These methods are installed in ArrayCreate.
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. It is used to specify the creation of new Arrays. It performs the following steps when called:
If length > 232 - 1, throw a RangeError exception.
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. It is used to specify the creation of a new Array or similar object using a constructor function that is derived from originalArray. It does not enforce that the constructor function returns an Array. It performs the following steps when called:
If originalArray was created using the standard built-in Array constructor for a realm that is not the realm of the running execution context, then a new Array is created using the realm of the running execution context. This maintains compatibility with Web browsers that have historically had that behaviour for the Array.prototype methods that now are defined using ArraySpeciesCreate.
In steps 3 and 4, if Desc.[[Value]] is an object then its valueOf method is called twice. This is legacy behaviour that was specified with this effect starting with the 2nd Edition of this specification.
10.4.3 String Exotic Objects
A String object is an exotic object that encapsulates a String value and exposes virtual integer-indexeddata properties corresponding to the individual code unit elements of the String value. String exotic objects always have a data property named "length" whose value is the length of the encapsulated String value. Both the code unit data properties and the "length" property are non-writable and non-configurable.
An object is a String exotic object (or simply, a String object) if its [[GetOwnProperty]], [[DefineOwnProperty]], and [[OwnPropertyKeys]] internal methods use the following implementations, and its other essential internal methods use the definitions found in 10.1. These methods are installed in StringCreate.
For each own property keyP of O such that Pis a String and P is not an array index, in ascending chronological order of property creation, do
Append P to keys.
For each own property keyP of O such that Pis a Symbol, in ascending chronological order of property creation, do
Append P to keys.
Return keys.
10.4.3.4 StringCreate ( value, prototype )
The abstract operation StringCreate takes arguments value (a String) and prototype (an Object) and returns a String exotic object. It is used to specify the creation of new String exotic objects. It performs the following steps when called:
Let S be MakeBasicObject(« [[Prototype]], [[Extensible]], [[StringData]] »).
Set S.[[Prototype]] to prototype.
Set S.[[StringData]] to value.
Set S.[[GetOwnProperty]] as specified in 10.4.3.1.
Set S.[[DefineOwnProperty]] as specified in 10.4.3.2.
Set S.[[OwnPropertyKeys]] as specified in 10.4.3.3.
The abstract operation StringGetOwnProperty takes arguments S (an Object that has a [[StringData]] internal slot) and P (a property key) and returns a Property Descriptor or undefined. It performs the following steps when called:
Most ECMAScript functions make an arguments object available to their code. Depending upon the characteristics of the function definition, its arguments object is either an ordinary object or an arguments exotic object. An arguments exotic object is an exotic object whose array index properties map to the formal parameters bindings of an invocation of its associated ECMAScript function.
An object is an arguments exotic object if its internal methods use the following implementations, with the ones not specified here using those found in 10.1. These methods are installed in CreateMappedArgumentsObject.
Arguments exotic objects have the same internal slots as ordinary objects. They also have a [[ParameterMap]] internal slot. Ordinary arguments objects also have a [[ParameterMap]] internal slot whose value is always undefined. For ordinary argument objects the [[ParameterMap]] internal slot is only used by Object.prototype.toString (20.1.3.6) to identify them as such.
Note 2
The integer-indexeddata properties of an arguments exotic object whose numeric name values are less than the number of formal parameters of the corresponding function object initially share their values with the corresponding argument bindings in the function's execution context. This means that changing the property changes the corresponding value of the argument binding and vice-versa. This correspondence is broken if such a property is deleted and then redefined or if the property is changed into an accessor property. If the arguments object is an ordinary object, the values of its properties are simply a copy of the arguments passed to the function and there is no dynamic linkage between the property values and the formal parameter values.
Note 3
The ParameterMap object and its property values are used as a device for specifying the arguments object correspondence to argument bindings. The ParameterMap object and the objects that are the values of its properties are not directly observable from ECMAScript code. An ECMAScript implementation does not need to actually create or use such objects to implement the specified semantics.
Note 4
Ordinary arguments objects define a non-configurable accessor property named "callee" which throws a TypeError exception on access. The "callee" property has a more specific meaning for arguments exotic objects, which are created only for some class of non-strict functions. The definition of this property in the ordinary variant exists to ensure that it is not defined in any other manner by conforming ECMAScript implementations.
Note 5
ECMAScript implementations of arguments exotic objects have historically contained an accessor property named "caller". Prior to ECMAScript 2017, this specification included the definition of a throwing "caller" property on ordinary arguments objects. Since implementations do not contain this extension any longer, ECMAScript 2017 dropped the requirement for a throwing "caller" accessor.
The abstract operation CreateUnmappedArgumentsObject takes argument argumentsList (a List of ECMAScript language values) and returns an ordinary object. It performs the following steps when called:
Let len be the number of elements in argumentsList.
The abstract operation MakeArgGetter takes arguments name (a String) and env (an Environment Record) and returns a function object. It creates a built-in function object that when executed returns the value bound for name in env. It performs the following steps when called:
Let getterClosure be a new Abstract Closure with no parameters that captures name and env and performs the following steps when called:
NOTE: getter is never directly accessible to ECMAScript code.
Return getter.
10.4.4.7.2 MakeArgSetter ( name, env )
The abstract operation MakeArgSetter takes arguments name (a String) and env (an Environment Record) and returns a function object. It creates a built-in function object that when executed sets the value bound for name in env. It performs the following steps when called:
Let setterClosure be a new Abstract Closure with parameters (value) that captures name and env and performs the following steps when called:
TypedArrays have the same internal slots as ordinary objects and additionally [[ViewedArrayBuffer]], [[ArrayLength]], [[ByteOffset]], [[ContentType]], and [[TypedArrayName]] internal slots.
An object is a TypedArray if its [[GetOwnProperty]], [[HasProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]], and [[OwnPropertyKeys]] internal methods use the definitions in this section, and its other essential internal methods use the definitions found in 10.1. These methods are installed by TypedArrayCreate.
For each own property keyP of O such that Pis a Symbol, in ascending chronological order of property creation, do
Append P to keys.
Return keys.
10.4.5.8 TypedArray With Buffer Witness Records
An TypedArray With Buffer Witness Record is a Record value used to encapsulate a TypedArray along with a cached byte length of the viewed buffer. It is used to help ensure there is a single shared memory read event of the byte length data block when the viewed buffer is a growable SharedArrayBuffer.
TypedArray With Buffer Witness Records have the fields listed in Table 32.
The byte length of the object's [[ViewedArrayBuffer]] when the Record was created.
10.4.5.9 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:
The abstract operation TypedArrayCreate takes argument prototype (an Object) and returns a TypedArray. It is used to specify the creation of new TypedArrays. It performs the following steps when called:
Let internalSlotsList be « [[Prototype]], [[Extensible]], [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] ».
Set A.[[OwnPropertyKeys]] as specified in 10.4.5.7.
Set A.[[Prototype]] to prototype.
Return A.
10.4.5.11 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:
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:
The abstract operation IsTypedArrayOutOfBounds takes argument taRecord (a TypedArray With Buffer Witness Record) and returns a Boolean. It checks if any of the object's numeric properties reference a value at an index not contained within the underlying buffer's bounds. It performs the following steps when called:
Let O be taRecord.[[Object]].
Let bufferByteLength be taRecord.[[CachedBufferByteLength]].
Assert: IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true if and only if bufferByteLength is detached.
Let byteOffsetEnd be byteOffsetStart + O.[[ArrayLength]] × elementSize.
If byteOffsetStart > bufferByteLength or byteOffsetEnd > bufferByteLength, return true.
NOTE: 0-length TypedArrays are not considered out-of-bounds.
Return false.
10.4.5.14 IsValidIntegerIndex ( O, index )
The abstract operation IsValidIntegerIndex takes arguments O (a TypedArray) and index (a Number) and returns a Boolean. It performs the following steps when called:
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, return false.
If ℝ(index) < 0 or ℝ(index) ≥ length, return false.
Return true.
10.4.5.15 TypedArrayGetElement ( O, index )
The abstract operation TypedArrayGetElement takes arguments O (a TypedArray) and index (a Number) and returns a Number, a BigInt, or undefined. It performs the following steps when called:
This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.
10.4.5.17 IsArrayBufferViewOutOfBounds ( O )
The abstract operation IsArrayBufferViewOutOfBounds takes argument O (a TypedArray or a DataView) and returns a Boolean. It checks if either any of a TypedArray's numeric properties or a DataView object's methods can reference a value at an index not contained within the underlying data block's bounds. This abstract operation exists as a convenience for upstream specifications. It performs the following steps when called:
A module namespace exotic object is an exotic object that exposes the bindings exported from an ECMAScript Module (See 16.2.3). There is a one-to-one correspondence between the String-keyed own properties of a module namespace exotic object and the binding names exported by the Module. The exported bindings include any bindings that are indirectly exported using export * export items. Each String-valued own property key is the StringValue of the corresponding exported binding name. These are the only String-keyed properties of a module namespace exotic object. Each such property has the attributes { [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: false }. Module namespace exotic objects are not extensible.
An object is a module namespace exotic object if its [[GetPrototypeOf]], [[SetPrototypeOf]], [[IsExtensible]], [[PreventExtensions]], [[GetOwnProperty]], [[DefineOwnProperty]], [[HasProperty]], [[Get]], [[Set]], [[Delete]], and [[OwnPropertyKeys]] internal methods use the definitions in this section, and its other essential internal methods use the definitions found in 10.1. These methods are installed by ModuleNamespaceCreate.
A List whose elements are the String values of the exported names exposed as own properties of this object. The list is sorted according to lexicographic code unit order.
ResolveExport is side-effect free. Each time this operation is called with a specific exportName, resolveSet pair as arguments it must return the same result. An implementation might choose to pre-compute or cache the ResolveExport results for the [[Exports]] of each module namespace exotic object.
An object is an immutable prototype exotic object if its [[SetPrototypeOf]] internal method uses the following implementation. (Its other essential internal methods may use any implementation, depending on the specific immutable prototype exotic object in question.)
The abstract operation SetImmutablePrototype takes arguments O (an Object) and V (an Object or null) and returns either a normal completion containing a Boolean or a throw completion. It performs the following steps when called:
10.5 Proxy Object Internal Methods and Internal Slots
A Proxy object is an exotic object whose essential internal methods are partially implemented using ECMAScript code. Every Proxy object has an internal slot called [[ProxyHandler]]. The value of [[ProxyHandler]] is an object, called the proxy's handler object, or null. Methods (see Table 34) of a handler object may be used to augment the implementation for one or more of the Proxy object's internal methods. Every Proxy object also has an internal slot called [[ProxyTarget]] whose value is either an object or the null value. This object is called the proxy's target object.
An object is a Proxy exotic object if its essential internal methods (including [[Call]] and [[Construct]], if applicable) use the definitions in this section. These internal methods are installed in ProxyCreate.
Table 34: 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
When a handler method is called to provide the implementation of a Proxy object internal method, the handler method is passed the proxy's target object as a parameter. A proxy's handler object does not necessarily have a method corresponding to every essential internal method. Invoking an internal method on the proxy results in the invocation of the corresponding internal method on the proxy's target object if the handler object does not have a method corresponding to the internal trap.
The [[ProxyHandler]] and [[ProxyTarget]] internal slots of a Proxy object are always initialized when the object is created and typically may not be modified. Some Proxy objects are created in a manner that permits them to be subsequently revoked. When a proxy is revoked, its [[ProxyHandler]] and [[ProxyTarget]] internal slots are set to null causing subsequent invocations of internal methods on that Proxy object to throw a TypeError exception.
Because Proxy objects permit the implementation of internal methods to be provided by arbitrary ECMAScript code, it is possible to define a Proxy object whose handler methods violates the invariants defined in 6.1.7.3. Some of the internal method invariants defined in 6.1.7.3 are essential integrity invariants. These invariants are explicitly enforced by the Proxy object internal methods specified in this section. An ECMAScript implementation must be robust in the presence of all possible invariant violations.
If SameValue(handlerProto, targetProto) is false, throw a TypeError exception.
Return handlerProto.
Note
[[GetPrototypeOf]] for Proxy objects enforces the following invariants:
The result of [[GetPrototypeOf]] must be either an Object or null.
If the target object is not extensible, [[GetPrototypeOf]] applied to the Proxy object must return the same value as [[GetPrototypeOf]] applied to the Proxy object's target object.
[[IsExtensible]] applied to the Proxy object must return the same value as [[IsExtensible]] applied to the Proxy object's target object with the same argument.
If targetDesc.[[Writable]] is true, throw a TypeError exception.
Return resultDesc.
Note
[[GetOwnProperty]] for Proxy objects enforces the following invariants:
The result of [[GetOwnProperty]] must be either an Object or undefined.
A property cannot be reported as non-existent, if it exists as a non-configurable own property of the target object.
A property cannot be reported as non-existent, if it exists as an own property of a non-extensible target object.
A property cannot be reported as existent, if it does not exist as an own property of the target object and the target object is not extensible.
A property cannot be reported as non-configurable, unless it exists as a non-configurable own property of the target object.
A property cannot be reported as both non-configurable and non-writable, unless it exists as a non-configurable, non-writable own property of the target object.
If settingConfigFalse is true and targetDesc.[[Configurable]] is true, throw a TypeError exception.
If IsDataDescriptor(targetDesc) is true, targetDesc.[[Configurable]] is false, and targetDesc.[[Writable]] is true, then
If Desc has a [[Writable]] field and Desc.[[Writable]] is false, throw a TypeError exception.
Return true.
Note
[[DefineOwnProperty]] for Proxy objects enforces the following invariants:
The result of [[DefineOwnProperty]]is a Boolean value.
A property cannot be added, if the target object is not extensible.
A property cannot be non-configurable, unless there exists a corresponding non-configurable own property of the target object.
A non-configurable property cannot be non-writable, unless there exists a corresponding non-configurable, non-writable own property of the target object.
If a property has a corresponding target object property then applying the Property Descriptor of the property to the target object using [[DefineOwnProperty]] will not throw an exception.
Let trapResult be ? Call(trap, handler, « target, P, Receiver »).
Let targetDesc be ? target.[[GetOwnProperty]](P).
If targetDesc is not undefined and targetDesc.[[Configurable]] is false, then
If IsDataDescriptor(targetDesc) is true and targetDesc.[[Writable]] is false, then
If SameValue(trapResult, targetDesc.[[Value]]) is false, throw a TypeError exception.
If IsAccessorDescriptor(targetDesc) is true and targetDesc.[[Get]] is undefined, then
If trapResult is not undefined, throw a TypeError exception.
Return trapResult.
Note
[[Get]] for Proxy objects enforces the following invariants:
The value reported for a property must be the same as the value of the corresponding target object property if the target object property is a non-writable, non-configurable own data property.
The value reported for a property must be undefined if the corresponding target object property is a non-configurable own accessor property that has undefined as its [[Get]] attribute.
Cannot change the value of a property to be different from the value of the corresponding target object property if the corresponding target object property is a non-writable, non-configurable own data property.
Cannot set the value of a property if the corresponding target object property is a non-configurable own accessor property that has undefined as its [[Set]] attribute.
A Proxy exotic object only has a [[Call]] internal method if the initial value of its [[ProxyTarget]] internal slot is an object that has a [[Call]] internal method.
A Proxy exotic object only has a [[Construct]] internal method if the initial value of its [[ProxyTarget]] internal slot is an object that has a [[Construct]] internal method.
Note 2
[[Construct]] for Proxy objects enforces the following invariants:
The result of [[Construct]] must be an Object.
10.5.14 ValidateNonRevokedProxy ( proxy )
The abstract operation ValidateNonRevokedProxy takes argument proxy (a Proxy exotic object) and returns either a normal completion containingunused or a throw completion. It throws a TypeError exception if proxy has been revoked. It performs the following steps when called:
If proxy.[[ProxyTarget]] is null, throw a TypeError exception.