const addFn = (...args) => args.reduce((total, cur) => total + cur, 0) const curry = (fn) => { let params = [] return function f(...rest) { if (rest.length) { params = params.concat(rest) return f } return fn(...params) } } const add = curry(addFn) const value = add(1, 2)(3)(4)() console.log(value) // 10
标签:...,const,MST,rest,params,return,curry From: https://www.cnblogs.com/zhenjianyu/p/17119269.html