javascript - Why is for (var i = 100; i--;) {} so much slower (70%) than for (var i = 100; i-->0;) {} in Firefox? -



javascript - Why is for (var i = 100; i--;) {} so much slower (70%) than for (var i = 100; i-->0;) {} in Firefox? -

here's test: http://jsperf.com/forloopspeed

as can see, difference huge in firefox, nowadays much lesser extent in safari, , absent in chrome , opera.

the analogous thing happens while loops too: http://jsperf.com/whileloopspeed

my guess checking whether i (a number) falsy value more computationally expensive checking true/false (the result of comparison).

javascript firefox

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -