//使用原型工厂封装继承 function extend(sub,sup){ sub.prototype=Object.create(sup.prototype); Object.defineProperty(sub.prototype,"constructor",{ value:sub, enumerable:false }); } function User(name,age){ this.name=name; this.age=age; } User.prototype.show=function(){ console.log(this.name,this.age); } function Admin(...args){ User.apply(this,args); } extend(Admin,User); let admin=new Admin('xj',12); admin.show();