var animal = function(name){
this.name = name;
this.eat = function(){
console.log("emmmmmmmmmmmmmmmmmmmmm")
}
}
animal.prototype.sleep = function(){
console.log("zzzzzzzzzzzzzzzzzzzzzz")
}
var dog = function(name){
animal.call(this, name);
}
dog.prototype = new animal();
dog.prototype.watch = function(person){
if(person != "master") console.log("汪汪汪汪汪汪汪汪汪汪汪汪")
}
var money = new dog ("旺财");
var lucky = new dog ("来福");
console.log(money instanceof animal) // true
console.log(money instanceof dog) // true
console.log(money.name); // 旺财
money.eat(); // emmmmmmmmmmmmmmmmmmmmm
money.sleep(); // zzzzzzzzzzzzzzzzzzzzzz
money.watch("someone"); // 汪汪汪汪汪汪汪汪汪汪汪汪