javascript curry funtion code example
Example 1: currying in javascript
//No currying
function volume(w, h, l) {
return w * h * l;
}
volume(4, 6, 3); // 72
//Currying
function volume(w) {
return function(h) {
return function(l) {
return w * h* l;
}
}
}
volume(4)(6)(3); // 72
Example 2: currying javascript
// It is also called nested function is ecmascript
const multiply = (a) => (b) => a*b;
multiply(3)(4); //Answer is 12
const multipleBy5 = multiply(5);
multipleBy5(10); //Answer is 50