DisposableStack() constructor

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Constructor DisposableStack() tạo các đối tượng DisposableStack.

Cú pháp

js
new DisposableStack()

Note: DisposableStack() chỉ có thể được khởi tạo với new. Cố gắng gọi nó mà không có new sẽ ném ra một TypeError.

Tham số

Không có.

Giá trị trả về

Một đối tượng DisposableStack mới.

Ví dụ

Tạo một DisposableStack

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

Đặc tả

Specification
ECMAScript Async Explicit Resource Management
# sec-disposablestack-constructor

Tương thích trình duyệt

Xem thêm