🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# constructor属性 >[danger]constructor 判断构造器的类型来得知创建的对象的类型, ***** ```javascript function Person(name) { this.name = name; } function Dog(name) { this.name = name; } var p = new Person("p"); var d = new Dog("d"); console.log(p.constructor);//打印得到Person函数对象 console.log(d.constructor);//打印得到Dog函数对象 if(p.constructor == Person){ console.log("是Person对象"); } if(d.constructor == Dog){ console.log("是Dog对象"); } ```