title: JavaScript object vs. array lookup performance
body: <p>What is the performance difference between retrieving the value by key in a JavaScript object vs iterating over an array of individual JavaScript objects? </p>
  
  <p>In my case, I have a JavaScript object containing user information where the keys are the user's IDs and the values are each user's information.</p>
  
  <p>The reason I ask this is because I would like to use the <code>angular-ui-select</code> module to select users, but I can't use that module with a Javascript object - it requires an array.</p>
  
  <p>How much, if anything, am I sacrificing by switching from a lookup by key, to a lookup by iteration?</p>
  
  <p>By key:</p>
  
  <pre><code>var user = users[id];
  </code></pre>
  
  <p>By iteration</p>
  
  <pre><code>var user;
  
  for (var i = 0; i &lt; users.length; i ++) {
    if (users[i].id == id) { 
      user = users[i]; break;
    }
  }
  </code></pre>