Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #local #storage #remove #multiple #items
ADD COMMENT
Topic
Name
2+6 =