Do you know what will be the output of this code?
JavaScript
let x = 1;
{
let x = 2;
}
console.log(x);
Show answer and explanation
The answer is 1.
let is scoped to the nearest block. The inner x is a different variable that shadows the outer one only inside the braces.