Facebook Pixel

What is the state in a curried function?

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.

Verify This Answer

Cross-check this information using these trusted sources:

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?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.