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

Creating an DisposableStack

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

Specifications

No specification found

No specification data found for javascript.builtins.DisposableStack.DisposableStack.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

See also