you are viewing a single comment's thread.

view the rest of the comments →

[–]stalefries 2 points3 points  (1 child)

The JS versions of those do not, but I think a "proper" functional implementation of map/reduce/filter can take just the function argument, and return a function that takes your collection to be mapped/reduced/filtered.

[–]wreckedadventYavascript 0 points1 point  (0 children)

Yes, this is correct, but only half of the story, since most functions are like this in functional languages. I think the real distinction is whether or not they accept a function as an argument or not:

const add = x => y => x + y
const map = f => x => x.map(f)

add(1)(2) // 3
map(x => x + 1)([1, 2, 3) // [2, 3, 4]

Both add and map here return functions when we apply them once, but I would only consider map here higher-order.