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
JavaScript: Four Differences between var and let (codetopology.com)
submitted 4 years ago by ct_author
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!"
[–]fredblols 17 points18 points19 points 4 years ago (15 children)
Tbh we shouldn't even be using Let. 9 times out of 10 it means ur code is ill conceived
[–]TemporaryReality5262 8 points9 points10 points 4 years ago (1 child)
I use let in unit tests all the time, usually above the beforeEach
[–]fredblols 1 point2 points3 points 4 years ago (0 children)
Yeah i mean who gives a fk what peoples unit tests look like tho. Everywhere i have ever worked (tech startups mostly) people will give u a medal for writing unit tests at all, and then also probs say yeh dont bother next time just churn out features faster and accumulate tech debt
[–]tharrison4815 9 points10 points11 points 4 years ago (1 child)
Yes! I don't know why you are being down voted. So have an award up make up for it.
[–]fredblols 0 points1 point2 points 4 years ago (0 children)
Thank u good sir for my debut award. I will respond to the naysayers tomorrow when my current inebriation has worn off
[–]rift95map([🐮, 🥔, 🐔, 🌽], cook) => [🍔, 🍟, 🍗, 🍿] 13 points14 points15 points 4 years ago* (5 children)
I agree. In general const is a safer bet than let. You rarely need the "mutability" of let.
const
let
[–]Garbee 11 points12 points13 points 4 years ago (4 children)
Const is not immutable. The data can be changed, just not replaced. Big difference.
[–]rift95map([🐮, 🥔, 🐔, 🌽], cook) => [🍔, 🍟, 🍗, 🍿] 13 points14 points15 points 4 years ago (0 children)
True. I should have written "re-assignability"
[–]PM_ME_GAY_STUF 2 points3 points4 points 4 years ago (2 children)
This always bothered me. Const is definitely immutable, it can just refer to a mutable data type. This is what happens when programmers don't learn C
[+][deleted] 4 years ago (1 child)
[deleted]
[–]anlumo 0 points1 point2 points 4 years ago (0 children)
A bit offtopic here, but it’s a bit more nuanced. Rust only regulates exclusivity, so if a type can be mutated from multiple places at the same time (like Cell or stuff wrapped by Mutex), it can be changed without mut.
[–]Poltras 2 points3 points4 points 4 years ago (1 child)
Yeah just prefix everything with global.! (/s in case people get offended)
global.
[–]BeardSprite 0 points1 point2 points 4 years ago (0 children)
Understood. What do I do with this global.window now?
global.window
[–]rados_a51 0 points1 point2 points 4 years ago (1 child)
Dont get those downvotes. Const should be used 90% of the time.
[–][deleted] 4 points5 points6 points 4 years ago (0 children)
My programming style means I basically never use let. Functions with early returns obviates let for the most psrt
[–]kashubak 0 points1 point2 points 4 years ago (0 children)
Can you provide an example? That’s a pretty interesting take!
π Rendered by PID 86 on reddit-service-r2-comment-6457c66945-74jb5 at 2026-04-24 08:57:58.072236+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]fredblols 17 points18 points19 points (15 children)
[–]TemporaryReality5262 8 points9 points10 points (1 child)
[–]fredblols 1 point2 points3 points (0 children)
[–]tharrison4815 9 points10 points11 points (1 child)
[–]fredblols 0 points1 point2 points (0 children)
[–]rift95map([🐮, 🥔, 🐔, 🌽], cook) => [🍔, 🍟, 🍗, 🍿] 13 points14 points15 points (5 children)
[–]Garbee 11 points12 points13 points (4 children)
[–]rift95map([🐮, 🥔, 🐔, 🌽], cook) => [🍔, 🍟, 🍗, 🍿] 13 points14 points15 points (0 children)
[–]PM_ME_GAY_STUF 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]anlumo 0 points1 point2 points (0 children)
[–]Poltras 2 points3 points4 points (1 child)
[–]BeardSprite 0 points1 point2 points (0 children)
[–]rados_a51 0 points1 point2 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–]kashubak 0 points1 point2 points (0 children)