JSFiddle - React, Tailwind, and code Playground
by Maxim Ivanov
JavaScript
function extend(child, parent) {
var emptyCtor = function() {};
emptyCtor.prototype = parent.prototype;
child.prototype.constructor = child;
child._super = parent.prototype; // fix
return child;
};
var ParentClass = function() {
this.a = 1;
};
var ChildClass = extend(function() {
ChildClass._super.constructor.call(this) // call parent
this.b = 2; // add new property
}, ParentClass);
var myObject = new ChildClass;
document.body.innerHTML = myObject.a + "<br>";
document.body.innerHTML += myObject.b + "<br>";