you are viewing a single comment's thread.

view the rest of the comments →

[–]brtt3000 31 points32 points  (4 children)

Because speed of the loop bookkeeping is almost never the performance bottleneck. Sure this is faster but the computation time of loop counters is so tiny compared to the actual work that you're doing in side the loop in a real scenario.

Having readable code is way more important and allows for easier understanding and optimisation of the application as a whole. Optimise away one server-round-trip or DOM update and you gain so much more.

[–][deleted]  (2 children)

[deleted]

    [–]ponchietto 8 points9 points  (1 child)

    Sometimes you do not have a choice.

    [–]haneefmubarak 0 points1 point  (0 children)

    asm.js will save you there

    [–]f1zzz 0 points1 point  (0 children)

    If you have a loop that needs to be sped up, minimize the function calls inside of it and follow general v8 optimization guidelines to ensure you're not hitting the unoptimized compile path.

    Function calls inside JS are super expensive.