Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

326
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda