On Oct 14, 2013, at 5:54 PM, Andrea Giammarchi wrote:

> Allen my confusion is with o4 ... what happens once you re-set/assign its 
> `__proto__` there?
> 
> Is it just a normal property so new value will be set ?
> Is it a magic inherited thing (it shouldn't) that will change the o4 
> prototype chain ?

JSON.parse is just a function that builds up simple (inheriting from 
Object.prototype) objects using [[DefineOwnProperty]] See 
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-24.3.2 step 
3.a.iv.3.a.  So if the JSON object text contains a "__proto__" property key, 
the object that is created with have a "__proto__" own data property.  If it 
doesn't then the Annex B2.2.1 Object.prototype__proto__ property is inherited. 
No magic involved.

Allen


> ...
> Assuming that Annex B.2.2.1 and B.3.1 are implemented: here are the cases of 
> interest:
> 
> let o1 = {__proto__: p};      // o1 inherits from p
> let o2 = {"__proto__": p};   // o2 inherits from p
> let o3 = {["__proto__"]: p};// o3 inherits from Object.prototype, has own 
> data property "__proto__" whose value is p.
> let o4 = JSON.parse('{"__proto__": "value"}');
>       //o4 inherits from Object.prototype, has own data property "__proto__" 
> whose value is "value"
> 
> //assuming that Object.prototype.__proto__ has not been tamper with:
> let o5 = new Object;
> o5.__proto__ = p ; //o5 inherits from p
> 
> let o6 =new Object;
> o6["__proto__"] = p; //o6 inherits from p
> 
> Allen
> 

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to