Subclasses (Definition)

Subclasses inherit the behavior from their superclass.

When you create a subclass in JavaScript, it is done by building a constructor function. To be completely correct, the constructor should be linked by the constructor property of the prototype property. We overwrite the prototype as an object is created, however the constructor is inherited from the object that was cloned. We need to set the constructor manually. That is done like this:

MyNewClass.prototype.constructor = MyNewClass;

Warnings:

See also:__proto__, Anchor object, Superclasses