Use Array.reduce() to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.
constadd=(x, y)=> x + y;
+constsquare= x => x * x;
+const addAndSquare =composeRight(add, square);
+addAndSquare(1,2);// 9
curry
Curries a function.
Use recursion. If the number of provided arguments (args) is sufficient, call the passed function fn. Otherwise, return a curried function fn that expects the rest of the arguments. If you want to curry a function that accepts a variable number of arguments (a variadic function, e.g. Math.min()), you can optionally pass the number of arguments to the second parameter arity.