DEV Community

Discussion on: Currying in JavaScript

Collapse
lonelymoon profile image
Hung Luong

Honestly speaking, I see the b => a => a * b pattern to be needlessly terse. Very rarely do I see that pattern (and sometimes, currying itself) serve any practical purpose other than trying to appear "functional". Just my 2c though, to each their own.

Collapse
lukeshiru profile image
LUKESHIRU • 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.