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

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -