← 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);
- A.outer outer
- B.inner outer
- C.inner inner
- 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 →