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]] ( thisArgument, argumentsList )
The [[Call]] internal method of a
- Let target be F.[[BoundTargetFunction]].
- Let boundThis be F.[[BoundThis]].
- Let boundArgs be F.[[BoundArguments]].
- Let args be the
list-concatenation of boundArgs and argumentsList. - Return ?
Call (target, boundThis, args).
10.4.1.2 [[Construct]] ( argumentsList, newTarget )
The [[Construct]] internal method of a
- Let target be F.[[BoundTargetFunction]].
Assert :IsConstructor (target) istrue .- Let boundArgs be F.[[BoundArguments]].
- Let args be the
list-concatenation of boundArgs and argumentsList. - If
SameValue (F, newTarget) istrue , set newTarget to target. - Return ?
Construct (target, args, newTarget).
10.4.1.3 BoundFunctionCreate ( targetFunction, boundThis, boundArgs )
The abstract operation BoundFunctionCreate takes arguments targetFunction (a
- Let proto be ? targetFunction.[[GetPrototypeOf]]().
- Let internalSlotsList be the
list-concatenation of « [[Prototype]], [[Extensible]] » and the internal slots listed inTable 31 . - Let obj be
MakeBasicObject (internalSlotsList). - Set obj.[[Prototype]] to proto.
- Set obj.[[Call]] as described in
10.4.1.1 . - If
IsConstructor (targetFunction) istrue , then- Set obj.[[Construct]] as described in
10.4.1.2 .
- Set obj.[[Construct]] as described in
- Set obj.[[BoundTargetFunction]] to targetFunction.
- Set obj.[[BoundThis]] to boundThis.
- Set obj.[[BoundArguments]] to boundArgs.
- Return obj.
10.4.2 Array Exotic Objects
An Array is an
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]] ( P, Desc )
The [[DefineOwnProperty]] internal method of an
- If P is
"length" , then- Return ?
ArraySetLength (A, Desc).
- Return ?
- Else if P is an
array index , then- Let lengthDesc be
OrdinaryGetOwnProperty (A,"length" ). Assert :IsDataDescriptor (lengthDesc) istrue .Assert : lengthDesc.[[Configurable]] isfalse .- Let length be lengthDesc.[[Value]].
Assert : length is a non-negativeintegral Number .- Let index be !
ToUint32 (P). - If index ≥ length and lengthDesc.[[Writable]] is
false , returnfalse . - Let succeeded be !
OrdinaryDefineOwnProperty (A, P, Desc). - If succeeded is
false , returnfalse . - If index ≥ length, then
- Set lengthDesc.[[Value]] to index +
1 𝔽. - Set succeeded to !
OrdinaryDefineOwnProperty (A,"length" , lengthDesc). Assert : succeeded istrue .
- Set lengthDesc.[[Value]] to index +
- Return
true .
- Let lengthDesc be
- Return ?
OrdinaryDefineOwnProperty (A, P, Desc).
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 A be
MakeBasicObject (« [[Prototype]], [[Extensible]] »). - Set A.[[Prototype]] to proto.
- Set A.[[DefineOwnProperty]] as specified in
10.4.2.1 . - Perform !
OrdinaryDefineOwnProperty (A,"length" , PropertyDescriptor { [[Value]]:𝔽 (length), [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:false }). - Return A.
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 C be ?
Get (originalArray,"constructor" ). - If
IsConstructor (C) istrue , then- Let thisRealm be
the current Realm Record . - Let realmC be ?
GetFunctionRealm (C). - If thisRealm and realmC are not the same
Realm Record , then
- Let thisRealm be
- If C
is an Object , then - If C is
undefined , return ?ArrayCreate (length). - If
IsConstructor (C) isfalse , throw aTypeError exception. - Return ?
Construct (C, «𝔽 (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 ( A, Desc )
The abstract operation ArraySetLength takes arguments A (an Array) and Desc (a
- If Desc does not have a [[Value]] field, then
- Return !
OrdinaryDefineOwnProperty (A,"length" , Desc).
- Return !
- Let newLenDesc be a copy of Desc.
- Let newLen be ?
ToUint32 (Desc.[[Value]]). - Let numberLen be ?
ToNumber (Desc.[[Value]]). - If
SameValueZero (newLen, numberLen) isfalse , throw aRangeError exception. - Set newLenDesc.[[Value]] to newLen.
- Let oldLenDesc be
OrdinaryGetOwnProperty (A,"length" ). Assert :IsDataDescriptor (oldLenDesc) istrue .Assert : oldLenDesc.[[Configurable]] isfalse .- Let oldLen be oldLenDesc.[[Value]].
- If newLen ≥ oldLen, then
- Return !
OrdinaryDefineOwnProperty (A,"length" , newLenDesc).
- Return !
- If oldLenDesc.[[Writable]] is
false , returnfalse . - If newLenDesc does not have a [[Writable]] field or newLenDesc.[[Writable]] is
true , then- Let newWritable be
true .
- Let newWritable be
- Else,
- NOTE: Setting the [[Writable]] attribute to
false is deferred in case any elements cannot be deleted. - Let newWritable be
false . - Set newLenDesc.[[Writable]] to
true .
- NOTE: Setting the [[Writable]] attribute to
- Let succeeded be !
OrdinaryDefineOwnProperty (A,"length" , newLenDesc). - If succeeded is
false , returnfalse . - For each own
property key P of A such that P is anarray index and !ToUint32 (P) ≥ newLen, in descending numeric index order, do- Let deleteSucceeded be ! A.[[Delete]](P).
- If deleteSucceeded is
false , then- Set newLenDesc.[[Value]] to !
ToUint32 (P) +1 𝔽. - If newWritable is
false , set newLenDesc.[[Writable]] tofalse . - Perform !
OrdinaryDefineOwnProperty (A,"length" , newLenDesc). - Return
false .
- Set newLenDesc.[[Value]] to !
- If newWritable is
false , then- Set succeeded to !
OrdinaryDefineOwnProperty (A,"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]] ( P )
The [[GetOwnProperty]] internal method of a
- Let desc be
OrdinaryGetOwnProperty (S, P). - If desc is not
undefined , return desc. - Return
StringGetOwnProperty (S, P).
10.4.3.2 [[DefineOwnProperty]] ( P, Desc )
The [[DefineOwnProperty]] internal method of a
- Let stringDesc be
StringGetOwnProperty (S, P). - If stringDesc is not
undefined , then- Let extensible be S.[[Extensible]].
- Return
IsCompatiblePropertyDescriptor (extensible, Desc, stringDesc).
- Return !
OrdinaryDefineOwnProperty (S, P, Desc).
10.4.3.3 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a
- Let keys be a new empty
List . - Let str be O.[[StringData]].
Assert : stris a String .- Let len be the length of str.
- For each
integer i such that 0 ≤ i < len, in ascending order, do - For each own
property key P of O such that P is anarray index and !ToIntegerOrInfinity (P) ≥ len, in ascending numeric index order, do- Append P to keys.
- For each own
property key P of O such that Pis a String and P is not anarray index , in ascending chronological order of property creation, do- Append P to keys.
- For each own
property key P of O such that Pis a Symbol , in ascending chronological order of property creation, do- Append P to keys.
- Return keys.
10.4.3.4 StringCreate ( value, prototype )
The abstract operation StringCreate takes arguments value (a String) and prototype (an Object) and returns a
- Let S be
MakeBasicObject (« [[Prototype]], [[Extensible]], [[StringData]] »). - Set S.[[Prototype]] to prototype.
- Set S.[[StringData]] to value.
- Set S.[[GetOwnProperty]] as specified in
10.4.3.1 . - Set S.[[DefineOwnProperty]] as specified in
10.4.3.2 . - Set S.[[OwnPropertyKeys]] as specified in
10.4.3.3 . - Let length be the length of value.
- Perform !
DefinePropertyOrThrow (S,"length" , PropertyDescriptor { [[Value]]:𝔽 (length), [[Writable]]:false , [[Enumerable]]:false , [[Configurable]]:false }). - Return S.
10.4.3.5 StringGetOwnProperty ( S, P )
The abstract operation StringGetOwnProperty takes arguments S (an Object that has a [[StringData]] internal slot) and P (a
- If P
is not a String , returnundefined . - Let index be
CanonicalNumericIndexString (P). - If index is
undefined , returnundefined . - If
IsIntegralNumber (index) isfalse , returnundefined . - If index is
-0 𝔽, returnundefined . - Let str be S.[[StringData]].
Assert : stris a String .- Let len be the length of str.
- If
ℝ (index) < 0 or len ≤ℝ (index), returnundefined . - Let resultStr be the
substring of str fromℝ (index) toℝ (index) + 1. - Return the PropertyDescriptor { [[Value]]: resultStr, [[Writable]]:
false , [[Enumerable]]:true , [[Configurable]]:false }.
10.4.4 Arguments Exotic Objects
Most ECMAScript functions make an arguments object available to their code. Depending upon the characteristics of the function definition, its arguments object is either 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]] ( P )
The [[GetOwnProperty]] internal method of an
- Let desc be
OrdinaryGetOwnProperty (args, P). - If desc is
undefined , returnundefined . - Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, P). - If isMapped is
true , then- Set desc.[[Value]] to !
Get (map, P).
- Set desc.[[Value]] to !
- Return desc.
10.4.4.2 [[DefineOwnProperty]] ( P, Desc )
The [[DefineOwnProperty]] internal method of an
- Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, P). - Let newArgDesc be Desc.
- If isMapped is
true andIsDataDescriptor (Desc) istrue , then- If Desc does not have a [[Value]] field, Desc has a [[Writable]] field, and Desc.[[Writable]] is
false , then- Set newArgDesc to a copy of Desc.
- Set newArgDesc.[[Value]] to !
Get (map, P).
- If Desc does not have a [[Value]] field, Desc has a [[Writable]] field, and Desc.[[Writable]] is
- Let allowed be !
OrdinaryDefineOwnProperty (args, P, newArgDesc). - If allowed is
false , returnfalse . - If isMapped is
true , then- If
IsAccessorDescriptor (Desc) istrue , then- Perform ! map.[[Delete]](P).
- Else,
- If
- Return
true .
10.4.4.3 [[Get]] ( P, Receiver )
The [[Get]] internal method of an
- Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, P). - If isMapped is
false , then- Return ?
OrdinaryGet (args, P, Receiver).
- Return ?
- Else,
10.4.4.4 [[Set]] ( P, V, 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, P).
- If isMapped is
true , then - Return ?
OrdinarySet (args, P, V, Receiver).
10.4.4.5 [[Delete]] ( P )
The [[Delete]] internal method of an
- Let map be args.[[ParameterMap]].
- Let isMapped be !
HasOwnProperty (map, P). - Let result be ?
OrdinaryDelete (args, P). - If result is
true and isMapped istrue , then- Perform ! map.[[Delete]](P).
- Return result.
10.4.4.6 CreateUnmappedArgumentsObject ( argumentsList )
The abstract operation CreateUnmappedArgumentsObject takes argument argumentsList (a
- Let len be the number of elements in argumentsList.
- Let obj be
OrdinaryObjectCreate (%Object.prototype% , « [[ParameterMap]] »). - Set obj.[[ParameterMap]] to
undefined . - Perform !
DefinePropertyOrThrow (obj,"length" , PropertyDescriptor { [[Value]]:𝔽 (len), [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:true }). - Let index be 0.
- Repeat, while index < len,
- Let val be argumentsList[index].
- Perform !
CreateDataPropertyOrThrow (obj, !ToString (𝔽 (index)), val). - Set index to index + 1.
- Perform !
DefinePropertyOrThrow (obj,@@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, argumentsList, env )
The abstract operation CreateMappedArgumentsObject takes arguments func (an Object), formals (a
Assert : formals does not contain a rest parameter, any binding patterns, or any initializers. It may contain duplicate identifiers.- Let len be the number of elements in argumentsList.
- 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 parameterNames be the
BoundNames of formals. - Let numberOfParameters be the number of elements in parameterNames.
- Let index be 0.
- Repeat, while index < len,
- Let val be argumentsList[index].
- Perform !
CreateDataPropertyOrThrow (obj, !ToString (𝔽 (index)), val). - Set index to index + 1.
- Perform !
DefinePropertyOrThrow (obj,"length" , PropertyDescriptor { [[Value]]:𝔽 (len), [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:true }). - Let mappedNames be a new empty
List . - Set index to numberOfParameters - 1.
- Repeat, while index ≥ 0,
- Let name be parameterNames[index].
- If mappedNames does not contain name, then
- Append name to mappedNames.
- If index < len, then
- Let g be
MakeArgGetter (name, env). - Let p be
MakeArgSetter (name, env). - Perform ! map.[[DefineOwnProperty]](!
ToString (𝔽 (index)), PropertyDescriptor { [[Set]]: p, [[Get]]: g, [[Enumerable]]:false , [[Configurable]]:true }).
- Let g be
- Set index to index - 1.
- Perform !
DefinePropertyOrThrow (obj,@@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, env )
The abstract operation MakeArgGetter takes arguments name (a String) and env (an
- Let getterClosure be a new
Abstract Closure with no parameters that captures name and env and performs the following steps when called:- Return env.GetBindingValue(name,
false ).
- Return env.GetBindingValue(name,
- Let getter be
CreateBuiltinFunction (getterClosure, 0,"" , « »). - NOTE: getter is never directly accessible to ECMAScript code.
- Return getter.
10.4.4.7.2 MakeArgSetter ( name, env )
The abstract operation MakeArgSetter takes arguments name (a String) and env (an
- Let setterClosure be a new
Abstract Closure with parameters (value) that captures name and env and performs the following steps when called:- Return ! env.SetMutableBinding(name, value,
false ).
- Return ! env.SetMutableBinding(name, value,
- Let setter be
CreateBuiltinFunction (setterClosure, 1,"" , « »). - NOTE: setter is never directly accessible to ECMAScript code.
- Return setter.
10.4.5 TypedArray Exotic Objects
A
An object is a TypedArray if its [[GetOwnProperty]], [[HasProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]], and [[OwnPropertyKeys]] internal methods use the definitions in this section, and its other essential internal methods use the definitions found in
10.4.5.1 [[GetOwnProperty]] ( P )
The [[GetOwnProperty]] internal method of a
- If P
is a String , then- Let numericIndex be
CanonicalNumericIndexString (P). - If numericIndex is not
undefined , then- Let value be
TypedArrayGetElement (O, 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 (O, P).
10.4.5.2 [[HasProperty]] ( P )
The [[HasProperty]] internal method of a
- If P
is a String , then- Let numericIndex be
CanonicalNumericIndexString (P). - If numericIndex is not
undefined , returnIsValidIntegerIndex (O, numericIndex).
- Let numericIndex be
- Return ?
OrdinaryHasProperty (O, P).
10.4.5.3 [[DefineOwnProperty]] ( P, Desc )
The [[DefineOwnProperty]] internal method of a
- If P
is a String , then- Let numericIndex be
CanonicalNumericIndexString (P). - If numericIndex is not
undefined , then- If
IsValidIntegerIndex (O, numericIndex) isfalse , returnfalse . - If Desc has a [[Configurable]] field and Desc.[[Configurable]] is
false , returnfalse . - If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is
false , returnfalse . - If
IsAccessorDescriptor (Desc) istrue , returnfalse . - If Desc has a [[Writable]] field and Desc.[[Writable]] is
false , returnfalse . - If Desc has a [[Value]] field, perform ?
TypedArraySetElement (O, numericIndex, Desc.[[Value]]). - Return
true .
- If
- Let numericIndex be
- Return !
OrdinaryDefineOwnProperty (O, P, Desc).
10.4.5.4 [[Get]] ( P, Receiver )
The [[Get]] internal method of a
- If P
is a String , then- Let numericIndex be
CanonicalNumericIndexString (P). - If numericIndex is not
undefined , then- Return
TypedArrayGetElement (O, numericIndex).
- Return
- Let numericIndex be
- Return ?
OrdinaryGet (O, P, Receiver).
10.4.5.5 [[Set]] ( P, V, Receiver )
The [[Set]] internal method of a
- If P
is a String , then- Let numericIndex be
CanonicalNumericIndexString (P). - If numericIndex is not
undefined , then- If
SameValue (O, Receiver) istrue , then- Perform ?
TypedArraySetElement (O, numericIndex, V). - Return
true .
- Perform ?
- If
IsValidIntegerIndex (O, numericIndex) isfalse , returntrue .
- If
- Let numericIndex be
- Return ?
OrdinarySet (O, P, V, Receiver).
10.4.5.6 [[Delete]] ( P )
The [[Delete]] internal method of a
- If P
is a String , then- Let numericIndex be
CanonicalNumericIndexString (P). - If numericIndex is not
undefined , then- If
IsValidIntegerIndex (O, numericIndex) isfalse , returntrue ; else returnfalse .
- If
- Let numericIndex be
- Return !
OrdinaryDelete (O, P).
10.4.5.7 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a
- Let taRecord be
MakeTypedArrayWithBufferWitnessRecord (O,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 P of O such that Pis a String and P is not aninteger index , in ascending chronological order of property creation, do- Append P to keys.
- For each own
property key P of O such that Pis a Symbol , in ascending chronological order of property creation, do- Append P to keys.
- Return keys.
10.4.5.8 TypedArray With Buffer Witness Records
An TypedArray With Buffer Witness Record is a
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.9 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.10 TypedArrayCreate ( prototype )
The abstract operation TypedArrayCreate takes argument prototype (an Object) and returns a
- Let internalSlotsList be « [[Prototype]], [[Extensible]], [[ViewedArrayBuffer]], [[TypedArrayName]], [[ContentType]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] ».
- Let A be
MakeBasicObject (internalSlotsList). - Set A.[[GetOwnProperty]] as specified in
10.4.5.1 . - Set A.[[HasProperty]] as specified in
10.4.5.2 . - Set A.[[DefineOwnProperty]] as specified in
10.4.5.3 . - Set A.[[Get]] as specified in
10.4.5.4 . - Set A.[[Set]] as specified in
10.4.5.5 . - Set A.[[Delete]] as specified in
10.4.5.6 . - Set A.[[OwnPropertyKeys]] as specified in
10.4.5.7 . - Set A.[[Prototype]] to prototype.
- Return A.
10.4.5.11 TypedArrayByteLength ( taRecord )
The abstract operation TypedArrayByteLength takes argument taRecord (a
- If
IsTypedArrayOutOfBounds (taRecord) istrue , return 0. - Let length be
TypedArrayLength (taRecord). - If length = 0, return 0.
- Let O be taRecord.[[Object]].
- If O.[[ByteLength]] is not
auto , return O.[[ByteLength]]. - Let elementSize be
TypedArrayElementSize (O). - Return length × elementSize.
10.4.5.12 TypedArrayLength ( taRecord )
The abstract operation TypedArrayLength takes argument taRecord (a
Assert :IsTypedArrayOutOfBounds (taRecord) isfalse .- Let O be taRecord.[[Object]].
- If O.[[ArrayLength]] is not
auto , return O.[[ArrayLength]]. Assert :IsFixedLengthArrayBuffer (O.[[ViewedArrayBuffer]]) isfalse .- Let byteOffset be O.[[ByteOffset]].
- Let elementSize be
TypedArrayElementSize (O). - Let byteLength be taRecord.[[CachedBufferByteLength]].
Assert : byteLength is notdetached .- Return
floor ((byteLength - byteOffset) / elementSize).
10.4.5.13 IsTypedArrayOutOfBounds ( taRecord )
The abstract operation IsTypedArrayOutOfBounds takes argument taRecord (a
- Let O be taRecord.[[Object]].
- Let bufferByteLength be taRecord.[[CachedBufferByteLength]].
Assert :IsDetachedBuffer (O.[[ViewedArrayBuffer]]) istrue if and only if bufferByteLength isdetached .- If bufferByteLength is
detached , returntrue . - Let byteOffsetStart be O.[[ByteOffset]].
- If O.[[ArrayLength]] is
auto , then- Let byteOffsetEnd be bufferByteLength.
- Else,
- Let elementSize be
TypedArrayElementSize (O). - Let byteOffsetEnd be byteOffsetStart + O.[[ArrayLength]] × elementSize.
- Let elementSize be
- If byteOffsetStart > bufferByteLength or byteOffsetEnd > bufferByteLength, return
true . - NOTE: 0-length
TypedArrays are not considered out-of-bounds. - Return
false .
10.4.5.14 IsValidIntegerIndex ( O, index )
The abstract operation IsValidIntegerIndex takes arguments O (a
- If
IsDetachedBuffer (O.[[ViewedArrayBuffer]]) istrue , returnfalse . - If
IsIntegralNumber (index) isfalse , returnfalse . - If index is
-0 𝔽, returnfalse . - Let taRecord be
MakeTypedArrayWithBufferWitnessRecord (O,unordered ). - NOTE: Bounds checking is not a synchronizing operation when O's backing buffer is a
growable SharedArrayBuffer . - If
IsTypedArrayOutOfBounds (taRecord) istrue , returnfalse . - Let length be
TypedArrayLength (taRecord). - If
ℝ (index) < 0 orℝ (index) ≥ length, returnfalse . - Return
true .
10.4.5.15 TypedArrayGetElement ( O, index )
The abstract operation TypedArrayGetElement takes arguments O (a
- If
IsValidIntegerIndex (O, index) isfalse , returnundefined . - Let offset be O.[[ByteOffset]].
- Let elementSize be
TypedArrayElementSize (O). - Let byteIndexInBuffer be (
ℝ (index) × elementSize) + offset. - Let elementType be
TypedArrayElementType (O). - Return
GetValueFromBuffer (O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType,true ,unordered ).
10.4.5.16 TypedArraySetElement ( O, index, value )
The abstract operation TypedArraySetElement takes arguments O (a
- If O.[[ContentType]] is
bigint , let numValue be ?ToBigInt (value). - Otherwise, let numValue be ?
ToNumber (value). - If
IsValidIntegerIndex (O, index) istrue , then- Let offset be O.[[ByteOffset]].
- Let elementSize be
TypedArrayElementSize (O). - Let byteIndexInBuffer be (
ℝ (index) × elementSize) + offset. - Let elementType be
TypedArrayElementType (O). - Perform
SetValueInBuffer (O.[[ViewedArrayBuffer]], byteIndexInBuffer, elementType, numValue,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.17 IsArrayBufferViewOutOfBounds ( O )
The abstract operation IsArrayBufferViewOutOfBounds takes argument O (a
- If O has a [[DataView]] internal slot, then
- Let viewRecord be
MakeDataViewWithBufferWitnessRecord (O,seq-cst ). - Return
IsViewOutOfBounds (viewRecord).
- Let viewRecord be
- Let taRecord be
MakeTypedArrayWithBufferWitnessRecord (O,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]] ( V )
The [[SetPrototypeOf]] internal method of a
- Return !
SetImmutablePrototype (O, V).
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]] ( P )
The [[GetOwnProperty]] internal method of a
- If P
is a Symbol , returnOrdinaryGetOwnProperty (O, P). - Let exports be O.[[Exports]].
- If exports does not contain P, return
undefined . - Let value be ? O.[[Get]](P, O).
- Return PropertyDescriptor { [[Value]]: value, [[Writable]]:
true , [[Enumerable]]:true , [[Configurable]]:false }.
10.4.6.6 [[DefineOwnProperty]] ( P, Desc )
The [[DefineOwnProperty]] internal method of a
- If P
is a Symbol , return !OrdinaryDefineOwnProperty (O, P, Desc). - Let current be ? O.[[GetOwnProperty]](P).
- If current is
undefined , returnfalse . - If Desc has a [[Configurable]] field and Desc.[[Configurable]] is
true , returnfalse . - If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is
false , returnfalse . - If
IsAccessorDescriptor (Desc) istrue , returnfalse . - If Desc has a [[Writable]] field and Desc.[[Writable]] is
false , returnfalse . - If Desc has a [[Value]] field, return
SameValue (Desc.[[Value]], current.[[Value]]). - Return
true .
10.4.6.7 [[HasProperty]] ( P )
The [[HasProperty]] internal method of a
- If P
is a Symbol , return !OrdinaryHasProperty (O, P). - Let exports be O.[[Exports]].
- If exports contains P, return
true . - Return
false .
10.4.6.8 [[Get]] ( P, Receiver )
The [[Get]] internal method of a
- If P
is a Symbol , then- Return !
OrdinaryGet (O, P, Receiver).
- Return !
- Let exports be O.[[Exports]].
- If exports does not contain P, return
undefined . - Let m be O.[[Module]].
- Let binding be m.ResolveExport(P).
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]] ( P, V, Receiver )
The [[Set]] internal method of a
- Return
false .
10.4.6.10 [[Delete]] ( P )
The [[Delete]] internal method of a
- If P
is a Symbol , then- Return !
OrdinaryDelete (O, P).
- Return !
- Let exports be O.[[Exports]].
- If exports contains P, return
false . - Return
true .
10.4.6.11 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of a
- Let exports be O.[[Exports]].
- Let symbolKeys be
OrdinaryOwnPropertyKeys (O). - 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 33 . - Let M be
MakeBasicObject (internalSlotsList). - Set M's essential internal methods to the definitions specified in
10.4.6 . - Set M.[[Module]] to module.
- Let sortedExports be a
List whose elements are the elements of exports ordered as if an Array of the same values had been sorted using %Array.prototype.sort% usingundefined as comparefn. - Set M.[[Exports]] to sortedExports.
- Create own properties of M corresponding to the definitions in
28.3 . - Set module.[[Namespace]] to M.
- Return M.
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]] ( V )
The [[SetPrototypeOf]] internal method of an
- Return ?
SetImmutablePrototype (O, V).
10.4.7.2 SetImmutablePrototype ( O, V )
The abstract operation SetImmutablePrototype takes arguments O (an Object) and V (an Object or
- Let current be ? O.[[GetPrototypeOf]]().
- If
SameValue (V, current) istrue , returntrue . - Return
false .