News for hackers. Stuff that matters.
Re:Cheatsheet for the modern JavaScript by K0nserv on Sunday October 01, 2017 @06:54AM (#15377256)
But the values are const? You just need to understand the implication of const in javascript.

Why would you choose to weaken the communication in your code by choosing `let` over `const` when you have no intention of reassign the value? `let` would just confuse the reader as they'd start anticipating the reassignment.

Compare:

```

// A variable containing an object that will not be reassigned

const a = { foo: 10};

// This is still valid

a.foo = 10;

```

vs

```

// A variable containing an object that might be reassigned.

let a = { foo: 10};

// This is still valid

a.foo = 10;

```

The first example says more about your intent and throwing that information away is a bad idea.

Re:Cheatsheet for the modern JavaScript by mbrock on Sunday October 01, 2017 @01:52PM (#15378910)
Let is a much nicer keyword though. It just reads better.

I almost never use variable mutation in JS, and I use let almost everywhere.

That lets me use the let/const distinction in a way that to me seems even more informative, namely to distinguish actual constants like "site base URL" or "pi".