fbpx

Explain the concept of currying in JavaScript and how it can be beneficial in functional programming.

Currying is a technique where a function with multiple arguments is transformed into a series of functions, each taking a single argument. This supports partial application and enhances reusability of functions. For example:

function curry(a) {
    return function(b) {
        return a + b;
    };
}

const add5 = curry(5);
console.log(add5(3)); // Output: 8

 

# Dream job to realty