Skip to content

Instantly share code, notes, and snippets.

@userkang
Created February 28, 2019 03:05
Show Gist options
  • Save userkang/e08b1bfc270bb4908a3cdcbde25e5fa3 to your computer and use it in GitHub Desktop.
Save userkang/e08b1bfc270bb4908a3cdcbde25e5fa3 to your computer and use it in GitHub Desktop.
函数柯理化
function curry(fn) {
var args = []
var len = fn.length
var result = function(n) {
args.push(n)
len--
if (len > 0) {
return result
} else {
fn.apply(null, args)
}
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment