The accumulated arguments. Each call adds to the accumulated arguments, which are kept alive by the closure. When enough arguments are collected (args.length >= fn.length), the original function is called with all of them.
What is the state in a curried function?
More FAQs in How Currying Relies on Closures in JavaScript
Each curried function returns a new function that closes over the previous arguments. The inner function has access to all outer arguments via the closure. Without closures, currying would not work.
Closures provide the accumulated arguments (state) across calls. Each returned function remembers the previous arguments via the closure. Without closures, the inner function would not have access to outer arguments.
The returned arrow function (...next) => curried(...args, ...next) closes over args and fn. Each partial call accumulates arguments via the closure. When enough are collected, fn is called.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.