fast way of looping in array with 300 elelment for searching key in javascript
<p>I have below code, I need it doesn't take so long for to sort through this array:</p>

<p>This is the code I am using now:</p>

<pre><code>var key= {
  '1001': {
    'color': 'green',
    'size': 'Big'
  },
  '1002': {
    'color': 'white',
    'size': 'extralarge'
  },
  '1003': {
    'color': 'orange',
    'size': 'small'
  },
  //(AND so on.......about 300 keys)

};

var code = 3001;
if (code in key) {
  var color= key[code]['color'];
  var size= key[code]['size'];
</code></pre>

<p>So basically, it cycles through hundreds of possibilities trying to find a match, which takes to much time.... </p>

<p>Is there a good way to do this so that it will not take so long?</p>
