title: post increment vs pre increment - Javascript Optimization
body: <p>I was browsing Google Code when I chanced upon this project called JSpeed - optimization for Javascript.</p>
  
  <p>I noticed one of the optimization was to change <code>i++</code> to <code>++i</code> in for loop statements.</p>
  
  <p><strong>Before Optimization</strong></p>
  
  <pre><code>for (i=0;i&lt;1;i++) {}
  
  for (var i = 0, j = 0; i &lt; 1000000; i++, j++) {
      if (i == 4) {
          var tmp = i / 2;
      }
  
      if ((i % 2) == 0) {
          var tmp = i / 2;
          i++;
      }
  }
  var arr = new Array(1000000);
  for (i = 0; i &lt; arr.length; i++) {}
  </code></pre>
  
  <p><strong>After optimization</strong></p>
  
  <pre><code>for(var i=0;i&lt;1;++i){}
  for(var i=0,j=0;i&lt;1000000;++i,++j){if(i==4){var tmp=i&gt;&gt;1;}
  if((i&amp;1)==0){var tmp=i&gt;&gt;1;i++;}}
  var arr=new Array(1000000);for(var i=0,arr_len=arr.length;i&lt;arr_len;++i){}
  </code></pre>
  
  <p>I know what pre and post increments do, but any idea how does this speeds the code up?</p>