06 / 09

Implement Currying using ES6 Arrow Functions

javascript
Difficulty: 5/10
Topics: currying, arrow functions, functional programming

Scenario Questions

0-2 years experience
  1. 1

    How would you write a curried add function using ES6 arrow syntax so it can be called like add(2)(3)?

  2. 2

    If you invoke your curried function with the first argument and later with the second, what value is returned each time?

2-5 years experience
  1. 1

    We have a utility fetchData(url, options) and want to support partial application. How would you refactor it to be curried, and what trade‑offs might that introduce?

  2. 2

    During a code review you see a curried function returning undefined when called as fn(a, b). How would you debug the issue and correct the implementation?

5-8 years experience
  1. 1

    Our front‑end team wants a curried API for configuring UI components, but most of the codebase uses regular functions. How would you design a wrapper that supports both styles without hurting performance?

  2. 2

    When using curried functions to pre‑configure server‑side rendering options, what are the memory and call‑stack implications, and how would you mitigate any problems?

8+ years experience
  1. 1

    A legacy monolith is being split into micro‑frontends. How would you decide whether to keep existing curried helpers or replace them with plain functions, and how would you plan the migration to avoid breaking contracts across teams?

  2. 2

    Your organization is standardizing a shared functional utilities library. What guidelines would you set for exposing functions as curried versus non‑curried, considering readability, tree‑shaking, and TypeScript typings?

Follow-up Questions

  • Can you walk me through the execution flow step by step?
  • What edge cases or error conditions would you guard against?
  • How does this approach affect testing and debugging?