Object.hasOwnintermediate// 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.
obj.hasOwnProperty throws on null-prototype objects because they don't inherit it. Object.hasOwn works safely on them.
Challenge: Implement checkNullProto(key, val) that creates a null-prototype object with the given key/val, then uses Object.hasOwn to check for that key.
checkNullProto('id', 42) // β true