minor
This commit is contained in:
parent
5b16f003cc
commit
ed0e64b838
1 changed files with 5 additions and 2 deletions
|
@ -224,9 +224,12 @@ alert(obj.__proto__); // [object Object], didn't work as intended
|
|||
|
||||
As we see from the code, the assignment to a primitive `5` is ignored.
|
||||
|
||||
That can be come a source of bugs and even vulnerabilies if we intent to store arbitrary key-value pairs in an object, and allow a visitor to specify the keys. In that case the visitor may choose "__proto__" as the key, and the assignment logic will be ruined (as shown above).
|
||||
That can become a source of bugs and even vulnerabilies if we intent to store arbitrary key-value pairs in an object, and allow a visitor to specify the keys.
|
||||
|
||||
There's another data structure [Map](info:map-set-weakmap-weakset), that we'll learn in the chapter <info:map-set-weakmap-weakset>, which supports arbitrary keys. Also there's a way to make objects treat `__proto__` as a regular property, but first we need to know more about objects to understand it.
|
||||
In that case the visitor may choose "__proto__" as the key, and the assignment logic will be ruined (as shown above).
|
||||
|
||||
There exist a way to make objects treat `__proto__` as a regular property, we'll cover it later, but first we need to know more about objects to understand it.
|
||||
There's another data structure [Map](info:map-set-weakmap-weakset), that we'll learn in the chapter <info:map-set-weakmap-weakset>, which supports arbitrary keys. Also
|
||||
````
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue