__proto__ and JSON

David Bruant bruant.d at gmail.com
Wed May 30 05:16:31 PDT 2012

Additionally to JSON, I'd like to ask about if decisions have been made 
for __proto__ in object literal notation.


Le 30/05/2012 14:07, Felix Böhm a écrit :
> After reading that __proto__ is becoming standardized, I was wondering 
> what the impacts on JSON would be. JSON is a subset of ECMAScript, so 
> __proto__ would break current semantics. Even worse, try to run 
> JSON.parse('{"__proto__": 1}'). The result in Chrome is an empty 
> object. It doesn't inherit from Number.prototype, the __proto__ 
> property simply gets ignored. In terms of portability, that's really bad.
> The only solution I can think of would be the {prop = value} syntax, 
> so that __proto__ can only be set via {__proto__ = obj}. Considering 
> that this syntax is intended to trigger setters, it would make a lot 
> of sense.
> I know that existing code will break, even some of my own scripts use 
> __proto__ with the old syntax. But I knew that __proto__ is 
> proprietary, and I didn't expect it to work forever.
> Otherwise, the JSON spec needs to be changed. I doubt that Doug 
> Crockford would support that.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120530/9107bc33/attachment-0001.html>

More information about the es-discuss mailing list