title: Objects vs arrays in Javascript for key/value pairs
body: <p>Say you have a very simple data structure:</p>
  
  <pre><code>(personId, name)
  </code></pre>
  
  <p>...and you want to store a number of these in a javascript variable. As I see it you have three options:</p>
  
  <pre><code>// a single object
  var people = {
      1 : 'Joe',
      3 : 'Sam',
      8 : 'Eve'
  };
  
  // or, an array of objects
  var people = [
      { id: 1, name: 'Joe'},
      { id: 3, name: 'Sam'},
      { id: 8, name: 'Eve'}
  ];
  
  // or, a combination of the two
  var people = {
      1 : { id: 1, name: 'Joe'},
      3 : { id: 3, name: 'Sam'},
      8 : { id: 8, name: 'Eve'}
  };
  </code></pre>
  
  <p>The second or third option is obviously the way to go if you have (or expect that you might have) more than one "value" part to store (eg, adding in their age or something), so, for the sake of argument, let's assume that there's never ever going to be any more data values needed in this structure. Which one do you choose and why?</p>
  
  <hr>
  
  <p><strong>Edit</strong>: The example now shows the most common situation: non-sequential ids.</p>