How To Convert an HTMLCollection to an Array

May 31, 2021

User avatar
Scott Tolinski

Here are three easy strategies to convert an HTMLCollection into an array.

Most concise (ES2015)

const newArray = [...htmlCollection];

Most clear (ES2015)

const newArray = Array.from(htmlCollection);

Classic

const newArray = Array.prototype.slice.call( htmlCollection )
🧰

checkout

cart:

loading

loginWindow

search

🎒

course

course:
steps:
series:
series:
series:
series:
series:

courses

tags

activeAuthors

posts

post

seriesList

browseSeries

activePlaylist

activeTutorial

playlistTutorials

user