function Animal(name) { this.name = name || "xxx"; this.type = "animal"; } Animal.prototype = { say : function(){ alert("I'm a " + this.type + ", my name is " + this.name) } } function Bird(name) { Animal.call(this, name); } Bird.prototype={ } var myBird = new Bird("xiaocui"); alert(myBird.type);
转载于:https://blog.51cto.com/3154408/1901044