10.1 Ordinary Object Internal Methods and Internal Slots
Allordinary objects have an internal slot called[[Prototype]]. The value of this internal slot is eithernull or an object and is used for implementing inheritance. Assume a property namedP is missing from anordinary objectO but exists on its[[Prototype]] object. IfP refers to adata property on the[[Prototype]] object,O inherits it for get access, making it behave as ifP was a property ofO. IfP refers to a writabledata property on the[[Prototype]] object, set access ofP onO creates a newdata property namedP onO. IfP refers to a non-writabledata property on the[[Prototype]] object, set access ofP onO fails. IfP refers to anaccessor property on the[[Prototype]] object, the accessor is inherited byO for both get access and set access.
Everyordinary object has a Boolean-valued[[Extensible]] internal slot which is used to fulfill the extensibility-related internal method invariants specified in6.1.7.3. Namely, once the value of an object's[[Extensible]] internal slot has been set tofalse, 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]] totrue.
Eachordinary 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 onO rather than calling the similarly-named abstract operation directly. These semantics ensure thatexotic objects have their overridden internal methods invoked whenordinary object internal methods are applied to them.
10.1.1[[GetPrototypeOf]] ( )
The[[GetPrototypeOf]] internal method of anordinary objectO takes no arguments and returns anormal completion containing either an Object ornull. It performs the following steps when called:
The abstract operation OrdinaryGetPrototypeOf takes argumentO (an Object) and returns an Object ornull. It performs the following steps when called:
ReturnO.[[Prototype]].
10.1.2[[SetPrototypeOf]] (V )
The[[SetPrototypeOf]] internal method of anordinary objectO takes argumentV (an Object ornull) and returns anormal completion containing a Boolean. It performs the following steps when called:
The abstract operation OrdinarySetPrototypeOf takes argumentsO (an Object) andV (an Object ornull) and returns a Boolean. It performs the following steps when called:
Ifp.[[GetPrototypeOf]] is not theordinary object internal method defined in10.1.1, setdone totrue.
Else, setp top.[[Prototype]].
SetO.[[Prototype]] toV.
Returntrue.
Note
The loop in step7 guarantees that there will be no cycles in any prototype chain that only includes objects that use theordinary object definitions for[[GetPrototypeOf]] and[[SetPrototypeOf]].
10.1.3[[IsExtensible]] ( )
The[[IsExtensible]] internal method of anordinary objectO takes no arguments and returns anormal completion containing a Boolean. It performs the following steps when called:
The abstract operation OrdinaryIsExtensible takes argumentO (an Object) and returns a Boolean. It performs the following steps when called:
ReturnO.[[Extensible]].
10.1.4[[PreventExtensions]] ( )
The[[PreventExtensions]] internal method of anordinary objectO takes no arguments and returns anormal completion containingtrue. It performs the following steps when called:
The abstract operation OrdinaryGetOwnProperty takes argumentsO (an Object) andP (aproperty key) and returns aProperty Descriptor orundefined. It performs the following steps when called:
IfO does not have an own property with keyP, returnundefined.
The abstract operation IsCompatiblePropertyDescriptor takes argumentsExtensible (a Boolean),Desc (aProperty Descriptor), andCurrent (aProperty Descriptor orundefined) and returns a Boolean. It performs the following steps when called:
The abstract operation ValidateAndApplyPropertyDescriptor takes argumentsO (an Object orundefined),P (aproperty key),extensible (a Boolean),Desc (aProperty Descriptor), andcurrent (aProperty Descriptor orundefined) and returns a Boolean. It returnstrue if and only ifDesc can be applied as the property of an object with specifiedextensibility and current propertycurrent while upholdinginvariants. When such application is possible andO is notundefined, it is performed for the property namedP (which is created if necessary). It performs the following steps when called:
Create an ownaccessor property namedP of objectO whose[[Get]],[[Set]],[[Enumerable]], and[[Configurable]] attributes are set to the value of the corresponding field inDesc ifDesc has that field, or to the attribute'sdefault value otherwise.
Else,
Create an owndata property namedP of objectO whose[[Value]],[[Writable]],[[Enumerable]], and[[Configurable]] attributes are set to the value of the corresponding field inDesc ifDesc has that field, or to the attribute'sdefault value otherwise.
IfDesc has a[[Get]] field andSameValue(Desc.[[Get]],current.[[Get]]) isfalse, returnfalse.
IfDesc has a[[Set]] field andSameValue(Desc.[[Set]],current.[[Set]]) isfalse, returnfalse.
Else ifcurrent.[[Writable]] isfalse, then
IfDesc has a[[Writable]] field andDesc.[[Writable]] istrue, returnfalse.
NOTE:SameValue returnstrue forNaN values which may be distinguishable by other means. Returning here ensures that any existing property ofO remains unmodified.
IfDesc has a[[Value]] field, returnSameValue(Desc.[[Value]],current.[[Value]]).
IfDesc has a[[Configurable]] field, letconfigurable beDesc.[[Configurable]]; else letconfigurable becurrent.[[Configurable]].
IfDesc has a[[Enumerable]] field, letenumerable beDesc.[[Enumerable]]; else letenumerable becurrent.[[Enumerable]].
Replace the property namedP of objectO with anaccessor property whose[[Configurable]] and[[Enumerable]] attributes are set toconfigurable andenumerable, respectively, and whose[[Get]] and[[Set]] attributes are set to the value of the corresponding field inDesc ifDesc has that field, or to the attribute'sdefault value otherwise.
IfDesc has a[[Configurable]] field, letconfigurable beDesc.[[Configurable]]; else letconfigurable becurrent.[[Configurable]].
IfDesc has a[[Enumerable]] field, letenumerable beDesc.[[Enumerable]]; else letenumerable becurrent.[[Enumerable]].
Replace the property namedP of objectO with adata property whose[[Configurable]] and[[Enumerable]] attributes are set toconfigurable andenumerable, respectively, and whose[[Value]] and[[Writable]] attributes are set to the value of the corresponding field inDesc ifDesc has that field, or to the attribute'sdefault value otherwise.
Else,
For each field ofDesc, set the corresponding attribute of the property namedP of objectO to the value of the field.
The abstract operation OrdinaryOwnPropertyKeys takes argumentO (an Object) and returns aList ofproperty keys. It performs the following steps when called:
The abstract operation OrdinaryObjectCreate takes argumentproto (an Object ornull) and optional argumentadditionalInternalSlotsList (aList of names of internal slots) and returns an Object. It is used to specify the runtime creation of newordinary objects.additionalInternalSlotsList contains the names of additional internal slots that must be defined as part of the object, beyond[[Prototype]] and[[Extensible]]. IfadditionalInternalSlotsList is not provided, a new emptyList is used. It performs the following steps when called:
LetinternalSlotsList be «[[Prototype]],[[Extensible]] ».
IfadditionalInternalSlotsList is present, setinternalSlotsList to thelist-concatenation ofinternalSlotsList andadditionalInternalSlotsList.
Although OrdinaryObjectCreate does little more than callMakeBasicObject, its use communicates the intention to create anordinary 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 createexotic objects invokeMakeBasicObject directly.
The abstract operation OrdinaryCreateFromConstructor takes argumentsconstructor (afunction object) andintrinsicDefaultProto (a String) and optional argumentinternalSlotsList (aList of names of internal slots) and returns either anormal completion containing an Object or athrow completion. It creates anordinary object whose[[Prototype]] value is retrieved from aconstructor's"prototype" property, if it exists. Otherwise the intrinsic named byintrinsicDefaultProto is used for[[Prototype]].internalSlotsList contains the names of additional internal slots that must be defined as part of the object. IfinternalSlotsList is not provided, a new emptyList 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 argumentsconstructor (afunction object) andintrinsicDefaultProto (a String) and returns either anormal completion containing an Object or athrow completion. It determines the[[Prototype]] value that should be used to create an object corresponding to a specificconstructor. The value is retrieved from theconstructor's"prototype" property, if it exists. Otherwise the intrinsic named byintrinsicDefaultProto 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.
Ifconstructor does not supply a[[Prototype]] value, the default value that is used is obtained from therealm of theconstructor function rather than from therunning execution context.
10.1.15 RequireInternalSlot (O,internalSlot )
The abstract operation RequireInternalSlot takes argumentsO (anECMAScript language value) andinternalSlot (an internal slot name) and returns either anormal completion containingunused or athrow completion. It throws an exception unlessOis an Object and has the given internal slot. It performs the following steps when called:
ThePrivateEnvironment Record forPrivate 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, orglobal
Defines howthis references are interpreted within the formal parameters and code body of the function.lexical means thatthis refers to thethis value of a lexically enclosing function.strict means that thethis value is used exactly as provided by an invocation of the function.global means that athis value ofundefined ornull is interpreted as a reference to theglobal object, and any otherthis value is first passed toToObject.
If the function is created as the initializer of a class field, the name to use forNamedEvaluation of the field;empty otherwise.
[[IsClassConstructor]]
a Boolean
Indicates whether the function is a classconstructor. (Iftrue, invoking the function's[[Call]] will immediately throw aTypeError exception.)
All ECMAScriptfunction objects have the[[Call]] internal method defined here. ECMAScript functions that are alsoconstructors in addition have the[[Construct]] internal method.
WhencalleeContext is removed from theexecution context stack in step7 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 argumentsF (an ECMAScriptfunction object) andnewTarget (an Object orundefined) and returns anexecution context. It performs the following steps when called:
The abstract operation OrdinaryCallBindThis takes argumentsF (an ECMAScriptfunction object),calleeContext (anexecution context), andthisArgument (anECMAScript language value) and returnsunused. It performs the following steps when called:
LetthisMode beF.[[ThisMode]].
IfthisMode islexical, returnunused.
LetcalleeRealm beF.[[Realm]].
LetlocalEnv be the LexicalEnvironment ofcalleeContext.
Even though field initializers constitute a function boundary, callingFunctionDeclarationInstantiation does not have any observable effect and so is omitted.
The abstract operation OrdinaryFunctionCreate takes argumentsfunctionPrototype (an Object),sourceText (a sequence of Unicode code points),ParameterList (aParse Node),Body (aParse Node),thisMode (lexical-this ornon-lexical-this),env (anEnvironment Record), andprivateEnv (aPrivateEnvironment Record ornull) and returns an ECMAScriptfunction 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 asMakeConstructor).sourceText is the source text of the syntactic definition of the function to be created. It performs the following steps when called:
LetinternalSlotsList be the internal slots listed inTable 28.
The abstract operation AddRestrictedFunctionProperties takes argumentsF (afunction object) andrealm (aRealm Record) and returnsunused. It performs the following steps when called:
The abstract operation MakeConstructor takes argumentF (an ECMAScriptfunction object or a built-infunction object) and optional argumentswritablePrototype (a Boolean) andprototype (an Object) and returnsunused. It convertsF into aconstructor. It performs the following steps when called:
The abstract operation MakeClassConstructor takes argumentF (an ECMAScriptfunction object) and returnsunused. It performs the following steps when called:
The abstract operation MakeMethod takes argumentsF (an ECMAScriptfunction object) andhomeObject (an Object) and returnsunused. It configuresF as a method. It performs the following steps when called:
The abstract operation SetFunctionName takes argumentsF (afunction object) andname (aproperty key orPrivate Name) and optional argumentprefix (a String) and returnsunused. It adds a"name" property toF. 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 argumentsF (afunction object) andlength (a non-negativeinteger or +∞) and returnsunused. It adds a"length" property toF. It performs the following steps when called:
Assert:F is an extensible object that does not have a"length" own property.
When anexecution context is established for evaluating an ECMAScript function a newFunction Environment Record is created and bindings for each formal parameter are instantiated in thatEnvironment 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 sameEnvironment Record as the parameters. If default value parameter initializers exist, a secondEnvironment 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.
NOTE: If there are multiple function declarations for the same name, the last declaration is used.
Insertd as the first element offunctionsToInitialize.
LetargumentsObjectNeeded betrue.
Iffunc.[[ThisMode]] islexical, then
NOTE: Arrow functions never have an arguments object.
SetargumentsObjectNeeded tofalse.
Else ifparameterNames contains"arguments", then
SetargumentsObjectNeeded tofalse.
Else ifhasParameterExpressions isfalse, then
IffunctionNames contains"arguments" orlexicalNames contains"arguments", then
SetargumentsObjectNeeded tofalse.
Ifstrict istrue orhasParameterExpressions isfalse, then
NOTE: Only a singleEnvironment Record is needed for the parameters, since calls toeval instrict mode code cannot create new bindings which are visible outside of theeval.
Letenv be the LexicalEnvironment ofcalleeContext.
Else,
NOTE: A separateEnvironment Record is needed to ensure that bindings created bydirect eval calls in the formal parameter list are outside the environment where parameters are declared.
LetcalleeEnv be the LexicalEnvironment ofcalleeContext.
LetalreadyDeclared be ! env.HasBinding(paramName).
NOTE:Early errors ensure that duplicate parameter names can only occur innon-strict functions that do not have parameter default values or rest parameters.
NOTE: A mapped argument object is only provided fornon-strict functions that don't have a rest parameter, any parameter default value initializers, or any destructured parameters.
NOTE: The following step cannot return aReturnCompletion because the only way such a completion can arise in expression position is by use ofYieldExpression, which is forbidden in parameter lists by Early Error rules in15.5.1 and15.6.1.
NOTE: Only a singleEnvironment Record is needed for the parameters and top-level vars.
LetinstantiatedVarNames be a copy of theListparameterBindings.
For each elementn ofvarNames, do
IfinstantiatedVarNames does not containn, then
Appendn toinstantiatedVarNames.
Perform ! env.CreateMutableBinding(n,false).
Perform ! env.InitializeBinding(n,undefined).
LetvarEnv beenv.
Else,
NOTE: A separateEnvironment 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 separateEnvironment Record for top-level lexical declarations so that adirect 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 forstrict functions because a strictdirect eval always places all declarations into a newEnvironment Record.
Set the LexicalEnvironment ofcalleeContext tolexEnv.
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.
A built-infunction object must have a[[Call]] internal method that conforms to the definition in10.3.1.
A built-infunction 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 in10.3.2.
An implementation may provide additional built-infunction objects that are not defined in this specification.
Letresult be theCompletion Record that isthe result of evaluatingF in a manner that conforms to the specification ofF. IfthisArgument isuninitialized, thethis value is uninitialized; otherwisethisArgument provides thethis value.argumentsList provides the named parameters.newTarget provides the NewTarget value.
NOTE: IfF is defined in this document, “the specification ofF” is the behaviour specified for it via algorithm steps or other means.
WhencalleeContext is removed from theexecution 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 argumentsbehaviour (anAbstract Closure, a set of algorithm steps, or some other definition of a function's behaviour provided in this specification),length (a non-negativeinteger or +∞),name (aproperty key or aPrivate Name), andadditionalInternalSlotsList (aList of names of internal slots) and optional argumentsrealm (aRealm Record),prototype (an Object ornull), andprefix (a String) and returns a built-infunction object.additionalInternalSlotsList contains the names of additional internal slots that must be defined as part of the object. This operation creates a built-infunction object. It performs the following steps when called:
Ifprototype is not present, setprototype torealm.[[Intrinsics]].[[%Function.prototype%]].
LetinternalSlotsList be aList containing the names of all the internal slots that10.3 requires for the built-infunction object that is about to be created.
Append tointernalSlotsList the elements ofadditionalInternalSlotsList.
Letfunc be a new built-infunction object that, when called, performs the action described bybehaviour using the provided arguments as the values of the corresponding parameters specified bybehaviour. The newfunction object has internal slots whose names are the elements ofinternalSlotsList, 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-inexotic objects. These objects generally behave similar toordinary objects except for a few specific situations. The followingexotic objects use theordinary object internal methods except where it is explicitly specified otherwise below:
An object is abound 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 in10.1. These methods are installed inBoundFunctionCreate.
An Array is anexotic object that gives special treatment toarray indexproperty keys (see6.1.7). A property whoseproperty name is anarray index is also called anelement. Every Array has a non-configurable"length" property whose value is always a non-negativeintegral Number whosemathematical 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 anarray 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 anarray index, the value of the"length" property is changed, if necessary, to be one more than the numeric value of thatarray index; and whenever the value of the"length" property is changed, every own property whose name is anarray 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" orarray index properties that may be inherited from its prototypes.
An object is anArray 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 in10.1. These methods are installed inArrayCreate.
The abstract operation ArrayCreate takes argumentlength (a non-negativeinteger) and optional argumentproto (an Object) and returns either anormal completion containing anArray exotic object or athrow completion. It is used to specify the creation of new Arrays. It performs the following steps when called:
The abstract operation ArraySpeciesCreate takes argumentsoriginalArray (an Object) andlength (a non-negativeinteger) and returns either anormal completion containing an Object or athrow completion. It is used to specify the creation of a new Array or similar object using aconstructor function that is derived fromoriginalArray. It does not enforce that theconstructor function returns an Array. It performs the following steps when called:
IforiginalArray was created using the standard built-in Arrayconstructor for arealm that is not therealm of therunning execution context, then a new Array is created using therealm of therunning execution context. This maintains compatibility with Web browsers that have historically had that behaviour for theArray.prototype methods that now are defined using ArraySpeciesCreate.
In steps3 and4, ifDesc.[[Value]] is an object then itsvalueOf 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 anexotic object that encapsulates a String value and exposes virtualinteger-indexeddata properties corresponding to the individual code unit elements of the String value.String exotic objects always have adata property named"length" whose value is the length of the encapsulated String value. Both the code unitdata properties and the"length" property are non-writable and non-configurable.
An object is aString 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 in10.1. These methods are installed inStringCreate.
For each ownproperty keyP ofO such thatPis a String andP is not anarray index, in ascending chronological order of property creation, do
AppendP tokeys.
For each ownproperty keyP ofO such thatPis a Symbol, in ascending chronological order of property creation, do
AppendP tokeys.
Returnkeys.
10.4.3.4 StringCreate (value,prototype )
The abstract operation StringCreate takes argumentsvalue (a String) andprototype (an Object) and returns aString exotic object. It is used to specify the creation of newString exotic objects. It performs the following steps when called:
The abstract operation StringGetOwnProperty takes argumentsS (an Object that has a[[StringData]] internal slot) andP (aproperty key) and returns aProperty Descriptor orundefined. It performs the following steps when called:
LetresultStr be thesubstring ofstr fromℝ(index) toℝ(index) + 1.
Return the PropertyDescriptor {[[Value]]:resultStr,[[Writable]]:false,[[Enumerable]]:true,[[Configurable]]:false }.
10.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the characteristics of the function definition, its arguments object is either anordinary object or anarguments exotic object. Anarguments exotic object is anexotic object whosearray index properties map to the formal parameters bindings of an invocation of its associated ECMAScript function.
An object is anarguments exotic object if its internal methods use the following implementations, with the ones not specified here using those found in10.1. These methods are installed inCreateMappedArgumentsObject.
Arguments exotic objects have the same internal slots asordinary objects. They also have a[[ParameterMap]] internal slot. Ordinary arguments objects also have a[[ParameterMap]] internal slot whose value is alwaysundefined. For ordinary argument objects the[[ParameterMap]] internal slot is only used byObject.prototype.toString (20.1.3.6) to identify them as such.
Note 2
Theinteger-indexeddata properties of anarguments exotic object whose numeric name values are less than the number of formal parameters of the correspondingfunction object initially share their values with the corresponding argument bindings in the function'sexecution 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 anaccessor property. If the arguments object is anordinary 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-configurableaccessor property named"callee" which throws aTypeError exception on access. The"callee" property has a more specific meaning forarguments exotic objects, which are created only for some class ofnon-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 ofarguments exotic objects have historically contained anaccessor 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 argumentargumentsList (aList ofECMAScript language values) and returns anordinary object. It performs the following steps when called:
The abstract operation MakeArgGetter takes argumentsname (a String) andenv (anEnvironment Record) and returns afunction object. It creates a built-infunction object that when executed returns the value bound forname inenv. It performs the following steps when called:
LetgetterClosure be a newAbstract Closure with no parameters that capturesname andenv and performs the following steps when called:
NOTE:getter is never directly accessible to ECMAScript code.
Returngetter.
10.4.4.7.2 MakeArgSetter (name,env )
The abstract operation MakeArgSetter takes argumentsname (a String) andenv (anEnvironment Record) and returns afunction object. It creates a built-infunction object that when executed sets the value bound forname inenv. It performs the following steps when called:
LetsetterClosure be a newAbstract Closure with parameters (value) that capturesname andenv and performs the following steps when called:
TypedArrays have the same internal slots asordinary objects and additionally[[ViewedArrayBuffer]],[[TypedArrayName]],[[ContentType]],[[ByteLength]],[[ByteOffset]], and[[ArrayLength]] internal slots.
An object is aTypedArray if its[[PreventExtensions]],[[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 in10.1. These methods are installed byTypedArrayCreate.
10.4.5.1[[PreventExtensions]] ( )
The[[PreventExtensions]] internal method of aTypedArrayO takes no arguments and returns anormal completion containing a Boolean. It performs the following steps when called:
NOTE: The extensibility-related invariants specified in6.1.7.3 do not allow this method to returntrue whenO can gain (or lose and then regain) properties, which might occur for properties withinteger index names when its underlying buffer is resized.
For each ownproperty keyP ofO such thatPis a Symbol, in ascending chronological order of property creation, do
AppendP tokeys.
Returnkeys.
10.4.5.9 TypedArray With Buffer Witness Records
AnTypedArray With Buffer Witness Record is aRecord value used to encapsulate aTypedArray 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 agrowable SharedArrayBuffer.
TypedArray With Buffer Witness Records have the fields listed inTable 30.
The abstract operation MakeTypedArrayWithBufferWitnessRecord takes argumentsobj (aTypedArray) andorder (seq-cst orunordered) and returns aTypedArray With Buffer Witness Record. It performs the following steps when called:
The abstract operation TypedArrayCreate takes argumentprototype (an Object) and returns aTypedArray. It is used to specify the creation of newTypedArrays. It performs the following steps when called:
LetinternalSlotsList be «[[Prototype]],[[Extensible]],[[ViewedArrayBuffer]],[[TypedArrayName]],[[ContentType]],[[ByteLength]],[[ByteOffset]],[[ArrayLength]] ».
The abstract operation TypedArrayByteLength takes argumenttaRecord (aTypedArray With Buffer Witness Record) and returns a non-negativeinteger. It performs the following steps when called:
The abstract operation TypedArrayLength takes argumenttaRecord (aTypedArray With Buffer Witness Record) and returns a non-negativeinteger. It performs the following steps when called:
The abstract operation IsTypedArrayOutOfBounds takes argumenttaRecord (aTypedArray 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:
The abstract operation IsValidIntegerIndex takes argumentsO (aTypedArray) andindex (a Number) and returns a Boolean. It performs the following steps when called:
The abstract operation TypedArrayGetElement takes argumentsO (aTypedArray) andindex (a Number) and returns a Number, a BigInt, orundefined. 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 aTypedArray or to aTypedArray which is backed by a detached ArrayBuffer.
10.4.5.19 IsArrayBufferViewOutOfBounds (O )
The abstract operation IsArrayBufferViewOutOfBounds takes argumentO (aTypedArray or a DataView) and returns a Boolean. It checks if either any of aTypedArray'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:
Amodule namespace exotic object is anexotic object that exposes the bindings exported from an ECMAScriptModule (See16.2.3). There is a one-to-one correspondence between the String-keyed own properties of amodule namespace exotic object and the binding names exported by theModule. The exported bindings include any bindings that are indirectly exported usingexport * export items. Each String-valued ownproperty key is theStringValue of the corresponding exported binding name. These are the only String-keyed properties of amodule 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 amodule 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 in10.1. These methods are installed byModuleNamespaceCreate.
AList whose elements are the String values of the exported names exposed as own properties of this object. The list is sorted according tolexicographic code unit order.
ResolveExport is side-effect free. Each time this operation is called with a specificexportName,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 eachmodule namespace exotic object.
An object is animmutable prototype exotic object if its[[SetPrototypeOf]] internal method uses the following implementation. (Its other essential internal methods may use any implementation, depending on the specificimmutable prototype exotic object in question.)
The abstract operation SetImmutablePrototype takes argumentsO (an Object) andV (an Object ornull) and returns either anormal completion containing a Boolean or athrow completion. It performs the following steps when called:
10.5 Proxy Object Internal Methods and Internal Slots
A Proxy object is anexotic 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'shandler object, ornull. Methods (seeTable 32) 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 ornull. This object is called the proxy'starget object.
An object is aProxy exotic object if its essential internal methods (including[[Call]] and[[Construct]], if applicable) use the definitions in this section. These internal methods are installed inProxyCreate.
Table 32: 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 subsequentlyrevoked. When a proxy is revoked, its[[ProxyHandler]] and[[ProxyTarget]] internal slots are set tonull causing subsequent invocations of internal methods on that Proxy object to throw aTypeError 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 in6.1.7.3. Some of the internal method invariants defined in6.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.
[[GetPrototypeOf]] for Proxy objects enforces the following invariants:
The result of[[GetPrototypeOf]] must be either an Object ornull.
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.
[[GetOwnProperty]] for Proxy objects enforces the following invariants:
The result of[[GetOwnProperty]] must be either an Object orundefined.
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.
IfIsDataDescriptor(targetDesc) istrue,targetDesc.[[Configurable]] isfalse, andtargetDesc.[[Writable]] istrue, then
IfDesc has a[[Writable]] field andDesc.[[Writable]] isfalse, throw aTypeError exception.
Returntrue.
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 theProperty Descriptor of the property to the target object using[[DefineOwnProperty]] will not throw an exception.
IfIsAccessorDescriptor(targetDesc) istrue andtargetDesc.[[Get]] isundefined, then
IftrapResult is notundefined, throw aTypeError exception.
ReturntrapResult.
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 owndata property.
The value reported for a property must beundefined if the corresponding target object property is a non-configurable ownaccessor property that hasundefined 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 owndata property.
Cannot set the value of a property if the corresponding target object property is a non-configurable ownaccessor property that hasundefined as its[[Set]] attribute.
AProxy 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.
AProxy 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 argumentproxy (aProxy exotic object) and returns either anormal completion containingunused or athrow completion. It throws aTypeError exception ifproxy has been revoked. It performs the following steps when called: