JavaScript NodeList values() Method

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline Widely available
Instance method

What You’ll Learn

The values() method of a NodeList returns an iterator of Node objects. Learn for...of over list.values(), how it compares to plain for...of list, keys(), and entries()—with five examples and try-it labs.

01

Kind

Instance method

02

Returns

Iterator

03

Yields

Nodes

04

Params

None

05

Loop

for...of

06

Status

Baseline widely

Introduction

A NodeList holds an ordered collection of DOM nodes. list.values() lets you walk those nodes one by one through an iterator—each step gives you the next Node, not an index number.

MDN’s classic setup: three children in a div produce <p>, a text node "hey", and <span> when you log each value from childNodes.

💡
Beginner tip

You can often write for (const node of list) instead of for (const node of list.values())—they behave the same because NodeList is iterable.

Understanding the values() Method

An instance method on NodeList that returns an iterator over all values in the list. The values are Node objects (elements, text nodes, comments, etc.).

  • Returns — an iterator (not an array).
  • Each step — the next Node in order.
  • Parameters — none.
  • Does not mutate the NodeList or the DOM by itself.
  • Baseline Widely available on MDN (since October 2017).

📝 Syntax

Call the method on a NodeList:

JavaScript
values()

Parameters

None.

Return value

An iterator. Each yielded value is a Node.

Typical pattern (MDN idea)

JavaScript
const list = node.childNodes;

for (const value of list.values()) {
  console.log(value);
  // <p>, #text "hey", <span>
}

⚡ Quick Reference

GoalCode / note
Get iteratorlist.values()
Loop nodesfor (const node of list.values())
Shorthandfor (const node of list)
To arrayArray.from(list.values()) or [...list]
ParametersNone
MDN statusBaseline Widely available (since October 2017)

🔍 At a Glance

Four facts to remember about NodeList.values().

Returns
iterator

Nodes

Params
none

No arguments

Mutates?
no

Read-only walk

Baseline
widely

Since Oct 2017

Examples Gallery

Examples follow MDN NodeList.values(). Labs use childNodes and querySelectorAll.

📚 Getting Started

Walk node values the MDN way.

Example 1 — for...of Over values() (MDN Idea)

Log each node from childNodes.

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()) {
  console.log(value);
}
Try It Yourself

How It Works

Each value is a live Node object—element, text, or other node type.

Example 2 — Read nodeName From Each Value

Inspect what kind of node each step yields.

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

How It Works

childNodes includes text nodes (#text), not just elements.

📈 Selectors & Arrays

Use values with querySelectorAll and Array.from.

Example 3 — querySelectorAll Values

Walk matched elements and read their text.

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

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

How It Works

Each value is an <li> element from the matched NodeList.

Example 4 — Materialize With Array.from

Turn the values iterator into a real array of nodes.

JavaScript
const nodes = Array.from(list.values());
console.log(nodes.length, nodes.map(n => n.nodeName));
Try It Yourself

How It Works

Useful when you need array methods like map, filter, or find.

Example 5 — values() vs keys()

Values yield nodes; keys yield index numbers.

JavaScript
for (const value of list.values()) {
  console.log("value", value.nodeName);
}

for (const key of list.keys()) {
  console.log("key", key);
}
Try It Yourself

How It Works

Pick values() when you need nodes; pick keys() when you only need indexes.

🚀 Common Use Cases

  • Walk nodes with for...of and early break.
  • Convert a NodeList to an array of nodes with Array.from.
  • Process matched elements from querySelectorAll.
  • Teach iterator methods alongside Array values().
  • Compare node iteration with keys() and entries().

🔧 How It Works

1

Get a NodeList

From childNodes, querySelectorAll, or another DOM API.

DOM
2

Call values()

list.values() returns a fresh iterator over Node objects.

Call
3

Iterate

for...of (or Array.from) pulls each node until the list is exhausted.

Loop
4

Use the node

Read properties, mutate content, or pass the node to other DOM APIs.

📝 Notes

  • MDN: Baseline Widely available (since October 2017) — no Deprecated / Experimental / Non-standard banner.
  • Returns an iterator; yields nodes, not indexes.
  • for...of list is equivalent to iterating list.values().
  • Does not mutate the DOM by itself.
  • Related learning: keys(), entries(), forEach(), childNodes.

Universal Browser Support

NodeList.values() is marked Baseline Widely available on MDN (since October 2017). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline · Widely available

NodeList.values()

Returns an iterator of Node objects. Use for...of or Array.from to consume it.

Universal Widely available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer No NodeList.values() (use a polyfill or indexed for loop)
Unsupported
NodeList.values() Excellent

Bottom line: Call list.values() when you need nodes as an iterator—for...of list is often enough.

Conclusion

NodeList.values() is the node iterator for a NodeList. Use for...of to walk each DOM node, or Array.from when you need a real array. For indexes only, use keys(); for both index and node, use entries().

Continue with length, keys(), entries(), or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use values() when you need explicit iterator control
  • Prefer for...of list when it reads clearer
  • Use Array.from(list.values()) for array methods
  • Check nodeName or nodeType when mixing node kinds
  • Compare with keys() and entries() while learning

❌ Don’t

  • Expect values() to yield index numbers
  • Pass arguments to values()
  • Assume an array return value (it is an iterator)
  • Forget that childNodes includes text nodes
  • Mutate the list while iterating without understanding live lists

Key Takeaways

Knowledge Unlocked

Five things to remember about NodeList.values()

DOM nodes, as an iterator.

5
Core concepts
⚙️02

Yields

Nodes

Values
🔒03

No params

values()

Rule
📄04

= for...of

list

Shorthand
🎯05

Baseline

since Oct 2017

Status

❓ 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.
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.
Did you know?

MDN’s example logs the actual nodes— <p>, a text node, and <span>. That is what values() is for: the Node objects themselves, not their indexes.

Explore NodeList.length

Next up: count nodes and use length in loops.

length property →

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.

5 people found this page helpful