localstorage Preious array to new value addition code example
Example: localsstorage array append element
function addEntry() {
var existingEntries = JSON.parse(localStorage.getItem("allEntries"));
if(existingEntries == null) existingEntries = [];
var entryTitle = document.getElementById("entryTitle").value;
var entryText = document.getElementById("entryText").value;
var entry = {
"title": entryTitle,
"text": entryText
};
localStorage.setItem("entry", JSON.stringify(entry));
existingEntries.push(entry);
localStorage.setItem("allEntries", JSON.stringify(existingEntries));
};