Mapping Over a NodeList in JavaScript

Sharing is Caring

In JavaScript a NodeList is an array-like list of objects. One thing to remember though is that array methods will not work on a nodelist because it’s not an array!

In Chrome Developer tools, a NodeList looks like this when being inspected:


Generally, NodeList items in JavaScript can only be accessed using their index number. We can get the number of items in a node list by calling the .length property.

In ES2015, when can use the Array.from method to convert a NodeList into an array.

We could also potentially Spread into an array and then map over that.


Sharing is Caring