What is currying in JavaScript?
Answer
Currying transforms a function with multiple arguments into a sequence of functions, each taking one argument. Instead of add(1, 2, 3), a curried version: add(1)(2)(3). Implementation: const curry = fn => function curried(...args) { if (args.length >= fn.length) return fn(...args); return (...more) => curried(...args, ...more); };. Benefits: partial application — pre-fill some arguments to create specialized functions: const add5 = curriedAdd(5); add5(3) // 8. Function composition — combine curried functions in pipelines. Point-free programming — compose operations without mentioning data. Example: const multiply = a => b => a * b; const double = multiply(2); const triple = multiply(3); [1,2,3].map(double) // [2,4,6]. Currying enables functional programming patterns and creates highly reusable, composable functions. Lodash's _.curry() supports mixed calling styles.