Skills101
← All practice quizzes

Quiz: Scope, Closures, Hoisting and this

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

How JavaScript finds a variable (the scope chain), why closures remember values, what hoisting and the temporal dead zone really are, the famous var-in-a-loop bug, and how the value of this is decided.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    let x = "outer";
    function f() {
      let x = "inner";
      return x;
    }
    console.log(f(), x);
    
  2. Question 2

    What does this print?

    function counter() {
      let n = 0;
      return () => ++n;
    }
    const a = counter();
    const b = counter();
    a(); a();
    console.log(a(), b());
    
  3. Question 3

    What does this print?

    console.log(typeof hello);
    var hello = "hi";
    
  4. Question 4

    What happens when you read a let variable before its declaration line in the same block?

  5. Question 5

    Why does a for (var i = 0; i < 3; i++) loop with setTimeout print 3 three times?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →