### 区别
>in运算符:给定的属性如果是对象的自由属性或继承属性返回true
>hasOwnProperty()方法:给定的属性如果是对象的自由属性返回true,如果是继承属性返回false
```
function Animal(){}//定义Animal构造函数
Animal.prototype = {//定义Animal原型
species:"动物",
say:function(){
console.log('i can say word');
}
}
function Cat(name,color){//定义构造函数Cat
this.name = name;
this.color = color;
}
var F = function(){};
F.prototype = Animal.prototype;
Cat.prototype = new F();
Cat.prototype.constructor = Cat;//Cat继承Animal 用F空对象作为媒介
var eh = new Cat('lili','white');//实例化对象
console.log('say' in eh)//=>true
console.log('name' in eh)//=>true
console.log('color' in eh)//=>true
console.log('species' in eh)=>true
console.log(eh.hasOwnProperty('say'))=>false 由于say为继承属性 非自有属性
console.log(eh.hasOwnProperty('species'))=>false 由于species为继承属性 非自有属性
console.log(eh.hasOwnProperty('name'))=>true
console.log(eh.hasOwnProperty('color'))=>true
for(var key in eh){
console.log(key);
if(eh.hasOwnProperty(key)){
console.log(key) //=>species say name color
}
}
```