Simplest way to loop node list / HTMLCollection using map, foreach etc

You unfold the checklist like this: const components = doc.getElementsByClassName(‘modal’); […elements].forEach((factor)=> { console.log(factor) }) Enter fullscreen mode Exit fullscreen mode Or in a single line like this, that is helpful in case you are doing a number of loops and don’t wish to unfold each time: const components = […document.getElementsByClassName(‘modal’)]; components.forEach((factor)=> { console.log(factor) }) Enter […]