Object.getOwnPropertyDescriptorbeginner// Inspect a single property's descriptor
const obj = { x: 42 }
Object.getOwnPropertyDescriptor(obj, 'x')
// β { value: 42, writable: true, enumerable: true, configurable: true }Use Object.getOwnPropertyDescriptor() to retrieve the descriptor object that describes a property's attributes.
If the key does not exist on the object (or is inherited), Object.getOwnPropertyDescriptor returns undefined.
Challenge: Implement hasDescriptor(obj, key) that returns true if the descriptor exists, false otherwise.
hasDescriptor({ a: 1 }, 'a') // β true
hasDescriptor({ a: 1 }, 'b') // β false