by troupo · 1w ago · 0 comments
jQuery returned useful collections. DOM methods return an anemic NodeList which doesn't even implement Array interface.
var $$ = q => document.querySelectorall(q).values()
Then you have access to a bunch of iterator methodshttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
$ = (selector) => Array.from(document.querySelectorAll(selector))
Still not as good as the original, but somewhat usable at least :/ $('body').childNodes.forEach(console.log)
I see a beautiful collection thereVery beautiful.
BTW, browsers didn't even add forEach to it until several years after they added document.querySelectorAll lol
Edit. https://caniuse.com/?search=nodelist
NodeList appeared in 2006(Firefox) - 2008 (Safari) - 2010 (Chrome)
forEach on it appeared in... 2016.