A property descriptor explains why an assignment silently fails, why a property vanishes from Object.keys(), or why delete does nothing. It records how a property stores or computes values and whether that behavior may be changed. section 5.2 section 5.2.3
Descriptors divide properties into two mutually exclusive forms:
- Data properties store a value through [[Value]] and may permit replacement through [[Writable]]. section 5.2 section 5.2.1
- Accessor properties compute reads with [[Get]] and handle writes with [[Set]]; they cannot also use [[Value]] or [[Writable]]. section 5.2
- [[Enumerable]] controls appearance in for...in and Object.keys(), while [[Configurable]] controls deletion and later descriptor changes. section 5.2.3
- Object literals default descriptor flags to true, whereas Object.defineProperty() defaults omitted flags to false. section 5.11 section 5.2.3
Diagnosing a locked property
const drawer = {}; Object.defineProperty(drawer, 'serialNumber', { value: 'SN-12345', writable: false, enumerable: true, configurable: false, }); drawer.serialNumber = 'SN-99999'; delete drawer.serialNumber; The assignment silently fails in sloppy mode but throws in strict mode; delete also fails because the property is non-configurable. Object.getOwnPropertyDescriptor(drawer, 'serialNumber') exposes these settings. section 5.2.3
Table 5.1 The property descriptor attributes and the property types they apply to:
|
Name
|
Description
|
Data Properties
|
Accessor Properties
|
|
[[Value]]
|
A stored JavaScript value
|
✓
|
|
|
[[Writable]]
|
A boolean indicating whether [[Value]] can be changed
|
✓
|
|
|
[[Get]]
|
Code used to compute the property value
|
|
✓
|
|
[[Set]]
|
Code used to modify the property value
|
|
✓
|
|
[[Enumerable]]
|
A boolean indicating whether the property can appear in iterations
|
✓
|
✓
|
|
[[Configurable]]
|
A boolean indicating whether the property descriptor itself can be
changed or deleted
|
✓
|
✓
|
Use the attribute matrix to distinguish data and accessor properties and to map each internal attribute to its permitted property type. section 5.2


