Last active
August 29, 2015 14:09
-
-
Save cawel/8b564a9ab298486e3e96 to your computer and use it in GitHub Desktop.
blog-the-good-parts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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