Static method Object.hasOwn()
The Object.hasOwn()
static method returns true if
the specified object has the indicated property as
its own property. If the property is inherited, or
does not exist, the method returns false.
const object1 = {
prop: 'exists'
};
console.log(Object.hasOwn(object1, 'prop'));
// Expected output: true
console.log(Object.hasOwn(object1, 'toString'));
// Expected output: false
console.log(Object.hasOwn(object1, 'undeclaredPropertyValue'));
// Expected output: false