Seems to just be just shorthand for querySelector / querySelectorAll for those that like the jQuery style syntax. And then the ability to use forEach and map on NodeList elements.
It's a neat little snippet for those that want that, but other than that, makes really no difference.
There's a point to using this: it's a nice little convenience that a lot of people like about jQuery's style that requires no dependencies, can be copied & pasted without introducing a blob of possibly fragile code, and should have basically zero impact on performance. Try thinking of it as an idiom instead of a library. If you honestly think that all syntax that can be described as shorthand has no point you're missing a lot of expressiveness. That attitude tends to lead to littering code with the kind of laboriously spelled out replacements for the standard library that someone new to a language is prone to.
Is your background mainly Java or perhaps K&R-era C? I can understand how coming from that you might not be used to the little convenient tweaks you can make to a more dynamic language.
Yep, it's just shorthand. It's something I've been using in some projects recently as an alternative to something like jQuery, so I thought it would be useful in some sense to share it!
I guess this is just stemming from my view that a huge library like jQuery isn't necessarily needed anymore, now that most browsers support things like a good native API for DOM manipulation and traversal.
5 comments
[ 3.5 ms ] story [ 21.3 ms ] threadIt's a neat little snippet for those that want that, but other than that, makes really no difference.
Is your background mainly Java or perhaps K&R-era C? I can understand how coming from that you might not be used to the little convenient tweaks you can make to a more dynamic language.
I guess this is just stemming from my view that a huge library like jQuery isn't necessarily needed anymore, now that most browsers support things like a good native API for DOM manipulation and traversal.