function Animal () {
this.name = "Animal ";
}
function Dog () {
this.name = "Dog ";
}
Dog.prototype = new Animal (); //此时B.prototype的构造器(B.prototype.constructor)变成了Animal
var dog = new Dog ();
//dog 的constructor为Animal
//如果我们要利用dog.constructor来做类型判断,或者通过dog.constructor访问Dog,一定要记得重新设置Dog.prototype.constructor = Dog;