1Uses of currying function
2 a) It helps to avoid passing same variable again and again.
3
4 b) It is extremely useful in event handling.
5
6syntax:
7
8 function Myfunction(a) {
9 return (b) => {
10 return (c) => {
11 return a * b * c
12 }
13 }
14 }
15
16
17myFunction(1)(2)(3);
1a technique that applies a function
2to its arguments one at a time, with
3each application returning a new function
4that accepts the next argument.
1// It is also called nested function is ecmascript
2const multiply = (a) => (b) => a*b;
3multiply(3)(4); //Answer is 12
4
5const multipleBy5 = multiply(5);
6multipleBy5(10); //Answer is 50
1Uses of currying function
2 a) It helps to avoid passing same variable again and again.
3
4 b) It is extremely useful in event handling.
5
6syntax:
7
8 function Myfunction(a) {
9 return (b) => {
10 return (c) => {
11 return a * b * c
12 }
13 }
14 }