<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<title>對(duì)象</title></head><body>
<script>
function Person(name,age){ this.name=name; this.age=age;
} var p1=new Person("zxf",30); console.log(p1.constructor.prototype) //console.log(Person.constructor)
</script></body></html>我的迷惑是為什么輸出的Object的constructor是Person而不是function Object(),查閱資料上也提到了但是下面沒(méi)解釋為什么,說(shuō)的沒(méi)看懂到底在解釋什么反倒最后來(lái)了句提示一定要讓構(gòu)造函數(shù)的原型的constructor為構(gòu)造函數(shù)本身
構(gòu)造函數(shù)的實(shí)例對(duì)象的constructor.prototype是Object{},這沒(méi)錯(cuò)但是
哆啦的時(shí)光機(jī)
2018-08-30 18:42:03