-
-
Save yardfarmer/80402da078bb831da62bab497eb7d009 to your computer and use it in GitHub Desktop.
函数 kerry 化 // source https://jsbin.com/pinade
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 splat(fn) { | |
return function(array) { | |
// 充分利用了 apply 拆分数组的特性 | |
return fn.apply(null, array); | |
}; | |
} | |
// 传入一个函数,返回另外一个函数 | |
var func = splat(function(x, y) { | |
return x + y; | |
}); | |
func([1, 2]); | |
console.log(func([1, 5])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment