Asynchronous and Event-Driven Programming Questions

The programming model of a single asynchronous runtime: callbacks, promises and futures, async/await, event loops and task/microtask scheduling (including microtask starvation and where rendering fits), reactive streams and back-pressure, and how ordering, cancellation, timeouts, retries and error propagation behave across JavaScript, Node.js, mobile coroutine or async runtimes, and a comparison with Python asyncio and Java futures. Includes the async mechanics of a data fetch such as parallel versus sequential requests, partial failure, stale or out-of-order responses, abort, debounced live search, single-flight token refresh, and bounded concurrency; wrapping callback APIs as promises, streaming work through async consumers, moving heavy work off the main thread and back, and diagnosing unhandled rejections, race conditions and leaked subscriptions. Excludes message-queue and pub/sub system design, server throughput and thread-pool tuning, per-language threading and memory models, rebuilding standard APIs from scratch, and fetch caching or state architecture.

HardTechnical
49 practiced

Write a small JavaScript class that simulates a single-threaded event loop with a call stack, a microtask queue and a macrotask queue, with methods to schedule each kind of task and to run until idle. Then use it to predict the output order of a snippet that mixes setTimeout, Promise.then and queueMicrotask, and check the prediction against a real run.

MediumTechnical
47 practiced

Write retryFetch(url, options, retries, backoffBaseMs) that retries only failures that are worth retrying, spaces attempts so many clients do not retry in lockstep, and stops a single hung attempt from blocking the rest. Explain which responses you would not retry and why.

MediumTechnical
52 practiced

Predict the console output of the snippet below, line by line, and explain what decides each position. Pay attention to the timer that is created from inside a promise callback.

js
console.log('A');
setTimeout(() => console.log('B'), 0);
Promise.resolve().then(() => console.log('C'));
Promise.resolve().then(() => { console.log('D'); setTimeout(() => console.log('E'), 0); });
console.log('F');
EasyTechnical
58 practiced

Take one asynchronous operation that can fail and show it written three ways: as nested callbacks, as a promise chain, and with async/await. For each version, explain how an error travels and where it would be lost if you were careless, and which version you would want to maintain.

EasyTechnical
50 practiced

Predict the exact console output of this snippet and explain why it is in that order.

js
console.log('start');
setTimeout(() => console.log('timeout 0'), 0);
Promise.resolve().then(() => console.log('promise1')).then(() => console.log('promise2'));
console.log('end');

Unlock Full Question Bank

Get access to all 10 Asynchronous and Event-Driven Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.