by coredev_ · 2w ago · 0 comments
There is a ton of stuff you can do now with JS directly that JQuery had to compensate for, that's why GitHub spent the effort to move off of JQ years ago.
CSS and JS has come a long way. I will even venture out to say that UI development does not suck these days, it's even a little enjoyable. You no longer have to spend 3 hours vertically aligning text in a div and then test it in four different browsers.
$ = (q) => document.querySelector(q)
and $$ = (q) => document.querySelectorAll(q)
and you're good to gojQuery 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 there