Answers for "local storage remove multiple items"

0

local storage remove multiple items

//You could just put the keys to remove in an array and loop over them:

let keysToRemove = ["summaryForm", "projectForm"];

for (key of keysToRemove) {
    localStorage.removeItem(key);
}
//Using a full loop, or, using forEach:

keysToRemove.forEach(k =>
    localStorage.removeItem(k))

//Or use localStorage.clear() if you want to just clear everything.
Posted by: Guest on July-22-2020

Code answers related to "local storage remove multiple items"

Code answers related to "Javascript"

Browse Popular Code Answers by Language