Loading

reduce使用

      // const add = (x) => x + 5;
      // const multiplication = (x) => x * 5;
      // const subtraction = (x) => x - 5;
      // const division = (x) => x / 5;
      // const handleFn = (...fns) => {
      //   return fns.reduce((prev, cur) => {
      //     return (...args) => {
      //       const res = prev(...args);
      //       return cur(res);
      //     };
      //   });
      // };
      // const targetFn = handleFn(add, multiplication, subtraction, division);
      // console.log(targetFn(5));
posted @ 2022-05-22 14:12  资深if-else侠  阅读(20)  评论(0编辑  收藏  举报