hasOwnProperty 这两个都是考虑对象自身的属性和方法,通过People.prototype.constructor.call(this) 继承的属性和方法也称作自己的属性和方法,比如name sing 而eat并不是,他是People.prototype的方法。
xialuo.sing()//singing不是本身的属性而是它的原型链上的。for(let k in xialuo){
console.log(k,':',xialuo[k]);//只能是构造器的属性和方法}//name : 夏洛// car : baomao// sing : ƒ (){}// age : 13
console.log(xialuo.hasOwnProperty('name'));//true
console.log(xialuo.hasOwnProperty('age'));//true
console.log(xialuo.hasOwnProperty('eat'));//false