What if one is using TypeScript?
Eloquent JavaScript 4th edition (2024)
101–110 of 249 posts
Re: Eloquent JavaScript 4th edition (2024)
#102How does this one compare as an all-in-one? Being up to date is a win, but I'm wondering about the quality of the writing.
Re: Eloquent JavaScript 4th edition (2024)
#103Earlier quoted context omitted.
It's a great explanation, but I've never heard the term 'binding' used to describe variables. It's usually reserved to function binding or bridge APIs like the DOM. The tricky thing is that "boxes" are the right abstraction for primitive values. After that you need to explain how references work, and that's pretty much the same 'tentacle' concept. This method spares the reader one step, but might cause confusion once…
"binding" is pretty standard terminology in some oldtimey languages; lisp, ML, etc.
The actual diagnostic itself is better educated:
$ set -u
$ asdasdf
$ echo $asdasdf
bash: asdasdf: unbound variableRe: Eloquent JavaScript 4th edition (2024)
#104I'm currently going through a hard copy of the book's third edition. But I'm wondering whether the description of the language in the book is detailed enough. Could you share some opinions on whether it will be good to go through some other JavaScript books after it? I'm considering going through "JavaScript: The Definitive Guide"[1] or "The Modern JavaScript Tutorial"[2] after it. [1] https://www.amazon.com/JavaScri…
Re: Eloquent JavaScript 4th edition (2024)
#105What's new in this edition?
Re: Eloquent JavaScript 4th edition (2024)
#106Earlier quoted context omitted.
I'm curious - could you expand on why it's a pitfall to think of variables as boxes?
Because that's not how variables work in JavaScript/Python etc (though it may be fine for say C++ in the case of value types and copy constructors). For example: I'm typing on phone so for a quick example: let a = []; let b = a; a.push(1); and consider the value of b now (or the fact that we could write "const" above because the binding is constant, even though we mutate the value). Or see the equivalent for Python b…
Also, does anyone have a link/reference to the place in the spec where it specifies this? I briefly skimmed through parts of [1] but couldn't find anything that says that JavaScript treats numbers this way.
Re: Eloquent JavaScript 4th edition (2024)
#107Someone asked about integer support in JavaScript. JS now supports BigInt! >2**57 144115188075855870 >2n**57n 144115188075855872n
Re: Eloquent JavaScript 4th edition (2024)
#108Earlier quoted context omitted.
Immutable variable isn't a oxymoron. It can still vary between instantiations. If you have (a)=>{const b = a}, b can have different values even though it can't be reassigned.
In the case of the code that you have cited, these are all different elaborations of the binding at the invocation of the lambda, due to the interplay between activation records and scope rules. It's not really an "immutable variable" - it's a local binding getting bound to different values on each scope entry. EDIT: By the way, the `b` binding in your code can be modified. Did you mean `const b = a;` ?
It is, I just wanted to point out that the term "immutable variable" is sensible. I think a good way to put it is that b is a variable, and when the statement runs a value is bound to b. So the value bound to b varies yet b can be immutable, in contrast to a constant which is a binding to always the same value.
> Did you mean `const b = a;` ?
Fixed, thanks :)
Re: Eloquent JavaScript 4th edition (2024)
#109Earlier quoted context omitted.
Because that's not how variables work in JavaScript/Python etc (though it may be fine for say C++ in the case of value types and copy constructors). For example: I'm typing on phone so for a quick example: let a = []; let b = a; a.push(1); and consider the value of b now (or the fact that we could write "const" above because the binding is constant, even though we mutate the value). Or see the equivalent for Python b…
I knew that in Python all variables are really references to objects (even when we're using a number) - is JavaScript the same way? Also, does anyone have a link/reference to the place in the spec where it specifies this? I briefly skimmed through parts of [1] but couldn't find anything that says that JavaScript treats numbers this way. [1] https://tc39.es/ecma262/multipage/#sec-intro