B.3.1 The __proto__ pseudo property

Andrea Giammarchi andrea.giammarchi at gmail.com
Sun Apr 21 15:40:25 PDT 2013


that said, I like the dual behavior if not because there's no way even by
accident somebody can change a prototype chain in a for/in loop

var copied = {__proto__:null,"__proto__":Array.prototype};
var copy = {};

for (var key in copied) {
  if (copied.hasOwnProperty(key)) {
    copy[key] = copied[key];
    // different from
    // copy.__proto__ = copied.__proto__;
  }
}

copy["__proto__"] === Array.prototype; // true

I've got the feeling this is not going that far though ... but it promotes
__proto__ avoidance ... now I am in conflict with myself :D




On Sun, Apr 21, 2013 at 3:35 PM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:

> uh wait ... you meant ... uh ... wait, sorry, OK :D
>
> so {__proto__:Array.prototype} is an instanceof Array
> {"__proto__":Array.prototype} is an object with a "__proto__" property
> that points to Array.prototype
>
> which means that "__proto__" is magically overwritten ... yak?!
>
>
>
> On Sun, Apr 21, 2013 at 3:33 PM, Andrea Giammarchi <
> andrea.giammarchi at gmail.com> wrote:
>
>> that won't work?
>>
>> "__proto__" in {"__proto__":{}}; // true
>> "__proto__" in {__proto__:{}}; // still true, since "__proto__" in
>> Object.prototype, unless deleted
>>
>> am I wrong?
>>
>>
>> On Sun, Apr 21, 2013 at 3:27 PM, Mark S. Miller <erights at google.com>wrote:
>>
>>> Warning: The following is a sickening idea. I would really hate to see
>>> us do it. But I feel obliged to post it as it may in fact be the right
>>> thing to do.
>>>
>>>
>>>
>>> Given: Web reality drives us towards recognizing {...., __proto__: ....,
>>> ....} as special syntax for initializing [[Prototype]].
>>>
>>> Given: JSON demands that the "__proto__" in JSON.parse('{....,
>>> "__proto__": ...., ....}') not be treated as a special case, and causes
>>> just the normal [[DefineOwnProperty]].
>>>
>>> Given: Web reality does not make demands on the meaning of {....,
>>> "__proto__": ...., ....}
>>>
>>> Given: The ES5 JSON spec demands that JSON.parse('{...., __proto__:
>>> ...., ....}') be rejected as an error.
>>>
>>>
>>>
>>> This suggests that, in JS as well, the "__proto__" in {....,
>>> "__proto__": ...., ....} not be treated as a special case. Quoting it turns
>>> off the special treatment.
>>>
>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130421/2e9c31ba/attachment.html>


More information about the es-discuss mailing list