function compose(...fn) {return (...args) => fn.reverse().slice(1).reduce((acc, cur) => cur(acc), fn[0](...args))}const add10 = (x) => x + 10;const mul10 = (x) => x * 10;const add100 = (x) => x + 100;// (10 + 100) * 10 + 10 = 1110// 从后往前操作console.log(compose(add10, mul10, add100)(10));
