by indocomsoft · 7y ago · 0 comments
Array.prototype.filter.call(document.querySelectorAll(selector), filterFn);
What's more idiomatic is document.querySelectorAll(selector).filter(filterFn)
The same holds for forEach.
I suggest you look into how javascript prototype based OOP works
This is why people convert it to an array, and one of many reasons the standard JS API (and the DOM one in particular) are annoying to work with.
[...document.querySelectorAll(selector)].filter(filterFn);If anything isn't that code _less_ idiomatic in that it's less specific to JS and more of a generic operation?