Why the arr.length is equal to 5 even though the there are only two child nodes of div id demo?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why the arr.length is equal to 5 even though the there are only two child nodes of div id demo??

https://code.sololearn.com/WMb8LlMIbYpn/?ref=app

2nd Jun 2020, 12:20 PM
Nitin Madas
Nitin Madas - avatar
3 Answers
+ 1
Plus 3 text nodes.
2nd Jun 2020, 12:24 PM
Calviղ
Calviղ - avatar
+ 1
What are text nodes?
2nd Jun 2020, 12:25 PM
Nitin Madas
Nitin Madas - avatar
+ 1
childNodes includes all child nodes—including non-element nodes like text and comment nodes. To get a collection of only elements, use ParentNode.children instead.
2nd Jun 2020, 12:27 PM
Calviղ
Calviղ - avatar