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 trialguram dgebuadze
Front End Web Development Techdegree Student 4,122 Pointswhat is node ? and whats difference between nodelist and html collection?
help
3 Answers
Steven Parker
231,271 PointsA "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.
guram dgebuadze
Front End Web Development Techdegree Student 4,122 PointsThank you steven for your help so many times.
guram dgebuadze
Front End Web Development Techdegree Student 4,122 PointsIn 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
231,271 PointsAs 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.
Tim Abbott
14,206 PointsTim Abbott
14,206 PointsThanks, very useful.