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()); } }