hasOwnProperty: is used to determine whether an object has a property or object that you gave the name. However, it should be noted that this method cannot check whether the object's prototype chain has this property, which must be a member of the object itself.
isPrototypeOf: is used to determine whether the object to check whether the prototype chain exists in the specified object instance. If it is, it returns true, otherwise it returns false.
The code copy is as follows:
function siteAdmin(nickName,siteName){
this.nickName=nickName;
this.siteName=siteName;
}
siteAdmin.prototype.showAdmin = function() {
alert(this.nickName+" is the webmaster of "+this.siteName+"!")
};
siteAdmin.prototype.showSite = function(siteUrl) {
this.siteUrl=siteUrl;
The address of return this.siteName+" is "+this.siteUrl;
};
var matou=new siteAdmin("Wulin.com","WEB front-end development");
var matou2=new siteAdmin("Wulin.com","WEB front-end development");
matou.age="30";
// matou.showAdmin();
// alert(matou.showSite("//www.VeVB.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