// 工具方法:继承原型
function inherit(superPro,subPro){
const prototype = Object.create(superPro.prototype);
Object.defineProperty(prototype,'constructor',{
value:superPro,
enumerable:false,
writable:true,
configurable:true
});
subPro.prototype = prototype;
}
// 父类 属性定义
function Person(name,friend){
this.name = name;
this.friend = friend;
}
// 父类 方法定义
Person.prototype.sayPerson = function(){
console.log('sayPerson');
}
// 子类
function Student(idno,name,friend){
this.idno = idno;
// 继承属性,并调用超类构造器
Person.call(this,name,friend)
}
// 原型继承调用
inherit(Person,Student)
const jack = new Student('25','lrx',[]);
jack.sayPerson()