In this #shorts video, we look at currying. Currying is an advanced programming technique that can help improve your code quality and readability.
Currying is the transformation of a function that takes multiple arguments into a series of functions that each takes one argument.
The first call of a curried function will return a function that takes the second call and so on until the last function has been called and the final value will be returned.
Curries functions are useful when you don’t want to supply all the arguments to a function at once.
Let’s take a look at a practical example of a curried function.
This Express API has a route with some middleware that takes a validation schema. The schema is run over the request object to make sure the body, query, and params of the request are exactly what we expect. The middleware can be used with any validation schema.
The middleware is a curried function that takes the validation schema as the first argument, then the Express request, response, and next function as the second argument.
🌎 Follow me here:
Discord: https://discord.gg/4ae2Esm6P7
Twitter: https://twitter.com/tomdoes_tech
Facebook: https://www.facebook.com/tomdoestech
Instagram: https://www.instagram.com/tomdoestech
TikTok: https://www.tiktok.com/@tomdoes_tech
☕ Buy me a coffee: https://www.buymeacoffee.com/tomn


Comments