Last active
October 31, 2018 21:54
-
-
Save jiayihu/abdceeb0f9529a5714a3b91a36fde483 to your computer and use it in GitHub Desktop.
Chrome snippet to console log your localStorage in a pretty format
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 items = Object.keys(localStorage); | |
items.forEach(item => { | |
try { | |
const value = JSON.parse(localStorage.getItem(item)); | |
console.group(item); | |
if (Array.isArray(value)) console.table(value); | |
else if (Object.prototype.toString.call(value) === '[object Object]') console.table([value]); | |
else console.log(value); | |
console.groupEnd(item); | |
} catch (exception) { | |
console.warn('Could not JSON parse the item ', item); | |
console.warn('The error is: ', exception); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment