Currying is a functional programming technique where a function that takes multiple arguments is transformed into a sequence of functions, each taking a single argument.
Currying in JavaScript transforms a function with multiple arguments into a nested series of functions, each taking a single argument.
The parent function takes the first provided argument and returns the function that takes the next argument and this keeps on repeating till the number of arguments ends. The function that receives the last argument returns the expected result.
We have a simple function add(a, b) that returns a + b. How would you rewrite it using currying so that you can call add(2)(3)?
If you have a curried function multiply(a)(b) and you call multiply(5) without the second argument, what does it return and why?
Our team is building a form validation library where each validator is a curried function that takes a config object first, then the value to validate. A bug appears where the config is shared across calls. What could be causing this and how would you fix it?
You need to compose three curried functions to process user input in a pipeline. How would you wire them together, and what trade‑offs does currying introduce compared to passing all arguments at once?
We're refactoring a large codebase to use a functional utility library that heavily relies on curried functions for API calls. What performance or memory considerations should we keep in mind, and how would you mitigate potential issues?
Design a generic curried fetch wrapper that allows partial application of URL, options, and then a callback. How would you ensure type safety and avoid leaking state across requests in a high‑traffic service?
Our organization wants to standardize a curried API across multiple microservices to improve composability. What architectural guidelines would you set, and how would you handle backward compatibility with existing non‑curried callers?
Consider a legacy monolithic JavaScript app where many functions are not curried. Propose a migration strategy to introduce currying without breaking downstream teams, including testing and rollout plans.