Favorites

DOM NodeList Interface

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
NodeList
DOM InterfaceThis interface is supported by all modern browsers.
Updated 28th November 2026

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

NameDescription
NodeList.forEach()The forEach() method runs a function once for each node in a NodeList, such as the results of querySelectorAll().

Example

<ul>
  <li>Apple</li>
  <li>Banana</li>
  <li>Cherry</li>
</ul>
const items = document.querySelectorAll('li');
console.log(items.length, items[0].textContent);
items.forEach(li => li.style.color = 'crimson');
const texts = [...items].map(li => li.textContent);
console.log(texts);

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.

This interface is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee