JSFiddle - React, Tailwind, and code Playground

JavaScript

function extend(parent, fn) {
        return function () {
            parent.call(this);
            fn.call(this);
            fn.prototype.constructor = parent;
        }
    }
    
    function foo() {
        var a = 1;
        this.getA = function () { return a; };
    }

    var bar = extend(foo, function () {
        var b = 2;
        this.getB = function () { return b; };
      });

    var obj = new bar();
    console.log(obj.getA()); //1
    console.log(obj.getB()); //2
    
    console.log(obj instanceof bar); //true
    console.log(obj instanceof foo); //false