JavaScript Interview Question #115
What is function currying?
Closures, Prototypes, Classes & Advanced Functions Mid-Level Intermediate
Quick Interview Answer
Currying transforms a function that accepts multiple arguments into a sequence of functions that each accept one argument. It is a functional-programming technique for creating reusable, partially configured operations.
Detailed Explanation
Currying transforms a function that accepts multiple arguments into a sequence of functions that each accept one argument. It is a functional-programming technique for creating reusable, partially configured operations.
Currying is not automatically better than ordinary parameters. It is most useful when repeated specialization improves composition or readability.
Code Example
const multiply = a => b => a * b;
const double = multiply(2);
const triple = multiply(3);
console.log(double(10)); // 20
console.log(triple(10)); // 30