Skip to solution
mediumFrontend

How does async/await work?

178 views
01

Understand the problem

Question presented to candidate: "Does an async function ALWAYS return a Promise, even if the function body never uses await at all? And if you await two things back to back, do they run one after another, or at the same time?"

What a strong answer should cover:

  • 📌 Interview term: async function — always returns a real Promise, no matter what the function body does — verified directly: an async function with literally no await in its body genuinely still returns a real Promise object, not a plain value.
  • 📌 Interview term: await — genuinely pauses the async function's execution at that exact line, resuming only once the awaited Promise settles — verified directly with a real, ordered array of pushes, confirming code AFTER calling an async function (but before awaiting its result) genuinely runs before the awaited line resumes.
  • 📌 Interview term: the real, direct answer to the prompt's sequencing question — verified directly, with a real, measured elapsed time: two sequential awaits genuinely run in series, one after another — NOT concurrently — a real two-step 30ms-each delay measured a genuine ~68ms total, not ~30ms, confirming the second await genuinely does not start until the first one has fully resolved.
  • 📌 Interview term: errors inside an async function become rejections — verified directly: a value thrown inside an async function genuinely becomes a real rejected Promise, catchable with an ordinary try/catch wrapped around the await — the same real mechanism this bank's own dedicated Promise-states question covers for a thrown error inside .then().
  • A precise answer names that await on a plain, non-Promise value genuinely just resolves immediately with that value — verified directly — and that async/await is fundamentally syntax sugar over Promises, not a genuinely different underlying mechanism.

Clarifying questions expected:

  • None — this is a definitional/technical question; directly answering both halves of the prompt (always-returns-a-Promise, and series-not-concurrent) with real proof is the strong signal.

Code / implementation expected: Yes — the real, timed proof that two sequential awaits run in series (not concurrently) is the clearest, most convincing demonstration.

async-await
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

Target Audience: Engineers preparing for JavaScript fundamentals/async interviews. Difficulty: Medium

How to read this doc: Concepts are explained in plain language first, then tagged with 📌 Interview term:. Every execution-order and timing claim below was actually run and measured in Node.

Solution ready — 2 min read

Classified // press E to declassify

04

Run the code

JSReal, timed proof: an async function with no await still returns a Promise, and two sequential awaits genuinely run in series, not concurrently
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 110 of 165 decoded in the JavaScript track. One more won't hurt.

Back to track