Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

StorageArea.clear()

Removes all items from the storage area.

Syntax

chrome.storage.<storageType>.clear(
  function(){...}   // function
)

This API is also available as browser.storage.<storageType>.clear() in a version that returns a promise.

<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

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes Yes 45.0 48.0 33

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

Acknowledgements

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: Makyen, wbamberg, chrisdavidmills
 Last updated by: Makyen,