labatrockwell/LAB_JS_Framework — Issue #7: use LAB.inherit
Author: soundanalogous
Created: 2011-12-06 17:08:25+00:00
State: open

Whenever you are using inheritance and need to call the superclass from the subclass constructor, use the following pattern. This pattern will avoid the duplicate call to the super class constructor that occurs with SubClass.prototype = new SuperClass()

LAB.SubClass = function() {
// call to super
LAB.SuperClass.call(this, optionalParams);
};

LAB.SubClass.prototype = LAB.inherit(LAB.SuperClass.prototype);
LAB.SubClass.prototype.constructor = LAB.SubClass;
// you can also add a reference to supr if you like