Skip to content Skip to sidebar Skip to footer

Retrieve All Data From Localstorage (without Knowing The Key Name)

I'm looking for a way to get all the information out of localStorage. The trouble I'm having is I don't know what the data will be as it is user generated. So here what happens, a

Solution 1:

window.localStorage.key is the solution. Example:

var i = 0,
    oJson = {},
    sKey;
for (; sKey = window.localStorage.key(i); i++) {
    oJson[sKey] = window.localStorage.getItem(sKey);
}
console.log(oJson);

Post a Comment for "Retrieve All Data From Localstorage (without Knowing The Key Name)"