3 ms·
Mixing immutably with mutation (using let) seems weird to me. If you want to go immutable to make understanding your app easier then great, but use const throug
by Touche 11y ago
Mixing immutably with mutation (using let) seems weird to me. If you want to go immutable to make understanding your app easier then great, but use const throughout then.
- elros 11y agoWhy? `const` isn't that much immutable than `let` is. For any reference type that's bound to a variable with `const`, you can mutate it without getting errors. This was very confusing to me at first, even though I understand the mechanics behind it. const a = {} // That's OK: a.a = 1 // That's not OK: a = 1 While I don't disagree with you on your point, one could easily create the counter-point that by using `const` you're implying something that's not true.
- kansface 11y agoThe translation to C would be * const, not const *. Const is strictly better than let because it prevents a certain class of bugs - use it everywhere possible instead of let/var.