Return to Snippet

Revision: 30200
at August 10, 2010 01:40 by andrew8088


Initial Code
var i,
    ls = localStorage,
    l = ls.length,
    key;

for (var i = 0; i < l; i++) {
    key = ls.key(i);
    console.log(key + ": " + ls.getItem(key));
}

Initial URL

                                

Initial Description
The `localStorage.key` method is a great way to loop over localStorage items.

Initial Title
Looping over localStorage items

Initial Tags
html5

Initial Language
JavaScript