DOM NodeList Interface
A NodeList is a list of nodes, such as the result of querySelectorAll(). It can be looped over with forEach() or for...of, but isn't a real array.
Description
A NodeList is an array-like collection of nodes. querySelectorAll() returns a static NodeList, a snapshot that doesn't change when the page does, while childNodes returns a live one that updates automatically.
It has length, index access, item(), forEach(), entries(), keys() and values(), and works with for...of. It doesn't have array methods such as map() or filter(); convert it with Array.from() or spread syntax first.
Because querySelectorAll() returns a static list, it's safe to remove or move the matched elements while looping over it. Live lists such as childNodes, by contrast, change as you modify the tree, which can cause items to be skipped. When you need a stable snapshot of a live list, copy it into an array first with Array.from().
Methods
| Name | Description |
|---|---|
NodeList.forEach() | The forEach() method runs a function once for each node in a NodeList, such as the results of querySelectorAll(). |
Example
Browser Support
The following information will show you the current browser support for the NodeList interface. Hover over a browser icon to see the version that first introduced support for this interface.
Desktop





Tablets & Mobile





