我正在查看一个使用原型的继承示例,如下:
function Person(name){
this.name = name
}
function Student(name){
Person.call(this, name)
}
Student.prototype = Object.create(Person.prototype)
Student.prototype.constructor = Student
let jim = new Student("Jim")
我的问题是,为什么需要使用Object.create(Person.prototype)
来设置原型?为什么不能像这样简单地设置:Person.prototype
?