bind

by Artem

JavaScript

'use strict';

Function.prototype.__bind__ = function(thisArg) {
	const self = this;
	return function() {
		self.apply(thisArg, arguments);
  }
}

function foo() {
	console.log(this.name);
}

var o = {
	name: 'Artem',
};


const bound = foo.__bind__(o);
bound();