title: Adding something to the top of a JSON object
body: <p>I have a JSON object which is initiated when the page is loaded, like this:</p>
  
  <pre><code>data[foo] = bar;
  data[foo2] = bar2;
  data[foo3] = bar3;
  </code></pre>
  
  <p>Is there a way to inject an element before the first <code>foo</code> element, so that when doing a <code>for var i in data</code>, the new element will be looped through before the elements that were added when the object was initiated?</p>
  
  <p>The reason is, I'm displaying some items to the user. When the user adds a new item via javascript, I want this new item to be displayed above all the existing items, however when I add the new item, i.e</p>
  
  <pre><code>data[newItem] = newItem;
  </code></pre>
  
  <p>Then the JSON object looks like this:</p>
  
  <pre><code>data[foo] = bar;
  data[foo2] = bar2;
  data[foo3] = bar3;
  data[newItem] = newItem;
  </code></pre>
  
  <p>Instead of how I want, which is:</p>
  
  <pre><code>data[newItem] = newItem;
  data[foo] = bar;
  data[foo2] = bar2;
  data[foo3] = bar3;
  </code></pre>
  
  <p>Any ideas?</p>