JS Built-ins
ObjectObject.definePropertiesintermediate

Object.defineProperties() β€” non-writable property

πŸ“– Usage Example
// Define multiple property descriptors at once
const obj = {}
Object.defineProperties(obj, {
  x: { value: 1, writable: true, enumerable: true },
  y: { value: 2, writable: false, enumerable: true },
})

Use Object.defineProperties() to define multiple properties with fine-grained descriptors in a single call.

Object.defineProperties() β€” immutable properties

You can mix writable and non-writable properties in a single Object.defineProperties call.

Challenge: Implement addMixed(obj) that adds editable (writable, value: 10) and fixed (non-writable, value: 99) to obj.

const o = {}
addMixed(o)
o.editable = 50   // works
o.fixed = 0       // silently fails
o.editable        // β†’ 50
o.fixed           // β†’ 99
πŸ’‘ Hints (2)
  • β€’ Set `writable: false` on the `fixed` property descriptor.
  • β€’ In sloppy mode, assignment to a non-writable property silently fails.