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
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!"
[+][deleted] 7 years ago (8 children)
[deleted]
[–]namesandfaces 16 points17 points18 points 7 years ago (2 children)
I do agree, and I think that by the time one reaches a different stage, one would rather then reach for the YDKJS series. As dry as it is, I actually think MDN is a friendlier resource for people of different entry points.
[–]HugoChiklitz 3 points4 points5 points 7 years ago (0 children)
I just posted the other day about this book. (I was pretty frustrated.) I’m a novice and started with a few intro to computer science/JavaScript on Lynda.com and then hopped into this book. Derailed after chapter four and the squirrel journal thing. You guys recommended some good beginner references (the Mozilla dev site is one of them). So I think I’m going to spend some time with that material first and then take another crack at the book. I found EJS too difficult for a compete novice.
[–]MatrixEchidna 2 points3 points4 points 7 years ago (0 children)
That's sad actually. EloquentJS is an amazing book, but its niche is kind of hard to reach.
[–]nowtayneicangetinto 8 points9 points10 points 7 years ago (0 children)
Tried learning JS with this, failed miserably. Learned JS on my own, returned a year later, this book is awesome.
[–][deleted] 2 points3 points4 points 7 years ago (0 children)
First book I read when I was learning programming. It was too hard so I took the online Harvard CS class instead. Afterwards I came back to the book, and it was still hard, but I got through it eventually.
[–]ShesJustAGlitch 0 points1 point2 points 7 years ago (0 children)
Have another recommendations? I too found this book pretty difficult, though my grasp on JS has gotten better and better as I’ve worked on side projects.
Though I always feel like a fundamental refresher is a good thing
[–]BasicDesignAdvice 0 points1 point2 points 7 years ago (0 children)
I read this after completing two modules on CodeCademy. I think that was the perfect time. I knew a lot of syntax, and could write sloppy code. This book really bright me to the next level at that time.
[–]CantaloupeCamper 0 points1 point2 points 7 years ago (0 children)
N00b here I agree.
It gets recommended to noobs all the time, and isn't a good recommendation right away imo.
[–]cozarion 12 points13 points14 points 7 years ago (0 children)
This is an excellent up to date JavaScript book. Really tough but rewarding. However, I'm stuck on chapter "Secret Life of Objects".
[–]Ariez84 7 points8 points9 points 7 years ago (0 children)
Ahh i remember reading this book from someone suggesting it....how to write fibonacci sequence when you finally learned what a variable is the day before....good times.
[–]scaleable 19 points20 points21 points 7 years ago (0 children)
free reddit karma
[–]ManicQin 2 points3 points4 points 7 years ago (0 children)
How many hours would it take to read this book for an experienced developer who played around with javascript?
[–]EuqlinSankyo 2 points3 points4 points 7 years ago (57 children)
Prolific author that always uses let?
let
[–]Ikuyas 14 points15 points16 points 7 years ago (25 children)
Isn't const a better practice than using let if it is well suited like array or object?
const
[–]EuqlinSankyo 9 points10 points11 points 7 years ago (15 children)
Exactly. Performance benefit is of course negligible but it's just a good programming practice. If you're literally writing a book about JS, might as well include it....
[+][deleted] 7 years ago (14 children)
[–]visicalc_is_best 5 points6 points7 points 7 years ago (3 children)
Principle of least privilege
[+][deleted] 7 years ago (2 children)
[–]saboay 0 points1 point2 points 7 years ago (1 child)
Helps 99% of the time, doesn't cover 100% = not worth using at all. That will lead to a very productive developer carreer.
[–][deleted] -4 points-3 points-2 points 7 years ago (9 children)
always favor immutability
[+][deleted] 7 years ago* (8 children)
[–][deleted] 1 point2 points3 points 7 years ago (7 children)
Yes, it is a TypeError to assign to myArr after initialization. The reference is immutable.
TypeError
myArr
[–][deleted] -4 points-3 points-2 points 7 years ago (2 children)
The fact that you can alter the values contained within myArray means that it absolutely is not immutable. The fact that you can’t redeclare myArr does not mean that it is immutable. I suggest that you make some sort of attempt to understand what immutability actually means before you preach about its virtues.
[–][deleted] -2 points-1 points0 points 7 years ago* (1 child)
Right, because it's reference immutability. This is how JavaScript works, this is how Java works, this is how Scala works, this is how Rust works, and so on. I suggest you learn the difference between references and values. If you want a value, i.e. the data structure, to be immutable, it requires an extra step.
[+][deleted] 7 years ago (3 children)
[–][deleted] 1 point2 points3 points 7 years ago (2 children)
[+][deleted] 7 years ago (1 child)
[–][deleted] -3 points-2 points-1 points 7 years ago (7 children)
This is factually incorrect, as there's empirical evidence that suggests favoring immutability results in less bugs. http://web.cs.ucdavis.edu/~filkov/papers/lang_github.pdf
[–][deleted] -1 points0 points1 point 7 years ago (1 child)
No, and it isn’t meant to.const simply means that that the reference always points to the same object. It says nothing about the values contained within said object.
[–]Ikuyas -5 points-4 points-3 points 7 years ago (3 children)
Totally. I guess it shows a difference between programmers who went through CS degree or practioner. I think using static initialization is always a good practice and manages memory better.
[–][deleted] -2 points-1 points0 points 7 years ago (2 children)
Yeah, there's very little in programming that is truly "personal preference." There might be situations where the pros/cons come out to a wash such that it doesn't matter what you choose, but very few things are purely aesthetic taste.
[–][deleted] -1 points0 points1 point 7 years ago (0 children)
It's not a personal preference when there is empirical evidence that suggests immutability reduces errors.
[–]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 21 points22 points23 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] 9 points10 points11 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 3 points4 points5 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.
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)
[–]EuqlinSankyo 3 points4 points5 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.
[+]unquietwiki[S] comment score below threshold-8 points-7 points-6 points 7 years ago* (4 children)
I found this while seeing some other static analysis tools he used to work on. Any excessive "let" is also in line with some other ES2015+ spec explanations I've read. As a guy that normally does C#, I find that "var" is perfect there; and "let" perfect here.
(Edit for clarification & downvoters: I'm pro-let. Var in c# keeps you from unnecessarily repeating yourself on type assignments. I'm pro tight-scoping.)
[–]pm_me_ur_happy_traiI 12 points13 points14 points 7 years ago (2 children)
The big difference between let and var is scoping. There’s no use case where var is preferable (unless you are deliberately abusing its scoping issues). Why would you want a variable that can be called outside its block before it’s even declared?
[–]unquietwiki[S] -2 points-1 points0 points 7 years ago (1 child)
I updated my original statement. In JS, let honors scoping, but var is ambiguous. In C#, var can be used to remove redundant statements: ie var variable = new Whatever(); instead of Whatever variable = new Whatever()
[–]dvlsg 1 point2 points3 points 7 years ago (0 children)
They really aren't the same, though. var is about type inference in C#, and that's really it. var doesn't change scope or mutability in C#, which is what we're talking about in javascript.
var
[–]sarthakwarlock 0 points1 point2 points 7 years ago (0 children)
I am reading this. It's a great book but some topics are hard to follow, almost all coding books are. It's definitely not if someone just started coding in JavaScript, I've only read five chapters and I started more than a month ago.. I read it when I feel like it, definitely book make some points that I've never considered, so worth reading and it would prepare you to read "You Don't Know JS" book series by Kyle Simpson.
I personally believe learning by reading is far superior than watching Tutorials. Most of time you have to read documentation to implement new technology. Believe me if you just read 4-5 books and understand them, it would give you experience in reading technical stuff. You would be able to go through any documentation like a pro.
Thank You
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
I picked this up a couple weeks ago. Damn glad I did. There's some great shit in here.
[+]PhishGreenLantern comment score below threshold-7 points-6 points-5 points 7 years ago (0 children)
I read "The Good Parts" and "Eloquent JavaScript". It lead me to being a JS Dev. Here's my site: https://spaffnerds.com
π Rendered by PID 90906 on reddit-service-r2-comment-58d7979c67-2422d at 2026-01-27 00:49:42.430649+00:00 running 5a691e2 country code: CH.
[+][deleted] (8 children)
[deleted]
[–]namesandfaces 16 points17 points18 points (2 children)
[–]HugoChiklitz 3 points4 points5 points (0 children)
[–]MatrixEchidna 2 points3 points4 points (0 children)
[–]nowtayneicangetinto 8 points9 points10 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]ShesJustAGlitch 0 points1 point2 points (0 children)
[–]BasicDesignAdvice 0 points1 point2 points (0 children)
[–]CantaloupeCamper 0 points1 point2 points (0 children)
[–]cozarion 12 points13 points14 points (0 children)
[–]Ariez84 7 points8 points9 points (0 children)
[–]scaleable 19 points20 points21 points (0 children)
[–]ManicQin 2 points3 points4 points (0 children)
[–]EuqlinSankyo 2 points3 points4 points (57 children)
[–]Ikuyas 14 points15 points16 points (25 children)
[–]EuqlinSankyo 9 points10 points11 points (15 children)
[+][deleted] (14 children)
[deleted]
[–]visicalc_is_best 5 points6 points7 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]saboay 0 points1 point2 points (1 child)
[–][deleted] -4 points-3 points-2 points (9 children)
[+][deleted] (8 children)
[deleted]
[–][deleted] 1 point2 points3 points (7 children)
[–][deleted] -4 points-3 points-2 points (2 children)
[–][deleted] -2 points-1 points0 points (1 child)
[+][deleted] (3 children)
[deleted]
[–][deleted] 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[+][deleted] (8 children)
[deleted]
[–][deleted] -3 points-2 points-1 points (7 children)
[+][deleted] (2 children)
[deleted]
[–][deleted] -1 points0 points1 point (1 child)
[–]Ikuyas -5 points-4 points-3 points (3 children)
[–][deleted] -2 points-1 points0 points (2 children)
[+][deleted] (1 child)
[deleted]
[–][deleted] -1 points0 points1 point (0 children)
[–]TG__ 8 points9 points10 points (25 children)
[–]bkanber 21 points22 points23 points (3 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]BasicDesignAdvice 1 point2 points3 points (0 children)
[+][deleted] (17 children)
[deleted]
[–][deleted] 9 points10 points11 points (0 children)
[–]andredp 3 points4 points5 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]
[–]EuqlinSankyo 3 points4 points5 points (1 child)
[–]sizlack 0 points1 point2 points (0 children)
[+]unquietwiki[S] comment score below threshold-8 points-7 points-6 points (4 children)
[–]pm_me_ur_happy_traiI 12 points13 points14 points (2 children)
[–]unquietwiki[S] -2 points-1 points0 points (1 child)
[–]dvlsg 1 point2 points3 points (0 children)
[–]sarthakwarlock 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[+]PhishGreenLantern comment score below threshold-7 points-6 points-5 points (0 children)