As you know, to take with localStorage only entries whose keys begin with a certain word, you can use the code:
for (i = 0; i < localStorage.length; i++) { var myKey = localStorage.key(i); if(myKey.slice(0,6) === 'myWord') { console.log(myKey); } } And how to delete all such records at the same time? I tried this:
... if(myKey.slice(0,6) === 'myWord') { localStorage.removeItem(myKey); } so:
... if(myKey.slice(0,6) === 'myWord') { localStorage.removeItem(localStorage.key(i)); } But deletes one by one each time the code is run.
And how to remove everything at once with one run?
cleardeletes all entries at once - Grundycleardeletes all entries in general, and I only need to delete those that start with a certain word - stckvrw