DEV Community

Discussion on: What the heck is Currying anyway?

Collapse
 
devdufutur profile image
Rudy Nappée • Edited

Great explanation on a not so easy concept.

However you should always put the "point" (argument on which the partial application operates in the end) in the last position :

const isType = type => obj => obj.type === type;

This way you don't need to redefine functions, just :

const isFruit = isType("Fruit");
const isVegetable = isType("Vegetable");

Or write in a straightforward way :

const fruits = items.filter(isType('fruit'));
const vegetables = items.filter(isType('Vegetable'));
Collapse
 
thebuildguy profile image
Tulsi Prasad

Thanks for the great tip! I'll add this to the blog soon! 🤗

Collapse
 
thebuildguy profile image
Tulsi Prasad

Finally got some time to update the post with this. Thanks again, for sharing!