In a tutorial I saw the following:
Array.from( template.querySelectorAll('.hw-text') )
.forEach( n => n.textContent = hwMsg );
But the following line would also work.
template.querySelectorAll('.hw-text').forEach( n => n.textContent = hwMsg );
Now I wonder why in the tuturial Array.from is used and what advantage you get from it.
>Solution :
forEach was not part of the original NodeList specification. Browser support for querySelectorAll and Array.from is wider than for forEach on NodeLists.
Whether that additional browser support is worth it today is partly a matter of opinion and partly dependant on the website’s target audience.