Storage clear() method
- Previous Page removeItem()
- Next Page key()
- Go Back to the Previous Level Storage Object
Definition and usage
The clear() method deletes all items of the Storage objects in this domain.
The clear() method belongs to the Storage object, it can be localStorage object, which can also be sessionStorage object.
Browser support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
clear() | 4 | 8 | 3.5 | 4 | 10.5 |
Syntax
localStorage.clear()
Or:
sessionStorage.clear()
Parameter value
No parameters
Technical details
DOM version: | Web Storage API |
---|---|
Return value: | No return value |
More examples
Instance
The same example, but using session storage instead of local storage.
Delete all session items:
sessionStorage.clear();
Related Pages
Web Storage Reference Manual:removeItem() Method
- Previous Page removeItem()
- Next Page key()
- Go Back to the Previous Level Storage Object