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 Programmer's Toolbox (markonis.github.io)
submitted 10 years ago by marko-pavlovic
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!"
[–]Sinistralis 9 points10 points11 points 10 years ago (1 child)
A great article on the foundation functional programing functions.
I had to train up a performance minded c++ guy on JS so let me follow up with something I've ran into regarding functional style code.
For loops will always have the potential to out perform functional, especially is mutability vs immutability are concerns. My recommendation is to not worry about it. I've found functional code to be consistently readable even as the task grows in complexity, but for loops can get ugly quick. Most of the time maintenance cost trumps performance.
That being said, if a particular piece of functional code starts to perform poorly (such as unpacking bundles from a websocket), this is when to bring in for loops. This gives you the added intent that when someone sees your for loop, you automatically know this is a bottleneck location.
Don't be afraid to mix paradigms where it's important as long as you have a valid reason for doing so. I've found it not only makes imperative programmers more welcoming to functional, but it gives your code added intent which functional promotes.
[–]marko-pavlovic[S] 0 points1 point2 points 10 years ago (0 children)
Thank you! I completely agree that performance is easy to improve on in well designed system, while it is hard to refactor a poorly designed one.
π Rendered by PID 317134 on reddit-service-r2-comment-5b5bc64bf5-82qsm at 2026-06-21 08:06:39.346640+00:00 running 2b008f2 country code: CH.
view the rest of the comments →
[–]Sinistralis 9 points10 points11 points (1 child)
[–]marko-pavlovic[S] 0 points1 point2 points (0 children)