When a property behaves unexpectedly, inspect its descriptor: Object.getOwnPropertyDescriptor() reveals whether an own property is a data property or accessor and exposes its controlling attributes. section 5.2.3
For data properties, the returned descriptor makes these controls explicit:
- writable determines whether assignment changes the value; strict mode throws for a non-writable property, while sloppy mode silently fails. section 5.2.3
- enumerable determines whether the property appears in for...in loops and Object.keys(); direct access still works when it is false. section 5.2.3
- configurable determines whether deletion and later descriptor changes are allowed; writable and configurable control different operations. section 5.2.3
Data versus accessor properties
For an accessor such as drawer.contents, the descriptor exposes get and set functions rather than a value; enumerable and configurable remain available as descriptor attributes.
