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.
The method only looks at own properties. Inherited properties return undefined even if accessible via the prototype chain.
Challenge: Implement inheritedIsUndefined() that creates an object with a prototype that has protoKey, checks that getOwnPropertyDescriptor returns undefined for it, and returns that result.
inheritedIsUndefined() // β true