Feedback on "Read-only Override Prohibition is [not a mistake]"

David Bruant bruant.d at gmail.com
Sun Jan 15 15:02:11 PST 2012


Le 15/01/2012 21:23, David Bruant a écrit :
> -----
> function C(){
>     this.length = 3;
> }
>
> function f(a,b){}
>
> C.prototype = f;
>
> var c = new C();
> console.log(c.length);
> -----
> For this code, ECMAScript 5 says:
> When doing "new C()", |this| is assigned "C.prototype" which is the
> function f (it has a non-writable, non-configurable "length" property
> with 2 as value).
> During "this.length = 3;", [[CanPut]] should return
> "inherited.[[Writable]]" (step 8.b). In this case, it should return
> false and log 2
So in the "2", we have:
IE8, Firefox 9->12, Opera 11.60, 12

and on the side of "3", we have:
Chrome 16, Safari 5 and Safari 5.1

Anyway, it seems that the divergence toward this aspect of the spec was
probably there even before ES5. If no one complained about it for years
it seems to indicate that there is room to change the spec without
breaking content, since content does not seem to rely on the spec
behavior, even if it was there since ES1.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120116/c48d640e/attachment.html>


More information about the es-discuss mailing list