e01.org

AsyncDisposableStack() constructor

The AsyncDisposableStack() constructor creates AsyncDisposableStack objects.

The **`AsyncDisposableStack()`** constructor creates AsyncDisposableStack objects.

## Syntax

```js-nolint
new AsyncDisposableStack()
```

> [!NOTE]
> `AsyncDisposableStack()` can only be constructed with [`new`](/docs/Web/JavaScript/Reference/Operators/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

## Browser compatibility

## See also

- [Polyfill of `AsyncDisposableStack` in `core-js`](https://core-js.io/docs/features/ecmascript/explicit-resource-management)
- [JavaScript resource management](/docs/Web/JavaScript/Guide/Resource_management)

source: MDN Web Docs mirror · page

Cite this

"AsyncDisposableStack() constructor". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncDisposableStack/AsyncDisposableStack

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·