forEach (ES5+)for loopfor-in correctly :-- This approach is best when you have sparse array.for-of (use an iterator implicitly) (ES6+)
forEach on the NodeList returned by querySelectorAll, you can do this:
var divs = Array.prototype.slice.call(document.querySelectorAll("div"), 0);
divs.forEach(function(div) {
// Use each
div here
});
jQuery.each(arr, function(index, value) { ... }
Some terse syntax of for loops in JavaScript.
So for instance, if you want to use
