Must built-in prototypes also be valid instances? (Was: Why DataView.prototype object's [[Class]] is "Object"?)

Brendan Eich brendan at mozilla.org
Mon Oct 1 17:40:27 PDT 2012


Norbert Lindenberg wrote:
>>>>> >>>>  3) The state mentioned in 2) is modifiable.
>>>>> >>>>  
>>>>> >>>>  True for some ES5 objects (Array, Date, RegExp),
>>>> >>>  Don't forget Object:-P.
>>> >>  
>>> >>  I'm thinking of state that goes beyond an empty object and makes a BuiltIn instance function as a BuiltIn instance. Object instances have no such state.
>> >  
>> >  Can Arrays? Remember, 'length' is observable just a data property and the custom [[DefineOwnProperty]] or [[Put]] hook is not state.
>
> length is part of the state, but you're right, sometimes it takes more than state and visible methods.

To be concrete, 'length' on an Array instance can be frozen (modulo 
implementation bugs to be fixed).

The issue is really mutable state hidden from Object.freeze. Mark will 
I'm sure confirm (and I'm sorry for filling his inbox!). Array is not a 
problem in this light. Glad to hear Intl.Collator isn't either.

/be


More information about the es-discuss mailing list