Merge pull request #2235 from vsemozhetbyt/patch-9

Fix links in 1.8.4 (Prototype methods)
This commit is contained in:
Ilya Kantor 2020-10-29 19:51:54 +03:00 committed by GitHub
commit 4379770f03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -176,8 +176,8 @@ alert(Object.keys(chineseDictionary)); // hello,bye
Modern methods to set up and directly access the prototype are:
- [Object.create(proto, [descriptors])](mdn:js/Object/create) -- creates an empty object with a given `proto` as `[[Prototype]]` (can be `null`) and optional property descriptors.
- [Object.getPrototypeOf(obj)](mdn:js/Object.getPrototypeOf) -- returns the `[[Prototype]]` of `obj` (same as `__proto__` getter).
- [Object.setPrototypeOf(obj, proto)](mdn:js/Object.setPrototypeOf) -- sets the `[[Prototype]]` of `obj` to `proto` (same as `__proto__` setter).
- [Object.getPrototypeOf(obj)](mdn:js/Object/getPrototypeOf) -- returns the `[[Prototype]]` of `obj` (same as `__proto__` getter).
- [Object.setPrototypeOf(obj, proto)](mdn:js/Object/setPrototypeOf) -- sets the `[[Prototype]]` of `obj` to `proto` (same as `__proto__` setter).
The built-in `__proto__` getter/setter is unsafe if we'd want to put user-generated keys into an object. Just because a user may enter `"__proto__"` as the key, and there'll be an error, with hopefully light, but generally unpredictable consequences.