(1) Demand
Want to determine whether an object contains attribute values.
(2) Ideas
1. It is possible to traverse all the properties of the object and make loop judgments
2. You can directly write obj[key]
3. Use the Object.hasOwn method
(3) Demo
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