DEV Community

Discussion on: DAY 2 of building the Higher Order Functions in javascript. the filter Higher Order Function.

Collapse
xtofl profile image
xtofl

In e.g. python, haskell, c#, ..., filter is conceived as a larger concept, applicable to all iterable objects.

That's why I prefer to stay more generic. It's a design goal you can choose for.

For small arrays, it's ok to return an array.

Thread Thread
emmanuelonah profile image
Emmanuel Onah Author

I really can't say about its usecase for other languages outside Javascript. But then in the context of javascript, i will give you a good example where you can best use it on the web. For example, when trying to handle a client side searching/sorting.... then rather than imperatively handling such operation its better to use the "filter prototype"(a declarative approach) because then the performance which you worry about is already considered by javascript to some extent.