https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty states:
configurable: True if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. Defaults to
false
.
So, I have a
var x = Object.defineProperty({}, "a", {
value:true,
writable:true,
enumerable:true,
configurable:false
});
Now I can play with x.a = false
, for(i in x)
etc. But even though the descriptor is should be unconfigurable, I can do
Object.defineProperty(x, "a", {writable:true}); // others defaulting to false
Object.defineProperty(x, "a", {}); // everything to false
Object.freeze(x); // does the same to the descriptors
The other way round, setting them to true again, or trying to define an accessor descriptor, raises errors now. To be exact: Object.defineProperty: invalid modification of non-configurable property
.
Why can I "downgrade" descriptors though they say they were non-configurable?