For(VAR I = 0; I <items. length; I ++) {Items [I]. onclicn=FN ;}
For(I = items. length; I --;) {Items [I]. onclicn=FN ;}
For(VaRI = 0, Len = items. length; I <ilen; I ++) {Items [I]. onclicn=FN ;}
1. One query of attributes of the control condition, such as items. length;
2. Compare the values of one control condition, for example, I <items. length;
3. Compare whether the control condition is true at a time, for example, I <items. Length = true;
4. One auto-increment operation, such as I ++;
5. An array query, such as itmes [I];
6. callback function call, such as items [I]. onclick = FN;
The optimization only needs to address the above six aspects...
The following figure shows how to expand the (du's device) loop body that is applied to a large number of iterations:
// Credit: Jeff Greenberg VaR I = item. Length % 8 ; While (I ){ // FN (item [I --]) } I = Math. Floor (items. Length/8 ); While (I ){ // FN (item [I --]); // FN (item [I --]); // FN (item [I --]); // FN (item [I --]); // FN (item [I --]); // FN (item [I --]); // FN (item [I --]); // FN (item [I --]); }