JS Built-ins
ObjectObject.definePropertiesintermediate

Object.defineProperties() β€” non-enumerable 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() β€” hiding properties

Properties defined with enumerable: false are invisible to Object.keys and for...in.

Challenge: Implement addWithHidden(obj) that adds a visible name property and a hidden _internal property.

const o = {}
addWithHidden(o)
Object.keys(o)           // β†’ ['name']
o._internal              // β†’ 'secret'
πŸ’‘ Hints (2)
  • β€’ Set `enumerable: false` on `_internal` to hide it from standard iteration.
  • β€’ `Object.getOwnPropertyNames` reveals all own properties regardless of enumerability.