⊗jsSpSgIL 91 of 294 menu

Iterating over a storage by indices in JavaScript

The localStorage object is not iterable. However, it does have indices and length. This means that you can iterate through the entries using the usual for loop with a counter:

for (let i = 0; i < localStorage.length; i++) { let key = localStorage.key(i); let val = localStorage.getItem(key); console.log(val); }

On button click, output with loop all the entries from the local storage.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline