1. What prints first in this promise example?
In the example below, A and B print during the current synchronous execution, and C prints afterward from the promise reaction. The output is A, B, C. A resolved promise does not make its then callback execute inline at the point where then is called.
Explain the boundary rather than memorizing a slogan about JavaScript being single-threaded. This exercise deliberately excludes timers and Node-specific scheduling APIs so the ordering being tested is clear. If an interviewer adds another scheduling mechanism, reason about that environment instead of assuming every asynchronous callback uses the same queue.
console.log('A');
Promise.resolve().then(() => console.log('C'));
console.log('B');2. Does Promise.all return completion order?
No. Its fulfillment values follow input order, even if the individual operations finish in a different order. It rejects when one input rejects, but that rejection does not automatically cancel the other operations. If partial outcomes matter, consider whether an all-settled style of result handling better fits the requirement.
Our example is loading a profile and preferences. If both are required, a combined failure may be appropriate. If preferences are optional, define a fallback explicitly instead of letting a convenient combinator decide the product behavior. Also distinguish starting operations from awaiting them: Promise.all does not itself provide a limit on in-flight requests.
3. What happens when a callback forgets to return?
A then callback that starts an operation without returning its promise breaks the intended chain. The next callback can proceed without waiting for that operation, and its failure may no longer be handled by the catch you expected. Return the nested operation when it is part of the work represented by the chain.
In the working example below, the first callback returns a transformed value, so the next receives 6. Change the first callback to a block body with no return and the next receives undefined. That tiny edit is a useful interview test because the code can look almost identical while its data flow changes completely.
Promise.resolve(3)
.then((value) => value * 2)
.then((value) => console.log(value)); // 64. Where should you catch an error?
Catch where you can make a meaningful decision: recover with a valid fallback, add useful context and propagate, or present a failure at the boundary. Returning a fallback from catch turns that part of the chain into a fulfilled path. Throwing again keeps the failure visible to downstream handling.
For an interview scenario, a profile request fails because authentication expired. Replacing the result with an empty profile may make the interface appear successful while losing the real cause. Explain whether the correct behavior is re-authentication, a visible error, or a retry. Do not describe every exception as a transient network problem.
5. Why can sequential awaits be unnecessarily slow?
If two operations are independent, starting the second only after the first completes adds waiting time. Starting both before awaiting the combined result can overlap their waits. But if the second requires the first result, sequential execution may be necessary. Identify the dependency graph before rewriting the code.
Now change the exercise from two requests to twenty thousand. Starting everything simultaneously may overload a service. A correct answer introduces bounded concurrency, cancellation where supported, and a deadline. The goal is not maximum simultaneous activity; it is useful throughput without exhausting the caller or its dependencies.
A practical promise interview exercise
Design a page that needs a required account record and optional recommendations. State what the user sees when either fails, which operations can start together, and when loading ends. Add a route change while requests are in flight. Explain how stale results are prevented from overwriting the new page's state.
Write a tiny test for success, required failure, optional failure, and out-of-order completion. During preparation, use Cluegent to challenge your assumptions, then explain the sequence unaided. The Node.js guide below extends the same reasoning to service capacity, while the React hooks guide applies it to component lifecycle and cleanup.
Sources checked
These official references support the guide. Product details and technical documentation can change; check the linked source for current information.
Where Cluegent helps
Cluegent supports permitted live workflows with transcript context, typed prompts, screenshot-aware answers, resume context, custom response behavior, quick action buttons, and a private desktop overlay. It is most useful when you already understand the subject and need help staying structured under pressure.
Frequently asked questions
Does Promise.all cancel other work after a rejection?
No. A rejected combined promise does not automatically cancel the other operations. Cancellation requires support and handling in the underlying operations.
Does Promise.all preserve input order?
Yes. Its fulfillment values correspond to input order rather than the order in which the operations completed.