forEach
, map
, filter
, etc. JavaScript does, however, provide a very simple way to convert NodeLists to Arrays:var nodesArray = Array.prototype.slice.call(document.querySelectorAll("div"));
The result of the code above is a true Array object containing all of
the nodes returned by the QSA. You could even make the code shorter
with this alternative:var nodesArray = [].slice.call(document.querySelectorAll("div"));
Both snippets will give you an Array for which you can iterate over and do all those other awesome array things!