JavaScript NodeList values() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

NodeList.values() returns an iterator of the list’s Node objects in order. Use it with for...of when you want each node, not its index (MDN).

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call nodeList.values. Start with this line.

JavaScript
nodeList.values()
CallWhat it does
nodeList.values()Primary signature.
nodeList.values(...)Call with the arguments your case needs.

Built into the browser. Call values(...) on a NodeList — no import required.

Library declarations
JavaScript
nodeList.values()

Parameters

ParameterDescription
values()Required. Returns the node iterator

Return Value

Return ValueDescription
*Iterator of Node objects

JavaScript Examples

Example 1 — for...of over values()

MDN pattern: walk every node in a NodeList.

JavaScript
const node = document.createElement("div");
node.appendChild(document.createElement("p"));
node.appendChild(document.createTextNode("hey"));
node.appendChild(document.createElement("span"));

const list = node.childNodes;

for (const value of list.values()) {
  if (value.nodeType === 3) {
    console.log('#text "' + value.textContent + '"');
  } else {
    console.log("<" + value.nodeName.toLowerCase() + ">");
  }
}
Try It Yourself

How It Works

  1. Build a NodeList. Three children: element, text, element.
  2. Call values(). You get an iterator of those Node objects.
  3. Loop with for...of. Each step yields the next node.
  4. Print a readable form. Text nodes show #text; elements show a tag-like label.

Example 2 — Log Each nodeName

A short loop that prints the type name of every value.

JavaScript
const node = document.createElement("div");
node.appendChild(document.createElement("p"));
node.appendChild(document.createTextNode("hey"));
node.appendChild(document.createElement("span"));

for (const value of node.childNodes.values()) {
  console.log(value.nodeName);
}
Try It Yourself

How It Works

  1. Same NodeList. Three children again via childNodes.
  2. Iterate values. Each value is a live Node reference.
  3. Read nodeName. Elements use tag names; text uses #text.
  4. Keep it simple. Great first check when debugging what a list contains.

Example 3 — Collect Text from querySelectorAll

Walk matched elements and read each node’s textContent.

JavaScript
const items = document.querySelectorAll("#fruit li");

for (const value of items.values()) {
  console.log(value.textContent);
}
Try It Yourself

How It Works

  1. Select elements. querySelectorAll returns a static NodeList of li nodes.
  2. Call values(). Iterate the element nodes themselves.
  3. Read text. textContent gives each list item’s label.
  4. Same as default iteration. for (const value of items) would work the same way.

Browser Support

NodeList.values() is Baseline Widely available (MDN, since October 2017). It works across modern desktop and mobile browsers.

✓ Baseline · Widely available

NodeList.values()

Iterator of Node objects for for...of and Array.from.

Wide Modern browser support
Google Chrome Supported · modern versions
Full support
Mozilla Firefox Supported · modern versions
Full support
Apple Safari Supported · modern Safari / iOS
Full support
Microsoft Edge Supported · Chromium Edge
Full support
Opera Follow Chromium
Full support
Internet Explorer No NodeList.values()
Not supported
values() Widely available

Bottom line: Safe for modern web apps. Use for...of or Array.from to consume the iterator. Internet Explorer does not support NodeList iterator methods.

Frequently Asked Questions

An iterator of Node objects — the actual DOM nodes in the NodeList, in order. Each step yields a node, not an index number (MDN).
No. MDN marks NodeList.values() as Baseline Widely available (since October 2017). It is not Deprecated, Experimental, or Non-standard.
values() yields Node objects. keys() yields unsigned integer indexes (0, 1, 2). entries() yields [index, node] pairs.
Yes. NodeList is iterable, and its default iterator behaves like values() — each step gives you the next node.
No. It only iterates existing nodes. It does not add, remove, or change nodes by itself.
Use values() with for...of when you want iterator control (break, continue) or to pass the iterator to Array.from. Use forEach() for simple callbacks.

Next: length

Learn how to read how many nodes are in a NodeList.

length tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful