More declarative and convenient functions than in Array.prototype

Why javascript map, filter and reduce, do not work like this ? :cold_sweat:

The Array.prototype methods are the fundamental methods, from which you can build higher abstractions, such as what you have demo’d there.

1 Like

fp-array is a group of functions to do declarative programming in a more convenient way than in Array.prototype

I think both of these posts are related.

The Array.prototype map, filter and reduce methods take a callback as an argument.

By having callback not be predefined the callback can be whatever the programmer writes it to be.

IMHO it is debatable whether or not having convenience at the expense of flexibility is worth it. But I can understand where some might value the convenience.

Is it really all that different?



My thoughts exactly. I don’t really see the purpose of that fp-array overhead TBH… and with the native functional approach you can pipe the result from any Array method to the next, not only chain methods of the same kind. Such as

const arr = [1, 2, 'foo', null, 3]


I suppose it’s more of a fun project or so. :-)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.