Get array of all variables in browser localStorage

  • 2 Replies
  • 1575 Views
*

Karen

  • *
  • 17
Get array of all variables in browser localStorage
« on: May 08, 2016, 19:00:30 pm »
I want to retrieve all localStorage variables into an array in javascript

Is there a method for this ?

*

Ruhit

  • *
  • 22
Re: Get array of all variables in browser localStorage
« Reply #1 on: May 19, 2016, 16:32:31 pm »
Code
var ls = [];

for (var i = 0; i < localStorage.length; i++){
    ls.push(localStorage.getItem(localStorage.key(i)));
}

*

Karen

  • *
  • 17
Re: Get array of all variables in browser localStorage
« Reply #2 on: May 19, 2016, 17:21:02 pm »
Ahh.. so it seems it has to be done manually

Thanks for the help!

 

Sitemap 1 2 3 4 5 6 7 8