3 ms·
> Using const implies that the value will not change as the reference is immutable. Use let if the value will change. Lol, I love modern JS, but that’s factual
by earthboundkid 5y ago
> Using const implies that the value will not change as the reference is immutable. Use let if the value will change.
Lol, I love modern JS, but that’s factually wrong. Const means the variable cannot be reassigned in the same scope. It is 100% mutable though. It “implies” nothing. Indeed, one of the few good uses of const (it’s basically useless most of the time) is Vue’s composition API, where you want to prevent rebinding but actively mutate.
- pikelet 5y agoThe wording around the value 'changing' is a bit ambiguous, but otherwise you're basically agreeing with them: the reference is immutable (not the referenced data).