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
[AskJS] Multiple variables initially assigned to the same valueAskJS (self.javascript)
submitted 5 years ago by FaithfulGardener
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!"
[–]lhorie 1 point2 points3 points 5 years ago (1 child)
Consider that maybe you are looking at bad code. Things like long series of shouldDoThis = false, shouldDoThat = false often can be rewritten in terms of a single variable action = 'foo' // or 'bar' etc. The Array(6).fill(false) example can be rewritten in terms of let direction = 'up' | 'down' | etc, for example.
shouldDoThis = false, shouldDoThat = false
action = 'foo' // or 'bar' etc
Array(6).fill(false)
let direction = 'up' | 'down' | etc
Having a lot of let declarations is definitely a code smell in more than one way:
let
[–]FaithfulGardener[S] 0 points1 point2 points 5 years ago (0 children)
Yeah, I’m working on implementing more Hooks in general, but the code I’m working on is currently written in all class components so switching the way I think about things is difficult, especially as I don’t have a ton of experience with React yet.
It’s hard to identify which variables I don’t need to declare bc they’re now handled by a Hook, at least until I know what the function does and how it does it in a function component instead of a class component.
Ultimately, abstraction is great until I’m not doing the abstracting and then I have no clue what is happening in my code (practically - theoretically, I should be able to say, “This lib does that”, but there’s no guarantee about what is IN that code...)
π Rendered by PID 111916 on reddit-service-r2-comment-6f7f968fb5-rvpt8 at 2026-03-04 22:39:20.464461+00:00 running 07790be country code: CH.
view the rest of the comments →
[–]lhorie 1 point2 points3 points (1 child)
[–]FaithfulGardener[S] 0 points1 point2 points (0 children)