4 ms·
I don't really know what to think about that. On one hand it may be a nice way to show to people that what they use in jQuery can be written in a few lines of
by eloisant 11y ago
I don't really know what to think about that.
On one hand it may be a nice way to show to people that what they use in jQuery can be written in a few lines of pure JS.
On the other hand it encourages people who could use pure JS (because they only use a small portion of jQuery) to stick with some non-standard helper syntax.
- andybak 11y ago> to stick with some non-standard helper syntax. Or in other words - replacing an ugly, verbose API with a widely recognised alternate syntax!
- anton-107 11y agoYes "document.querySelectorAll(selector)" is a bit verbose, but jQuery API is no better, do you know what would "$(selector)" actually do? You can't - it depends on what "selector" is.
- yakshaving_jgt 11y ago> "document.querySelectorAll(selector)" is a bit verbose Right. 35 characters. > "…but jQuery API is no better" Your jQuery example is 11 characters. I can’t believe you’re using verbosity as a measurement, while at the same time claiming 35 and 11 are the same. Does. Not. Compute.
- anton-107 11y agoSorry for confusion, what i meant was: yes DOM API is a bit verbose, but jQuery is exactly the opposite in a bad sense: it's using too few words to express too many different things.
- Akkuma 11y agojQuery uses CSS selectors, which is fairly clear if you have a general understanding of them.
- anton-107 11y agoSo does querySelectorAll, that's not the issue with jQuery API. The problem is that "jQuery" function, aliased as "$" has 9 signatures (doing 9 different things, depending on which arguments you send to it), while querySelectorAll does only one thing