title: JSON.parse error Javascript
body: <p>A problem. Again. Here is the code: </p>
  
  <pre><code>if(localStorage.getItem("temporaryArray")){
      var temporaryArray = JSON.parse(localStorage.getItem("temporaryArray"));
  }else{
      var temporaryArray = [];
  }
  </code></pre>
  
  <p>So basically what it does is that when a new page is loaded I don't want to reset the array because later in the code I assign something to this array in localStorage. So what I'm trying to say is that if you can get this item, then when the code is loaded again assign this variable to the localStorage item. Else, just set it to an empty array. But here is the error I'm getting because the array is currently empty(I think that's the reason why):</p>
  
  <pre><code>Uncaught SyntaxError: Unexpected token o in JSON at position 1
      at JSON.parse (&lt;anonymous&gt;)
      at main.js:61
  </code></pre>
  
  <p>Any help would be very much appreciated. </p>