企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 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对象"); } ```