4 ms·
may I ask what's the point of `const tagNames =`? removing it would make no difference, as far as I can tell - just make sure the previous line ends with a semi
by 123yawaworht456 2y ago
may I ask what's the point of `const tagNames =`? removing it would make no difference, as far as I can tell - just make sure the previous line ends with a semicolon (or add it at the same line as the opening square bracket)
- hoten 2y agoWell, it's polluting the global window scope with all those helpers. That's a reason to never use this imo. There are plenty of other jquery-lite helper libraries out there. 95 percent the utility with hardly any cost in terms of script size. Converting querySelectorAll to an array is honestly most of the benefit of these libraries.
- spankalee 2y ago> Converting querySelectorAll to an array is honestly most of the benefit of these libraries. Now that NodeList is iterable, I don't even know that converting to an array is that useful anymore. [...document.querySelector('div')] is pretty easy. Iterator.from(document.querySelector('div')) too (doesn't work yet in Safari).
- xPaw 2y agoYou don't need to convert querySelectorAll to an array, you can directly iterate it, or use forEach.
- meow_catrix 2y agoNot if you want to map or reduce it.
- smusamashah 2y agoYes, exactly. The first two statements have no use in the last two lines that this library is for. Or may be I don't understand Javascript much.