Non-writable property in a prototype

Dmitry A. Soshnikov dmitry.soshnikov at gmail.com
Tue Mar 15 14:53:41 PDT 2011


I am sure such a question was recently on Twitter (and on this list). 
FF4 and IE9 are correct in this case. Moreover, in strict mode there 
will be an error in this case.

It's not possible to _shadow_ an inherited read-only property via 
_assignment_. But it's still possible to do it via `Object.defineProperty`.

Dmitry.

On 16.03.2011 0:50, Michał Raczkowski wrote:
> Hi,
>
> I'm new in the list, so I'd like to say hello to everyone.
>
> I have a question on implementations of ES5 in web browsers.
> Apparently IE9 and FF4 implementations of ES5 differ in some details
> from Webkit, Chrome and Safari.
> The following code gives "proto,false" in IE9 and FF4, but "own,true"
> in Chrome and Safari.
>
> function Ctor() {};
> Object.defineProperty(Ctor.prototype, "prop", {value: "proto"});
> var obj = new Ctor();
> obj.prop = "own";
> alert(obj.prop + "," + obj.hasOwnProperty("prop"));
>
> Could you tell which implementation is correct?
>
> greetings
> Michal
> _______________________________________________
> es5-discuss mailing list
> es5-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es5-discuss



More information about the es5-discuss mailing list