ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
# isPrototypeOf属性 >[danger]isPrototypeOf: 判断某个对象是否是指定实例对象的原型对象,如果在返回true,反之返回false(找父类) ***** ```javascript //构造函数 function Person(name,age) { this.name = name;//私有的属性 this.age = age; } //方法都加在原型上 Person.prototype = { constructor:Person,//记得,上来第一步就把指向给修改了--公式 say:function () { console.log("我是公有的方法"); }, }; //实例化对象 var per1 = new Person("ZS",18); console.log(per1); //原型对象也是对象--万物皆对象 console.log(Person.prototype.isPrototypeOf(per1)); console.log(Person.prototype.isPrototypeOf(per2));//true console.log(Person.prototype.isPrototypeOf({}));//false ```