<p>In the past and with most my current projects I tend to use a for loop like this:</p>

<pre><code>var elements = document.getElementsByTagName('div');
for (var i=0; i&lt;elements.length; i++) {
    doSomething(elements[i]);
}
</code></pre>

<p>I've heard that using a "reverse while" loop is quicker but I have no real way to confirm this:</p>

<pre><code>var elements = document.getElementsByTagName('div'), 
    length = elements.length;

while(length--) {
    doSomething(elements[length]);
}
</code></pre>

<p>What is considered as best practice when it comes to looping though elements in JavaScript, or any array for that matter?</p>

At the risk of getting yelled at, i would get a javascript helper library like
jquery
or
prototype
they encapsulate the logic in nice methods - both have an .each method/iterator to do it - and they both strive to make it cross-browser compatible
EDIT: This answer was posted in 2008. Today much better constructs exist. This particular case could be solved with a
```
.forEach
```
.