When I declare a variable using the let keyword that is already declared using the let keyword in the same scope, then it throws a SyntaxError exception. Consider this example:
let a = 0;
let a = 1; // SyntaxError
function foo() {
let b = 2;
let b = 3; // SyntaxError
if(true) {
let c = 4;
let c = 5; // SyntaxError
}
}
foo();
I know that example can't execute because we can't re-declare variable with let but we can do it with var. So I want to know clearly what happen insight nodejs and browser ?
"I wanna know how browser or nodejs process this situation ?"
Can anyone explain?