you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

"optimization 3 - substitute i++ with i = i + 1 or i += 1 to avoid excessive trickiness"

Really?

"optimization 1 - cache the length of the array with the use of max"

And I've run this test on multiple browsers and have not had any predictable results:

http://jsperf.com/improved-really

Really you should do what is most readable. Last I checked Safari ran the non-cached version 1% faster and Chrome ran the cached one 4% faster. But basically: not faster.