const $ = _ => document.querySelector(_)
Pretty well sums up the state of jQuery in 2019 (almost 2020!)
const $ = _ => document.querySelector(_)
Pretty well sums up the state of jQuery in 2019 (almost 2020!)
Ok, you will say, but you can always do
[... document.querySelectorAll('.foo .bar')].map(it => it.style.backgroundColor = 'corn');
instead of $('.foo .bar').css('backgroundColor', 'corn');
and it is clearly better because it does not use jQuery.
Don't get me wrong, jQuery has many issues that make it a very poor choice for big modern web applications, but please don't tell me that it can be replaced by querySelectorAll.
I didn't, and it can't -- my comment was merely to suggest that jQuery is now a shell of its old self, thanks largely to the improvement of browser DOM APIs.
I'd also probably recommend using Array.from instead of a spread (for clarity) but less concerned about that part.
Btw, querySelectorAll() to match multiple elements.
* IE partial until 2011
$ = function(_) { return document.querySelector(_) }
It basically turns `$` into an alias for `document.querySelector`. I'm not sure that it's any different from:
$ = document.querySelector
https://www.taniarascia.com/this-bind-call-apply-javascript/
For this specific case, you can see this at https://stackoverflow.com/q/13383886/8334056
$ = document.querySelector.bind(document);