Created
February 28, 2019 03:05
-
-
Save userkang/e08b1bfc270bb4908a3cdcbde25e5fa3 to your computer and use it in GitHub Desktop.
函数柯理化
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 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