title: Empty elements in JS array declaration
body: <p>it's my first question here, after have been reading for years, so be nice with me please.</p>
  
  <p>I'm having trouble with array management in js/jq.</p>
  
  <p>I have array with several elements, which is processed with $.each function.
  I want to extract matching elements to another array and return this array.
  But for some reason (don't know if it's because array declaration, jquery.each function...) I'm having first empty element.</p>
  
  <p>I think I'm making this more difficult to understand than it's, so made jsfiddle.</p>
  
  <pre><code>var arr = new Array();
  $.each([1,2,3], function(index,element){
      if (element == 2){
          arr[index] = element;
      }
  });
  </code></pre>
  
  <p>arr must have only 1 element, but arr.length returns 2 because first array slot is empty.</p>
  
  <p>Here is a fiddle <a href="http://jsfiddle.net/moay7y95/" rel="nofollow">http://jsfiddle.net/moay7y95/</a></p>
  
  <p>I'm so sure that it's a simple and little stupid thing, but I've not been able to find an answer.</p>
  
  <p>Thanks in advance!</p>