Skip to content

闭包与柯里化

const xy = (x) => {
  return y => {
    return x * y
  }
}
xy(2)(2) // 4

function myCurry(func) {
  return function curried(...args) {
    return args.length >= func.length ?
      func.call(this, ...args) :
      (...rest) => {
        return curried.call(this, ...args, ...rest);
      };
  };
}

MIT License.