Skip to content

Instantly share code, notes, and snippets.

@alfredbez
Created October 8, 2014 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alfredbez/be6b609d876001ee1bc4 to your computer and use it in GitHub Desktop.
Save alfredbez/be6b609d876001ee1bc4 to your computer and use it in GitHub Desktop.
cleares localStorage if key begins with specific string
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