Removes all items from the storage area.
Syntax
chrome.storage.<storageType>.clear(callback);
<storageType
> will be one of the writable storage types — storage.sync
or storage.local
.
Parameters
callback Optional
- A callback function that is run when the operation completes. The callback takes no arguments. If the operation failed,
runtime.lastError
is set.
Browser compatibility
Examples
Callback-based version:
// callback to clear() just checks for errors function onCleared() { if (chrome.runtime.lastError) { console.log(chrome.runtime.lastError); } else { console.log("OK"); } } chrome.storage.local.clear(onCleared);
Promise-based version:
function onCleared() { console.log("OK"); } function onError(e) { console.log(e); } var clearStorage = browser.storage.local.clear(); clearStorage.then(onCleared, onError);
Example add-ons
Document Tags and Contributors
Tags:
Contributors to this page:
wbamberg,
chrisdavidmills
Last updated by:
wbamberg,