JavaScriptInterview preparation
Intermediate·Concept·2 min read

How does async JavaScript run?

Practice this question

Definition:

Asynchronous JavaScript lets a program start work that may finish later without waiting synchronously for the result. A promise represents eventual completion, and async/await provides a readable way to work with promises. The runtime queues continuations and runs them when the current synchronous work has finished and the relevant checkpoints are reached.

Key points:

  • Synchronous code runs first; queued promise callbacks run after the current code finishes.

  • await pauses that async function, not the whole JavaScript thread.

  • Making a CPU-heavy function async does not stop it from blocking.

  • An async function always returns a promise, including when it returns a plain value.

  • Use try/catch around an awaited operation to handle a rejection; synchronous try/catch cannot catch an unrelated later callback error.

  • The executor passed to new Promise(...) runs immediately; .then(...) callbacks run asynchronously.

Comparison:

PointPromise with .thenasync / await
What it providesA future result and callbacksSyntax for consuming promises
Error handling.catch(...)try/catch around await
Creates a new threadNoNo
Best readabilityShort chainsMulti-step flows

Example:

JavaScript
async function getTotal() {
  const price = await Promise.resolve(100);
  return price + 20;
}
getTotal().then(console.log); // 120

Interview point:

  • Promises coordinate results; they do not create a new JavaScript thread or automatically make heavy work non-blocking.
Adapted from 01_JAVASCRIPT_TYPESCRIPT.md · “How does async JavaScript run?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.