JSFiddle - React, Tailwind, and code Playground
by silv3r_m00n
JavaScript
Function.prototype.inherits = function( parent )
{
if ( parent.constructor == Function )
{
//Normal Inheritance
this.prototype = new parent;
this.prototype.constructor = this;
if('parent' in this.prototype)
{
var l = this.prototype.parent.length;
this.prototype.parent[l] = parent.prototype;
}
else
{
this.prototype.parent = [];
this.prototype.parent[0] = parent.prototype;
}
this.prototype.uber_level = this.prototype.parent.length - 1;
this.prototype.uber = function(name)
{
var level = this.uber_level--;
this.parent[level][name].call(this);
//restore the uber level so that next time calls work properly
this.uber_level++;
}
}
else
{
//Pure Virtual Inheritance
this.prototype = parent;
this.prototype.constructor = this;
this.prototype.parent = parent;
}
return this;
}
function A()
{
}
A.prototype.bing = function()
{
document.write('Inside A <br />');
}
function B()
{
}
B.inherits( A );
B.prototype.bing=function()
{
document.write('Inside B <br />');
this.uber('bing');
}
function C()
{
}
C.inherits( B );
/*
C.prototype.bing=function()
{
document.write('Inside C <br />');
this.uber('bing');
}
*/
var ko = new C;
ko.bing();
ko.bing();