Answers for "how to update objects in locall storage"

0

how to update objects in locall storage

// Get the existing data
var existing = localStorage.getItem('myFavoriteSandwich');

// If no existing data, create an array
// Otherwise, convert the localStorage string to an array
existing = existing ? existing.split(',') : [];

// Add new data to localStorage Array
existing.push('tuna');

// Save back to localStorage
localStorage.setItem('myFavoriteSandwich', existing.toString());
Posted by: Guest on April-19-2020

Code answers related to "how to update objects in locall storage"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language