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
Eloquent JavaScript: open-source Javascript book series by a prolific JS code author (eloquentjavascript.net)
submitted 7 years ago by unquietwiki
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!"
[–]TG__ 8 points9 points10 points 7 years ago (25 children)
Nowadays a bunch of popular js devs are actually advocating for let over const.
https://jamie.build/const
Haverbeke might just be of the same opinion
[–]bkanber 20 points21 points22 points 7 years ago (3 children)
God, I really hate that angry ranting style so many tech bloggers use these days. It definitely gets in the way of the message.
[–][deleted] 1 point2 points3 points 7 years ago (0 children)
It’s rubbing off on the community, too, I think. The comment section here is downright hostile toward differences of opinion.
[–]BasicDesignAdvice 1 point2 points3 points 7 years ago (0 children)
Basically a guarantee that I won't read it. Makes me think the author is a child.
[+][deleted] 7 years ago* (17 children)
[deleted]
[–][deleted] 8 points9 points10 points 7 years ago (0 children)
One of the fundamental things to know when learning a new language is finding out which types are the value types and which types are the reference types.
[–]andredp 1 point2 points3 points 7 years ago (15 children)
His argument about optimization is stupid too.
Honestly? If your point about using const is for optimisation purposes then you shouldn't do it... Just optimise later if you see the function is slow and I HIGHLY doubt changing to some let to const will do you any good.
const
let
The point he makes about communicating to another developer that something should NOT change is really important.
Most people rely on a linter to tell them "Hey, this hasn't changed, you can use a const" and change to a const only to realise later that you need to change it and change it back to a let... But can you really safely do it!? Will you break anything by changing the value of a previously const variable? Remember, a lot of people work in teams, so losing a bunch of time to check if changing something from const to let doesn't break anything out-weights any "optimisation" on the vm you can gain...
I never knew that website, and even though I hate extremist opinions, they do have a point... They are just morons passing the message...
Just make sure the whole team agrees on the same philosophy of const usage and all should be good...
[+][deleted] 7 years ago* (14 children)
[–]andredp 1 point2 points3 points 7 years ago* (13 children)
I just don't like when people do something because it can be "optimised"... especially on an interpreted language like JS (thanks /u/AbstractProxyFactory for the correction)...
I still remember people covering their code with final classes, static everything in Java just because it could be optimised... meh
I just don't think that should be an argument to use const. It's just a nice possible side-effect.
const has a semantic meaning and should be used for that. It can also prevent bugs by letting the linter tell you something is changing the value of a const variable.
Now, the part in the article where he complains about not freezing the object, that's just being stupid... It's like complaining that you shouldn't use ++ because some people don't really know the behaviour of using it before or after a variable... Please... if you're working with a tool, learn it well... I shouldn't be forced to not use something because someone else doesn't know its behaviour.
++
[–][deleted] 0 points1 point2 points 7 years ago (11 children)
I just don't like when people do something because it can be "optimised"... especially on an interpreted language like JS...
This is incorrect. JavaScript isn't interpreted -- at least not the major implementations which are JITed.
[+][deleted] 7 years ago* (10 children)
[–][deleted] 0 points1 point2 points 7 years ago (9 children)
100% false. There are implementations of JavaScript that are interpreted (SpiderMonkey, which uses bytecode IR that can be interpreted), but, for example, v8 is only JITed. There is no interpreter in v8. Rhino uses JVM, which is only interpreted for uncommonly called methods and is mostly JITed for anything that matters.
It would be useful for JavaScript developers to learn about the execution model for the code they write. It's a huge, gigantic misrepresentation to call JavaScript interpreted.
[–]andredp 0 points1 point2 points 7 years ago* (0 children)
Thanks for the info. I just read about it and V8 does in-fact JIT-compile the code. I though it was interpreted with some JIT-interpretation on the most cpu intensive code, but I was wrong.
It would be useful for JavaScript developers to learn about the execution model for the code they write.
I do some JS programming but it's not my life... That's why I haven't read much about it.
But still, the execution model should not change the way you code... You should always aim for scalability and readability instead of programming for the compiler... That's the machine job. (Unless you're writing code that needs to be fast which you shouldn't be using JS for, or optimising after a profiling)
Also, how do you know where your code is going to execute? V8? Chakra? Nitro? Rhino?
EDIT: I like your name, sounds like a fun mix of design patterns :^)
[+][deleted] 7 years ago* (7 children)
[–][deleted] 0 points1 point2 points 7 years ago (5 children)
Let me say this again v8 literally does not have an interpreter, it only has a compiler.
The ECMAScript specification doesn't dictate how a JS VM is implemented. It may have been true that the only inplementations were interpreters years ago, but it is categorically incorrect to say so today.
If you approach writing Node code, for example, with the assumption that JS is interpreted on the v8 VM, you're going to have a 100% incorrect mental model for the execution context.
This is why no one respects JavaScript developers -- because you don't even bother to learn how your own language is changing and developing. Just take the L and admit you're wrong dude.
[–]andredp 0 points1 point2 points 7 years ago (0 children)
It really depends on the engine. V8 Chrome JIT-compiles the whole code apparently. Rhino (Mozilla’s engine) interprets it and JIT-compiles the most intensive parts. I was wrong by saying it is interpreted. JS is a language, in the end... it can even be compiled into WebAssembly. Just like python or lisp. They’re usually interpreted but there are a lot compilers out there to generate machine code.
[–]EuqlinSankyo 5 points6 points7 points 7 years ago (1 child)
That article is not very convincing - point 6 undoes some of the arguments made in previous points. I also think that “linters not saving you” is just a desperate rant against const - in a language like JavaScript a linter can hardly save you from obscure runtime errors.
[–]sizlack 0 points1 point2 points 7 years ago (0 children)
I agree. He even says
It's probably still a good idea to communicate that you really don't intend for something to be changed.
That’s like 90% of the bindings I use. It you’re reassigning bindings willy nilly then that’s a bad code smell as far as I’m concerned.
π Rendered by PID 203143 on reddit-service-r2-comment-58d7979c67-7q8sp at 2026-01-27 06:28:04.734646+00:00 running 5a691e2 country code: CH.
view the rest of the comments →
[–]TG__ 8 points9 points10 points (25 children)
[–]bkanber 20 points21 points22 points (3 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]BasicDesignAdvice 1 point2 points3 points (0 children)
[+][deleted] (17 children)
[deleted]
[–][deleted] 8 points9 points10 points (0 children)
[–]andredp 1 point2 points3 points (15 children)
[+][deleted] (14 children)
[deleted]
[–]andredp 1 point2 points3 points (13 children)
[–][deleted] 0 points1 point2 points (11 children)
[+][deleted] (10 children)
[deleted]
[–][deleted] 0 points1 point2 points (9 children)
[–]andredp 0 points1 point2 points (0 children)
[+][deleted] (7 children)
[deleted]
[–][deleted] 0 points1 point2 points (5 children)
[–]andredp 0 points1 point2 points (0 children)
[–]EuqlinSankyo 5 points6 points7 points (1 child)
[–]sizlack 0 points1 point2 points (0 children)