JavaScript bank Async & Concurrency JavaScript / 38 questions Your progress 0 / 38 done Saved in this browser. Reset All 38 Easy 7 Medium 16 Hard 15 Hide done No questions match those filters. 01 Explain the JavaScript event loop, call stack, task queue, and microtask queue end to end. Medium 02 Why do Promises (microtasks) always run before `setTimeout` callbacks (macrotasks), even with a 0ms delay? Medium 03 Trace the exact console.log output order for a mix of synchronous code, `Promise.then`, and `setTimeout`. Hard 04 Explain how `requestAnimationFrame` and `requestIdleCallback` fit into the browser's rendering pipeline relative to the event loop. Hard 05 What is 'starvation' of the macrotask queue caused by recursive microtasks? How can it happen? Hard 06 Explain how Node.js's event loop phases (timers, poll, check, close callbacks) differ from the browser's model. Hard 07 How does the browser decide when to repaint relative to microtask queue draining? Hard 08 Explain the evolution of async patterns in JS: callbacks -> Promises -> async/await. Easy 09 What is 'callback hell' and how do Promises solve it structurally? Easy 10 Explain concurrency vs parallelism in the context of JavaScript's single-threaded model. Medium 11 How would you run multiple independent async operations concurrently but limit concurrency to N at a time? Hard 12 Explain how Web Workers enable true parallelism despite JS being single-threaded. Hard 13 What are async iterators and async generators? Give a practical use case (e.g., paginated API consumption). Hard 14 Explain the three states of a Promise and how state transitions are one-way. Easy 15 Implement a Promise class from scratch (Promises/A+ subset) supporting `.then` chaining. Hard 16 Implement `Promise.all` from scratch, handling rejection short-circuiting. Hard 17 Implement `Promise.race`, `Promise.any`, and `Promise.allSettled` from scratch. Hard 18 Explain the difference between `Promise.all`, `Promise.allSettled`, `Promise.race`, and `Promise.any` with use cases for each. Medium 19 What is promise chaining and how does returning a value vs a Promise from `.then` affect the chain? Medium 20 Explain unhandled promise rejections — how do you catch them globally in browsers and Node.js? Medium 21 Implement a `retry(fn, retries, delay)` utility that retries a Promise-returning function on failure. Medium 22 Explain microtask ordering when multiple `.then()` handlers are chained versus attached separately to the same promise. Hard 23 Explain how `async`/`await` desugars to Promises and generators under the hood. Medium 24 How do you handle errors in `async`/`await` code — `try/catch` vs `.catch()`? Show both. Easy 25 Why does using `await` inside a `for` loop run operations sequentially, and how would you parallelize them? Medium 26 Explain what happens if you forget to `await` an async function call — what bugs can result? Medium 27 Implement a function that processes an array of URLs with `fetch`, limiting concurrency to 3 in-flight requests. Hard 28 Explain top-level `await` in ES modules — what constraints does it introduce for module loading? Hard 29 What is a callback function? Distinguish synchronous callbacks (e.g., `Array.map`) from asynchronous ones (e.g., `setTimeout`). Easy 30 Explain 'callback hell' with a nested example and refactor it using Promises. Easy 31 What is the error-first callback convention used in Node.js? Why was it adopted? Medium 32 Implement a simple `EventEmitter` class supporting `on`, `off`, and `emit`. Medium 33 Explain how converting a callback-based API to a Promise-based one ('promisify') works. Medium 34 Explain the difference between `setTimeout` and `setInterval`, including drift issues with `setInterval`. Easy 35 Why is a `setTimeout` with 0ms delay not truly immediate? Explain minimum clamped delays. Medium 36 Implement a recursive `setTimeout` pattern to replace `setInterval` and explain why it's more reliable. Medium 37 Implement `debounce` and `throttle` and explain the precise behavioral difference with a UI example (search box vs scroll handler). Medium 38 How would you implement a countdown timer that stays accurate despite tab throttling in background tabs? Hard ← Previous Engine Internals Next → Networking