SharedStorage: clear() method

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Phương thức clear() của giao diện SharedStorage xóa bộ lưu trữ chia sẻ của nguồn gốc hiện tại, xóa toàn bộ dữ liệu.

Cú pháp

js
clear()

Tham số

Không có.

Giá trị trả về

Một Promise thực hiện với undefined.

Ngoại lệ

Note: Trong trường hợp WindowSharedStorage, nếu thao tác clear() không ghi thành công vào cơ sở dữ liệu vì lý do khác ngoài bộ lưu trữ chia sẻ không khả dụng, không có lỗi nào được ném ra, thao tác vẫn thực hiện với undefined.

Ví dụ

js
window.sharedStorage.clear().then(() => console.log("Shared storage cleared"));

Thông số kỹ thuật

Specification
Shared Storage API
# dom-sharedstorage-clear

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

Xem thêm