bind

by Artem

JavaScript

'use strict';

Function.prototype.__bind__ = function(ctx) {
	const that = this;
	return function() {
			ctx.__tmp__ = that;
  		ctx.__tmp__();
      delete ctx.__tmp__;
  }
};

var o = {
	name: 'Artem'
};


function foo() {
	console.log('Hello, my name is ', this.name);
}

foo.__bind__(o)();