ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# hasOwnProperty属性 检测对象上的属性和方法,只能检查私有的,不能检测公有的 ```javascript function Person(name, age) { //私有的 this.name = name; this.age = age; } Person.prototype = { //公有的 constructor:Person, study:function () { console.log(this.name,this.age); }, say:function () { console.log(this.name," say hello"); } } var p = new Person("zs",10); console.log(p.hasOwnProperty("name"));//true console.log(p.hasOwnProperty("study"));//false console.log(p.hasOwnProperty("name222"));//false ```