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.
Object.getOwnPropertyDescriptor(obj, key) returns the full descriptor object for an own property: { value, writable, enumerable, configurable }.
Challenge: Implement getDescriptor(obj, key) that returns the descriptor for the given key.
getDescriptor({ x: 1 }, 'x')
// β { value: 1, writable: true, enumerable: true, configurable: true }