javascript foreach htmlcollection code example Example: html collection of elements to array const boxArray = [...document.getElementsByClassName('box')];