4 ms·
Ask HN: Why does JavaScript use NodeList instead of Array?
This question is too speculative to ask on StackOverflow and indeed speculative answers is what I seek.
Why does JS use the concept of NodeLists and collection instead of simple arrays? The first thing everyone does with NodeList it to convert it to array. Sure, some NodeLists are "live", but not all of them and I have never used this property. IMHO it's an ugly paradigm that must be slowing down the DOM.
- mxstbr 12y agoQuoted from a thread on StackOverflow: "Because the DOM is designed to not depend on anything language specific. All types returned by the DOM API will be host types rather than native types. This allows the DOM to be language agnostic and not dependent on any specific language construct." [1] [1] https://stackoverflow.com/questions/21768551/javascript-why-use-nodelist-instead-of-using-array https://stackoverflow.com/questions/21768551/javascript-why-...
- dandare 12y agoty