Javascript and 'Call()'

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:-


// 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;

Many thanks! :slight_smile:

Ah, never mind I found the problem :slight_smile: In the parent class I had a reference to an Object of the child class and it was getting stuck in a never ending loop of instantiation - problem solved :wink: