elements
is a NodeList that matches given selector:const elements = document.querySelectorAll(...);
elements
by using one of the approach below:[...elements].forEach(function(ele) {...});
// `Array.from` is not supported on IEArray.from(elements).forEach(function(ele) {...});// Or[].forEach.call(elements, function(ele) {...});// Or[].slice.call(elements, 0).forEach(function(ele) {...});
forEach
method:elements.forEach(function(ele) {...});