I know an if
statement doesnt have its own scope like a function, meaning it shares the same scope with the containing context. If so, why am I allowed to redeclare the same variable again?
var foo = 123;if (true) { console.log(foo) // 123 var foo = 456; // Shouldnt it throw an error if refers to same variable?}console.log(foo) // 456