JSFiddle - React, Tailwind, and code Playground

by alexflav23

JavaScript

function inheritance(child, parent) {

    /** @constructor */
    function temp() {};
    temp.prototype = parent.prototype;
    child.prototype = new temp();
    child.superClass_ = parent.prototype;// Making the child aware of the parent.
    /** @override */
    child.prototype.constructor = child;
};
function A() {
  
};
A.prototype.doSomething = function(t) {alert("I'm " + t)};

function B() {
    A.call(this);
};
inheritance(B, A);

B.prototype.callFromA = function() {
    B.superClass_.doSomething(" also called from a B instance");
};


var b = new B();
b.doSomething(" called from a B instance.");
b.callParentMethod();