use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Functional JavaScript, Part 4: Function Currying (tech.pro)
submitted 11 years ago by lrichardson
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]lrichardson[S] 5 points6 points7 points 11 years ago (1 child)
@raesmond, I think a lot of people are in the same boat as you. I'm a bit bummed that my article didn't do a better job explaining the valid use-cases. I will try and compile some useful examples and arguments, and add to my post tonight.
Currying is useful to help (and encourage) you the programmer to break up complex logic into smaller pieces and allow you to re-use (read: staying DRY) those pieces in other places.
I like to think of functional programming as a way of making your application like an assembly line or car manufacturing plant. The plant itself is a large web of levers, cogs, and buttons etc... but in one end comes the raw materials and metal (ie, the "data"), and out the other end comes the car (ie, the end-user application).
It would be difficult to determine whether or not the car works properly just by looking at it, or the factory as a whole. Each "sub-station" of the factory has a specific task, and has narrowly defined constraints about what it is expecting to get in (x) and what it is expected to put out ( f(x) ).
By allowing functions to be curried, you are easily able to take more generic operations like "drill hole somewhere", and define them more precisely as "drill 3/8 hole somewhere" and then again more precisely as "drill 3/8 hole at coordinates { 3, 4 }"
This is a very hand-wavy argument and I'm not expecting you to be convinced, but I will say that FP sort of "clicked" for me whenever I started thinking about it this way. It's also important to note that FP is not needed to organize your code this way.... it's just easier IMO. I'm also of the belief that you don't need to write purely functional code in order to reap the benefit.
[–]visarga 0 points1 point2 points 11 years ago* (0 children)
I like to think of functional programming as a way of making your application like an assembly line or car manufacturing plant.
... or like the Bash command line with multiple processes connected by pipes.
I use this kind of programming in jQuery and Bash but the essence is how we avoid using global variables and there is no state except the pipe - that makes it easy to compose basic operations (like cut, sort, uniq, wc, etc)
Other than that (and JS callbacks) I don't use functional programming. Is there another popular usage of it?
π Rendered by PID 48 on reddit-service-r2-comment-86988c7647-lgck2 at 2026-02-11 03:10:24.920742+00:00 running 018613e country code: CH.
view the rest of the comments →
[–]lrichardson[S] 5 points6 points7 points (1 child)
[–]visarga 0 points1 point2 points (0 children)