Javascript why using a NodeList instead of using an array

I read the document and did not fully understand the advantage of using NodeList.

Since it is like an array (I knew that it was not an array), what are the advantages of using a NodeList?

+5
source share
3 answers

NodeList is actually not a javascript construct for vanilla, as it is part of the DOM API. Just as the ecma specification will not include types such as [HtmlElement], it also does not mention NodeList.

Where you will find it in the World Wide Web Consortium (W3C) docs for the DOM api.

open NodeList interface

NodeList , . NodeList DOM .

( ) NodeList. , . , javascript.

NodeLists "" DOM. , - .

+2

NodeList, DOM . DOM , , , Array ? DOM , . , DOM API, , . DOM - .

, , Array NodeList . .

Array.prototype.map.call(nodeList, function (a, index) { ... });

"" NodeLists , NodeList API, . , NodeList DOM, , .

+2

Source: https://habr.com/ru/post/1526843/


All Articles