On Github ik5 / emcascript6_lecture
Most people at 2009 just didn't know the answer !
function varTest() {
var x = 31;
if (true) {
var x = 71; // same variable!
alert(x); // 71
}
alert(x); // 71
}
function letTest() {
let x = 31;
if (true) {
let x = 71; // different variable
alert(x); // 71
}
alert(x); // 31
}
const PI = 3.1415926535897932385; // First time we place it
PI = 3.14 ; // Nothing will be changed
const PI = 3.14 ; // Still nothing happened
var PI = 3.14 ; // Now we changed it (?)