DEV Community

loading...

Discussion on: Higher-order functions & Why you should use them

Collapse
johnkazer profile image
John Kazer

Your final example is more-or-less currying, which would also be a useful next step. Also, rather than adding the first argument in the filter() call, you could set this up earlier and make the functions (possibly) even more re-usable:

const above10 = above(10);
const marksAboveTen = marks.filter(above10);
Enter fullscreen mode Exit fullscreen mode
Collapse
aminnairi profile image
Amin Author

Hi John and thanks for pointing that out!

Indeed currying has made its way out (in a shy way) in this example, I tried to keep the focus on higher-order functions for beginners but you are totally right and those topics are linked together. There is still plenty room for optimizations.

I'm glad that you brought that subject at light so that readers can check that out if they are curious. Unfortunately I would require an entire website if I were to speak about functional programming because this subject is really fun and interesting and full of good ideas and concepts!