文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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

相关阅读 更多 +
排行榜 更多 +
少女爱换装

少女爱换装

休闲益智 下载
百变英雄射击

百变英雄射击

飞行射击 下载
魔灵契约

魔灵契约

休闲益智 下载