DisposableStack() constructor
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The DisposableStack()
constructor creates DisposableStack
objects.
Syntax
js
new DisposableStack()
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
Specification |
---|
ECMAScript Async Explicit Resource Management> # sec-disposablestack-constructor> |
Browser compatibility
Loading…