4 ms·
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 gi
by Cyberdog 2mo 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?
- silverlimetea 2mo agoThis is the specific tool. Wrapping it in Array.from is the extra step. The Array-like already works for forEach and for .. of