(Ad, please don’t block.)

Quizzes » Variable scopes and closures (advanced)

1. Static vs. dynamic

Which one means “at runtime”?

2. Static vs. dynamic

Which one means “at compile time, without running the program”?

3. Block-scoping

let foo = 'a';
{
  let foo = 'b';
  console.log(foo);
}
console.log(foo);

4. Block-scoping

let foo; // (A)
{
  let foo = 123;
}
console.log(foo);

5. Temporal dead zone 1/5

let foo = 'a';
console.log(foo); // (A)
{
  let foo;
  foo = 'b';
}

What happens in line A?

6. Temporal dead zone 2/5

let foo = 'a';
{
  console.log(foo); // (A)
  let foo;
  foo = 'b';
}

What happens in line A?

7. Temporal dead zone 3/5

let foo = 'a';
{
  let foo;
  console.log(foo); // (A)
  foo = 'b';
}

What happens in line A?

8. Temporal dead zone 4/5

let foo = 'a';
{
  let foo;
  foo = 'b';
  console.log(foo); // (A)
}

What happens in line A?

9. Temporal dead zone 5/5

let foo = 'a';
{
  let foo;
  foo = 'b';
}
console.log(foo); // (A)

What happens in line A?

10. Closures (1/2)

const foo = 'a';
function func() {
  return foo;
}
function returnFunc(foo) {
  return func;
}
const result = returnFunc('b')();

What happens?

11. Closures (2/2)

const foo = 'a';
function returnFunc(foo) {
  function func() {
    return foo;
  }
  return func;
}
const result = returnFunc('b')();

What happens?


Correct answers: 0 out of 0