title: jQuery localStorage and arrays
body: <p>What I am trying to do is store some data from input forms into an array, but is there any way to create the array if it does not exist then run the rest of the script, otherwise, if it does exist then continue with the same script as well.</p>
  
  <p>I want to store the array as localStorage, so later on I can display the items.</p>
  
  <pre><code>var routes = [];
  
  div.on('click', function() {
     routes.push({ routeF : $('input[name=routeFrom]').val() });
     routes.push({ routeT : $('input[name=routeTo]').val() });
     routes.push({ leaving : $('select').val() });
  
     localStorage['routes'] = JSON.stringify(routes);
     var storedRoutes = JSON.parse(localStorage['routes']);
  });
  </code></pre>
  
  <p>I want to be able to do this without doing:</p>
  
  <pre><code>if(routes[]) {
      //do code
  } else { 
      var routes = []; 
      //do same code
  }
  </code></pre>