2
以下两种继承Javascript对象的方法有什么区别吗?用Javascript继承对象的两种不同(?)方法
function Person(name) {
this.name = name;
}
function Student(name, id) {
Person.call(this, name);
this.id = id;
}
方法1:
Student.prototype.__proto__ = Person.prototype;
方法2:
Student.prototype = new Person;
Student.prototype.constructor = Student;
我不认为设置'constructor'属性是有用的。 – user123444555621