JSFiddle - React, Tailwind, and code Playground

JavaScript

Function.prototype.ourBind = function (thisArg) {
    var that = this;

    return function () {
        return that.apply(thisArg, arguments);
    };
};

var obj = {
    val: 4
};

function foo() {
    alert(this.val);
}

var bar = foo.ourBind(obj);

foo(); // behaves as expected; alerts `undefined` as `foo` is not attached to an object
bar(); // breaks the rules! alerts `4` because `bind()` sets `this` to `obj`.

bar.call(window); // this has no effect; still alerts `4`.