DEV Community

Discussion on: Currying in JavaScript

 
macsikora profile image
Pragmatic Maciej

Currying is not pattern. It is function property. In all FP languages functions are like that, so they are curried.

If you have function f: a ->b->c then by applying only a we have function g: b->c.

In JS as it's not FP language we need to make currying manually by using closures and returning function from function. It doesn't violate any purity as it is exactly FP concept.

Thread Thread
 
jwp profile image
John Peters

But has no value as far as I can tell.

Thread Thread
 
macsikora profile image
Pragmatic Maciej

If it would not have value it would not exists. It has huge value. But this answer would be worth a whole post about that ;)

Thread Thread
 
jesuscovam profile image
jesuscovam

maybe the second function would need a valued computed from the first function, so it could be use as a pipeline of computed values that are reusable and can be rearranged as legos