Created
August 2, 2016 06:14
-
-
Save yuyang041060120/9f75ed8bbe12ac9d55f6c391692e7925 to your computer and use it in GitHub Desktop.
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 curry(fn) { | |
var len = fn.length; | |
var ctx = this; | |
return innerExec([]); | |
function innerExec(args) { | |
return function () { | |
var newArgs = args.concat(Array.prototype.slice.apply(arguments)); | |
if (len === newArgs.length) { | |
return fn.apply(ctx, newArgs); | |
} else { | |
return innerExec(newArgs); | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment