JS Built-ins
ObjectObject.getOwnPropertyDescriptorsintermediate

Object.getOwnPropertyDescriptors() β€” Symbol properties separate

πŸ“– Usage Example
// Inspect all property descriptors at once
const obj = { a: 1, b: 2 }
Object.getOwnPropertyDescriptors(obj)
// β†’ { a: { value: 1, writable: true, ... }, b: { value: 2, ... } }

Use Object.getOwnPropertyDescriptors() to get all property descriptors of an object, useful when doing a complete clone.

Object.getOwnPropertyDescriptors() β€” no Symbols

Object.getOwnPropertyDescriptors returns only string-keyed own properties. Symbol-keyed properties are excluded (use Object.getOwnPropertySymbols for those).

Challenge: Implement hasNoSymbol(obj) that returns true if the descriptors map does not include Symbol keys.

const s = Symbol('test')
hasNoSymbol({ [s]: 1 }) // β†’ true (Symbol not in descriptors)
πŸ’‘ Hints (2)
  • β€’ `Object.getOwnPropertyDescriptors` only returns string-keyed properties.
  • β€’ To get Symbol-keyed property descriptors, use `Object.getOwnPropertySymbols` combined with `Object.getOwnPropertyDescriptor`.