From 614c85ad5de601d941ea72292a3c3e927d43bafc Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Thu, 22 Jul 2021 23:37:04 +0300 Subject: [PATCH] minor fixes --- .../01-property-descriptors/article.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/1-js/07-object-properties/01-property-descriptors/article.md b/1-js/07-object-properties/01-property-descriptors/article.md index f8f8d21d..7ac7bb28 100644 --- a/1-js/07-object-properties/01-property-descriptors/article.md +++ b/1-js/07-object-properties/01-property-descriptors/article.md @@ -221,12 +221,6 @@ Math.PI = 3; // Error Making a property non-configurable is a one-way road. We cannot change it back with `defineProperty`. -To be precise, non-configurability imposes several restrictions on `defineProperty`: -1. Can't change `configurable` flag. -2. Can't change `enumerable` flag. -3. Can't change `writable: false` to `true` (the other way round works). -4. Can't change `get/set` for an accessor property (but can assign them if absent). - **The idea of "configurable: false" is to prevent changes of property flags and its deletion, while allowing to change its value.** Here `user.name` is non-configurable, but we can still change it (as it's writable): @@ -263,6 +257,11 @@ delete user.name; Object.defineProperty(user, "name", { value: "Pete" }); ``` +```smart header="The only attribute change possible: writable true -> false" +There's a minor exception, that we have to mention. + +We can change `writable: true` to `false` for a non-configurable property, thus making the property readonly (can add another layer of protection). But not the other way around. +``` ## Object.defineProperties