Technical Mid Level

Compare callbacks, Promises, and async/await. When would you use Promise.all versus Promise.allSettled versus Promise.race?

Quick Tip

Match the method to the requirement: "Promise.all for parallel fetches that all must succeed. Promise.allSettled when I need partial results. Promise.race for implementing timeouts around slow operations."

What good answers include

Callbacks: oldest pattern, leads to nesting (callback hell). Promises: chainable, better error handling with catch. Async/await: syntactic sugar over Promises, reads like synchronous code. Promise.all: resolves when all settle successfully, rejects on first failure — use for independent tasks where all must succeed. Promise.allSettled: resolves when all settle regardless of success/failure — use when you want all results even if some fail. Promise.race: resolves/rejects with the first to settle — use for timeouts or fastest-response-wins patterns.

What interviewers are looking for

Tests async JavaScript fluency. Candidates who default to sequential awaits when operations are independent miss easy parallelism. Those who cannot explain Promise.allSettled may not handle partial failures well.

← All JavaScript questions