From HTML5 reference:
Like other JavaScript objects, you
can treat the localStorage object as
an associative array. Instead of using
the getItem() and setItem() methods,
you can simply use square brackets.
localStorage.setItem('test', 'testing 1');
localStorage.setItem('test2', 'testing 2');
localStorage.setItem('test3', 'testing 3');
for(var i in localStorage)
{
console.log(localStorage[i]);
}
//test for firefox 3.6 see if it works
//with this way of iterating it
for(var i=0, len=localStorage.length; i<len; i++) {
var key = localStorage.key(i);
var value = localStorage[key];
console.log(key + " => " + value);
}
This will output:
testing 3
testing 2
testing 1
test3 => testing 3
test2 => testing 2
test => testing 1
Here is the JSFiddle Demo