(转)js中的hasOwnProperty和isPrototypeOf方法
时间:2010-12-08 来源:jenry(云飞扬)
function siteAdmin(nickName,siteName){ this.nickName=nickName; this.siteName=siteName; } siteAdmin.prototype.showAdmin = function() { alert(this.nickName+"是"+this.siteName+"的站长!") }; siteAdmin.prototype.showSite = function(siteUrl) { this.siteUrl=siteUrl; return this.siteName+"的地址是"+this.siteUrl; }; var matou=new siteAdmin("愚人码头","WEB前端开发"); var matou2=new siteAdmin("愚人码头","WEB前端开发"); matou.age="30"; // matou.showAdmin(); // alert(matou.showSite("http://www.css88.com/")); alert(matou.hasOwnProperty("nickName"));//true alert(matou.hasOwnProperty("age"));//true alert(matou.hasOwnProperty("showAdmin"));//false alert(matou.hasOwnProperty("siteUrl"));//false alert(siteAdmin.prototype.hasOwnProperty("showAdmin"));//true alert(siteAdmin.prototype.hasOwnProperty("siteUrl"));//false alert(siteAdmin.prototype.isPrototypeOf(matou))//true alert(siteAdmin.prototype.isPrototypeOf(matou2))//true
相关阅读 更多 +
- 系统休眠文件删除后果 如何删除计算机的休眠文件 2025-04-22
- 站群服务器是什么意思 站群服务器的作用 站群服务器和普通服务器的区别 2025-04-22
- jQuery插件有何作用 jQuery插件的使用方法 2025-04-22
- jQuery插件有哪些种类 简单的jQuery插件实例 2025-04-22
-