In JavaScript, why is a “reverse while” loop an order of magnitude faster than “for”?
问题 In these benchmarks, http://jsperf.com/the-loops, Barbara Cassani showed that a "reverse while" loop is way faster, while (iterations > 0) { a = a + 1; a = a - 1; iterations--; } than a usual "for" loop: for (i = 0; i < iterations; i++) { a = a + 1; a = a - 1; } Why? Update Okay, forget about it, there is a bug in the test, iterations = 100 , is executed only once per page. Therefore reducing it, well, means that we don't really enter the loops. Sorry. 回答1: Except for the big bug in the