DOM Storage.removeItem() Method
The removeItem() method deletes a key and its value from localStorage or sessionStorage. clear() deletes everything.
Description
The removeItem() method deletes a key and its value from the storage. Removing a key that doesn't exist does nothing. clear() removes every key for the origin, so use it carefully on a shared domain.
Removing a key that doesn't exist does nothing and doesn't fire a storage event. When clearing data on logout, remove the keys your application uses rather than calling clear(), in case other scripts on the same origin store data too.
Storage access can throw, for example in some private browsing modes or in sandboxed iframes, so wrap calls in try...catch where it matters. Both localStorage and sessionStorage support the method, and changes made in one tab fire a storage event in other tabs on the same origin.
Syntax
storage.removeItem(keyName)
storage.clear()Parameters
- keyNameThe key to remove.
Return Value
None (undefined).
Example
Browser Support
The following information will show you the current browser support for the Storage.removeItem() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





