B.3.1 The __proto__ pseudo property

Brandon Benvie bbenvie at mozilla.com
Tue May 21 09:47:21 PDT 2013


On 5/21/2013 9:43 AM, Andrea Giammarchi wrote:
> On Tue, May 21, 2013 at 12:56 AM, Brendan Eich <brendan at mozilla.com 
> <mailto:brendan at mozilla.com>> wrote:
>
>     Andrea Giammarchi wrote:
>
>         can I also suggest to analyze, if there's still any doubt left
>         on a method VS a property yet, this piece of code if not
>         highlighted before?
>
>
>     I do not understand what you mean here.
>
> I mean that JSON, as part of the specs, needs to consider that "magic" 
> property case, resulting into an `instanceof Object`, with an 
> enumerable property that will show up in a `for/in` loop but it's not 
> able to mutate the object.
>
> ```
> var obj = JSON.parse('{"__proto__":[]}');
> alert(obj instanceof Array); // false
> alert(obj["__proto__"] instanceof Array); // true
> obj["__proto__"] = obj["__proto__"];
> // or
> for (var key in obj) {
>   obj[key] = obj[key];
>   // could be a generic
>   // clone operation
> }
> alert(obj instanceof Array); // false
> alert(obj instanceof Object); // true
> ```
>
> Above kind of object is "not perfectly described in current specs" and 
> is different from any other where the `__proto__` is the inherited and 
> not own property.

JSON is not a subset of JS [1] already. There's no reason why it has to 
follow a newly specified JS syntax rule.

[1] http://timelessrepo.com/json-isnt-a-javascript-subset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130521/acd1b3e2/attachment.html>


More information about the es-discuss mailing list