Object.getOwnPropertyDescriptorintermediate// 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.
For properties defined with a getter, the descriptor contains a get function instead of value and writable.
Challenge: Implement isGetter(obj, key) that returns true if the descriptor for key has a get function.
const o = {}
Object.defineProperty(o, 'x', { get: () => 1 })
isGetter(o, 'x') // β true
isGetter(o, 'y') // β false