From b6f97a6ab400af93a36b1bcf148b6e243ab0db5a Mon Sep 17 00:00:00 2001 From: Gleb Date: Wed, 8 Oct 2025 02:23:34 +0300 Subject: [PATCH] Update article.md Setting __proto__ of an existing object to null also works. --- 1-js/08-prototypes/04-prototype-methods/article.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/1-js/08-prototypes/04-prototype-methods/article.md b/1-js/08-prototypes/04-prototype-methods/article.md index 9c5f1eb3dd..e9d8db3569 100644 --- a/1-js/08-prototypes/04-prototype-methods/article.md +++ b/1-js/08-prototypes/04-prototype-methods/article.md @@ -167,6 +167,20 @@ alert(obj[key]); // "some value" `Object.create(null)` creates an empty object without a prototype (`[[Prototype]]` is `null`): +Note that setting __proto__ of an existing object to null also works. + +```js run +*!* +let obj = {}; +obj.__proto__ = null; +*/!* + +let key = prompt("What's the key?", "__proto__"); +obj[key] = "some value"; + +alert(obj[key]); // "some value" +``` + ![](object-prototype-null.svg) So, there is no inherited getter/setter for `__proto__`. Now it is processed as a regular data property, so the example above works right.