Hey guys,
On the subject of prototype inheritance chains in JavaScript - do you have to keep using the call method each time you go down the chain?
The reason I ask this is because on my code I use the call method on the first child object/class with no problems, and on the next child down the chain if I use call(this) my browser freezes up.
If I omit call from the next child down I don't seem to be missing any properties - I have all of the properties of the child above and its first parent as intended.
Btw I am using Mozilla's suggested method e.g:-
Many thanks!Code:// 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;![]()



Reply With Quote

Bookmarks