A surprising difference appears when defining the same property two ways: object literals enable writable, enumerable, and configurable by default, while Object.defineProperty() disables all three unless specified. section 5.2.3
Use these defaults as a practical rule:
- Object literal properties default to writable: true, enumerable: true, and configurable: true. section 5.2.3
- Object.defineProperty() and Object.defineProperties() default writable, enumerable, and configurable to false when omitted. section 5.2.3
- Writable controls value changes; configurable controls deletion and later descriptor changes; enumerable controls whether listing APIs expose the property. section 5.2.3
The same-looking property, different behavior
Object.getOwnPropertyDescriptor() reveals the difference: a property created as { prop: 'value' } reports all three attributes as true, whereas one created with Object.defineProperty(obj, 'prop', { value: 'value' }) reports all three as false.






















