Alexon
2022-02-22 05:48
Fn1 ->prototype->obj
so obj.constructor=Fn1;
Fn2->prototype->obj
will obj.constructor=Fn2 ?
what is obj.constructor? Fn1 or Fn2?
两个构造函数的prototype不会指向同一对象
var zhangsan=new Person('zhangsan'); console.log(prim.money); console.log(zhangsan.name); console.log(zhangsan.money); console.log(zhangsan.__proto__); console.log(zhangsan.constructor); var dog=new Animal('dog') console.log(dog.name); console.log(dog.money);
2022-02-23 23:42:32
共 3 条回复 >
直面JavaScript中的30个疑难杂症
14383 学习 · 20 问题
相似问题
回答 4
回答 1