🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Scope, Closures, Hoisting and this: all 15 questions

Quiz: Scope, Closures, Hoisting and this · Question 1 of 15

What does this print? (code)

What does this print?

let x = "outer";
function f() {
  let x = "inner";
  return x;
}
console.log(f(), x);
  1. A.outer outer
  2. B.inner outer
  3. C.inner inner
  4. D.ReferenceError
Answer & explanation

Correct answer: inner outer

The inner x shadows the outer one only inside f; outside, x is still "outer".

Can you get the rest right without peeking?

Take the timed Quiz: Scope, Closures, Hoisting and this quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →