javascript 承袭

javascript 继承function SuperType(name){this.name namethis.colors [“red”, “blue”, “green”]}Su

javascript 继承

function SuperType(name){this.name = name;this.colors = [“red”, “blue”, “green”];}SuperType.prototype.sayName = function(){alert(this.name);};function SubType(name, age){SuperType.call(this, name);this.age = age;}inheritPrototype(SubType, SuperType);SubType.prototype.sayAge = function(){alert(this.age);};