Please check out the following example:
MyBaseClass = function(a) {
this.a = a;
};
$.extend(MyBaseClass.prototype, {
init: function() {
console.log('I am initializing the base class');
}
});
MyChildClass = $.extend(MyBaseClass, {
init: function() {
MyBaseClass.prototype.init();
console.log('I am initializing the child class');
}
});
var = new MyChildClass();
var.init();
Тhis should output both 'I am initializing the base class' and 'I am initializing the child class'.
I need to be able to inherit the class MyBaseClass, but still to be able to call his init() method at the beginning of the new init() method.
How do I do that?
$.extenddoesn't do what you think.varat the bottom$.extendanyway?