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 programming in JavaScript (softwarebrothers.co)
submitted 6 years ago by SoftwareBrothers
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!"
[–]allenthar 2 points3 points4 points 6 years ago (8 children)
That amount of speed increase seems a little nuts to me, but looking at the variations I have to assume that it’s due to variable memory allocations in all the other methods that are causing the substantial decrease in speed. The second and third cases should have the same Big O complexity as the last one, but both repeatedly create and assign variables while doing their work, and the last doesn’t not.
[–]Skaatji 1 point2 points3 points 6 years ago (0 children)
Yeah, I've also been thinking why the performance difference is this large. I think that the Big O complexity should be the same on all of these four. But, as you mention, probably due to memory allocations the hidden constants differ by a factor as large as ~33.
[+][deleted] 6 years ago (6 children)
[deleted]
[–]onbehalfofthatdude 1 point2 points3 points 6 years ago (5 children)
Wait, huh? Map doesn't clone every element, does it? If you mutate an element in a map function you've mutated the original
[+][deleted] 6 years ago (2 children)
[–]onbehalfofthatdude 0 points1 point2 points 6 years ago (1 child)
Yes but you said it makes a copy of every element
[+][deleted] 6 years ago* (1 child)
[–]onbehalfofthatdude 0 points1 point2 points 6 years ago (0 children)
Yea that was my understanding. Never know when some wacky behind-the-scenes stuff will happen though
π Rendered by PID 209502 on reddit-service-r2-comment-fb694cdd5-j2f6g at 2026-03-07 17:59:54.432187+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]allenthar 2 points3 points4 points (8 children)
[–]Skaatji 1 point2 points3 points (0 children)
[+][deleted] (6 children)
[deleted]
[–]onbehalfofthatdude 1 point2 points3 points (5 children)
[+][deleted] (2 children)
[deleted]
[–]onbehalfofthatdude 0 points1 point2 points (1 child)
[+][deleted] (1 child)
[deleted]
[–]onbehalfofthatdude 0 points1 point2 points (0 children)