10 Ordinary and Exotic Objects Behaviours
10.1 Ordinary Object Internal Methods and Internal Slots
All
Every
In the following algorithm descriptions, assume obj is an
Each
10.1.1 [[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of an
- Return
OrdinaryGetPrototypeOf (obj).
10.1.1.1 OrdinaryGetPrototypeOf ( obj )
The abstract operation OrdinaryGetPrototypeOf takes argument obj (an Object) and returns an Object or
- Return obj.[[Prototype]].
10.1.2 [[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of an
- Return
OrdinarySetPrototypeOf (obj, proto).
10.1.2.1 OrdinarySetPrototypeOf ( obj, proto )
The abstract operation OrdinarySetPrototypeOf takes arguments obj (an Object) and proto (an Object or
- Let current be obj.[[Prototype]].
- If
SameValue (proto, current) istrue , returntrue . - Let extensible be obj.[[Extensible]].
- If extensible is
false , returnfalse . - Let cursor be proto.
- Let done be
false . - Repeat, while done is
false ,- If cursor is
null , then- Set done to
true .
- Set done to
- Else if
SameValue (cursor, obj) istrue , then- Return
false .
- Return
- Else,
- If cursor.[[GetPrototypeOf]] is not the
ordinary object internal method defined in10.1.1 , set done totrue . - Else, set cursor to cursor.[[Prototype]].
- If cursor.[[GetPrototypeOf]] is not the
- If cursor is
- Set obj.[[Prototype]] to proto.
- Return
true .
The loop in step
10.1.3 [[IsExtensible]] ( )
The [[IsExtensible]] internal method of an
- Return
OrdinaryIsExtensible (obj).
10.1.3.1 OrdinaryIsExtensible ( obj )
The abstract operation OrdinaryIsExtensible takes argument obj (an Object) and returns a Boolean. It performs the following steps when called:
- Return obj.[[Extensible]].
10.1.4 [[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of an
- Return
OrdinaryPreventExtensions (obj).
10.1.4.1 OrdinaryPreventExtensions ( obj )
The abstract operation OrdinaryPreventExtensions takes argument obj (an Object) and returns
- Set obj.[[Extensible]] to
false . - Return
true .
10.1.5 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of an
- Return
OrdinaryGetOwnProperty (obj, propertyKey).
10.1.5.1 OrdinaryGetOwnProperty ( obj, propertyKey )
The abstract operation OrdinaryGetOwnProperty takes arguments obj (an Object) and propertyKey (a
- If obj does not have an own property with key propertyKey, return
undefined . - Let propertyDesc be a newly created
Property Descriptor with no fields. - Let ownProperty be obj's own property whose key is propertyKey.
- If ownProperty is a
data property , then- Set propertyDesc.[[Value]] to the value of ownProperty's [[Value]] attribute.
- Set propertyDesc.[[Writable]] to the value of ownProperty's [[Writable]] attribute.
- Else,
Assert : ownProperty is anaccessor property .- Set propertyDesc.[[Get]] to the value of ownProperty's [[Get]] attribute.
- Set propertyDesc.[[Set]] to the value of ownProperty's [[Set]] attribute.
- Set propertyDesc.[[Enumerable]] to the value of ownProperty's [[Enumerable]] attribute.
- Set propertyDesc.[[Configurable]] to the value of ownProperty's [[Configurable]] attribute.
- Return propertyDesc.
10.1.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )
The [[DefineOwnProperty]] internal method of an
- Return ?
OrdinaryDefineOwnProperty (obj, propertyKey, propertyDesc).
10.1.6.1 OrdinaryDefineOwnProperty ( obj, propertyKey, propertyDesc )
The abstract operation OrdinaryDefineOwnProperty takes arguments obj (an Object), propertyKey (a
- Let current be ?
obj.[[GetOwnProperty]](propertyKey) . - Let extensible be ?
IsExtensible (obj). - Return
ValidateAndApplyPropertyDescriptor (obj, propertyKey, extensible, propertyDesc, current).
10.1.6.2 IsCompatiblePropertyDescriptor ( extensible, propertyDesc, current )
The abstract operation IsCompatiblePropertyDescriptor takes arguments extensible (a Boolean), propertyDesc (a
- Return
ValidateAndApplyPropertyDescriptor (undefined ,"" , extensible, propertyDesc, current).
10.1.6.3 ValidateAndApplyPropertyDescriptor ( obj, propertyKey, extensible, propertyDesc, current )
The abstract operation ValidateAndApplyPropertyDescriptor takes arguments obj (an Object or
Assert : propertyKey is aproperty key .- If current is
undefined , then- If extensible is
false , returnfalse . - If obj is
undefined , returntrue . - If
IsAccessorDescriptor (propertyDesc) istrue , then- Create an own
accessor property named propertyKey of object obj whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in propertyDesc if propertyDesc has that field, or to the attribute'sdefault value otherwise.
- Create an own
- Else,
- Create an own
data property named propertyKey of object obj whose [[Value]], [[Writable]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in propertyDesc if propertyDesc has that field, or to the attribute'sdefault value otherwise.
- Create an own
- Return
true .
- If extensible is
Assert : current is afully populated Property Descriptor .- If propertyDesc does not have any fields, return
true . - If current.[[Configurable]] is
false , then- If propertyDesc has a [[Configurable]] field and propertyDesc.[[Configurable]] is
true , returnfalse . - If propertyDesc has an [[Enumerable]] field and propertyDesc.[[Enumerable]] is not current.[[Enumerable]], return
false . - If
IsGenericDescriptor (propertyDesc) isfalse andIsAccessorDescriptor (propertyDesc) is notIsAccessorDescriptor (current), returnfalse . - If
IsAccessorDescriptor (current) istrue , then - Else if current.[[Writable]] is
false , then- If propertyDesc has a [[Writable]] field and propertyDesc.[[Writable]] is
true , returnfalse . NOTE :SameValue returnstrue forNaN values which may be distinguishable by other means. Returning here ensures that any existing property of obj remains unmodified.- If propertyDesc has a [[Value]] field, return
SameValue (propertyDesc.[[Value]], current.[[Value]]).
- If propertyDesc has a [[Writable]] field and propertyDesc.[[Writable]] is
- If propertyDesc has a [[Configurable]] field and propertyDesc.[[Configurable]] is
- If obj is not
undefined , then- If
IsDataDescriptor (current) istrue andIsAccessorDescriptor (propertyDesc) istrue , then- If propertyDesc has a [[Configurable]] field, let configurable be propertyDesc.[[Configurable]]; else let configurable be current.[[Configurable]].
- If propertyDesc has an [[Enumerable]] field, let enumerable be propertyDesc.[[Enumerable]]; else let enumerable be current.[[Enumerable]].
- Replace the property named propertyKey of object obj 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 propertyDesc if propertyDesc has that field, or to the attribute'sdefault value otherwise.
- Else if
IsAccessorDescriptor (current) istrue andIsDataDescriptor (propertyDesc) istrue , then- If propertyDesc has a [[Configurable]] field, let configurable be propertyDesc.[[Configurable]]; else let configurable be current.[[Configurable]].
- If propertyDesc has an [[Enumerable]] field, let enumerable be propertyDesc.[[Enumerable]]; else let enumerable be current.[[Enumerable]].
- Replace the property named propertyKey of object obj 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 propertyDesc if propertyDesc has that field, or to the attribute'sdefault value otherwise.
- Else,
- For each field name fieldName of propertyDesc, set the attribute named fieldName of the property named propertyKey of object obj to the value of propertyDesc's fieldName field.
- If
- Return
true .
10.1.7 [[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of an
- Return ?
OrdinaryHasProperty (obj, propertyKey).
10.1.7.1 OrdinaryHasProperty ( obj, propertyKey )
The abstract operation OrdinaryHasProperty takes arguments obj (an Object) and propertyKey (a
- Let hasOwn be ?
obj.[[GetOwnProperty]](propertyKey) . - If hasOwn is not
undefined , returntrue . - Let parent be ?
obj.[[GetPrototypeOf]]() . - If parent is not
null , then- Return ?
parent.[[HasProperty]](propertyKey) .
- Return ?
- Return
false .
10.1.8 [[Get]] ( propertyKey, receiver )
The [[Get]] internal method of an
- Return ?
OrdinaryGet (obj, propertyKey, receiver).
10.1.8.1 OrdinaryGet ( obj, propertyKey, receiver )
The abstract operation OrdinaryGet takes arguments obj (an Object), propertyKey (a
- Let propertyDesc be ?
obj.[[GetOwnProperty]](propertyKey) . - If propertyDesc is
undefined , then- Let parent be ?
obj.[[GetPrototypeOf]]() . - If parent is
null , returnundefined . - Return ?
parent.[[Get]](propertyKey, receiver) .
- Let parent be ?
- If
IsDataDescriptor (propertyDesc) istrue , return propertyDesc.[[Value]]. Assert :IsAccessorDescriptor (propertyDesc) istrue .- Let getter be propertyDesc.[[Get]].
- If getter is
undefined , returnundefined . - Return ?
Call (getter, receiver).
10.1.9 [[Set]] ( propertyKey, value, receiver )
The [[Set]] internal method of an
- Return ?
OrdinarySet (obj, propertyKey, value, receiver).
10.1.9.1 OrdinarySet ( obj, propertyKey, value, receiver )
The abstract operation OrdinarySet takes arguments obj (an Object), propertyKey (a
- Let ownDesc be ?
obj.[[GetOwnProperty]](propertyKey) . - Return ?
OrdinarySetWithOwnDescriptor (obj, propertyKey, value, receiver, ownDesc).
10.1.9.2 OrdinarySetWithOwnDescriptor ( obj, propertyKey, value, receiver, ownDesc )
The abstract operation OrdinarySetWithOwnDescriptor takes arguments obj (an Object), propertyKey (a
- If ownDesc is
undefined , then- Let parent be ?
obj.[[GetPrototypeOf]]() . - If parent is not
null , return ?parent.[[Set]](propertyKey, value, receiver) . - Set ownDesc to the PropertyDescriptor { [[Value]]:
undefined , [[Writable]]:true , [[Enumerable]]:true , [[Configurable]]:true }.
- Let parent be ?
- If
IsDataDescriptor (ownDesc) istrue , then- If ownDesc.[[Writable]] is
false , returnfalse . - If receiver
is not an Object , returnfalse . - Let existingDesc be ?
receiver.[[GetOwnProperty]](propertyKey) . - If existingDesc is
undefined , thenAssert : receiver does not currently have a property propertyKey.- Return ?
CreateDataProperty (receiver, propertyKey, value).
- If
IsAccessorDescriptor (existingDesc) istrue , returnfalse . - If existingDesc.[[Writable]] is
false , returnfalse . - Let valueDesc be the PropertyDescriptor { [[Value]]: value }.
- Return ?
receiver.[[DefineOwnProperty]](propertyKey, valueDesc) .
- If ownDesc.[[Writable]] is
Assert :IsAccessorDescriptor (ownDesc) istrue .- Let setter be ownDesc.[[Set]].
- If setter is
undefined , returnfalse . - Perform ?
Call (setter, receiver, « value »). - Return
true .
10.1.10 [[Delete]] ( propertyKey )
The [[Delete]] internal method of an
- Return ?
OrdinaryDelete (obj, propertyKey).
10.1.10.1 OrdinaryDelete ( obj, propertyKey )
The abstract operation OrdinaryDelete takes arguments obj (an Object) and propertyKey (a
- Let propertyDesc be ?
obj.[[GetOwnProperty]](propertyKey) . - If propertyDesc is
undefined , returntrue . - If propertyDesc.[[Configurable]] is
true , then- Remove the own property with name propertyKey from obj.
- Return
true .
- Return
false .
10.1.11 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of an
- Return
OrdinaryOwnPropertyKeys (obj).
10.1.11.1 OrdinaryOwnPropertyKeys ( obj )
The abstract operation OrdinaryOwnPropertyKeys takes argument obj (an Object) and returns a
- Let keys be a new empty
List . - For each own
property key propertyKey of obj such that propertyKey is anarray index , in ascending numeric index order, do- Append propertyKey to keys.
- For each own
property key propertyKey of obj such that propertyKeyis a String and propertyKey is not anarray index , in ascending chronological order of property creation, do- Append propertyKey to keys.
- For each own
property key propertyKey of obj such that propertyKeyis a Symbol , in ascending chronological order of property creation, do- Append propertyKey to keys.
- Return keys.
10.1.12 OrdinaryObjectCreate ( proto [ , additionalInternalSlotsList ] )
The abstract operation OrdinaryObjectCreate takes argument proto (an Object or
- Let internalSlotsList be « [[Prototype]], [[Extensible]] ».
- If additionalInternalSlotsList is present, set internalSlotsList to the
list-concatenation of internalSlotsList and additionalInternalSlotsList. - Let obj be
MakeBasicObject (internalSlotsList). - Set obj.[[Prototype]] to proto.
- Return obj.
Although OrdinaryObjectCreate does little more than call
10.1.13 OrdinaryCreateFromConstructor ( ctor, intrinsicDefaultProto [ , internalSlotsList ] )
The abstract operation OrdinaryCreateFromConstructor takes arguments ctor (a
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.- Let proto be ?
GetPrototypeFromConstructor (ctor, intrinsicDefaultProto). - If internalSlotsList is present, let slots be internalSlotsList.
- Else, let slots be a new empty
List . - Return
OrdinaryObjectCreate (proto, slots).
10.1.14 GetPrototypeFromConstructor ( ctor, intrinsicDefaultProto )
The abstract operation GetPrototypeFromConstructor takes arguments ctor (a
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.- Let proto be ?
Get (ctor,"prototype" ). - If proto
is not an Object , then- Let realm be ?
GetFunctionRealm (ctor). - Set proto to realm's intrinsic object named intrinsicDefaultProto.
- Let realm be ?
- Return proto.
If ctor does not supply a [[Prototype]] value, the default value that is used is obtained from the
10.1.15 RequireInternalSlot ( obj, internalSlot )
The abstract operation RequireInternalSlot takes arguments obj (an
- If obj
is not an Object , throw aTypeError exception. - If obj does not have an internalSlot internal slot, throw a
TypeError exception. - Return
unused .
10.2 ECMAScript Function Objects
ECMAScript
In addition to [[Extensible]] and [[Prototype]], ECMAScript
| Internal Slot | Type | Description |
|---|---|---|
| [[Environment]] |
an |
The |
| [[PrivateEnvironment]] |
a |
The |
| [[FormalParameters]] |
a |
The root parse node of the source text that defines the function's formal parameter list. |
| [[ECMAScriptCode]] |
a |
The root parse node of the source text that defines the function's body. |
| [[ConstructorKind]] |
|
Whether or not the function is a derived class |
| [[Realm]] |
a |
The |
| [[ScriptOrModule]] |
a |
The script or module in which the function was created. |
| [[ThisMode]] |
|
Defines how this references are interpreted within the formal parameters and code body of the function. this refers to the |
| [[Strict]] | a Boolean |
|
| [[HomeObject]] |
an Object or |
If the function uses super, this is the object whose [[GetPrototypeOf]] provides the object where super property lookups begin.
|
| [[SourceText]] | a sequence of Unicode code points |
The |
| [[Fields]] |
a |
If the function is a class, this is a list of |
| [[PrivateMethods]] |
a |
If the function is a class, this is a list representing the non-static private methods and accessors of the class. |
| [[ClassFieldInitializerName]] |
a String, a Symbol, a |
If the function is created as the initializer of a class field, the name to use for |
| [[IsClassConstructor]] | a Boolean |
Indicates whether the function is a class |
All ECMAScript
10.2.1 [[Call]] ( thisArg, argList )
The [[Call]] internal method of an ECMAScript
- Let callerContext be the
running execution context . - Let calleeContext be
PrepareForOrdinaryCall (func,undefined ). Assert : calleeContext is now therunning execution context .- If func.[[IsClassConstructor]] is
true , then- Let error be a newly created
TypeError object. NOTE : error is created in calleeContext with func's associatedRealm Record .- Remove calleeContext from the
execution context stack and restore callerContext as therunning execution context . - Throw error.
- Let error be a newly created
- Perform
OrdinaryCallBindThis (func, calleeContext, thisArg). - Let result be
Completion (OrdinaryCallEvaluateBody (func, argList)). - Remove calleeContext from the
execution context stack and restore callerContext as therunning execution context . - If result is a
return completion , return result.[[Value]]. Assert : result is athrow completion .- Return ? result.
When calleeContext is removed from the
10.2.1.1 PrepareForOrdinaryCall ( func, newTarget )
The abstract operation PrepareForOrdinaryCall takes arguments func (an ECMAScript
- Let callerContext be the
running execution context . - Let calleeContext be a new
ECMAScript code execution context . - Set the Function of calleeContext to func.
- Let calleeRealm be func.[[Realm]].
- Set the
Realm of calleeContext to calleeRealm. - Set the ScriptOrModule of calleeContext to func.[[ScriptOrModule]].
- Let localEnv be
NewFunctionEnvironment (func, newTarget). - Set the LexicalEnvironment of calleeContext to localEnv.
- Set the VariableEnvironment of calleeContext to localEnv.
- Set the PrivateEnvironment of calleeContext to func.[[PrivateEnvironment]].
- If callerContext is not already suspended, suspend callerContext.
- Push calleeContext onto the
execution context stack ; calleeContext is now therunning execution context . NOTE : Any exception objects produced after this point are associated with calleeRealm.- Return calleeContext.
10.2.1.2 OrdinaryCallBindThis ( func, calleeContext, thisArg )
The abstract operation OrdinaryCallBindThis takes arguments func (an ECMAScript
- Let thisMode be func.[[ThisMode]].
- If thisMode is
lexical , returnunused . - Let calleeRealm be func.[[Realm]].
- Let localEnv be the LexicalEnvironment of calleeContext.
- If thisMode is
strict , then- Let thisValue be thisArg.
- Else,
- If thisArg is either
undefined ornull , then- Let globalEnv be calleeRealm.[[GlobalEnv]].
Assert : globalEnv is aGlobal Environment Record .- Let thisValue be globalEnv.[[GlobalThisValue]].
- Else,
- If thisArg is either
Assert : localEnv is aFunction Environment Record .Assert : The next step never returns anabrupt completion because localEnv.[[ThisBindingStatus]] is notinitialized .- Perform !
BindThisValue (localEnv, thisValue). - Return
unused .
10.2.1.3 Runtime Semantics: EvaluateBody
The
- Return ?
EvaluateFunctionBody ofFunctionBody with arguments func and argList.
- Return ?
EvaluateConciseBody ofConciseBody with arguments func and argList.
- Return ?
EvaluateGeneratorBody ofGeneratorBody with arguments func and argList.
- Return ?
EvaluateAsyncGeneratorBody ofAsyncGeneratorBody with arguments func and argList.
- Return ?
EvaluateAsyncFunctionBody ofAsyncFunctionBody with arguments func and argList.
- Return ?
EvaluateAsyncConciseBody ofAsyncConciseBody with arguments func and argList.
Assert : argList is empty.Assert : func.[[ClassFieldInitializerName]] is notempty .- If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue , then- Let value be ?
NamedEvaluation ofInitializer with argument func.[[ClassFieldInitializerName]].
- Let value be ?
- Else,
- Let rhs be ?
Evaluation ofAssignmentExpression . - Let value be ?
GetValue (rhs).
- Let rhs be ?
- Return
ReturnCompletion (value).
Even though field initializers constitute a function boundary, calling
Assert : argList is empty.- Return ?
EvaluateClassStaticBlockBody ofClassStaticBlockBody with argument func.
10.2.1.4 OrdinaryCallEvaluateBody ( func, argList )
The abstract operation OrdinaryCallEvaluateBody takes arguments func (an ECMAScript
- Return ?
EvaluateBody of func.[[ECMAScriptCode]] with arguments func and argList.
10.2.2 [[Construct]] ( argList, newTarget )
The [[Construct]] internal method of an ECMAScript
- Let callerContext be the
running execution context . - Let kind be func.[[ConstructorKind]].
- If kind is
base , then- Let thisArg be ?
OrdinaryCreateFromConstructor (newTarget," ).%Object.prototype% "
- Let thisArg be ?
- Let calleeContext be
PrepareForOrdinaryCall (func, newTarget). Assert : calleeContext is now therunning execution context .- If kind is
base , then- Perform
OrdinaryCallBindThis (func, calleeContext, thisArg). - Let initializeResult be
Completion (InitializeInstanceElements (thisArg, func)). - If initializeResult is an
abrupt completion , then- Remove calleeContext from the
execution context stack and restore callerContext as therunning execution context . - Return ? initializeResult.
- Remove calleeContext from the
- Perform
- Let ctorEnv be the LexicalEnvironment of calleeContext.
- Let result be
Completion (OrdinaryCallEvaluateBody (func, argList)). - Remove calleeContext from the
execution context stack and restore callerContext as therunning execution context . - If result is a
throw completion , then- Return ? result.
Assert : result is areturn completion .- If result.[[Value]]
is an Object , return result.[[Value]]. - If kind is
base , return thisArg. - If result.[[Value]] is not
undefined , throw aTypeError exception. - Let thisBinding be ? ctorEnv.GetThisBinding().
Assert : thisBindingis an Object .- Return thisBinding.
10.2.3 OrdinaryFunctionCreate ( proto, sourceText, paramList, body, thisMode, envRecord, privateEnv )
The abstract operation OrdinaryFunctionCreate takes arguments proto (an Object), sourceText (a sequence of Unicode code points), paramList (a
- Let internalSlotsList be the internal slots listed in
Table 25 . - Let func be
OrdinaryObjectCreate (proto, internalSlotsList). - Set func.[[Call]] to the definition specified in
10.2.1 . - Set func.[[SourceText]] to sourceText.
- Set func.[[FormalParameters]] to paramList.
- Set func.[[ECMAScriptCode]] to body.
- Let strict be
IsStrict (body). - Set func.[[Strict]] to strict.
- If thisMode is
lexical-this , set func.[[ThisMode]] tolexical . - Else if strict is
true , set func.[[ThisMode]] tostrict . - Else, set func.[[ThisMode]] to
global . - Set func.[[IsClassConstructor]] to
false . - Set func.[[Environment]] to envRecord.
- Set func.[[PrivateEnvironment]] to privateEnv.
- Set func.[[ScriptOrModule]] to
GetActiveScriptOrModule (). - Set func.[[Realm]] to
the current Realm Record . - Set func.[[HomeObject]] to
undefined . - Set func.[[Fields]] to a new empty
List . - Set func.[[PrivateMethods]] to a new empty
List . - Set func.[[ClassFieldInitializerName]] to
empty . - Let length be the
ExpectedArgumentCount of paramList. - Perform
SetFunctionLength (func, length). - Return func.
10.2.4 AddRestrictedFunctionProperties ( func, realm )
The abstract operation AddRestrictedFunctionProperties takes arguments func (a
Assert : realm.[[Intrinsics]].[[%ThrowTypeError% ]] exists and has been initialized.- Let thrower be realm.[[Intrinsics]].[[
%ThrowTypeError% ]]. - Perform !
DefinePropertyOrThrow (func,"caller" , PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]:false , [[Configurable]]:true }). - Perform !
DefinePropertyOrThrow (func,"arguments" , PropertyDescriptor { [[Get]]: thrower, [[Set]]: thrower, [[Enumerable]]:false , [[Configurable]]:true }). - Return
unused .
10.2.4.1 %ThrowTypeError% ( )
This function is the
It is an anonymous built-in
It performs the following steps when called:
- Throw a
TypeError exception.
The value of the [[Extensible]] internal slot of this function is
The
The
10.2.5 MakeConstructor ( func [ , writableProto [ , proto ] ] )
The abstract operation MakeConstructor takes argument func (an ECMAScript
- If func is an ECMAScript
function object , thenAssert :IsConstructor (func) isfalse .Assert : func is an extensible object that does not have a"prototype" own property.- Set func.[[Construct]] to the definition specified in
10.2.2 .
- Else,
- Set func.[[Construct]] to the definition specified in
10.3.2 .
- Set func.[[Construct]] to the definition specified in
- Set func.[[ConstructorKind]] to
base . - If writableProto is not present, set writableProto to
true . - If proto is not present, then
- Set proto to
OrdinaryObjectCreate (%Object.prototype% ). - Perform !
DefinePropertyOrThrow (proto,"constructor" , PropertyDescriptor { [[Value]]: func, [[Writable]]: writableProto, [[Enumerable]]:false , [[Configurable]]:true }).
- Set proto to
- Perform !
DefinePropertyOrThrow (func,"prototype" , PropertyDescriptor { [[Value]]: proto, [[Writable]]: writableProto, [[Enumerable]]:false , [[Configurable]]:false }). - Return
unused .
10.2.6 MakeClassConstructor ( func )
The abstract operation MakeClassConstructor takes argument func (an ECMAScript
Assert : func.[[IsClassConstructor]] isfalse .- Set func.[[IsClassConstructor]] to
true . - Return
unused .
10.2.7 MakeMethod ( func, homeObj )
The abstract operation MakeMethod takes arguments func (an ECMAScript
Assert : homeObj is anordinary object .- Set func.[[HomeObject]] to homeObj.
- Return
unused .
10.2.8 DefineMethodProperty ( homeObj, name, closure, enumerable )
The abstract operation DefineMethodProperty takes arguments homeObj (an Object), name (a
Assert : homeObj is an ordinary, extensible object.- If name is a
Private Name , returnPrivateElement { [[Key]]: name, [[Kind]]:method , [[Value]]: closure }. - Let propertyDesc be the PropertyDescriptor { [[Value]]: closure, [[Writable]]:
true , [[Enumerable]]: enumerable, [[Configurable]]:true }. - Perform ?
DefinePropertyOrThrow (homeObj, name, propertyDesc). NOTE :DefinePropertyOrThrow only returns anabrupt completion when attempting to define a class static method whose name is"prototype" .- Return
unused .
10.2.9 SetFunctionName ( func, name [ , prefix ] )
The abstract operation SetFunctionName takes arguments func (a
Assert : func is an extensible object that does not have a"name" own property.- If name
is a Symbol , then- Let description be name.[[Description]].
- If description is
undefined , set name to the empty String. - Else, set name to the
string-concatenation of"[" , description, and"]" .
- Else if name is a
Private Name , then- Set name to name.[[Description]].
- If func has an [[InitialName]] internal slot, then
- Set func.[[InitialName]] to name.
- If prefix is present, then
- Let prefixedName be the
string-concatenation of prefix, the code unit 0x0020 (SPACE), and name. - If func has an [[InitialName]] internal slot, then
NOTE : The choice in the following step is made independently each time this Abstract Operation is invoked.- Set func.[[InitialName]] to an
implementation-defined choice of either name or prefixedName.
- Set name to prefixedName.
- Let prefixedName be the
- Perform !
DefinePropertyOrThrow (func,"name" , PropertyDescriptor { [[Value]]: name, [[Writable]]:false , [[Enumerable]]:false , [[Configurable]]:true }). - Return
unused .
10.2.10 SetFunctionLength ( func, length )
The abstract operation SetFunctionLength takes arguments func (a
Assert : func is an extensible object that does not have a"length" own property.- Perform !
DefinePropertyOrThrow (func,"length" , PropertyDescriptor { [[Value]]:𝔽 (length), [[Writable]]:false , [[Enumerable]]:false , [[Configurable]]:true }). - Return
unused .
10.2.11 FunctionDeclarationInstantiation ( func, argList )
The abstract operation FunctionDeclarationInstantiation takes arguments func (an ECMAScript
When an
It performs the following steps when called:
- Let calleeContext be the
running execution context . - Let code be func.[[ECMAScriptCode]].
- Let strict be func.[[Strict]].
- Let formals be func.[[FormalParameters]].
- Let paramNames be the
BoundNames of formals. - If paramNames has any duplicate entries, let hasDuplicates be
true ; else let hasDuplicates befalse . - Let simpleParamList be
IsSimpleParameterList of formals. - Let hasParamExprs be
ContainsExpression of formals. - Let variableNames be the
VarDeclaredNames of code. - Let variableDecls be the
VarScopedDeclarations of code. - Let lexicalNames be the
LexicallyDeclaredNames of code. - Let funcNames be a new empty
List . - Let funcsToInitialize be a new empty
List . - For each element variableDecl of variableDecls, in reverse
List order, do- If variableDecl is neither a
VariableDeclaration nor aForBinding nor aBindingIdentifier , thenAssert : variableDecl is either aFunctionDeclaration , aGeneratorDeclaration , anAsyncFunctionDeclaration , or anAsyncGeneratorDeclaration .- Let funcName be the sole element of the
BoundNames of variableDecl. - If funcNames does not contain funcName, then
- Insert funcName as the first element of funcNames.
NOTE : If there are multiple function declarations for the same name, the last declaration is used.- Insert variableDecl as the first element of funcsToInitialize.
- If variableDecl is neither a
- Let argumentsObjNeeded be
true . - If func.[[ThisMode]] is
lexical , thenNOTE : Arrow functions never have an arguments object.- Set argumentsObjNeeded to
false .
- Else if paramNames contains
"arguments" , then- Set argumentsObjNeeded to
false .
- Set argumentsObjNeeded to
- Else if hasParamExprs is
false , then- If funcNames contains
"arguments" or lexicalNames contains"arguments" , then- Set argumentsObjNeeded to
false .
- Set argumentsObjNeeded to
- If funcNames contains
- If strict is
true or hasParamExprs isfalse , thenNOTE : Only a singleEnvironment Record is needed for the parameters, since calls toevalinstrict mode code cannot create new bindings which are visible outside of theeval.- Let envRecord be the LexicalEnvironment of calleeContext.
- 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.- Let calleeEnv be the LexicalEnvironment of calleeContext.
- Let envRecord be
NewDeclarativeEnvironment (calleeEnv). Assert : The VariableEnvironment of calleeContext and calleeEnv are the sameEnvironment Record .- Set the LexicalEnvironment of calleeContext to envRecord.
- For each String paramName of paramNames, do
- Let alreadyDeclared be ! envRecord.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.- If alreadyDeclared is
false , then- Perform ! envRecord.CreateMutableBinding(paramName,
false ). - If hasDuplicates is
true , then- Perform ! envRecord.InitializeBinding(paramName,
undefined ).
- Perform ! envRecord.InitializeBinding(paramName,
- Perform ! envRecord.CreateMutableBinding(paramName,
- If argumentsObjNeeded is
true , then- If strict is
true or simpleParamList isfalse , then- Let argumentsObj be
CreateUnmappedArgumentsObject (argList).
- Let argumentsObj be
- Else,
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.- Let argumentsObj be
CreateMappedArgumentsObject (func, formals, argList, envRecord).
- If strict is
true , then- Perform ! envRecord.CreateImmutableBinding(
"arguments" ,false ). NOTE : Instrict mode code early errors prevent attempting to assign to this binding, so its mutability is not observable.
- Perform ! envRecord.CreateImmutableBinding(
- Else,
- Perform ! envRecord.CreateMutableBinding(
"arguments" ,false ).
- Perform ! envRecord.CreateMutableBinding(
- Perform ! envRecord.InitializeBinding(
"arguments" , argumentsObj). - Let paramBindings be the
list-concatenation of paramNames and «"arguments" ».
- If strict is
- Else,
- Let paramBindings be paramNames.
- Let iteratorRecord be
CreateListIteratorRecord (argList). - If hasDuplicates is
true , then- Let usedEnv be
undefined .
- Let usedEnv be
- Else,
- Let usedEnv be envRecord.
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 .- Perform ?
IteratorBindingInitialization of formals with arguments iteratorRecord and usedEnv. - If hasParamExprs is
false , thenNOTE : Only a singleEnvironment Record is needed for the parameters and top-level vars.- Let instantiatedVariableNames be a copy of the
List paramBindings. - For each element n of variableNames, do
- If instantiatedVariableNames does not contain n, then
- Append n to instantiatedVariableNames.
- Perform ! envRecord.CreateMutableBinding(n,
false ). - Perform ! envRecord.InitializeBinding(n,
undefined ).
- If instantiatedVariableNames does not contain n, then
- Let variableEnv be envRecord.
- 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.- Let variableEnv be
NewDeclarativeEnvironment (envRecord). - Set the VariableEnvironment of calleeContext to variableEnv.
- Let instantiatedVariableNames be a new empty
List . - For each element n of variableNames, do
- If instantiatedVariableNames does not contain n, then
- Append n to instantiatedVariableNames.
- Perform ! variableEnv.CreateMutableBinding(n,
false ). - If paramBindings does not contain n or funcNames contains n, then
- Let initialValue be
undefined .
- Let initialValue be
- Else,
- Let initialValue be ! envRecord.GetBindingValue(n,
false ).
- Let initialValue be ! envRecord.GetBindingValue(n,
- Perform ! variableEnv.InitializeBinding(n, initialValue).
NOTE : A var with the same name as a formal parameter initially has the same value as the corresponding initialized parameter.
- If instantiatedVariableNames does not contain n, then
- If strict is
true , then- Let lexicalEnv be variableEnv.
- Else,
- If the
host is a web browser orotherwise supports Block-Level Function Declarations Web Legacy Compatibility Semantics , then- For each
FunctionDeclaration funcDecl that is directly contained in theStatementList of anyBlock ,CaseClause , orDefaultClause x such that codeContains x istrue , do- Let funcName be the
StringValue of theBindingIdentifier of funcDecl. - If replacing the
FunctionDeclaration funcDecl with aVariableStatement that has funcName as aBindingIdentifier would not produce any Early Errors for func and paramNames does not contain funcName, thenNOTE : A var binding for funcName is only instantiated here if it is neither a VarDeclaredName, the name of a formal parameter, or anotherFunctionDeclaration .- If instantiatedVariableNames does not contain funcName and funcName is not
"arguments" , then- Perform ! variableEnv.CreateMutableBinding(funcName,
false ). - Perform ! variableEnv.InitializeBinding(funcName,
undefined ). - Append funcName to instantiatedVariableNames.
- Perform ! variableEnv.CreateMutableBinding(funcName,
- When the
FunctionDeclaration funcDecl is evaluated, perform the following steps in place of theFunctionDeclaration Evaluation algorithm provided in15.2.6 :- Let fEnv be the
running execution context 's VariableEnvironment. - Let bEnv be the
running execution context 's LexicalEnvironment. - Let fObj be ! bEnv.GetBindingValue(funcName,
false ). - Perform ! fEnv.SetMutableBinding(funcName, fObj,
false ). - Return
unused .
- Let fEnv be the
- Let funcName be the
- For each
- Let lexicalEnv be
NewDeclarativeEnvironment (variableEnv). 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 .
- If the
- Set the LexicalEnvironment of calleeContext to lexicalEnv.
- Let lexicalDecls be the
LexicallyScopedDeclarations of code. - For each element lexicalDecl of lexicalDecls, do
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.- For each element dn of the
BoundNames of lexicalDecl, do- If
IsConstantDeclaration of lexicalDecl istrue , then- Perform ! lexicalEnv.CreateImmutableBinding(dn,
true ).
- Perform ! lexicalEnv.CreateImmutableBinding(dn,
- Else,
- Perform ! lexicalEnv.CreateMutableBinding(dn,
false ).
- Perform ! lexicalEnv.CreateMutableBinding(dn,
- If
- Let privateEnv be the PrivateEnvironment of calleeContext.
- For each
Parse Node funcDecl of funcsToInitialize, do- Let funcName be the sole element of the
BoundNames of funcDecl. - Let funcObj be
InstantiateFunctionObject of funcDecl with arguments lexicalEnv and privateEnv. - Perform ! variableEnv.SetMutableBinding(funcName, funcObj,
false ).
- Let funcName be the sole element of the
- Return
unused .
10.3 Built-in Function Objects
A built-in
In addition to the internal slots required of every
- [[Realm]], a
Realm Record that represents therealm 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 . - [[Async]], a Boolean that indicates whether the function has async function call and construct behaviour in
BuiltinCallOrConstruct .
The initial value of a built-in
A built-in
A built-in
An implementation may provide additional built-in
10.3.1 [[Call]] ( thisArg, argList )
The [[Call]] internal method of a built-in
- Return ?
BuiltinCallOrConstruct (func, thisArg, argList,undefined ).
10.3.2 [[Construct]] ( argList, newTarget )
The [[Construct]] internal method of a built-in
- Let result be ?
BuiltinCallOrConstruct (func,uninitialized , argList, newTarget). Assert : resultis an Object .- Return result.
10.3.3 BuiltinCallOrConstruct ( func, thisArg, argList, newTarget )
The abstract operation BuiltinCallOrConstruct takes arguments func (a built-in
- Let callerContext be the
running execution context . - If callerContext is not already suspended, suspend callerContext.
- Let calleeContext be a new
execution context . - Set the Function of calleeContext to func.
- Let calleeRealm be func.[[Realm]].
- Set the
Realm of calleeContext to calleeRealm. - Set the ScriptOrModule of calleeContext to
null . - Perform any necessary
implementation-defined initialization of calleeContext. - Push calleeContext onto the
execution context stack ; calleeContext is now therunning execution context . - If func.[[Async]] is
true , then- Let promiseCapability be !
NewPromiseCapability (%Promise% ). - Let resultsClosure be a new
Abstract Closure with no parameters that captures func, thisArg, argList, and newTarget and performs the following steps when called:- Let result be the
Completion Record that isthe result of evaluating func in a manner that conforms to the specification of func. If thisArg isuninitialized , thethis value is uninitialized; else thisArg provides thethis value. argList provides the named parameters. newTarget provides the NewTarget value. NOTE : If func is defined in this document, “the specification of func” is the behaviour specified for it via algorithm steps or other means.- Return
Completion (result).
- Let result be the
- Perform
AsyncFunctionStart (promiseCapability, resultsClosure). - Remove calleeContext from the
execution context stack and restore callerContext as therunning execution context . - Return promiseCapability.[[Promise]].
- Let promiseCapability be !
- Let result be the
Completion Record that isthe result of evaluating func in a manner that conforms to the specification of func. If thisArg isuninitialized , thethis value is uninitialized; else thisArg provides thethis value. argList provides the named parameters. newTarget provides the NewTarget value. NOTE : If func is defined in this document, “the specification of func” is the behaviour specified for it via algorithm steps or other means.- Remove calleeContext from the
execution context stack and restore callerContext as therunning execution context . - Return ? result.
When calleeContext is removed from the
10.3.4 CreateBuiltinFunction ( behaviour, length, name, additionalInternalSlotsList [ , realm [ , proto [ , prefix [ , async ] ] ] ] )
The abstract operation CreateBuiltinFunction takes arguments behaviour (an
- If realm is not present, set realm to
the current Realm Record . - If proto is not present, set proto to realm.[[Intrinsics]].[[
%Function.prototype% ]]. - If async is not present, set async to
false . - Let internalSlotsList be a
List containing the names of all the internal slots that10.3 requires for the built-infunction object that is about to be created. - Append the elements of additionalInternalSlotsList to internalSlotsList.
- 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 newfunction object has internal slots whose names are the elements of internalSlotsList, and an [[InitialName]] internal slot. - Set func.[[Async]] to async.
- Set func.[[Prototype]] to proto.
- Set func.[[Extensible]] to
true . - Set func.[[Realm]] to realm.
- Set func.[[InitialName]] to
null . - Perform
SetFunctionLength (func, length). - If prefix is not present, then
- Perform
SetFunctionName (func, name).
- Perform
- Else,
- Perform
SetFunctionName (func, name, prefix).
- Perform
- Return func.
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
10.4.1 Bound Function Exotic Objects
A
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
| Internal Slot | Type | Description |
|---|---|---|
| [[BoundTargetFunction]] | a callable Object |
The wrapped |
| [[BoundThis]] |
an |
The value that is always passed as the |
| [[BoundArguments]] |
a |
A list of values whose elements are used as the first arguments to any call to the wrapped function. |
10.4.1.1 [[Call]] ( thisArg, argList )
The [[Call]] internal method of a
- Let target be func.[[BoundTargetFunction]].
- Let boundThis be func.[[BoundThis]].
- Let boundArgs be func.[[BoundArguments]].
- Let args be the
list-concatenation of boundArgs and argList. - Return ?
Call (target, boundThis, args).
10.4.1.2 [[Construct]] ( argList, newTarget )
The [[Construct]] internal method of a
- Let target be func.[[BoundTargetFunction]].
Assert :IsConstructor (target) istrue .- Let boundArgs be func.[[BoundArguments]].
- Let args be the
list-concatenation of boundArgs and argList. - If
SameValue (func, newTarget) istrue , set newTarget to target. - Return ?
Construct (target, args, newTarget).
10.4.1.3 BoundFunctionCreate ( targetFunc, boundThis, boundArgs )
The abstract operation BoundFunctionCreate takes arguments targetFunc (a
- Let proto be ?
targetFunc.[[GetPrototypeOf]]() . - Let internalSlotsList be the
list-concatenation of « [[Prototype]], [[Extensible]] » and the internal slots listed inTable 26 . - Let obj be
MakeBasicObject (internalSlotsList). - Set obj.[[Prototype]] to proto.
- Set obj.[[Call]] as specified in
10.4.1.1 . - If
IsConstructor (targetFunc) istrue , then- Set obj.[[Construct]] as specified in
10.4.1.2 .
- Set obj.[[Construct]] as specified in
- Set obj.[[BoundTargetFunction]] to targetFunc.
- Set obj.[[BoundThis]] to boundThis.
- Set obj.[[BoundArguments]] to boundArgs.
- Return obj.
10.4.2 Array Exotic Objects
An Array is an
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.4.2.1 [[DefineOwnProperty]] ( propertyKey, propertyDesc )
The [[DefineOwnProperty]] internal method of an
- If propertyKey is
"length" , return ?ArraySetLength (array, propertyDesc). - If propertyKey is an
array index , then- Let lengthDesc be
OrdinaryGetOwnProperty (array,"length" ). Assert : lengthDesc is notundefined .Assert :IsDataDescriptor (lengthDesc) istrue .Assert : lengthDesc.[[Configurable]] isfalse .- Let length be lengthDesc.[[Value]].
Assert : length is a non-negativeintegral Number .- Let index be !
ToUint32 (propertyKey). - If index ≥ length and lengthDesc.[[Writable]] is
false , returnfalse . - Let succeeded be !
OrdinaryDefineOwnProperty (array, propertyKey, propertyDesc). - If succeeded is
false , returnfalse . - If index ≥ length, then
- Set lengthDesc.[[Value]] to index +
1 𝔽. - Set succeeded to !
OrdinaryDefineOwnProperty (array,"length" , lengthDesc). Assert : succeeded istrue .
- Set lengthDesc.[[Value]] to index +
- Return
true .
- Let lengthDesc be
- Return ?
OrdinaryDefineOwnProperty (array, propertyKey, propertyDesc).
10.4.2.2 ArrayCreate ( length [ , proto ] )
The abstract operation ArrayCreate takes argument length (a non-negative
- If length > 232 - 1, throw a
RangeError exception. - If proto is not present, set proto to
%Array.prototype% . - Let array be
MakeBasicObject (« [[Prototype]], [[Extensible]] »). - Set array.[[Prototype]] to proto.
- Set array.[[DefineOwnProperty]] as specified in
10.4.2.1 . - Perform !
OrdinaryDefineOwnProperty (array,"length" , PropertyDescriptor { [[Value]]:𝔽 (length), [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:false }). - Return array.
10.4.2.3 ArraySpeciesCreate ( originalArray, length )
The abstract operation ArraySpeciesCreate takes arguments originalArray (an Object) and length (a non-negative
- Let isArray be ?
IsArray (originalArray). - If isArray is
false , return ?ArrayCreate (length). - Let ctor be ?
Get (originalArray,"constructor" ). - If
IsConstructor (ctor) istrue , then- Let thisRealm be
the current Realm Record . - Let ctorRealm be ?
GetFunctionRealm (ctor). - If thisRealm and ctorRealm are not the same
Realm Record , then- If
SameValue (ctor, ctorRealm.[[Intrinsics]].[[%Array% ]]) istrue , set ctor toundefined .
- If
- Let thisRealm be
- If ctor
is an Object , then- Set ctor to ?
Get (ctor,%Symbol.species% ). - If ctor is
null , set ctor toundefined .
- Set ctor to ?
- If ctor is
undefined , return ?ArrayCreate (length). - If
IsConstructor (ctor) isfalse , throw aTypeError exception. - Return ?
Construct (ctor, «𝔽 (length) »).
If originalArray was created using the standard built-in Array Array.prototype methods that now are defined using ArraySpeciesCreate.
10.4.2.4 ArraySetLength ( array, propertyDesc )
The abstract operation ArraySetLength takes arguments array (an Array) and propertyDesc (a
- If propertyDesc does not have a [[Value]] field, then
- Return !
OrdinaryDefineOwnProperty (array,"length" , propertyDesc).
- Return !
- Let newLengthDesc be a copy of propertyDesc.
- Let newLength be ?
ToUint32 (propertyDesc.[[Value]]). - Let numberLength be ?
ToNumber (propertyDesc.[[Value]]). - If
SameValueZero (newLength, numberLength) isfalse , throw aRangeError exception. - Set newLengthDesc.[[Value]] to newLength.
- Let oldLengthDesc be
OrdinaryGetOwnProperty (array,"length" ). Assert : oldLengthDesc is notundefined .Assert :IsDataDescriptor (oldLengthDesc) istrue .Assert : oldLengthDesc.[[Configurable]] isfalse .- Let oldLength be oldLengthDesc.[[Value]].
- If newLength ≥ oldLength, then
- Return !
OrdinaryDefineOwnProperty (array,"length" , newLengthDesc).
- Return !
- If oldLengthDesc.[[Writable]] is
false , returnfalse . - If newLengthDesc does not have a [[Writable]] field or newLengthDesc.[[Writable]] is
true , then- Let newWritable be
true .
- Let newWritable be
- Else,
NOTE : Setting the [[Writable]] attribute tofalse is deferred in case any elements cannot be deleted.- Let newWritable be
false . - Set newLengthDesc.[[Writable]] to
true .
- Let succeeded be !
OrdinaryDefineOwnProperty (array,"length" , newLengthDesc). - If succeeded is
false , returnfalse . - For each own
property key propertyKey of array such that propertyKey is anarray index and !ToUint32 (propertyKey) ≥ newLength, in descending numeric index order, do- Let deleteSucceeded be ! array.[[Delete]](propertyKey).
- If deleteSucceeded is
false , then- Set newLengthDesc.[[Value]] to !
ToUint32 (propertyKey) +1 𝔽. - If newWritable is
false , set newLengthDesc.[[Writable]] tofalse . - Perform !
OrdinaryDefineOwnProperty (array,"length" , newLengthDesc). - Return
false .
- Set newLengthDesc.[[Value]] to !
- If newWritable is
false , then- Set succeeded to !
OrdinaryDefineOwnProperty (array,"length" , PropertyDescriptor { [[Writable]]:false }). Assert : succeeded istrue .
- Set succeeded to !
- Return
true .
10.4.3 String Exotic Objects
A String object is an
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.4.3.1 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of a
- Let propertyDesc be
OrdinaryGetOwnProperty (string, propertyKey). - If propertyDesc is not
undefined , return propertyDesc. - Return
StringGetOwnProperty (string, propertyKey).
10.4.3.2 [[DefineOwnProperty]] ( propertyKey, propertyDesc )
The [[DefineOwnProperty]] internal method of a
- Let stringDesc be
StringGetOwnProperty (string, propertyKey). - If stringDesc is not
undefined , then- Let extensible be string.[[Extensible]].
- Return
IsCompatiblePropertyDescriptor (extensible, propertyDesc, stringDesc).
- Return !
OrdinaryDefineOwnProperty (string, propertyKey, propertyDesc).
10.4.3.3 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a
- Let keys be a new empty
List . - Let string be obj.[[StringData]].
Assert : stringis a String .- Let length be the length of string.
- For each
integer i such that 0 ≤ i < length, in ascending order, do - For each own
property key propertyKey of obj such that propertyKey is anarray index and !ToIntegerOrInfinity (propertyKey) ≥ length, in ascending numeric index order, do- Append propertyKey to keys.
- For each own
property key propertyKey of obj such that propertyKeyis a String and propertyKey is not anarray index , in ascending chronological order of property creation, do- Append propertyKey to keys.
- For each own
property key propertyKey of obj such that propertyKeyis a Symbol , in ascending chronological order of property creation, do- Append propertyKey to keys.
- Return keys.
10.4.3.4 StringCreate ( value, proto )
The abstract operation StringCreate takes arguments value (a String) and proto (an Object) and returns a
- Let string be
MakeBasicObject (« [[Prototype]], [[Extensible]], [[StringData]] »). - Set string.[[Prototype]] to proto.
- Set string.[[StringData]] to value.
- Set string.[[GetOwnProperty]] as specified in
10.4.3.1 . - Set string.[[DefineOwnProperty]] as specified in
10.4.3.2 . - Set string.[[OwnPropertyKeys]] as specified in
10.4.3.3 . - Let length be the length of value.
- Perform !
DefinePropertyOrThrow (string,"length" , PropertyDescriptor { [[Value]]:𝔽 (length), [[Writable]]:false , [[Enumerable]]:false , [[Configurable]]:false }). - Return string.
10.4.3.5 StringGetOwnProperty ( string, propertyKey )
The abstract operation StringGetOwnProperty takes arguments string (an Object that has a [[StringData]] internal slot) and propertyKey (a
- If propertyKey
is not a String , returnundefined . - Let numericIndex be
CanonicalNumericIndexString (propertyKey). - If numericIndex is not an
integral Number , returnundefined . - If numericIndex is
-0 𝔽 or numericIndex <-0 𝔽, returnundefined . - Let stringData be string.[[StringData]].
Assert : stringDatais a String .- Let length be the length of stringData.
- If
ℝ (numericIndex) ≥ length, returnundefined . - Let resultString be the
substring of stringData fromℝ (numericIndex) toℝ (numericIndex) + 1. - Return the PropertyDescriptor { [[Value]]: resultString, [[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 an
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
While
Object.prototype.toString (
The
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.
Ordinary arguments objects define a non-configurable
ECMAScript implementations of
10.4.4.1 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of an
- Let propertyDesc be
OrdinaryGetOwnProperty (args, propertyKey). - If propertyDesc is
undefined , returnundefined . - Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, propertyKey). - If isMapped is
true , then- Set propertyDesc.[[Value]] to !
Get (map, propertyKey).
- Set propertyDesc.[[Value]] to !
- Return propertyDesc.
10.4.4.2 [[DefineOwnProperty]] ( propertyKey, propertyDesc )
The [[DefineOwnProperty]] internal method of an
- Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, propertyKey). - Let newArgDesc be propertyDesc.
- If isMapped is
true andIsDataDescriptor (propertyDesc) istrue , then- If propertyDesc does not have a [[Value]] field, propertyDesc has a [[Writable]] field, and propertyDesc.[[Writable]] is
false , then- Set newArgDesc to a copy of propertyDesc.
- Set newArgDesc.[[Value]] to !
Get (map, propertyKey).
- If propertyDesc does not have a [[Value]] field, propertyDesc has a [[Writable]] field, and propertyDesc.[[Writable]] is
- Let allowed be !
OrdinaryDefineOwnProperty (args, propertyKey, newArgDesc). - If allowed is
false , returnfalse . - If isMapped is
true , then- If
IsAccessorDescriptor (propertyDesc) istrue , then- Perform ! map.[[Delete]](propertyKey).
- Else,
- If propertyDesc has a [[Value]] field, then
- If propertyDesc has a [[Writable]] field and propertyDesc.[[Writable]] is
false , then- Perform ! map.[[Delete]](propertyKey).
- If
- Return
true .
10.4.4.3 [[Get]] ( propertyKey, receiver )
The [[Get]] internal method of an
- Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, propertyKey). - If isMapped is
false , return ?OrdinaryGet (args, propertyKey, receiver). Assert : map contains a formal parameter mapping for propertyKey.- Return !
Get (map, propertyKey).
10.4.4.4 [[Set]] ( propertyKey, value, receiver )
The [[Set]] internal method of an
- If
SameValue (args, receiver) isfalse , then- Let isMapped be
false .
- Let isMapped be
- Else,
- Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, propertyKey).
- If isMapped is
true , then - Return ?
OrdinarySet (args, propertyKey, value, receiver).
10.4.4.5 [[Delete]] ( propertyKey )
The [[Delete]] internal method of an
- Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, propertyKey). - Let result be ?
OrdinaryDelete (args, propertyKey). - If result is
true and isMapped istrue , then- Perform ! map.[[Delete]](propertyKey).
- Return result.
10.4.4.6 CreateUnmappedArgumentsObject ( argList )
The abstract operation CreateUnmappedArgumentsObject takes argument argList (a
- Let length be the number of elements in argList.
- Let obj be
OrdinaryObjectCreate (%Object.prototype% , « [[ParameterMap]] »). - Set obj.[[ParameterMap]] to
undefined . - Perform !
DefinePropertyOrThrow (obj,"length" , PropertyDescriptor { [[Value]]:𝔽 (length), [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:true }). - Let index be 0.
- Repeat, while index < length,
- Let value be argList[index].
- Perform !
CreateDataPropertyOrThrow (obj, !ToString (𝔽 (index)), value). - Set index to index + 1.
- Perform !
DefinePropertyOrThrow (obj,%Symbol.iterator% , PropertyDescriptor { [[Value]]:%Array.prototype.values% , [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:true }). - Perform !
DefinePropertyOrThrow (obj,"callee" , PropertyDescriptor { [[Get]]:%ThrowTypeError% , [[Set]]:%ThrowTypeError% , [[Enumerable]]:false , [[Configurable]]:false }). - Return obj.
10.4.4.7 CreateMappedArgumentsObject ( func, formals, argList, envRecord )
The abstract operation CreateMappedArgumentsObject takes arguments func (an ECMAScript
Assert : formals does not contain a rest parameter, any binding patterns, or any initializers. It may contain duplicate identifiers.- Let length be the number of elements in argList.
- Let obj be
MakeBasicObject (« [[Prototype]], [[Extensible]], [[ParameterMap]] »). - Set obj.[[GetOwnProperty]] as specified in
10.4.4.1 . - Set obj.[[DefineOwnProperty]] as specified in
10.4.4.2 . - Set obj.[[Get]] as specified in
10.4.4.3 . - Set obj.[[Set]] as specified in
10.4.4.4 . - Set obj.[[Delete]] as specified in
10.4.4.5 . - Set obj.[[Prototype]] to
%Object.prototype% . - Let map be
OrdinaryObjectCreate (null ). - Set obj.[[ParameterMap]] to map.
- Let paramNames be the
BoundNames of formals. - Let paramCount be the number of elements in paramNames.
- Let index be 0.
- Repeat, while index < length,
- Let value be argList[index].
- Perform !
CreateDataPropertyOrThrow (obj, !ToString (𝔽 (index)), value). - Set index to index + 1.
- Perform !
DefinePropertyOrThrow (obj,"length" , PropertyDescriptor { [[Value]]:𝔽 (length), [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:true }). - Let mappedNames be a new empty
List . - Set index to paramCount - 1.
- Repeat, while index ≥ 0,
- Let name be paramNames[index].
- If mappedNames does not contain name, then
- Append name to mappedNames.
- If index < length, then
- Let getter be
MakeArgGetter (name, envRecord). - Let setter be
MakeArgSetter (name, envRecord). - Perform ! map.[[DefineOwnProperty]](!
ToString (𝔽 (index)), PropertyDescriptor { [[Set]]: setter, [[Get]]: getter, [[Enumerable]]:false , [[Configurable]]:true }).
- Let getter be
- Set index to index - 1.
- Perform !
DefinePropertyOrThrow (obj,%Symbol.iterator% , PropertyDescriptor { [[Value]]:%Array.prototype.values% , [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:true }). - Perform !
DefinePropertyOrThrow (obj,"callee" , PropertyDescriptor { [[Value]]: func, [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:true }). - Return obj.
10.4.4.7.1 MakeArgGetter ( name, envRecord )
The abstract operation MakeArgGetter takes arguments name (a String) and envRecord (an
- Let getterClosure be a new
Abstract Closure with no parameters that captures name and envRecord and performs the following steps when called:- Return
NormalCompletion (! envRecord.GetBindingValue(name,false )).
- Return
- Let getter be
CreateBuiltinFunction (getterClosure, 0,"" , « »). NOTE : getter is never directly accessible to ECMAScript code.- Return getter.
10.4.4.7.2 MakeArgSetter ( name, envRecord )
The abstract operation MakeArgSetter takes arguments name (a String) and envRecord (an
- Let setterClosure be a new
Abstract Closure with parameters (value) that captures name and envRecord and performs the following steps when called:- Return
NormalCompletion (! envRecord.SetMutableBinding(name, value,false )).
- Return
- Let setter be
CreateBuiltinFunction (setterClosure, 1,"" , « »). NOTE : setter is never directly accessible to ECMAScript code.- Return setter.
10.4.5 TypedArray Exotic Objects
A
Because
An object is a TypedArray 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 in
10.4.5.1 [[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of a
NOTE : The extensibility-related invariants specified in6.1.7.3 do not allow this method to returntrue when obj can gain (or lose and then regain) properties, which might occur for properties withinteger index names when its underlying buffer is resized.- If
IsTypedArrayFixedLength (obj) isfalse , returnfalse . - Return
OrdinaryPreventExtensions (obj).
10.4.5.2 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of a
- If propertyKey
is a String , then- Let numericIndex be
CanonicalNumericIndexString (propertyKey). - If numericIndex is not
undefined , then- Let value be
TypedArrayGetElement (obj, numericIndex). - If value is
undefined , returnundefined . - Return the PropertyDescriptor { [[Value]]: value, [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:true }.
- Let value be
- Let numericIndex be
- Return
OrdinaryGetOwnProperty (obj, propertyKey).
10.4.5.3 [[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of a
- If propertyKey
is a String , then- Let numericIndex be
CanonicalNumericIndexString (propertyKey). - If numericIndex is not
undefined , returnIsValidIntegerIndex (obj, numericIndex).
- Let numericIndex be
- Return ?
OrdinaryHasProperty (obj, propertyKey).
10.4.5.4 [[DefineOwnProperty]] ( propertyKey, propertyDesc )
The [[DefineOwnProperty]] internal method of a
- If propertyKey
is a String , then- Let numericIndex be
CanonicalNumericIndexString (propertyKey). - If numericIndex is not
undefined , then- If
IsValidIntegerIndex (obj, numericIndex) isfalse , returnfalse . - If propertyDesc has a [[Configurable]] field and propertyDesc.[[Configurable]] is
false , returnfalse . - If propertyDesc has an [[Enumerable]] field and propertyDesc.[[Enumerable]] is
false , returnfalse . - If
IsAccessorDescriptor (propertyDesc) istrue , returnfalse . - If propertyDesc has a [[Writable]] field and propertyDesc.[[Writable]] is
false , returnfalse . - If propertyDesc has a [[Value]] field, perform ?
TypedArraySetElement (obj, numericIndex, propertyDesc.[[Value]]). - Return
true .
- If
- Let numericIndex be
- Return !
OrdinaryDefineOwnProperty (obj, propertyKey, propertyDesc).
10.4.5.5 [[Get]] ( propertyKey, receiver )
The [[Get]] internal method of a
- If propertyKey
is a String , then- Let numericIndex be
CanonicalNumericIndexString (propertyKey). - If numericIndex is not
undefined , then- Return
TypedArrayGetElement (obj, numericIndex).
- Return
- Let numericIndex be
- Return ?
OrdinaryGet (obj, propertyKey, receiver).
10.4.5.6 [[Set]] ( propertyKey, value, receiver )
The [[Set]] internal method of a
- If propertyKey
is a String , then- Let numericIndex be
CanonicalNumericIndexString (propertyKey). - If numericIndex is not
undefined , then- If
SameValue (obj, receiver) istrue , then- Perform ?
TypedArraySetElement (obj, numericIndex, value). - Return
true .
- Perform ?
- If
IsValidIntegerIndex (obj, numericIndex) isfalse , returntrue .
- If
- Let numericIndex be
- Return ?
OrdinarySet (obj, propertyKey, value, receiver).
10.4.5.7 [[Delete]] ( propertyKey )
The [[Delete]] internal method of a
- If propertyKey
is a String , then- Let numericIndex be
CanonicalNumericIndexString (propertyKey). - If numericIndex is not
undefined , then- If
IsValidIntegerIndex (obj, numericIndex) isfalse , returntrue . - Return
false .
- If
- Let numericIndex be
- Return !
OrdinaryDelete (obj, propertyKey).
10.4.5.8 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a
- Let taRecord be
MakeTypedArrayWithBufferWitnessRecord (obj,seq-cst ). - Let keys be a new empty
List . - If
IsTypedArrayOutOfBounds (taRecord) isfalse , then- Let length be
TypedArrayLength (taRecord). - For each
integer i such that 0 ≤ i < length, in ascending order, do
- Let length be
- For each own
property key propertyKey of obj such that propertyKeyis a String and propertyKey is not aninteger index , in ascending chronological order of property creation, do- Append propertyKey to keys.
- For each own
property key propertyKey of obj such that propertyKeyis a Symbol , in ascending chronological order of property creation, do- Append propertyKey to keys.
- Return keys.
10.4.5.9 TypedArray With Buffer Witness Records
An TypedArray With Buffer Witness Record is a
TypedArray With Buffer Witness Records have the fields listed in
| Field Name | Value | Meaning |
|---|---|---|
| [[Object]] |
a |
The |
| [[CachedBufferByteLength]] |
a non-negative |
The byte length of the object's [[ViewedArrayBuffer]] when the |
10.4.5.10 MakeTypedArrayWithBufferWitnessRecord ( obj, order )
The abstract operation MakeTypedArrayWithBufferWitnessRecord takes arguments obj (a
- Let buffer be obj.[[ViewedArrayBuffer]].
- If
IsDetachedBuffer (buffer) istrue , then- Let byteLength be
detached .
- Let byteLength be
- Else,
- Let byteLength be
ArrayBufferByteLength (buffer, order).
- Let byteLength be
- Return the
TypedArray With Buffer Witness Record { [[Object]]: obj, [[CachedBufferByteLength]]: byteLength }.
10.4.5.11 TypedArrayCreate ( proto )
The abstract operation TypedArrayCreate takes argument proto (an Object) and returns a
- Let internalSlotsList be « [[Prototype]], [[Extensible]], [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] ».
- Let ta be
MakeBasicObject (internalSlotsList). - Set ta.[[PreventExtensions]] as specified in
10.4.5.1 . - Set ta.[[GetOwnProperty]] as specified in
10.4.5.2 . - Set ta.[[HasProperty]] as specified in
10.4.5.3 . - Set ta.[[DefineOwnProperty]] as specified in
10.4.5.4 . - Set ta.[[Get]] as specified in
10.4.5.5 . - Set ta.[[Set]] as specified in
10.4.5.6 . - Set ta.[[Delete]] as specified in
10.4.5.7 . - Set ta.[[OwnPropertyKeys]] as specified in
10.4.5.8 . - Set ta.[[Prototype]] to proto.
- Return ta.
10.4.5.12 TypedArrayByteLength ( taRecord )
The abstract operation TypedArrayByteLength takes argument taRecord (a
Assert :IsTypedArrayOutOfBounds (taRecord) isfalse .- Let obj be taRecord.[[Object]].
- If obj.[[ByteLength]] is not
auto , return obj.[[ByteLength]]. - Let length be
TypedArrayLength (taRecord). - Let elementSize be
TypedArrayElementSize (obj). NOTE : The returned byte length is always aninteger multiple of elementSize, even when the underlying buffer has been resized to a non-integer multiple.- Return length × elementSize.
10.4.5.13 TypedArrayLength ( taRecord )
The abstract operation TypedArrayLength takes argument taRecord (a
Assert :IsTypedArrayOutOfBounds (taRecord) isfalse .- Let obj be taRecord.[[Object]].
- If obj.[[ArrayLength]] is not
auto , return obj.[[ArrayLength]]. Assert :IsFixedLengthArrayBuffer (obj.[[ViewedArrayBuffer]]) isfalse .- Let byteOffset be obj.[[ByteOffset]].
- Let elementSize be
TypedArrayElementSize (obj). - Let byteLength be taRecord.[[CachedBufferByteLength]].
Assert : byteLength is notdetached .- Return
floor ((byteLength - byteOffset) / elementSize).
10.4.5.14 IsTypedArrayOutOfBounds ( taRecord )
The abstract operation IsTypedArrayOutOfBounds takes argument taRecord (a
- Let obj be taRecord.[[Object]].
- Let bufferByteLength be taRecord.[[CachedBufferByteLength]].
- If
IsDetachedBuffer (obj.[[ViewedArrayBuffer]]) istrue , thenAssert : bufferByteLength isdetached .- Return
true .
Assert : bufferByteLength is a non-negativeinteger .- Let byteOffsetStart be obj.[[ByteOffset]].
- If obj.[[ArrayLength]] is
auto , then- Let byteOffsetEnd be bufferByteLength.
- Else,
- Let elementSize be
TypedArrayElementSize (obj). - Let arrayByteLength be obj.[[ArrayLength]] × elementSize.
- Let byteOffsetEnd be byteOffsetStart + arrayByteLength.
- Let elementSize be
NOTE : A 0-lengthTypedArray whose [[ByteOffset]] is bufferByteLength is not considered out-of-bounds.- If byteOffsetStart > bufferByteLength or byteOffsetEnd > bufferByteLength, return
true . - Return
false .
10.4.5.15 IsTypedArrayFixedLength ( obj )
The abstract operation IsTypedArrayFixedLength takes argument obj (a
- If obj.[[ArrayLength]] is
auto , returnfalse . - Let buffer be obj.[[ViewedArrayBuffer]].
- If
IsFixedLengthArrayBuffer (buffer) isfalse andIsSharedArrayBuffer (buffer) isfalse , returnfalse . - Return
true .
10.4.5.16 IsValidIntegerIndex ( obj, index )
The abstract operation IsValidIntegerIndex takes arguments obj (a
- If
IsDetachedBuffer (obj.[[ViewedArrayBuffer]]) istrue , returnfalse . - If index is not an
integral Number , returnfalse . - If index is
-0 𝔽 or index <-0 𝔽, returnfalse . - Let taRecord be
MakeTypedArrayWithBufferWitnessRecord (obj,unordered ). NOTE : Bounds checking is not a synchronizing operation when obj's backing buffer is agrowable SharedArrayBuffer .- If
IsTypedArrayOutOfBounds (taRecord) istrue , returnfalse . - Let length be
TypedArrayLength (taRecord). - If
ℝ (index) ≥ length, returnfalse . - Return
true .
10.4.5.17 TypedArrayGetElement ( obj, index )
The abstract operation TypedArrayGetElement takes arguments obj (a
- If
IsValidIntegerIndex (obj, index) isfalse , returnundefined . - Let offset be obj.[[ByteOffset]].
- Let elementSize be
TypedArrayElementSize (obj). - Let byteIndexInBuffer be (
ℝ (index) × elementSize) + offset. - Let elementType be
TypedArrayElementType (obj). - Return
GetValueFromBuffer (obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType,true ,unordered ).
10.4.5.18 TypedArraySetElement ( obj, index, value )
The abstract operation TypedArraySetElement takes arguments obj (a
- If obj.[[ContentType]] is
bigint , let number be ?ToBigInt (value). - Else, let number be ?
ToNumber (value). - If
IsValidIntegerIndex (obj, index) istrue , then- Let offset be obj.[[ByteOffset]].
- Let elementSize be
TypedArrayElementSize (obj). - Let byteIndexInBuffer be (
ℝ (index) × elementSize) + offset. - Let elementType be
TypedArrayElementType (obj). - Perform
SetValueInBuffer (obj.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, number,true ,unordered ).
- Return
unused .
This operation always appears to succeed, but it has no effect when attempting to write past the end of a
10.4.5.19 IsArrayBufferViewOutOfBounds ( obj )
The abstract operation IsArrayBufferViewOutOfBounds takes argument obj (a
- If obj has a [[DataView]] internal slot, then
- Let viewRecord be
MakeDataViewWithBufferWitnessRecord (obj,seq-cst ). - Return
IsViewOutOfBounds (viewRecord).
- Let viewRecord be
- Let taRecord be
MakeTypedArrayWithBufferWitnessRecord (obj,seq-cst ). - Return
IsTypedArrayOutOfBounds (taRecord).
10.4.6 Module Namespace Exotic Objects
A export * export items. Each String-valued own
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
| Internal Slot | Type | Description |
|---|---|---|
| [[Module]] |
a |
The |
| [[Exports]] |
a |
A |
10.4.6.1 [[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of a
- Return
null .
10.4.6.2 [[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of a
- Return !
SetImmutablePrototype (obj, proto).
10.4.6.3 [[IsExtensible]] ( )
The [[IsExtensible]] internal method of a
- Return
false .
10.4.6.4 [[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of a
- Return
true .
10.4.6.5 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of a
- If propertyKey
is a Symbol , returnOrdinaryGetOwnProperty (obj, propertyKey). - Let exports be obj.[[Exports]].
- If exports does not contain propertyKey, return
undefined . - Let value be ? obj.[[Get]](propertyKey, obj).
- Return PropertyDescriptor { [[Value]]: value, [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:false }.
10.4.6.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )
The [[DefineOwnProperty]] internal method of a
- If propertyKey
is a Symbol , return !OrdinaryDefineOwnProperty (obj, propertyKey, propertyDesc). - Let current be ? obj.[[GetOwnProperty]](propertyKey).
- If current is
undefined , returnfalse . - If propertyDesc has a [[Configurable]] field and propertyDesc.[[Configurable]] is
true , returnfalse . - If propertyDesc has an [[Enumerable]] field and propertyDesc.[[Enumerable]] is
false , returnfalse . - If
IsAccessorDescriptor (propertyDesc) istrue , returnfalse . - If propertyDesc has a [[Writable]] field and propertyDesc.[[Writable]] is
false , returnfalse . - If propertyDesc has a [[Value]] field, return
SameValue (propertyDesc.[[Value]], current.[[Value]]). - Return
true .
10.4.6.7 [[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of a
- If propertyKey
is a Symbol , return !OrdinaryHasProperty (obj, propertyKey). - Let exports be obj.[[Exports]].
- If exports contains propertyKey, return
true . - Return
false .
10.4.6.8 [[Get]] ( propertyKey, receiver )
The [[Get]] internal method of a
- If propertyKey
is a Symbol , then- Return !
OrdinaryGet (obj, propertyKey, receiver).
- Return !
- Let exports be obj.[[Exports]].
- If exports does not contain propertyKey, return
undefined . - Let module be obj.[[Module]].
- Let binding be module.ResolveExport(propertyKey).
Assert : binding is aResolvedBinding Record .- Let targetModule be binding.[[Module]].
Assert : targetModule is notundefined .- If binding.[[BindingName]] is
namespace , then- Return
GetModuleNamespace (targetModule).
- Return
- Let targetEnv be targetModule.[[Environment]].
- If targetEnv is
empty , throw aReferenceError exception. - Return ? targetEnv.GetBindingValue(binding.[[BindingName]],
true ).
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
10.4.6.9 [[Set]] ( propertyKey, value, receiver )
The [[Set]] internal method of a
- Return
false .
10.4.6.10 [[Delete]] ( propertyKey )
The [[Delete]] internal method of a
- If propertyKey
is a Symbol , then- Return !
OrdinaryDelete (obj, propertyKey).
- Return !
- Let exports be obj.[[Exports]].
- If exports contains propertyKey, return
false . - Return
true .
10.4.6.11 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a
- Let exports be obj.[[Exports]].
- Let symbolKeys be
OrdinaryOwnPropertyKeys (obj). - Return the
list-concatenation of exports and symbolKeys.
10.4.6.12 ModuleNamespaceCreate ( module, exports )
The abstract operation ModuleNamespaceCreate takes arguments module (a
Assert : module.[[Namespace]] isempty .- Let internalSlotsList be the internal slots listed in
Table 28 . - Let namespace be
MakeBasicObject (internalSlotsList). - Set namespace's essential internal methods to the definitions specified in
10.4.6 . - Set namespace.[[Module]] to module.
- Let sortedExports be a
List whose elements are the elements of exports, sorted according tolexicographic code unit order . - Set namespace.[[Exports]] to sortedExports.
- Create own properties of namespace corresponding to the definitions in
28.3 . - Set module.[[Namespace]] to namespace.
- Return namespace.
10.4.7 Immutable Prototype Exotic Objects
An
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
Unlike other
10.4.7.1 [[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of an
- Return ?
SetImmutablePrototype (obj, proto).
10.4.7.2 SetImmutablePrototype ( obj, proto )
The abstract operation SetImmutablePrototype takes arguments obj (an Object) and proto (an Object or
- Let current be ?
obj.[[GetPrototypeOf]]() . - If
SameValue (proto, current) istrue , returntrue . - Return
false .
10.5 Proxy Object Internal Methods and Internal Slots
A Proxy object is an
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
| 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
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
In the following algorithm descriptions, assume obj is an ECMAScript Proxy object, propertyKey is a
10.5.1 [[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"getPrototypeOf" ). - If trap is
undefined , then- Return ?
target.[[GetPrototypeOf]]() .
- Return ?
- Let handlerProto be ?
Call (trap, handler, « target »). - If handlerProto
is not an Object and handlerProto is notnull , throw aTypeError exception. - Let extensibleTarget be ?
IsExtensible (target). - If extensibleTarget is
true , return handlerProto. - Let targetProto be ?
target.[[GetPrototypeOf]]() . - If
SameValue (handlerProto, targetProto) isfalse , throw aTypeError exception. - Return handlerProto.
[[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.
10.5.2 [[SetPrototypeOf]] ( proto )
The [[SetPrototypeOf]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"setPrototypeOf" ). - If trap is
undefined , then- Return ?
target.[[SetPrototypeOf]](proto) .
- Return ?
- Let boolTrapResult be
ToBoolean (?Call (trap, handler, « target, proto »)). - If boolTrapResult is
false , returnfalse . - Let extensibleTarget be ?
IsExtensible (target). - If extensibleTarget is
true , returntrue . - Let targetProto be ?
target.[[GetPrototypeOf]]() . - If
SameValue (proto, targetProto) isfalse , throw aTypeError exception. - Return
true .
[[SetPrototypeOf]] for Proxy objects enforces the following invariants:
-
The result of [[SetPrototypeOf]]
is a Boolean value. - If the target object is not extensible, the argument value must be the same as the result of [[GetPrototypeOf]] applied to target object.
10.5.3 [[IsExtensible]] ( )
The [[IsExtensible]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"isExtensible" ). - If trap is
undefined , then- Return ?
IsExtensible (target).
- Return ?
- Let boolTrapResult be
ToBoolean (?Call (trap, handler, « target »)). - Let targetResult be ?
IsExtensible (target). - If boolTrapResult is not targetResult, throw a
TypeError exception. - Return boolTrapResult.
[[IsExtensible]] for Proxy objects enforces the following invariants:
-
The result of [[IsExtensible]]
is a Boolean value. - [[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.
10.5.4 [[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"preventExtensions" ). - If trap is
undefined , then- Return ?
target.[[PreventExtensions]]() .
- Return ?
- Let boolTrapResult be
ToBoolean (?Call (trap, handler, « target »)). - If boolTrapResult is
true , then- Let extensibleTarget be ?
IsExtensible (target). - If extensibleTarget is
true , throw aTypeError exception.
- Let extensibleTarget be ?
- Return boolTrapResult.
[[PreventExtensions]] for Proxy objects enforces the following invariants:
-
The result of [[PreventExtensions]]
is a Boolean value. -
[[PreventExtensions]] applied to the Proxy object only returns
true if [[IsExtensible]] applied to the Proxy object's target object isfalse .
10.5.5 [[GetOwnProperty]] ( propertyKey )
The [[GetOwnProperty]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"getOwnPropertyDescriptor" ). - If trap is
undefined , then- Return ?
target.[[GetOwnProperty]](propertyKey) .
- Return ?
- Let trapResultObj be ?
Call (trap, handler, « target, propertyKey »). - If trapResultObj
is not an Object and trapResultObj is notundefined , throw aTypeError exception. - Let targetDesc be ?
target.[[GetOwnProperty]](propertyKey) . - If trapResultObj is
undefined , then- If targetDesc is
undefined , returnundefined . - If targetDesc.[[Configurable]] is
false , throw aTypeError exception. - Let extensibleTarget be ?
IsExtensible (target). - If extensibleTarget is
false , throw aTypeError exception. - Return
undefined .
- If targetDesc is
- Let extensibleTarget be ?
IsExtensible (target). - Let resultDesc be ?
ToPropertyDescriptor (trapResultObj). - Perform
CompletePropertyDescriptor (resultDesc). - Let valid be
IsCompatiblePropertyDescriptor (extensibleTarget, resultDesc, targetDesc). - If valid is
false , throw aTypeError exception. - If resultDesc.[[Configurable]] is
false , then- If targetDesc is
undefined or targetDesc.[[Configurable]] istrue , then- Throw a
TypeError exception.
- Throw a
- If resultDesc has a [[Writable]] field and resultDesc.[[Writable]] is
false , thenAssert : targetDesc has a [[Writable]] field.- If targetDesc.[[Writable]] is
true , throw aTypeError exception.
- If targetDesc is
- Return resultDesc.
[[GetOwnProperty]] for Proxy objects enforces the following invariants:
-
The result of [[GetOwnProperty]] must be either a
Property Descriptor 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.
10.5.6 [[DefineOwnProperty]] ( propertyKey, propertyDesc )
The [[DefineOwnProperty]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"defineProperty" ). - If trap is
undefined , then- Return ?
target.[[DefineOwnProperty]](propertyKey, propertyDesc) .
- Return ?
- Let propertyDescObj be
FromPropertyDescriptor (propertyDesc). - Let boolTrapResult be
ToBoolean (?Call (trap, handler, « target, propertyKey, propertyDescObj »)). - If boolTrapResult is
false , returnfalse . - Let targetDesc be ?
target.[[GetOwnProperty]](propertyKey) . - Let extensibleTarget be ?
IsExtensible (target). - If propertyDesc has a [[Configurable]] field and propertyDesc.[[Configurable]] is
false , then- Let settingConfigFalse be
true .
- Let settingConfigFalse be
- Else,
- Let settingConfigFalse be
false .
- Let settingConfigFalse be
- If targetDesc is
undefined , then- If extensibleTarget is
false , throw aTypeError exception. - If settingConfigFalse is
true , throw aTypeError exception.
- If extensibleTarget is
- Else,
- If
IsCompatiblePropertyDescriptor (extensibleTarget, propertyDesc, targetDesc) isfalse , throw aTypeError exception. - If settingConfigFalse is
true and targetDesc.[[Configurable]] istrue , throw aTypeError exception. - If
IsDataDescriptor (targetDesc) istrue , targetDesc.[[Configurable]] isfalse , and targetDesc.[[Writable]] istrue , then- If propertyDesc has a [[Writable]] field and propertyDesc.[[Writable]] is
false , throw aTypeError exception.
- If propertyDesc has a [[Writable]] field and propertyDesc.[[Writable]] is
- If
- Return
true .
[[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.
10.5.7 [[HasProperty]] ( propertyKey )
The [[HasProperty]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"has" ). - If trap is
undefined , then- Return ?
target.[[HasProperty]](propertyKey) .
- Return ?
- Let boolTrapResult be
ToBoolean (?Call (trap, handler, « target, propertyKey »)). - If boolTrapResult is
false , then- Let targetDesc be ?
target.[[GetOwnProperty]](propertyKey) . - If targetDesc is not
undefined , then- If targetDesc.[[Configurable]] is
false , throw aTypeError exception. - Let extensibleTarget be ?
IsExtensible (target). - If extensibleTarget is
false , throw aTypeError exception.
- If targetDesc.[[Configurable]] is
- Let targetDesc be ?
- Return boolTrapResult.
[[HasProperty]] for Proxy objects enforces the following invariants:
-
The result of [[HasProperty]]
is a Boolean value. - 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 the target object and the target object is not extensible.
10.5.8 [[Get]] ( propertyKey, receiver )
The [[Get]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"get" ). - If trap is
undefined , then- Return ?
target.[[Get]](propertyKey, receiver) .
- Return ?
- Let trapResult be ?
Call (trap, handler, « target, propertyKey, receiver »). - Let targetDesc be ?
target.[[GetOwnProperty]](propertyKey) . - If targetDesc is not
undefined and targetDesc.[[Configurable]] isfalse , then- If
IsDataDescriptor (targetDesc) istrue and targetDesc.[[Writable]] isfalse , then- If
SameValue (trapResult, targetDesc.[[Value]]) isfalse , throw aTypeError exception.
- If
- If
IsAccessorDescriptor (targetDesc) istrue and targetDesc.[[Get]] isundefined , then- If trapResult is not
undefined , throw aTypeError exception.
- If trapResult is not
- If
- Return trapResult.
[[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 ownaccessor property that hasundefined as its [[Get]] attribute.
10.5.9 [[Set]] ( propertyKey, value, receiver )
The [[Set]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"set" ). - If trap is
undefined , then- Return ?
target.[[Set]](propertyKey, value, receiver) .
- Return ?
- Let boolTrapResult be
ToBoolean (?Call (trap, handler, « target, propertyKey, value, receiver »)). - If boolTrapResult is
false , returnfalse . - Let targetDesc be ?
target.[[GetOwnProperty]](propertyKey) . - If targetDesc is not
undefined and targetDesc.[[Configurable]] isfalse , then- If
IsDataDescriptor (targetDesc) istrue and targetDesc.[[Writable]] isfalse , then- If
SameValue (value, targetDesc.[[Value]]) isfalse , throw aTypeError exception.
- If
- If
IsAccessorDescriptor (targetDesc) istrue , then- If targetDesc.[[Set]] is
undefined , throw aTypeError exception.
- If targetDesc.[[Set]] is
- If
- Return
true .
[[Set]] for Proxy objects enforces the following invariants:
-
The result of [[Set]]
is a Boolean value. -
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 hasundefined as its [[Set]] attribute.
10.5.10 [[Delete]] ( propertyKey )
The [[Delete]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"deleteProperty" ). - If trap is
undefined , then- Return ?
target.[[Delete]](propertyKey) .
- Return ?
- Let boolTrapResult be
ToBoolean (?Call (trap, handler, « target, propertyKey »)). - If boolTrapResult is
false , returnfalse . - Let targetDesc be ?
target.[[GetOwnProperty]](propertyKey) . - If targetDesc is
undefined , returntrue . - If targetDesc.[[Configurable]] is
false , throw aTypeError exception. - Let extensibleTarget be ?
IsExtensible (target). - If extensibleTarget is
false , throw aTypeError exception. - Return
true .
[[Delete]] for Proxy objects enforces the following invariants:
-
The result of [[Delete]]
is a Boolean value. - A property cannot be reported as deleted, if it exists as a non-configurable own property of the target object.
- A property cannot be reported as deleted, if it exists as an own property of the target object and the target object is non-extensible.
10.5.11 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"ownKeys" ). - If trap is
undefined , then- Return ?
target.[[OwnPropertyKeys]]() .
- Return ?
- Let trapResultArray be ?
Call (trap, handler, « target »). - Let trapResult be ?
CreateListFromArrayLike (trapResultArray,property-key ). - If trapResult contains any duplicate entries, throw a
TypeError exception. - Let extensibleTarget be ?
IsExtensible (target). - Let targetKeys be ?
target.[[OwnPropertyKeys]]() . Assert : targetKeys is aList ofproperty keys .Assert : targetKeys contains no duplicate entries.- Let targetConfigurableKeys be a new empty
List . - Let targetNonconfigurableKeys be a new empty
List . - For each element key of targetKeys, do
- Let propertyDesc be ?
target.[[GetOwnProperty]](key) . - If propertyDesc is not
undefined and propertyDesc.[[Configurable]] isfalse , then- Append key to targetNonconfigurableKeys.
- Else,
- Append key to targetConfigurableKeys.
- Let propertyDesc be ?
- If extensibleTarget is
true and targetNonconfigurableKeys is empty, then- Return trapResult.
- Let uncheckedResultKeys be a
List whose elements are the elements of trapResult. - For each element key of targetNonconfigurableKeys, do
- If uncheckedResultKeys does not contain key, throw a
TypeError exception. - Remove key from uncheckedResultKeys.
- If uncheckedResultKeys does not contain key, throw a
- If extensibleTarget is
true , return trapResult. - For each element key of targetConfigurableKeys, do
- If uncheckedResultKeys does not contain key, throw a
TypeError exception. - Remove key from uncheckedResultKeys.
- If uncheckedResultKeys does not contain key, throw a
- If uncheckedResultKeys is not empty, throw a
TypeError exception. - Return trapResult.
[[OwnPropertyKeys]] for Proxy objects enforces the following invariants:
-
The result of [[OwnPropertyKeys]] is a
List . -
The returned
List contains no duplicate entries. -
Each element of the returned
List is aproperty key . -
The result
List must contain the keys of all non-configurable own properties of the target object. -
If the target object is not extensible, then the result
List must contain all the keys of the own properties of the target object and no other values.
10.5.12 [[Call]] ( thisArg, argList )
The [[Call]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"apply" ). - If trap is
undefined , then- Return ?
Call (target, thisArg, argList).
- Return ?
- Let argArray be
CreateArrayFromList (argList). - Return ?
Call (trap, handler, « target, thisArg, argArray »).
A
10.5.13 [[Construct]] ( argList, newTarget )
The [[Construct]] internal method of a
- Perform ?
ValidateNonRevokedProxy (obj). - Let target be obj.[[ProxyTarget]].
Assert :IsConstructor (target) istrue .- Let handler be obj.[[ProxyHandler]].
Assert : handleris an Object .- Let trap be ?
GetMethod (handler,"construct" ). - If trap is
undefined , then- Return ?
Construct (target, argList, newTarget).
- Return ?
- Let argArray be
CreateArrayFromList (argList). - Let newObj be ?
Call (trap, handler, « target, argArray, newTarget »). - If newObj
is not an Object , throw aTypeError exception. - Return newObj.
A
[[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
- If proxy.[[ProxyTarget]] is
null , throw aTypeError exception. Assert : proxy.[[ProxyHandler]] is notnull .- Return
unused .
10.5.15 ProxyCreate ( target, handler )
The abstract operation ProxyCreate takes arguments target (an
- If target
is not an Object , throw aTypeError exception. - If handler
is not an Object , throw aTypeError exception. - Let proxy be
MakeBasicObject (« [[ProxyHandler]], [[ProxyTarget]] »). - Set proxy's essential internal methods, except for [[Call]] and [[Construct]], to the definitions specified in
10.5 . - If
IsCallable (target) istrue , then- Set proxy.[[Call]] as specified in
10.5.12 . - If
IsConstructor (target) istrue , then- Set proxy.[[Construct]] as specified in
10.5.13 .
- Set proxy.[[Construct]] as specified in
- Set proxy.[[Call]] as specified in
- Set proxy.[[ProxyTarget]] to target.
- Set proxy.[[ProxyHandler]] to handler.
- Return proxy.