Making Web apps with HTML5 and LocalStorage – Part 1
Posted on September 8, 2010
localStorage sets fields on the domain. Even when you close the browser, reopen it, and go back to the site, it remembers all fields in localStorage.
HTML5 Local Storage is based on named key/value pairs. You store data based on a named key, then you can retrieve that data with the same key. The named key is a string. The data can be any type supported by JavaScript, including strings, Booleans, integers, or floats.
var foo = localStorage.getItem("bar");
// ...
localStorage.setItem("bar", foo);
…could be rewritten to use square bracket syntax instead:
var foo = localStorage["bar"]; // ... localStorage["bar"] = foo;
Tags: html5, localStorage, localStorage.getItem, localStorage.setItem, Storage, Webapps

