AsyncDisposableStack() constructor

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The AsyncDisposableStack() constructor creates AsyncDisposableStack objects.

Syntax

js
new AsyncDisposableStack()

Note: AsyncDisposableStack() can only be constructed with new. Attempting to call it without new throws a TypeError.

Parameters

None.

Return value

A new AsyncDisposableStack object.

Examples

Creating an AsyncDisposableStack

js
const disposer = new AsyncDisposableStack();
disposer.defer(() => console.log("Disposed!"));
await disposer.disposeAsync();
// Logs: Disposed!

Specifications

Specification
ECMAScript Async Explicit Resource Management
# sec-properties-of-the-asyncdisposablestack-constructor

Browser compatibility

See also