Created
October 8, 2014 10:40
-
-
Save alfredbez/be6b609d876001ee1bc4 to your computer and use it in GitHub Desktop.
cleares localStorage if key begins with specific string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pattern = 'http://www.domain.com/section/'; | |
for (var key in localStorage){ | |
if(key.substr(0,pattern.length) === pattern){ | |
localStorage.removeItem(key); | |
console.log('localStorage: cleared key "' + key + '"'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment