Storage clear() Method
Description
The clear() method removes all the Storage Object item for this domain.
The clear() method belongs to the Storage Object, which can be either a localStorage object or a sessionStorrage object.
Browser Support
Method | |||||
---|---|---|---|---|---|
clear() | 4 | 8 | 3.5 | 4 | 10.5 |
Syntax
localStorage.clear()
Or:
sessionStorage.clear()
Parameter Values
No parameters.
Technical Details
DOM Version: | Web Storage API |
---|---|
Return Value: | No return value |
More Examples
Example
The same example, but using session storage instead of local storage.
Remove all session items:
sessionStorage.clear();
Try it Yourself »
Related Pages
Web Storage Reference: removeItem() Method