This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

clear

Summary

Causes the list associated with the object to be emptied of all key/value pairs, if there are any.

Method of apis/web-storage/Storageapis/web-storage/Storage

Syntax

 object.clear();

Return Value

No return value

Examples

The following button clears the local storage area for the current domain.

<button onclick="localStorage.clear()">
    Clear Stored Values</button>

Notes

sessionStorage is cleared immediately. localStorage key/value pairs are removed from memory, and disk storage quota is updated.

Related specifications

W3C Web Storage Specification
W3C Editor’s Draft

Attributions