6 ms·
Why the arrow? That works just fine with a dot. let names = document.querySelectorAll('.entry') .sortBy('title')
by danbruc 11y ago
Why the arrow? That works just fine with a dot.
let names = document.querySelectorAll('.entry')
.sortBy('title')
.filter(entry => entry.getAttribute('data-url') in whitelist)
.map(entry => entry.getAttribute('name');
- wycats 11y agoOnly if those methods are added to NodeList, which they haven't been. (and of course 'sortBy' is nonstandard)
- danbruc 11y agoOf course, but you can extend the underlying type. But I can see why you wouldn't want to do that over and over for all collection types. There is probably a tradeoff between reusing the established dot syntax and having a different syntax to be explicit about invoking a non-member function.