Getting a key by index in a localStorage in JavaScript

Each entry in the local storage has its own index. By index you can retrieve the key of this entry:

let key = localStorage.key(0); console.log(key);

Knowing the key, you can get the value of this entry:

let key = localStorage.key(0); let val = localStorage.getItem(key); console.log(val);

Retrieve the value of entries with different indices.

enru