title: Can't add to javascript array in loop
body: <p>I'm having some issues with the following code:</p>
  
  <pre><code>var tmpArray = new Array();
  for(var n in fnlArray){
      if(fnlArray[n] == largest.val){
          alert(fnlArray[n] +"-"+ largest.val);
          tmpArray[n] = fnlArray[n];
      }
  }
  </code></pre>
  
  <p>fnlArray contents is: </p>
  
  <pre>fnlArray['result1'] = 1;
  fnlArray['result2'] = 2;
  fnlArray['result3'] = 2;
  fnlArray['result4'] = 2;
  and largest.val = 2;</pre>
  
  <p>The issue I'm having is the alert gets fired so I would expect to end up with tmpArray with the following:</p>
  
  <pre>tmpArray['result2'] = 2;
  tmpArray['result3'] = 2;
  tmpArray['result4'] = 2;</pre>
  
  <p>But the array (tmpArray) is always empty. Is this an issue with adding items to the array dynamically within a loop? </p>