4 ms·
> There are bugs caused by mutatable state. > There has never been a bug caused by reassigning a function local variable while leaving it mutable. The latter
by elyobo 7y ago
> There are bugs caused by mutatable state.
> There has never been a bug caused by reassigning a function local variable while leaving it mutable.
The latter _is_ mutable state. const doesn't prevent all mutations, but it does prevent some, while let prevents none. I'll take the limited protections of const (with awareness of its limitations; many examples of let are of confused devs trying to avoid making their objects immutable).