###var vs let vs const var is only used for backward compatibility with plain javascript (ES5 and before) "var" variables are visible outside the block scope
var m = "hello";
if (m){
var i:number;
for(i=0; i<3;i++){
console.log(m + ' ' + i)
}
}
console.log(i); // outputs 2
"let" variables are not visible outsidde the block scope
var m = "hello";
if (m){
let i:number;
for(i=0; i<3;i++){
console.log(m + ' ' + i)
}
}
console.log(i) //undefined
"const" variables is one of the best practices because creates an inmutable reference,
const m = "hello";