function User(){}
User.prototype.name=function(){
    console.log("user.name");
}

function Admin(){}

//方式1
//Admin.prototype.__proto__==Object.prototype
console.log(Admin.prototype.__proto__==Object.prototype)
// Admin.prototype.__proto__=User.prototype;

//方式2
Admin.prototype=Object.create(User.prototype)
Admin.prototype.role=function(){
    console.log("admin.role");
}

function Member(){}

Member.prototype.role=function(){
    console.log("member.role");
}
let a=new Admin();
a.role();

 

posted on 2022-01-29 14:25  weakup  阅读(8)  评论(0编辑  收藏  举报