JS Built-ins
ObjectObject.definePropertiesadvanced

Object.defineProperties() β€” configurable: false prevents deletion

πŸ“– 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() β€” locking properties

When configurable: false, you cannot delete the property or redefine its descriptor.

Challenge: Implement addLocked(obj) that defines a locked property with configurable: false.

const o = {}
addLocked(o)
delete o.locked  // silently fails
o.locked         // β†’ 42
πŸ’‘ Hints (2)
  • β€’ Set `configurable: false` to prevent deletion and redefinition.
  • β€’ Combine with `writable: false` for full immutability.