文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>(转)js中的hasOwnProperty和isPrototypeOf方法

(转)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

相关阅读 更多 +
排行榜 更多 +
夕鸟

夕鸟

生活实用 下载
partyplay

partyplay

聊天通讯 下载
婚礼纪

婚礼纪

生活实用 下载