最常用地方:react-redux的connect函数
// 支持多参数传递
var processCurry = function (fn, args) {
var self = this
var len = fn.length
var args = args || []
return function () {
var _args = Array.prototype.slice.call(arguments)
var arg = args.concat(_args);
if (arg.length < len) {
return processCurry.call(self, fn, arg)
}
return fn.apply(self, arg)
}
}
var add = function (a, b, c, d) {
console.log(a + b + c + d);
return a + b + c + d
}
var addCurry = processCurry(add)
addCurry(1)(2, 3)(4)