Discussing HTML5 localstorage object

Localstorage object is only available in HTML5. Main benefit of this object is that object persist the values whether you closed the browser.

Also we can say this is a cookie with no expiration date with more extra benefits and features. Here are simple syntax of localstorage (we are not covering sessionstorage).

localStorage.setItem("Author", "Gaurav Kumar Arora");

In above our storage key is ‘Author’ and subsequent value is ‘Gaurav Kumar Arora’

localStorage.Author= "Gaurav Kumar Arora";

There is one another way (as a C# coder, I like it ), we can add value of a key. Here we are adding ‘Author’ key’s value as ‘Gaurav Kumar Arora’.

localStorage.removeItem("Author");

Sometime we need to operations like removal of a specific key. Here, we are removing ‘Author’ key from our localstorage.

This is a very simple description of usage of localstorage. I am going to publish a full article on HTML5 (which will cover all the things) .

Leave A Reply