美文网首页
hasOwnProperty的使用

hasOwnProperty的使用

作者: 读心的心 | 来源:发表于2019-12-11 17:29 被阅读0次

function Person(name, age, job) {
this.name = name;
this.age = age;
this.job = job;
}
console.log(new Person("xuelian","","微信小程序"));
console.log(Person.hasOwnProperty("name"));//true
/**

  • 原型模式
    */
    function Person1(){}
    Person1.prototype.name = "duxin";
    Person1.prototype.age = 25;
    Person1.prototype.job = "web wechat"

const person1 = new Person1();
console.log(person1.name);

console.log("name" in person1);//true
console.log(person1.hasOwnProperty("name"));//false

相关文章

网友评论

      本文标题:hasOwnProperty的使用

      本文链接:https://www.haomeiwen.com/subject/vihagctx.html