local storage remove multiple items

Solutions on MaxInterview for local storage remove multiple items by the best coders in the world

showing results for - "local storage remove multiple items"
Zackery
24 Jan 2018
1//You could just put the keys to remove in an array and loop over them:
2
3let keysToRemove = ["summaryForm", "projectForm"];
4
5for (key of keysToRemove) {
6    localStorage.removeItem(key);
7}
8//Using a full loop, or, using forEach:
9
10keysToRemove.forEach(k =>
11    localStorage.removeItem(k))
12
13//Or use localStorage.clear() if you want to just clear everything.