DisposableStack() constructor

The DisposableStack() constructor creates DisposableStack objects.

Syntax

js
new DisposableStack()

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

Parameters

None.

Return value

A new DisposableStack object.

Examples

undefined

Creating a DisposableStack

js
const disposer = new DisposableStack();
disposer.defer(() => console.log("Disposed!"));
disposer.dispose();
// Logs: Disposed!

Specifications

See also