Currying in JavaScript

Currying in JavaScript

Assume the captain of a team passing the baton to it's junior. The junior after doing it's part passes onto the baton to their respective junior. This process continues till the mission is accomplished.

Screen Shot 2022-03-26 at 6.42.26 PM.png

The function A takes into the starting argument and returns the function B which takes onto the next argument and this process continues till the argument is exhausted is known as currying.


From the above code snippets, we can see that function area has an argument length which returns a function with argument breadth . In the next line, it returns area signifying the end of argument.

The console.log of area with length = 5 units & breadth = 10 units gives 50 sq.units as area. Screen Shot 2022-03-26 at 6.17.05 PM.png

Thanks for reading.