The clear() method clears (deletes) all the items in the specified web storage.
Syntax of the clear() Method
clear()
accepts no argument. Here is the syntax:
webStorageObject
represents the storage object whose items you wish to clear—that is, localStorage
or sessionStorage
.
Examples
Below are examples of the clear()
method.
How to clear all items from session storage
Invoke sessionStorage
’s clear()
method.
Try Editing It
How to clear all items from local storage
Invoke localStorage
’s clear()
method.
Try Editing It