Hacker News new | ask | show | jobs
by Cyberdog 11 days ago
querySelector/querySelectorAll() are great for plucking out deeply nested elements but if all you need is to find all elements of a certain class and the API gives you a tool to do exactly that, why not do that instead of reaching for the general-purpose Swiss army knife? Sure, the execution speed difference may be only measurable in microseconds, but it takes about the same amount of time to type so why not use the specific tool?
1 comments

This is the specific tool. Wrapping it in Array.from is the extra step.

The Array-like already works for forEach and for .. of