Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created September 14, 2019 16:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NyaGarcia/b6fbb48e32197620bf31eb6cd96bdeb0 to your computer and use it in GitHub Desktop.
Save NyaGarcia/b6fbb48e32197620bf31eb6cd96bdeb0 to your computer and use it in GitHub Desktop.
Converting a nodeList to array with the spread operator
const nodeList = document.getElementsByClassName("pokemon");
const array = [...nodeList];
console.log(nodeList); //Result: HTMLCollection [ div.pokemon, div.pokemon ]
console.log(array); //Result: Array [ div.pokemon, div.pokemon ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment