CKTIS / JavaScript
await operator — waiting for a result
An await expression suspends the current execution of an async function or module until the awaited value settles. It produces a promise’s fulfillment value or throws its rejection reason without blocking the entire thread.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
await expressionawait expression evaluates its operand and waits for its result through the promise mechanism. Promise fulfillment supplies the value of the await expression; rejection throws its reason at that point. You can handle it with try...catch. Ordinary values and thenables—objects with a callable then method—are also accepted.
await suspends the current execution of an async function or module, not the entire thread. Even an ordinary value or an already fulfilled promise causes asynchronous resumption. This is why outside appears before 42 in the example. await itself does not move computation to another thread.
Use it inside an async function body (including an async generator) or at module top level. An ordinary script or an ordinary function nested inside an async function does not gain that permission. await requires an operand and cannot occur in async function parameter initializers. Its use as an identifier is restricted by context; avoid that name.
Consecutive await statements can unnecessarily serialize independent operations. To wait for several independent operations together, start them first and then use await Promise.all(...). Support for await syntax does not establish the availability of any Web API in the environment.
Examples
async function main() {
console.log("start");
const value = await Promise.resolve(42);
console.log(value);
}
main().catch(console.error);
console.log("outside");Result
start outside 42
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.