JavaScript associative array and Array.indexOf lookup : <p>Supposed to have a 100,000 items or more array of objects, with unique ids like:</p>

<pre><code>myObj={
  id:makeUniqueId()
  , key:"bla"
  , key2:"blabla"
}
</code></pre>

<p>and I have to put these object in ad array with unique ids by <code>myObj.id</code>, so I would do like</p>

<p><code>objectsList.push( myObj )</code></p>

<p>having those alternative guards:</p>

<pre><code>if(typeof( objectsIdMap[ myObj.id ] )=="undefined" ) {
  objectsIdMap[ myObj.id ]={};
  objectsList.push( myObj );
}
</code></pre>

<p>and</p>

<pre><code>if( objectsIdList.indexOf( myObj.id) &lt; 0 ) {
   objectsIdList.push( myObj.id );
   objectsList.push( myObj );
}
</code></pre>

<p>Which has better performances and why? Any productive way to achieve better performances using <code>Set</code> or <code>Map</code>?</p>
