i had made a small code snippet for multiple inheritance in js. this code is working for me but actually i like to get the review, that its good and if any problem; provide the solution. etc. the code snippet is below.
/**
* WebbaseUtility provide the bundle of utilities used for support the webbase
* functionalities;
* @package : WebbaseUtility;
* @version : 1.0.0;
*/
var WebbaseUtility = {};
/**
* ObjectExt module extends the object properties and functionalities like inheritance etc;
* @module : ObjectExt;
* @package : Webbase;
* @version : 1.0.0;
* @return Object;
*/
var ObjectExt = WebbaseUtility.ObjectExt = (function() {
/**
* ObjectExt Constructor;
*/
var ObjectExt = function() {
};
/**
* This method provide inheritance to the object supplied; this method inherit the
* public methods from the Parent class to the Child class. this also provide
* multiple inheritance, in which the method ambiguity is solved by the overriding
* the last inherited class's method;
* @access public;
* @method inherit;
* @param Object Parent;
* @param Object Child;
* @return Object;
*/
ObjectExt.prototype.inherit = function(Parent, Child) {
var TempObj = function(){}, MultipleInheritanceTempObj = function(){};
MultipleInheritanceTempObj.prototype = Child.prototype;
TempObj.prototype = Parent.prototype;
for(var key in MultipleInheritanceTempObj.prototype) {
TempObj.prototype[key] = MultipleInheritanceTempObj.prototype[key];
}
MultipleInheritanceTempObj = null;
Child.prototype = new TempObj();
if(Child.uber === undefined) {
Child.uber = Parent.prototype;
}else {
for(var key in Parent.prototype) {
Child.uber[key] = Parent.prototype[key];
}
}
Child.prototype.constructor = Child;
return Child;
};
return new ObjectExt();
})();
Child = WebbaseUtility.ObjectExt.inherit(ParentA, Child);
Child = WebbaseUtility.ObjectExt.inherit(ParentB, Child);