What's exactly the action scope of let in a for-loop in JavaScript?
for (let i = 0; i < 3; i++) {
let i = 4;
console.log(i);
}
console.log(i);Run Code Online (Sandbox Code Playgroud)
The external console.log throws an error:
"Uncaught Reference Error: i is not defined"
It proves i is in a block action scope, however, why doesn't the i defined in the for-loop throw any duplicate definition error?