The DOM Standard defines a collection as a list of nodes with a root and a filter, and says a collection is live unless stated otherwise. A live collection doesn't store its members: length and indexing answer from the tree as it is now. A static collection is a snapshot of the matches at creation time; later changes don't touch it.
Which one you get depends on the method, not the type:
| Returns | Type | Live? |
|---|---|---|
children, getElementsByTagName(), getElementsByClassName(), document.forms, table.rows |
HTMLCollection |
live |
childNodes |
NodeList |
live |
document.getElementsByName() |
NodeList |
live |
querySelectorAll() |
NodeList |
static |
The interfaces differ too. HTMLCollection holds only elements and adds namedItem() (lookup by id or name); the standard calls it "a historical artifact". NodeList can hold any node and has forEach(), keys(), values() and entries(). Both have length and indexing, and Web IDL gives every interface with an indexed getter a Symbol.iterator, so for…of, spread and Array.from() work on both; only NodeList has forEach().
Identity follows from liveness. children and childNodes return the same object every time; getElementsBy*() may return the same object for the same argument; querySelectorAll() always builds a new list.
Liveness bites when you change the tree while iterating it. Removing a class from each element of getElementsByClassName() in an index loop shifts the remaining items down and skips every other one. Inserting matching elements during for…of over a live collection can loop forever. Copy first ([...live]), use querySelectorAll(), or iterate backwards.