Object.getOwnPropertyDescriptorsintermediate// 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.
You can use the result to inspect flags for every property at once.
Challenge: Implement allEnumerable(obj) that returns true if every own property is enumerable.
allEnumerable({ a: 1, b: 2 }) // β true