title: How to concat objects in localStorage in Angular JS
body: <p>We have to concat objects to turn them into an array of objects in the HTML5 localStorage.</p>
  
  <p>We first check whether there are already some data. If it is not there we only add that item or we append another item to the existing item to turn it into an array.</p>
  
  <pre><code>if(type === 'server'){
      var old = $window.localStorage.getItem('selectedServers');
      if(old === null)
          localStorage.setItem('selectedServers', JSON.stringify(item));
      else
          localStorage.setItem('selectedServers', JSON.stringify(old.concat(item)));
  }
  </code></pre>
  
  <p>But this code does not work. Even <code>JSON.stringify(old+data)</code> gives unexpected result.</p>
  
  <p>The result comes with unexpected <code>\</code>s. <code>item</code> here is the object to be added or rather appended.</p>
  
  <p>How to achieve the same in Angular JS?</p>