post increment vs pre increment - Javascript Optimization
问题 I was browsing Google Code when I chanced upon this project called JSpeed - optimization for Javascript. I noticed one of the optimization was to change i++ to ++i in for loop statements. Before Optimization for (i=0;i<1;i++) {} for (var i = 0, j = 0; i < 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 < arr.length; i++) {} After optimization for(var i=0;i<1;++i){} for(var i=0,j=0;i<1000000;++i,++j