Skip to main content

Command Palette

Search for a command to run...

Currying in JavaScript

Published
1 min read
Currying in JavaScript
D

Full Stack Developer. I have hands on experience in crafting web applications using TypeScript, Next , React ,TailwindCSS. I have also worked with PostgresDB and AWS S3. I have also developed dAPP based upon ERC 20 , ERC 721 tokens.

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.

carbon.png

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.