function Animal () {
this.name = "Animal ";
}this
function Dog () {
this.name = "Dog ";
}prototype
Dog.prototype = new Animal (); //此时B.prototype的构造器(B.prototype.constructor)变成了Animal io
var dog = new Dog ();function
//dog 的constructor为Animal im
//若是咱们要利用dog.constructor来作类型判断,或者经过dog.constructor访问Dog,必定要记得从新设置Dog.prototype.constructor = Dog;co