@@ -227,32 +227,42 @@ To be precise, non-configurability imposes several restrictions on `defineProper
2272273 . Can't change ` writable: false ` to ` true ` (the other way round works).
2282284 . Can't change ` get/set ` for an accessor property (but can assign them if absent).
229229
230- Here we are making ` user.name ` a "forever sealed" constant:
230+ ** The idea of "configurable: false" is to prevent changes of property flags and its deletion, while allowing to change its value.**
231+
232+ Here ` user.name ` is non-configurable, but we can still change it (as it's writable):
231233
232234``` js run
233- let user = { };
235+ let user = {
236+ name: " John"
237+ };
238+
239+ Object .defineProperty (user, " name" , {
240+ configurable: false
241+ });
242+
243+ user .name = " Pete" ; // works fine
244+ delete user .name ; // Error
245+ ```
246+
247+ And here we make ` user.name ` a "forever sealed" constant:
248+
249+ ``` js run
250+ let user = {
251+ name: " John"
252+ };
234253
235254Object .defineProperty (user, " name" , {
236- value: " John" ,
237255 writable: false ,
238256 configurable: false
239257});
240258
241- * ! *
242259// won't be able to change user.name or its flags
243260// all this won't work:
244- // user.name = "Pete"
245- // delete user.name
246- // Object.defineProperty(user, "name", { value: "Pete" })
247- Object .defineProperty (user, " name" , {writable: true }); // Error
248- */ ! *
261+ user .name = " Pete" ;
262+ delete user .name ;
263+ Object .defineProperty (user, " name" , { value: " Pete" });
249264```
250265
251- ``` smart header="\" Non-configurable\" doesn't mean \" non-writable\" "
252- Notable exception: a value of non-configurable, but writable property can be changed.
253-
254- The idea of `configurable: false` is to prevent changes to property flags and its deletion, not changes to its value.
255- ```
256266
257267## Object.defineProperties
258268
0 commit comments