高程二十二章中有介绍
function curry (fn) {
console.log(arguments)
var args = Array.prototype.slice.call(arguments, 1)
console.log(args)
return function() {
var innerArgs = Array.prototype.slice.call(arguments)
console.info(innerArgs)
var finalArgs = args.concat(innerArgs)
console.info(finalArgs)
return fn.apply(null, finalArgs)
}
}
先提供柯理化函数模板便于记录,待用熟用明白再来分享。
网友评论