3 ms·
I use `let` mostly and I only use `const` for special cases when changing the variable would break the program and I want to constrain future developers from do
by cryptica 7y ago
I use `let` mostly and I only use `const` for special cases when changing the variable would break the program and I want to constrain future developers from doing that. For example, when I import some library references in Node.js using `require`, I will use `const` or if I need to define a magic number like `const HANDSHAKE_TIMEOUT = ...`.
I don't see the point of using const everywhere though because I don't code in a pure functional style and I don't pretend to.
Often, it makes sense to re-assign a variable and I don't want to mislead future developers into thinking that it's not OK to do so if the requirements have changed.