Web Storage: removeItem()
The removeItem() method deletes the value stored under one key.
localStorage.removeItem('draft');Removing a key that does not exist is safe. Use this method when a preference or temporary value should no longer be kept.
Common mistakes
- Remove the value from the same storage object where it was saved.
- Do not assume removal from one tab removes another tab's session state.
- Update the page UI after deleting a value if the UI displays it.