News for hackers. Stuff that matters.
Re:You might not need jQuery (2014) by porker on Thursday January 14, 2021 @04:38AM (#25774192)
> With modern JavaScript you can easily cast a NodeList to an Array, e.g.

Ah, thanks. I got bitten by this recently and didn't know what to do with this "thing that's not an array but seems like it should be, and doesn't always behave like one"

Re:You might not need jQuery (2014) by nicoburns on Thursday January 14, 2021 @05:51AM (#25774869)
FYI the reason it's not an array is because if you store a reference to it, it will stay up to date as and when the DOM changes.
Re:You might not need jQuery (2014) by jarek-foksa on Thursday January 14, 2021 @08:12AM (#25775897)
The NodeList returned by querySelectorAll() is not live. There is really no reason for it to return a NodeList other than backward compatibility.
Re:You might not need jQuery (2014) by spiralx on Thursday January 14, 2021 @06:54AM (#25775310)
Before that ES2015 allowed you to do Array.from(nodeList, mapFunc?) which I still use due to the optional mapping function e.g. Array.from(document.querySelectorAll('a'), a => a.href)