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

Brian is a software architect and technology leader living in Niagara Falls with 13+ years of development experience. He is passionate about automation, business process re-engineering, and building a better tomorrow.

Brian is a proud father of four: two boys, and two girls and has been happily married to Crystal for more than ten years. From time to time, Brian may post about his faith, his family, and definitely about technology.