JSFiddle - React, Tailwind, and code Playground

JavaScript

function bind1(func, obj) {

        var self = func, context = obj;

        return function() {
                var args = [], i;
                for(i = 0; i< arguments.length; i++) args.push(arguments[i]);

                return self.apply(context, args);
        }
    }

window.x = 1;
var ctx = {x:2};

function testThis(a) { console.log("x=" + this.x + ", a=" + a); }
console.log(testThis(100)); // x=1, a=100
var boundFunction = bind1(testThis, ctx);
console.log(boundFunction(100)); // x=2, a= 100