Object.create:创建新的对象,新对象完全引用原对象,新对象的改变完全不会影响元对象,常用来实现“继承”(ps:js中没有继承的说法)。
var bird={
name:'bird',
speak:function(){
console.log(this);
console.log("I am a "+this.name);
}
}
var b1=Object.create(bird);
console.log(b1.name); //“bird”
b1.speak(); //“I am a bird”
console.log(b1); //{}
console.log(b1 instanceof bird);
//错误
TypeError: Right-hand side of 'instanceof' is not callable