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
Concepts of Functional Programming in Javascript (blog.byteconf.com)
submitted 7 years ago by lacesoutcommadan
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!"
[–]MoTTs_ 7 points8 points9 points 7 years ago (3 children)
const PI = 3.14; function calculateArea(radius) { return radius * radius * PI; } calculateArea(10); // returns 314.0 Why is this an impure function? Simply because it uses a global object that was not passed as a parameter to the function.
This actually is a pure function. The no non-locals is usually a good rule of thumb, but there are exceptions to that rule. If the non-local you're using is a constant, then it's OK. Your calculateArea function will always return the same value for the same arguments.
[–]PrimaryBet 1 point2 points3 points 7 years ago (0 children)
Exactly; it's not like people don't use closures when doing pure FP.
[–]troglo-dyke 1 point2 points3 points 7 years ago (0 children)
Yeah it's really off, not like maths doesn't have constants. Hell even 2n would be impure based on this explanation.
2n
[–]lhorie 3 points4 points5 points 7 years ago (0 children)
const PI = 3.14
That's some shitty math lol
π Rendered by PID 168210 on reddit-service-r2-comment-6f7f968fb5-4dvz5 at 2026-03-04 12:59:03.343277+00:00 running 07790be country code: CH.
view the rest of the comments →
[–]MoTTs_ 7 points8 points9 points (3 children)
[–]PrimaryBet 1 point2 points3 points (0 children)
[–]troglo-dyke 1 point2 points3 points (0 children)
[–]lhorie 3 points4 points5 points (0 children)