What is currying, and how is it used?

Currying is the transformation of a function with multiple arguments into a sequence of functions, each with a single argument. It enables partial application of functions, where some arguments are preset, allowing the function to be reused with different arguments in a more flexible way.

const multiply = (a) => (b) => (c) => a * b * c;
const multiplyBy2 = multiply(2);
console.log(multiplyBy2(3)(4)); // 24