JSFiddle - React, Tailwind, and code Playground

by Horia-Adrian Ionescu

JavaScript

if(! Function.prototype.bind2){
	Function.prototype.bind2 = function(o){
  	var fn = this;
    return function(){
    	return fn.apply(o,arguments);
    }
  }
}
function foo(a){
	console.log(this.bar + "&" + a);
}
var obj = { bar: "bar of obj"};
foo = foo.bind2(obj);
foo("buz");