JSFiddle - React, Tailwind, and code Playground
JavaScript
var obj = {
x: 2,
foo: function() {
console.log(this.x);
}
}
obj.foo();
var bar = obj.foo;
bar();
var baz = obj.foo.bind({
x: 3
});
baz();
Function.prototype.mybind = function (context) {
console.log(this);
var self = this;
return function () {
self.call(context);
}
}
var bazz = obj.foo.mybind({
x: 33
});
bazz();