请教大家,关于原型__proto__的取值问题,有点疑惑

qq_29448025 2020-02-29 09:44:45
问题:如下图



注:用chrome最新版本浏览器测试结果。
...全文
148 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_29448025 2020-02-29
  • 打赏
  • 举报
回复
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>原型测试</title>
</head>
<body>
    <script>
        function Student(name,age) {
            this.name=name;
            this.age=age;
        }
        let stu=new Student("张三",18);
        let arr=new Array(30,40,50);
    </script>

</body>
</html>
以上是原代码。
天际的海浪 2020-02-29
  • 打赏
  • 举报
回复
stu.__proto__ 就是 Student.prototype 自定义的函数的prototype 都是 Object 对象 你 console.log(stu); 才是显示Student 同样,arr.__proto__ 就是 Array.prototype Array.prototype 是js固有的内置对象,浏览器自然会为它标注个名称。 那个(0)是 Array.prototype.length 的值。

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧