Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Read an write to localstorage
// READ FROM LOCALSTORAGE
if(localStorage.getItem('data')){
let dataString = localStorage.getItem('data');
dataArray = JSON.parse(dataString);
}else{
dataArray = [];
}
// WRITE TO LOCALSTORAGE
let dataString = JSON.stringify(dataArray);
localStorage.setItem('data', dataString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.