Closed soyuka closed 9 years ago
I think the answer is that sometimes a for loop is faster, sometimes while. Especially in the browser the optimization makes it difficult to tell. Look here https://github.com/Hypercubed/ArraySpeedTests.
As for reverse-iterating, even if it is faster, doing a forEach in reverse would be too surprising for the user. Instead I would suggest implementing a forEachReverse function... who knows. Maybe it is faster... sometimes.
I agree about the reverse ;). Thanks for the link!
The readme states that this is the fatest way to iterate:
I think that it's not correct. I've read many times that this was the fatest:
Also, reverse-iterating in a for loop will be faster then the standard one.
jsperf