8.6.2.1 For all objects

2010-04-18

This set applies to all native objects. Every object, including host objects, must implement all of these properties. But for host objects the [[DefaultValue]] internal method may throw a TypeError exception.

Name: [[Prototype]]
Type: Object or Null
Description: The prototype of this object. This is used to implement inheritance. The [[Prototype]] chain must be finite. That means that the chain must eventually lead to a Null type. Whether a native object can have a host object for its [[Prototype]] depends on the implementation. Named data properties of the [[Prototype]] object are inherited (visible as properties of the child object) for the purpose of get access, but not for put access. Named accessor properties are inherited for both get and put access.

Note that prototype is one of the cores of this language! When you have an object with only named property "x" and you set its [[Prototype]] to an object with only a named property "y", accessing the "y" property of the original object will suddenly return the same as the value of the "y" property of the prototype object. In other words:

Code: (Ecma)
var a = { x: 5 }; // instance of Object
alert(a.y); // undefined
Object.prototype.y = 4;
alert(a.y); // 4

The behavior of accessors is a little inconsistent, since both [[Get]] and [[Put]] are inherited. This means that the only way of creating an own property of the child is to call the [[DefineOwnProperty]] method. Other attempts will result in the inherited [[Put]] method being called.

Name: [[Class]]
Type: String
Description: Classification of object defined by the specification. The value is defined for built-in objects. For host objects it may be anything except for the following: Arguments, Array, Boolean, Date, Error, Function, JSON, Math, Number, Object, RegExp or String. The spec does not define a way to directly access [[Class]], except perhaps through the Object.prototype.toString method.

Name: [[Extensible]]
Type: Boolean
Description: If true, own named properties may be added to the object. If false, named properties may not be added to the object. Additionally, [[Prototype]] and [[Class]] may not be changed.

Once the [[Extensible]] property has been set to false, it may not be set to true. (Does this mean that when the [[Extensible]] property is false but has not been explicitly set that way, it may still be set to true?). Host objects may not have this attribute set true once it has been observed to be false.

Note that the specification does not specify any way for [[Class]], [[Extensible]] or [[Prototype]] to be modified from within the language. Implementations that do allow this should still follow the rules of [[Extensible]].

Name: [[Get]]
Function: [[Get]](propertyName:String)
Return: any
Description: Return the [[Value]] of given property

Name: [[GetOwnProperty]]
Function: [[GetOwnProperty]](propertyName:String)
Returns: Undefined or Property Descriptor
Description: Returns the fully populated Property Descriptor of the named own property of this object, or undefined if absent.

For host objects the following rules apply:
- If data property and the value may change over time then either or both of the [[Writable]] and [[Configurable]] attributes must be true.
- If a data property has false for both [[Writable]] and [[Configurable]] then the SameValue must be returned for [[Value]] for [[Value]] attribute of the property on all calls to [[GetOwnProperty]].
- If any attribute other than [[Writable]] may change over time or if the property can disappear, the [[Configurable]] attribute must be true.
- If the [[Writable]] attribute may change from false to true, then the [[Configurable]] attribute must be true.
- If the [[Extensible]] attribute of a host object has been observed as false then if a call to [[GetOwnProperty]] describes a property not to exist, all subsequent calls must also report the property not to exist.

Name: [[GetOwnProperty]]
Function: [[GetOwnProperty]](propertyName:String)
Return: Undefined or Property Descriptor
Description: Returns the fully populated Property Descriptor of the named property of this object (including prototype), or undefined if absent.

Name: [[Put]]
Function: [[Put]](propertyName:String, value:any, error:Boolean)
Return: void
Description: Sets the specified named property to the value of the second parameter. The third parameter handles error handling.

Name: [[CanPut]]
Function: [[CanPut]](propertyName:String)
Return: Boolean
Description: Returns whether you can store a value to this property

Name: [[HasProperty]]
Function: [[HasProperty]](propertyName:String)
Return: Boolean
Description: Returns whether this object already contains this property (also by prototype?). Much like the in operator, if prototype is included.

Name: [[Delete]]
Function: [[Delete]](propertyName:String, error:Boolean)
Return: Boolean
Description: Removes the specified named own property from the object. The flag controls error handling.

Name: [[DefaultValue]]
Function: [[DefaultValue]](Hint:String)
Return: primitive
Description: Return default value for this object, with an optional type hint supplied as an argument. Note that the hint does not mean the returned value will be of that type.

Name: [[DefineOwnProperty]]
Function: [[DefineOwnProperty]](propertyName:String, PropertyDescriptor, error:Boolean)
Return: Boolean
Description: Creates or alters the named own property to have the state described by a Property Descriptor. The flag controls error handling.