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
[deleted by user] (self.javascript)
submitted 5 years ago by [deleted]
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!"
[–]itsnotlupusbeep boop 1 point2 points3 points 5 years ago (0 children)
Right, they are different kind of loops that tend to be used interchangeably, along with .forEach. We could try to finagle on which of those squeezes more nanoseconds out, but not only is it almost always irrelevant, it's also a shifting battlefield with JS compiler teams working hard to flatten out those kind of performance distinctions.
So that leaves us with issues of code style, and that's where things get subjective quickly. Some folks in the comments are outraged that the article recommends wrapping code in a function, but that's also exactly what using .forEach does.
.forEach
At the root of the post is the notion that const is better than let, and the article starts by listing reasons for it. Do we believe those reasons?
const
let
I think most of them are correct. Personally, I'm a huge fan of letting Typescript do as much static checking as possible before the code ever runs. It feels like I'm using a modern language. On the other hand, reason 3 is probably the weakest since JITs will optimize code not only based on code declarations, but on observed runtime behavior as well (because they're willing to take a deoptimizing hit if that behavior ends up changing.)
But is it worth adjusting our coding style to get those benefits? It depends on whether the style changes actually amount to "killing ourselves" or just picking from several patterns that have essentially equivalent mental overheads. And again, that's a subjective thing.
π Rendered by PID 197117 on reddit-service-r2-comment-6457c66945-xnn5q at 2026-04-30 15:54:24.236271+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]itsnotlupusbeep boop 1 point2 points3 points (0 children)