JSFiddle - React, Tailwind, and code Playground
JavaScript
(function () {
'use strict';
Object.prototype.inherit = function (parent) {
for (var k in parent.prototype) {
var func = parent.prototype[k];
if (!this.prototype[k]) { // child function doesn't get overwrite by parent
this.prototype[k] = func; //function only exists in one parent class
}
}
this.prototype.$super = parent.prototype;
};
function Parent(){
console.log('Init Parent');
}
Parent.prototype.sayHi = function(){
console.log('Hi From Parent');
}
function Child(name){
Parent.call(this);
console.log('Init Child');
this.name = name;
}
Child.prototype.sayHi = function(){
this.$super.sayHi();
console.log(this.name + ' from Child');
};
Child.inherit(Parent);
var aaron = new Child('Aaron');
aaron.sayHi();
})();