DOM: Node vs Element, NodeList vs HTMLCollection

By Xah Lee. Date: . Last updated: .

What is NodeList, HTMLCollection?

NodeList and HTMLCollection are both Array-Like Objects that are returned by many DOM methods.

They are collection of Nodes.

Iterable Object

NodeList and HTMLCollection are Iterable Objects. You can use for-of Loop on them.

Array-Like Object

NodeList and HTMLCollection are Array-Like Objects. [see Apply Array Method to Array-Like Object]

is Live Object?

What Does getElementsByClassName Return?

How to Determine NodeList or HTMLCollection

You can find out the type by:

let xx = document.getElementsByClassName("xx");
Reflect.apply(Object.prototype.toString, xx, []);

It'll return a string like "[object HTMLCollection]" or "[object NodeList]".

[see Determine Type of Object]

JavaScript/DOM: Node Name, Node Type, Node Value

JavaScript in Depth

DOM Scripting


DOM Methods

Basic Examples

HTML Input

Web Scripting Examples

Web Scripting Misc