const o = { key: '1' };
Object.defineProperty(o, 'key', { value: '2' });
// configurable of `o.key` is true
Object.defineProperty(o, 'newKey', { value: '2' });
// configurable of `o.newKey` is false
I have read the spec of DefineProperty
, the result of above code is correct, but It's still confusing for me.
Why not make the configurable of property key
to be the default value false
? As the document at MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#description