function Father(name,age){
this.name = name;
this.age = age;
}
Father.prototype.sayName = function () {
console.log(this.name)
}
function Son(name,age,score){
Father.call(this,name,age);
this.score = score;
}
Son.prototype = new Father();
Son.prototype.constructor = Son;
Son.prototype.printScore = function () {
console.log(this.score)
}
let son = new Son('黄帅帅',18,100);
console.log(son)
son.sayName();
son.printScore();
结果