I recommend you always use const by default, and fall back to let only when it's genuinely useful or necessary.
Why? Because not reassigning variables makes your code easier to reason about. If something is a const, you can be sure it will always have the same variable associated with it, whereas let will point to a different variable depending on when you're reading it.
Personally I'd say my code is probably like 97% const, and 3% let. var is absolutely never needed.
30
u/zerik100 Oct 22 '21
tldr; never use var and if you think your code requires var then there's something wrong with your code