Skip to content
skillbld
Day 10 of 14 30 minBlock scopeHoistingClosures

Learn where variables live and who can see them. Block, function and global scope, why let and const behave better than var, and closures, the way functions remember variables from where they were created.

By the end of today you can

  • Explain block, function and global scope
  • Predict which variable a name refers to when names are shadowed
  • Explain hoisting and the temporal dead zone for let and const
  • Write a closure and explain what it remembers
  • Use closures to keep private state, and avoid the classic loop bug

What's inside

  • 4 sections
  • 3 diagrams and mind maps
  • 7 code examples you can run
  • 5-question quiz
  1. 1Scope: where a name is visible
  2. 2let, const and the old var
  3. 3Closures: functions that remember
  4. 4The classic loop trap

Sign in free to read this lesson

Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.

Sign in free
Day 10: Scope & Closures · JavaScript · SkillBld