Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Making Changes to the DOM Getting and Setting Text with textContent and innerHTML

3 Answers

Steven Parker
Steven Parker
231,248 Points

A "node" is a single point on the DOM tree. All elements are nodes, but nodes can also contain things that are not elements.

An "HTMLCollection" is a group of elements, always in document order. It is also always "live", meaning changes made to the DOM will be immediately reflected in the contents of the collection.

A "nodeList" is a collection of nodes, which as mentioned may include elments and/or other things. Depending on how it was obtained it might be "live", but check the documentation before assuming that.

Both are array-like but they are not actual arrays. They share some array methods but not all.

For more details, see the MDN pages on HTMLCollection and NodeList.

Tim Abbott
Tim Abbott
14,206 Points

Thanks, very useful.

guram dgebuadze
seal-mask
.a{fill-rule:evenodd;}techdegree
guram dgebuadze
Front End Web Development Techdegree Student 4,122 Points

In the links you shared here is written: ''Although NodeList is not an Array, it is possible to iterate over it with forEach(). It can also be converted to a real Array using Array.from().'' But there was nothing said about this in video lectures, also I work without problem in arrays and what's the problem, differenece?

Steven Parker
Steven Parker
231,248 Points

As you pointed out, "forEach" is a good example of a method they have in common. But arrays have many methods that these don't, such as "reverse", "sort", "slice", "push", etc. For more details, compare the methods in the links above to the ones for the array prototype.