Reputation: 18149
I was reading http://www.w3schools.com/html5/html5_webstorage.asp and, well, pretty cool. However, they didn't explain how could the user "delete" the localStorage. Like with cookies. How can I delete localStorage?
Upvotes: 0
Views: 595
Reputation: 651
You can "clear()" the local-storage
localstorage.clear()
Here are some more details:
The clear() method must atomically cause the list associated with the object to be emptied of all key/value pairs, if there are any. If there are none, then the method must do nothing.
When the setItem(), removeItem(), and clear() methods are invoked, events are fired on other Document objects that can access the newly stored or removed data, as defined in the sections on the sessionStorage and localStorage attributes.
This specification does not require that the above methods wait until the data has been physically written to disk. Only consistency in what different scripts accessing the same underlying list of key/value pairs see is required.
Upvotes: 2