title: Javascript: Convert a list of objects to an associative array
body: <p>I'm looking for a way to take an array of JavaScript objects and get an associative array of those objects keyed by some attribute.</p>
  
  <p>For example, given this array of objects:</p>
  
  <pre><code>var data = [
    {'id': 100, name: 'bob', foo: 'bar'},
    {'id': 200, name: 'john', foo: 'qux'}
  ];
  </code></pre>
  
  <p>I want to be able to look up each object by its id, so I want an object like this:</p>
  
  <pre><code>var new_data = {
    100: {name: 'bob', foo: 'bar'}, 
    200: {name: 'john', foo: 'qux'}
  }
  
  // now I can use new_data[200] to access `john`
  </code></pre>
  
  <p>While I'm sure it's easy enough to construct a new object and then iterate over each object in the original array and append a new key:value pair to new object, I was wondering if there was a more concise way of doing it. </p>