[projs3e] About the configurable attribute to false and Object.defineProperty()

Skip to first unread message


Sep 28, 2017, 3:43:37 AM9/28/17
to Zakas Books

PS: I'm Chinese. I will try my best to describe my questions in English as clearly as possible.

My question is at chapter 6 (6.1.1), nearby the example DataPropertiesExample03.htm : you said -- If the configurable attribute was set to false , no attribute can be changed besides writable.

However, when I test it, I found it throw an Error.(Please look at the picture below.)  I wonder whether it's the error of the book or my misunderstanding.

In addition, I found that, when the property already exists, I used Object.defineProperty() to modify configurable to false . Next, I modified other attributes -- value to "Caaa" and it logs "Caaa", configurable to true and it threw an error.

I feel confused that why I modified other attributes such as value, writable and enumerable, it could ran out a result but configurable to true then throw an error, after I set configurable to false.(Please look at the picture below.) 

I am looking forward to receiving your reply.

Thanks a lot!


Nicholas Zakas

Sep 28, 2017, 12:22:08 PM9/28/17
to zakas...@googlegroups.com

If a property is not configurable, you can change writable from true to false, but not from false to true. So the book is correct even though it could probably be clearer.

For your second example, I'm not 100% sure, but I think you are allowed to set the value property because it was not set when the property was created. 

You received this message because you are subscribed to the Google Groups "Zakas Books" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zakasbooks+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
0 new messages