Pseudarray
Pseudarray is an object that is similar to an array. It has numeric properties, like arrays. And also the length property.
It is most often encountered when working with the DOM -
all properties and methods that return
multiple elements usually return a
pseudarray. For example, the property children
returns a pseudarray of child elements.
Although pseudarrays are similar to arrays, they
are still ordinary objects. They do not have the properties
and methods of arrays, such as forEach, join,
slice, etc.
Example
Pseudarrays do not have array methods. Therefore, the following code will throw an error:
let children = document.body.children;
console.log(children.push());
Example
Since pseudarrays have numeric properties
and length, they can be iterated over in a loop. In
this example, let's output all child elements:
let children = document.documentElement.children;
for (let i = 0; i < children.length; i++) {
console.log(children[i]);
}