I would say that you should, as a principle, use let
whenever it is not inconvenient to do so. Such as:
for (let i = 0; i < 100; i++) {
// Do something
}
if (condition) {
let msg = a + b + c;
console.log(msg);
alert(msg);
}
The advantages to this approach is:
- Less risk of overriding some global variable use for something else
- Less risk of memory leaks due to variables staying in memory long after they have become irrelevant