A failed assignment can look mysterious: `obj.foo = 'bar'` either changes nothing or throws. [[Writable]] supplies the missing diagnosis. It is the boolean internal attribute of a data-property descriptor that determines whether the property's stored [[Value]] may change. It applies only to data properties; accessor properties use [[Get]] and [[Set]] instead. section 5.2 section 5.2.3
Use the descriptor APIs to inspect the rule and interpret its observable effects:
- `Object.getOwnPropertyDescriptor(object, name)` exposes `value` and `writable`, identifying a data property and its mutability. section 5.2.3
- With `writable: false`, assignment silently fails in sloppy mode but throws an error in strict mode; the stored value remains unchanged. section 5.2.3
- With `writable: true`, assignment may update the stored value. `writable` controls the value, whereas `configurable` controls whether the descriptor can later be changed or deleted. section 5.2.3
A deliberately read-only identifier
const drawer = { contents: 'tax documents' }; Object.defineProperty(drawer, 'internalId', { value: 12345, writable: false }); drawer.contents = 'invoices'; drawer.internalId = 54321; `contents` changes, but `internalId` does not—and strict mode determines whether the latter assignment is silent or exceptional. section 5.2.3
