DEV Community


Discussion on: Currying in JavaScript

lukeshiru profile image
△ LUKE知る • Edited

Ideally that a and that b should have more significant names like:

const multiply = multiplier => multiplicand => multiplicand * multiplier;
Enter fullscreen mode Exit fullscreen mode

But having less boilerplate code (no function, no return, no curly braces) makes it far easier to read.

Thread Thread
lonelymoon profile image
Hung Luong

I understand, but variable naming was not my concern. The point is that most of the time this pattern is just used for the sake of currying itself i.e a => b => c => //imperative code with a, b and c anyway. In which case it's only easy to write, not read - a reader (like me) can be left with "yes but why??"

It's already arguable that we need both multiply and multiplyByTwo. Surely there are valid use cases out there, especially in term of function factories, I just don't see many of them in my experience.