I\'m a big fan of using the forEach method on nodeLists like this:
var nodes = document.querySelectorAll(\".foo\"); [].forEach.call(nodes, function (item) {
Here's a nice performance comparison. According to it Array.forEach is slower than a native for loop.
Array.forEach
for