230

Possible Duplicate:
JavaScript - Are loops really faster in reverse…?

I don't know if this question is valid in other languages or not, but I'm asking this specifically for JavaScript.

I see in some articles and questions that the fastest loop in JavaScript is something like:

for(var i = array.length; i--; )

Also in Sublime Text 2, when you try to write a loop, it suggests:

for (var i = Things.length - 1; i >= 0; i--) {
    Things[i]
};

I want to know, why is i-- faster than i++ in loops?

Community
  • 1
  • 1
Afshin Mehrabani
  • 33,262
  • 29
  • 136
  • 201

0 Answers0