构造函数的实例对象的constructor.prototype是Object{},这没错但是

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>对象</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>

https://img2.mukewang.com/5bc691f50001ce3904650133.jpg


我的迷惑是为什么输出的Object的constructor是Person而不是function Object(),查阅资料上也提到了但是下面没解释为什么,说的没看懂到底在解释什么反倒最后来了句提示一定要让构造函数的原型的constructor为构造函数本身

https://img2.mukewang.com/5bc692010001724f07600528.jpg

https://img1.mukewang.com/5bc6920a00011d3a06270250.jpg


哆啦的时光机
浏览 704回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript