// https://blog.csdn.net/u013861109/article/details/52432618
function Site() {
this.name = 'codePlayer'
this.url = 'http://www.365mini.com'
this.sayHello = () => {
console.log('欢迎:', this.name)
}
}
const obj = {
engine: 'PHP',
sayHi: () => {
console.log('欢迎访问:', this.engine)
}
}
Site.prototype = obj
const s1 = new Site()
// console.log(s1.hasOwnProperty('name'))
// console.log(s1.hasOwnProperty('url'))
// console.log(s1.hasOwnProperty('sayHello'))
// console.log(s1.hasOwnProperty('engine'))
// console.log(s1.hasOwnProperty('sayHi'))
// console.log(s1)
// console.log('name' in s1)
// console.log('url' in s1)
// console.log('engine' in s1)
// console.log('sayHi' in s1)
// 关键词
// obj.hasOwnProperty()方法,只在对象自身来查找是否有指定的属性,
// 返回值的类型是boolean
// searchStr in obj方法,不仅会在对象自身来查找是否有指定的属性,
// 还会沿着原型链,会原型链上去查找是否有指定的属性
// 使用中要根据需求,来选用,相同点是都能判断对象是否有指定的属性
// in语法的查找范围要大一点
console