Removing localStorage entries - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window localStorage


Removing localStorage entries

Demo Code

ResultView the demo in separate window

      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*w  w  w .  j a v  a 2  s .  com*/
var foo = localStorage.getItem('foo');
if (foo) {
   console.log('i had it, now i remove it');
} else {
   console.log('i didnt have it, now i set it');
  localStorage.setItem('foo', 'bar');


Related Tutorials