HTMLCollection interface represents a generic collection (array-like object similar to
arguments) of elements (in document order) and offers methods and properties for selecting from the list.
Note: This interface is called
HTMLCollection for historical reasons (before the modern DOM, collections implementing this interface could only have HTML elements as their items).
HTMLCollection in the HTML DOM is live; it is automatically updated when the underlying document is changed. For this reason it is a good idea to make a copy (e.g., using
Array.from) to iterate over if adding, moving, or removing nodes.
Note: This interface was an attempt to create an unmodifiable list and only continues to be supported to not break code that's already using it. Modern APIs use types that wrap around ECMAScript array types instead, so you can treat them like ECMAScript arrays, and at the same time impose additional semantics on their usage (such as making their items read-only).