Skip to content

Instantly share code, notes, and snippets.

@takidog
Created May 29, 2022 05:52
Show Gist options
  • Save takidog/a0cbc81a8b313f22166c39b0f5246dbc to your computer and use it in GitHub Desktop.
Save takidog/a0cbc81a8b313f22166c39b0f5246dbc to your computer and use it in GitHub Desktop.
localStorage backup, recover
var result = [];
Object.keys(localStorage).forEach(function(key){
result.push({"name":key,"value":localStorage.getItem(key)});
});
console.log(JSON.stringify(result));
let recover = ; // paste result on here, without add any ' ".
for (let item of recover){
localStorage.setItem(item['name'],item['value']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment