Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
17
rated 0 times [  21] [ 4]  / answers: 1 / hits: 180472  / 13 Years ago, wed, december 7, 2011, 12:00:00

I'm just wondering how to get all key values in localStorage.






I have tried to retrieve the values with a simple JavaScript loop



for (var i=1; i <= localStorage.length; i++)  {
alert(localStorage.getItem(i))
}


But it works only if the keys are progressive numbers, starting at 1.






How do I get all the keys, in order to display all available data?


More From » html

 Answers
18

in ES2017 you can use:



Object.entries(localStorage)

[#88690] Tuesday, December 6, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
margob

Total Points: 302
Total Questions: 89
Total Answers: 100

Location: Guadeloupe
Member since Sat, Jul 25, 2020
4 Years ago
;