News for hackers. Stuff that matters.
Re:JavaScript async/await implemented in V8 by bb85 on Monday May 16, 2016 @10:02PM (#11710919)
The great thing about let and const, for me, is that it gives you crucial information about variables without having to look further down.

const should be the default, and if you're going to reassign it, then use let.

In most code, you'll use const on the vast majority of variables, and it'll make let assignments stick out, which helps a lot when you're browsing the code or refactoring.

Re:JavaScript async/await implemented in V8 by spraak on Tuesday May 17, 2016 @04:15AM (#11711996)
This right here. One of my friends (a more experienced developer) told me at coffee one day, "I use const for everything" which really stuck with me. It really helps make it clear if you need a mutation to have let stand out.
Re:JavaScript async/await implemented in V8 by rpastuszak on Tuesday May 17, 2016 @05:42AM (#11712287)
However, it's worth noting that using const doesn't make variables immutable. It only protects them of being reassigned:

const val = 'a'; val = 'b'; // TypeError

const obj = { val: 'a' }; obj.val = 'b'; // This line will still work.

obj = { val: 'b' }; // TypeError

Re:JavaScript async/await implemented in V8 by dcherman on Tuesday May 17, 2016 @10:41AM (#11714027)
Yep. In those cases, I still prefer let personally even though I know the variable itself will not be re-assigned, kind of as an indicator that I expect the referenced object to be mutated.
Re:JavaScript async/await implemented in V8 by candu on Tuesday May 17, 2016 @11:18AM (#11714353)
Coming from a background that includes some experience with C / C++, `const` here works as I expect it to. I'd prefer `const` even for the object reference case: I get errors on reassignment this way, and presumably it makes additional optimizations possible. To each their own, I suppose :)

There's also `Object.defineProperty()`, `Object.freeze()` for more control over mutability.

Re:JavaScript async/await implemented in V8 by WorldMaker on Tuesday May 17, 2016 @11:55AM (#11714657)
I just wish let was in fact const (and something like "local" could be let), simply because the keyword let is nicer to type, easier to read, and more importantly better in line with the meaning of let in Lisp/Scheme/ML/OCaml/et al.
Re:JavaScript async/await implemented in V8 by spraak on Tuesday May 17, 2016 @02:07PM (#11715871)
Yeah, I was thinking the same! I was even considering writing a custom babel transform to do this for me :P