10.1 Ordinary Object Internal Methods and Internal Slots
All
Every
In the following algorithm descriptions, assume O is an
Each
10.1.1 [[GetPrototypeOf]] ( )
The [[GetPrototypeOf]] internal method of an
- Return
OrdinaryGetPrototypeOf (O).
10.1.1.1 OrdinaryGetPrototypeOf ( O )
The abstract operation OrdinaryGetPrototypeOf takes argument O (an Object) and returns an Object or
- Return O.[[Prototype]].
10.1.2 [[SetPrototypeOf]] ( V )
The [[SetPrototypeOf]] internal method of an
- Return
OrdinarySetPrototypeOf (O, V).
10.1.2.1 OrdinarySetPrototypeOf ( O, V )
The abstract operation OrdinarySetPrototypeOf takes arguments O (an Object) and V (an Object or
- Let current be O.[[Prototype]].
- If
SameValue (V, current) istrue , returntrue . - Let extensible be O.[[Extensible]].
- If extensible is
false , returnfalse . - Let p be V.
- Let done be
false . - Repeat, while done is
false ,- If p is
null , then- Set done to
true .
- Set done to
- Else if
SameValue (p, O) istrue , then- Return
false .
- Return
- Else,
- If p.[[GetPrototypeOf]] is not the
ordinary object internal method defined in10.1.1 , set done totrue . - Else, set p to p.[[Prototype]].
- If p.[[GetPrototypeOf]] is not the
- If p is
- Set O.[[Prototype]] to V.
- Return
true .
The loop in step
10.1.3 [[IsExtensible]] ( )
The [[IsExtensible]] internal method of an
- Return
OrdinaryIsExtensible (O).
10.1.3.1 OrdinaryIsExtensible ( O )
The abstract operation OrdinaryIsExtensible takes argument O (an Object) and returns a Boolean. It performs the following steps when called:
- Return O.[[Extensible]].
10.1.4 [[PreventExtensions]] ( )
The [[PreventExtensions]] internal method of an
- Return
OrdinaryPreventExtensions (O).
10.1.4.1 OrdinaryPreventExtensions ( O )
The abstract operation OrdinaryPreventExtensions takes argument O (an Object) and returns
- Set O.[[Extensible]] to
false . - Return
true .
10.1.5 [[GetOwnProperty]] ( P )
The [[GetOwnProperty]] internal method of an
- Return
OrdinaryGetOwnProperty (O, P).
10.1.5.1 OrdinaryGetOwnProperty ( O, P )
The abstract operation OrdinaryGetOwnProperty takes arguments O (an Object) and P (a
- If O does not have an own property with key P, return
undefined . - Let D be a newly created
Property Descriptor with no fields. - Let X be O's own property whose key is P.
- If X is a
data property , then- Set D.[[Value]] to the value of X's [[Value]] attribute.
- Set D.[[Writable]] to the value of X's [[Writable]] attribute.
- Else,
Assert : X is anaccessor property .- Set D.[[Get]] to the value of X's [[Get]] attribute.
- Set D.[[Set]] to the value of X's [[Set]] attribute.
- Set D.[[Enumerable]] to the value of X's [[Enumerable]] attribute.
- Set D.[[Configurable]] to the value of X's [[Configurable]] attribute.
- Return D.
10.1.6 [[DefineOwnProperty]] ( P, Desc )
The [[DefineOwnProperty]] internal method of an
- Return ?
OrdinaryDefineOwnProperty (O, P, Desc).
10.1.6.1 OrdinaryDefineOwnProperty ( O, P, Desc )
The abstract operation OrdinaryDefineOwnProperty takes arguments O (an Object), P (a
- Let current be ? O.[[GetOwnProperty]](P).
- Let extensible be ?
IsExtensible (O). - Return
ValidateAndApplyPropertyDescriptor (O, P, extensible, Desc, current).
10.1.6.2 IsCompatiblePropertyDescriptor ( Extensible, Desc, Current )
The abstract operation IsCompatiblePropertyDescriptor takes arguments Extensible (a Boolean), Desc (a
- Return
ValidateAndApplyPropertyDescriptor (undefined ,"" , Extensible, Desc, Current).
10.1.6.3 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )
The abstract operation ValidateAndApplyPropertyDescriptor takes arguments O (an Object or
Assert :IsPropertyKey (P) istrue .- If current is
undefined , then- If extensible is
false , returnfalse . - If O is
undefined , returntrue . - If
IsAccessorDescriptor (Desc) istrue , then- Create an own
accessor property named P of object O whose [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute'sdefault value otherwise.
- Create an own
- Else,
- Create an own
data property named P of object O whose [[Value]], [[Writable]], [[Enumerable]], and [[Configurable]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute'sdefault value otherwise.
- Create an own
- Return
true .
- If extensible is
Assert : current is afully populated Property Descriptor .- If Desc does not have any fields, return
true . - If current.[[Configurable]] is
false , then- If Desc has a [[Configurable]] field and Desc.[[Configurable]] is
true , returnfalse . - If Desc has an [[Enumerable]] field and Desc.[[Enumerable]] is not current.[[Enumerable]], return
false . - If
IsGenericDescriptor (Desc) isfalse andIsAccessorDescriptor (Desc) is notIsAccessorDescriptor (current), returnfalse . - If
IsAccessorDescriptor (current) istrue , then - Else if current.[[Writable]] is
false , then- If Desc has a [[Writable]] field and Desc.[[Writable]] is
true , returnfalse . - If Desc has a [[Value]] field and
SameValue (Desc.[[Value]], current.[[Value]]) isfalse , returnfalse .
- If Desc has a [[Writable]] field and Desc.[[Writable]] is
- If Desc has a [[Configurable]] field and Desc.[[Configurable]] is
- If O is not
undefined , then- If
IsDataDescriptor (current) istrue andIsAccessorDescriptor (Desc) istrue , then- If Desc has a [[Configurable]] field, let configurable be Desc.[[Configurable]]; else let configurable be current.[[Configurable]].
- If Desc has a [[Enumerable]] field, let enumerable be Desc.[[Enumerable]]; else let enumerable be current.[[Enumerable]].
- Replace the property named P of object O with an
accessor property whose [[Configurable]] and [[Enumerable]] attributes are set to configurable and enumerable, respectively, and whose [[Get]] and [[Set]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute'sdefault value otherwise.
- Else if
IsAccessorDescriptor (current) istrue andIsDataDescriptor (Desc) istrue , then- If Desc has a [[Configurable]] field, let configurable be Desc.[[Configurable]]; else let configurable be current.[[Configurable]].
- If Desc has a [[Enumerable]] field, let enumerable be Desc.[[Enumerable]]; else let enumerable be current.[[Enumerable]].
- Replace the property named P of object O with a
data property whose [[Configurable]] and [[Enumerable]] attributes are set to configurable and enumerable, respectively, and whose [[Value]] and [[Writable]] attributes are set to the value of the corresponding field in Desc if Desc has that field, or to the attribute'sdefault value otherwise.
- Else,
- For each field of Desc, set the corresponding attribute of the property named P of object O to the value of the field.
- If
- Return
true .
10.1.7 [[HasProperty]] ( P )
The [[HasProperty]] internal method of an
- Return ?
OrdinaryHasProperty (O, P).
10.1.7.1 OrdinaryHasProperty ( O, P )
The abstract operation OrdinaryHasProperty takes arguments O (an Object) and P (a
- Let hasOwn be ? O.[[GetOwnProperty]](P).
- If hasOwn is not
undefined , returntrue . - Let parent be ? O.[[GetPrototypeOf]]().
- If parent is not
null , then- Return ? parent.[[HasProperty]](P).
- Return
false .
10.1.8 [[Get]] ( P, Receiver )
The [[Get]] internal method of an
- Return ?
OrdinaryGet (O, P, Receiver).
10.1.8.1 OrdinaryGet ( O, P, Receiver )
The abstract operation OrdinaryGet takes arguments O (an Object), P (a
- Let desc be ? O.[[GetOwnProperty]](P).
- If desc is
undefined , then- Let parent be ? O.[[GetPrototypeOf]]().
- If parent is
null , returnundefined . - Return ? parent.[[Get]](P, Receiver).
- If
IsDataDescriptor (desc) istrue , return desc.[[Value]]. Assert :IsAccessorDescriptor (desc) istrue .- Let getter be desc.[[Get]].
- If getter is
undefined , returnundefined . - Return ?
Call (getter, Receiver).
10.1.9 [[Set]] ( P, V, Receiver )
The [[Set]] internal method of an
- Return ?
OrdinarySet (O, P, V, Receiver).
10.1.9.1 OrdinarySet ( O, P, V, Receiver )
The abstract operation OrdinarySet takes arguments O (an Object), P (a
- Let ownDesc be ? O.[[GetOwnProperty]](P).
- Return ?
OrdinarySetWithOwnDescriptor (O, P, V, Receiver, ownDesc).
10.1.9.2 OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc )
The abstract operation OrdinarySetWithOwnDescriptor takes arguments O (an Object), P (a
- If ownDesc is
undefined , then- Let parent be ? O.[[GetPrototypeOf]]().
- If parent is not
null , then- Return ? parent.[[Set]](P, V, Receiver).
- Else,
- Set ownDesc to the PropertyDescriptor { [[Value]]:
undefined , [[Writable]]:true , [[Enumerable]]:true , [[Configurable]]:true }.
- Set ownDesc to the PropertyDescriptor { [[Value]]:
- If
IsDataDescriptor (ownDesc) istrue , then- If ownDesc.[[Writable]] is
false , returnfalse . - If Receiver
is not an Object , returnfalse . - Let existingDescriptor be ? Receiver.[[GetOwnProperty]](P).
- If existingDescriptor is not
undefined , then- If
IsAccessorDescriptor (existingDescriptor) istrue , returnfalse . - If existingDescriptor.[[Writable]] is
false , returnfalse . - Let valueDesc be the PropertyDescriptor { [[Value]]: V }.
- Return ? Receiver.[[DefineOwnProperty]](P, valueDesc).
- If
- Else,
Assert : Receiver does not currently have a property P.- Return ?
CreateDataProperty (Receiver, P, V).
- If ownDesc.[[Writable]] is
Assert :IsAccessorDescriptor (ownDesc) istrue .- Let setter be ownDesc.[[Set]].
- If setter is
undefined , returnfalse . - Perform ?
Call (setter, Receiver, « V »). - Return
true .
10.1.10 [[Delete]] ( P )
The [[Delete]] internal method of an
- Return ?
OrdinaryDelete (O, P).
10.1.10.1 OrdinaryDelete ( O, P )
The abstract operation OrdinaryDelete takes arguments O (an Object) and P (a
- Let desc be ? O.[[GetOwnProperty]](P).
- If desc is
undefined , returntrue . - If desc.[[Configurable]] is
true , then- Remove the own property with name P from O.
- Return
true .
- Return
false .
10.1.11 [[OwnPropertyKeys]] ( )
The [[OwnPropertyKeys]] internal method of an
- Return
OrdinaryOwnPropertyKeys (O).
10.1.11.1 OrdinaryOwnPropertyKeys ( O )
The abstract operation OrdinaryOwnPropertyKeys takes argument O (an Object) and returns a
- Let keys be a new empty
List . - For each own
property key P of O such that P is anarray index , 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.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 O be
MakeBasicObject (internalSlotsList). - Set O.[[Prototype]] to proto.
- Return O.
Although OrdinaryObjectCreate does little more than call
10.1.13 OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] )
The abstract operation OrdinaryCreateFromConstructor takes arguments constructor (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 (constructor, intrinsicDefaultProto). - If internalSlotsList is present, let slotsList be internalSlotsList.
- Else, let slotsList be a new empty
List . - Return
OrdinaryObjectCreate (proto, slotsList).
10.1.14 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto )
The abstract operation GetPrototypeFromConstructor takes arguments constructor (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 (constructor,"prototype" ). - If proto
is not an Object , then- Let realm be ?
GetFunctionRealm (constructor). - Set proto to realm's intrinsic object named intrinsicDefaultProto.
- Let realm be ?
- Return proto.
If constructor does not supply a [[Prototype]] value, the default value that is used is obtained from the
10.1.15 RequireInternalSlot ( O, internalSlot )
The abstract operation RequireInternalSlot takes arguments O (an
- If O
is not an Object , throw aTypeError exception. - If O does not have an internalSlot internal slot, throw a
TypeError exception. - Return
unused .