Object.hasOwnbeginner// Check if a property is directly on the object
const obj = { name: 'Alice' }
Object.hasOwn(obj, 'name') // β true
Object.hasOwn(obj, 'toString') // β falseUse Object.hasOwn() to reliably check if a property is an own property, without being fooled by inherited properties.
Object.hasOwn(obj, key) returns true if obj has an own property named key. It is a safer replacement for Object.prototype.hasOwnProperty.call.
Challenge: Implement checkOwn(obj, key) that uses Object.hasOwn to check for an own property.
checkOwn({ a: 1 }, 'a') // β true
checkOwn({ a: 1 }, 'b') // β false