On this page
  1. Promise.withResolvers
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Promise.withResolvers

Prev: any | Up: Promise | Next: resolve
Rel: Promise, Promise & Async Guide
Ref: MDN Web Docs — Promise.withResolvers
Tags: #public #web #javascript #builtins #promise #tier/standard


Signature & Overview

Promise.withResolvers()

Returns { promise, resolve, reject } directly without wrapping logic inside new Promise(...) (ES2024).

Notes & Pitfalls

Example

const { promise, resolve } = Promise.withResolvers();
queueMicrotask(() => resolve("ready"));
console.assert((await promise) === "ready");

Linked from

Related notes