定义构造器并扩充它的原型
var Mammal = function(name){ this.name = name; };
Mammal.prototype.getName = function(){ return this.name; }; Mammal.prototype.says = function(){ return this.saying||""; };
var Cat = function(name){ this.name = name; this.saying = "cat"; };
Cat.prototype = new Mammal();
Cat.prototype.sayCatName = function(){ return this.name; };
var cat = new Cat("bb");
var name = cat.getName();//bb
cat.says();//cat