Standard built-ins

Promise.withResolvers()

Try the free JavaScript compiler

Creates a promise capability and exposes its promise, resolve and reject functions in an object. Useful for event-driven completion; availability is runtime-dependent.

Formal Syntax & Structure

javascript syntaxjavascript
Promise.withResolvers()

Return Value

object

Contains promise, resolve and reject.

Working Example

Example Snippetjavascript
const {promise, resolve} = Promise.withResolvers();promise.then(console.log);resolve(12);
JavaScript Reference