class Person {
constructor(){
this.name = ""
this.age = 0
}
sayName(){
console.log('sayName')
}
}
var o1 = new Person()
console.log(o1.hasOwnProperty('name')) // true
console.log(o1.hasOwnProperty('sayName')) // false
console.log('name' in o1) //true
console.log('sayName' in o1) //true
function hasPrototypeProperty(obj, name){
return !obj.hasOwnProperty(name) && name in obj;
}
console.log(hasPrototypeProperty(o1, 'sayName'))