how to loop over dom objects javascript

JavaScript
 Array.from($('.'+$( this ).attr('id'))).forEach(function(obj){

    console.log(obj);
  });//Loop thru DOM elements

var all = document.getElementsByTagName("*");

for (var i=0, max=all.length; i < max; i++) {
     // Do something with the element here
}
Source

Also in JavaScript: