Created
August 31, 2012 15:58
-
-
Save egermano/3555023 to your computer and use it in GitHub Desktop.
bind to change the function scope
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
// bind to change the function scope and send arguments for the functions | |
Function.prototype.bind = function(context) { | |
var __method = this, | |
args = Array.prototype.slice.call(arguments, 1); | |
return function() { | |
var a = Array.prototype.concat(Array.prototype.slice.call(arguments), args); | |
return __method.apply(context, Array.prototype.slice.call(a)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment