I can console log an HTML collection from the DOM but when I try to log it after it's been converted into an array, it somehow becomes empty.
const results = document.getElementsByClassName("hit-container");
const resultsArr = [...results];
console.log(results);
console.log(resultsArr);
The first console log will return all the elements within the HTML collection. The second console log will return an empty array.
I want to return the array with all the elements so I can perform array functions on the collection of elements.
Using Array.from() will also yield the same issue.