JavaScript interview challenges
The "implement it yourself" questions that come up in frontend and JavaScript interviews: debounce, throttle, Promise.all, a concurrency-limited map, deep clone, curry, an event emitter and more. Write your version in the browser and run real async tests against it, with timers and promises, then compare with an explained solution.
0 of 11 solved
1. Implement debounce
Delay a function until calls stop coming in for wait ms, then call it once with the latest arguments.
2. Implement throttle
Run a function at most once every wait ms, no matter how often it's called.
3. Implement Promise.all
Wait for every promise, keep the results in input order, and reject as soon as one fails.
4. Implement Promise.allSettled
Wait for every promise and report each one's status, without ever rejecting.
5. Run async tasks with a concurrency limit
Map over items with an async function, but never run more than limit at the same time.
6. Implement deepClone
Copy nested objects and arrays so that changing the copy never touches the original, including circular references.
7. Implement Array.prototype.flat
Flatten nested arrays up to a given depth.
8. Implement curry
Turn f(a, b, c) into a function you can call as f(a)(b)(c), f(a, b)(c) or f(a)(b, c).
9. Implement an EventEmitter
Build on, off, once and emit, the pattern behind Node's events and most UI libraries.
10. Implement memoize
Cache a function's results so repeated calls with the same arguments don't recompute.
11. Implement deepEqual
Compare two values by structure: same keys, same values, all the way down.