JavaScript继承写法 - Rocky的前端
构造函数+原型法
function person(name,age){ this.name = name; this.age = age;}person.prototype.say = function(){ console.log(this.name+":"+this.age);}function superman(name,age){ person.call(this,name,age);}superman.prototype = new person();superman.prototype.fight = function(){ this.say(); console.log("fighting...");}var s = new superman('superman',29);s.fight();