async function doSomething() {
await using disposer = new AsyncDisposableStack();
const resource = disposer.use(new Resource());
resource.doSomething();
// disposer is disposed here immediately before the function exits
// which causes the resource to be disposed
}AsyncDisposableStack.prototype[Symbol.asyncDispose]()
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.