开发者社区> 问答> 正文

Javascript 中的Object.create() 问题

function Student(){}
function Person(){}
Student.prototype = Object.create(Person.prototype);
//Student.prototype.constructor = Student;
console.log(Student.prototype);
注释前,Student.prototype为Student{};
解除后,Student.prototype为Object{}。

Object.create函数返回的为什么是Object对象(不应该是Person{}吗)?
修改Student.prototype.constructor属性为什么可以更改Student.prototype?

展开
收起
小旋风柴进 2016-03-19 11:31:17 1714 0
1 条回答
写回答
取消 提交回答
  • Object是所有js对象的基类,可以这样认为。
    constructor 指定构造函数

    2019-07-17 19:07:51
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
JavaScript面向对象的程序设计 立即下载
Delivering Javascript to World 立即下载
编程语言如何演化-以JS的private为例 立即下载