The DisposableStack() constructor creates DisposableStack objects.
Syntax
new DisposableStack()
[!NOTE]
DisposableStack()can only be constructed withnew. Attempting to call it withoutnewthrows a TypeError.
Parameters
None.
Return value
A new DisposableStack object.
Examples
Creating a DisposableStack
const disposer = new DisposableStack();
disposer.defer(() => console.log("Disposed!"));
disposer.dispose();
// Logs: Disposed!
Specifications
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
