Created
July 12, 2013 08:27
-
-
Save CatTail/5982799 to your computer and use it in GitHub Desktop.
Bind function to this OR bind this to function ?!
This file contains hidden or 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.prototype.curry = function () { | |
var fn = this; | |
var args = [].slice.call(arguments, 0); | |
return function () { | |
return fn.apply(this, args.concat([].slice.call(arguments, 0))); | |
}; | |
}; | |
var bind = function (func, thisArg) { | |
return function () { | |
return func.apply(thisArg, arguments); | |
}; | |
}; | |
var bind2 = function (func, thisArg) { | |
var applied = func.apply.curry(thisArg); | |
return function () { | |
applied.apply(func, arguments); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
equals to