Posted By

andrew8088 on 08/10/10


Tagged

html5 localstorage


Versions (?)

Looping over localStorage items


 / Published in: JavaScript
 

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

  1. var i,
  2. ls = localStorage,
  3. l = ls.length,
  4. key;
  5.  
  6. for (var i = 0; i < l; i++) {
  7. key = ls.key(i);
  8. console.log(key + ": " + ls.getItem(key));
  9. }

Report this snippet  

You need to login to post a comment.