About _ _ proto__ of js

JSON.parse("{"__proto__":{"a":1}}")

{__proto__:{a:1}}

first sentence! = second sentence

JSON.parse("{"__proto__":{"a":1}}").a == undefined

{__proto__:{a:1}}.a == 1

this is why, what did JSON.parse do, thank you!

Dec.28,2021

what the JSON.parse does at the bottom can be found in the standard
https://www.ecma-internationa.
. The other 1703 edge do not know what strange caching mechanism there is. If you can't print it for a while, you can print out


.

log JSON.parse ('{"_ proto__": {"a": 1}}') and {_ proto__: {aproto__ 1}} respectively. As a result, it seems that JSON.parse ignores the'_ _ proto__' attribute;

then try'_ proto__''_ _ proto_' to successfully log out, so I don't know why


refer to the standard upstairs and infer from 24.3.1.1

var b = {}
Object.defineProperty(b, '__proto__', {
    get: function(){return {a:1}}
})

this is what you want

Menu