EasyClosures & Scope💻 Output Question

let block scope — inner does not leak

💡

Hint

let creates a new binding per block. Inner and outer x are independent — no leaking.

What does this output?

let x = 'outer';
{
  let x = 'inner';
  console.log(x);
}
console.log(x);

Correct Output

inner
outer

Why this output?

Explanation: let is block-scoped. The inner x exists only inside the block. The outer x is completely unaffected.

Key Insight: let creates a new binding per block. Inner and outer x are independent — no leaking.

More Closures & Scope Output Questions

EasyClassic var in loop with setTimeoutEasylet in loop — each iteration gets own bindingMediumIIFE captures loop variableMediumClosure mutation persists across calls

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz