4 ms·
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
by K0nserv 9y ago
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.
- mbrock 9y agoLet 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".