Object.prototype.* writable?

Oliver Hunt oliver at apple.com
Sat May 7 10:31:03 PDT 2011

On May 7, 2011, at 10:24 AM, Cedric Vivier wrote:
>> 2. Would it be possible for Object.prototype.* to be read-only for
>> ES-Harmony (or even just strict mode)?
>> 3. By read-only, I mean that changes to it would just silently be discarded.
>> Alternatively (especially for strict mode), warnings/errors could be thrown
>> if attempting to override them?
> Doesn't Object.freeze(Object.prototype) provide exactly this behavior already?

Unless of course someone has already got code in your page that does Object.freeze = function(){};

Same thing applies to preventExtensions, seal, create, defineProperty, etc and of course the Object constructor itself.

It does annoy me that these were not made immutable.  The safest way to create an object is still either with an object literal or new SomeFunction;

I'm not convinced that Object.create added anything of value to the language, and certainly wouldn't recommend
its use for general object creation.


More information about the es-discuss mailing list