ich das Konzept der Vererbung in Javascript zu studieren und das Tutorial Ich betrachte verwendet diesen Code:Vererbung innerhalb Javascript
// define the Student class
function Student() {
// Call the parent constructor
Person.call(this);
}
// inherit Person
Student.prototype = new Person();
// correct the constructor pointer because it points to Person
Student.prototype.constructor = Student;
Meine Frage ist, warum ist es notwendig, sowohl den Konstruktor Eltern rufen , Person.call(this)
und stellen Sie den Student
Prototyp gleich ein neues Person
Objekt (dh Student.prototype = new Person();
)?
http://stackoverflow.com/questions/892595/javascript-prototypal-inheritance?rq=1 –