将使用多个参数的函数转换成一系列使用一个参数的函数的技术

    1. function curry(fn) {
    2. let judge = (...args) => {
    3. if (args.length === fn.length) return fn(...args)
    4. return (...arg) => judge(...args, ...arg)
    5. }
    6. return judge
    7. }
    8. function add(a, b, c) {
    9. return a + b + c
    10. }
    11. add(1, 2, 3)
    12. let addCurry = curry(add)
    13. addCurry(1)(2)(3)