A surprising assignment often becomes obvious once the property’s internal shape is named: a data property stores its value in [[Value]], while an accessor property computes it through [[Get]] and [[Set]]. These property kinds are mutually exclusive. section 5.2
At the language level, assigning to a data property replaces the exact value held by [[Value]], and reading the property returns that value without computation or side effects. Engines may use different physical storage, but the specification model remains [[Value]]. section 5.2.1
Direct replacement
For a drawer object with contents: 'tax documents', reading drawer.contents returns that string; assigning drawer.contents = 'invoices' replaces the stored value. The property behaves as data storage rather than computed access. section 5.2.1
Use these distinctions when inspecting descriptor behavior:
- Treat [[Value]] and [[Writable]] as data-property attributes. section 5.2
- Do not combine [[Value]] with [[Get]] or [[Set]]; accessor properties use the latter pair instead. section 5.2
- Separate the specification model from engine storage mechanisms such as those used by V8. section 5.2.1
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
|
✓
|
✓
|
Compare [[Value]] with [[Writable]], [[Get]], [[Set]], [[Enumerable]], and [[Configurable]] across data and accessor properties. section 5.2
