hasOwnProperty的使用
2019-12-11 本文已影响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