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.
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss