function Admin(){
    Admin.prototype.showAdmin=function(){
        return "admin";
    }
}
function Enterprise(){
    Enterprise.prototype.showEnterprise=function(){
        return "Enterprise";
    }
}
for (const obj of [new Admin,new Enterprise]) {
    if(obj instanceof Admin){
        console.log(obj.showAdmin());
    }else if(obj instanceof Enterprise){
        console.log(obj.showEnterprise());
    }
}

 

posted on 2022-01-29 19:36  weakup  阅读(4)  评论(0编辑  收藏  举报