Skip to main content
JavaScript Interview Questions Predict Output P0 Hard

Recovery followed by a failing finally

Predict what reaches the last catch. What does returning from the first catch do?

Official Reference

Code Snippet

Promise.reject("initial")
  .catch(reason => { console.log(reason); return "recovered"; })
  .finally(() => { console.log("cleanup"); throw new Error("late"); })
  .then(value => console.log(value))
  .catch(error => console.log(error.message));

Expected Output & Explanation

initial
cleanup
late

The first catch recovers with a fulfillment. The finally callback then throws, replacing that outcome with a rejection. The intervening fulfillment handler is skipped.

Module Context & References

JavaScript · Async output drills Trace microtasks, promise identity, thenables and error recovery
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.