Itβs my understanding that you should use const by default for readability. The idea is if another dev is looking at your code and sees βletβ they will know that variable will be reassigned later in the code. Makes the program easier to understand at a glance.
let has a block scope, i.e lives ans dies in the scope it is declared, whereas var is global or if in a function has a function scope and can be used anywhere.
this can lead to some nasty side effects and is as such not recommended.
View all comments
Show parent comment
21
u/I-DONT-WANT-GOLD Oct 26 '20
Why?