JSFiddle - React, Tailwind, and code Playground

HTML

<div id="result"></div>

JavaScript

function log(str) {
            var div = document.createElement("div");
            div.innerHTML = str;
            document.getElementById("result").appendChild(div);
        }

        function extend(parent, fn, baseCtorParams) {
            var Constructor = function () {
                if (typeof baseCtorParams === "function") {
                    parent.apply(this, baseCtorParams.apply(this, arguments));
                }
                else {
                    parent.apply(this);
                }
                fn.apply(this, arguments);
            }
            Constructor.prototype = parent.prototype;
            Constructor.prototype.constructor = fn;
            return Constructor;
        }

        function foo() {
            var a = 1;
            this.getA = function () { return a; };
        }

        var child = extend(foo, function (p) {
            log("child: " + p);
            var b = 2;
            this.getB = function () { return b; };
        });

        var bar = extend(child, function (p1, p2) {
            log("bar: " + p1 + " " + p2);
            var c = 3;
            this.getC = function () { return c; };
        }, function (p1, p2) { return [p2]; });

        var obj = new bar("p1", "p2");
        log(obj.getA()); //1
        log(obj.getB()); //2
        log(obj.getC()); //3

        log(obj instanceof bar); //true
        log(obj instanceof child); //true    
        log(obj instanceof foo); //true

        log(obj.constructor.name); //How to retrieve "bar"?