Skip to content

Instantly share code, notes, and snippets.

@cawel
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cawel/8b564a9ab298486e3e96 to your computer and use it in GitHub Desktop.
Save cawel/8b564a9ab298486e3e96 to your computer and use it in GitHub Desktop.
blog-the-good-parts
Function.method('bind', function(that) {
var method = this,
slice = Array.prototype.slice,
args = slice.apply(arguments, [1]);
return function() {
return method.apply(that, args.concat( slice.apply(arguments, [0])) );
};
});
var x = function() {
return this.value;
}.bind({value: 666});
alert( x() ); // 666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment