Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

325
Views
Converting HTML collection to array returns an empty array (JavaScript)

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!