Last active
June 18, 2017 14:34
-
-
Save kauffmanes/c2bf22b496a9cb8a9df7a50c63118e92 to your computer and use it in GitHub Desktop.
parse localStorage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fetchAll = function () { | |
var finds = []; | |
if (localStorage.length === 0) { | |
return []; | |
} | |
for (var i=0;i<localStorage.length;i++) { | |
try { | |
finds.push(JSON.parse(localStorage.getItem(localStorage.key(i)))); | |
} catch (err) { | |
console.log(err); | |
} | |
} | |
return finds; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment