JavaScript
🔒 Scope, hoisting and closures
Who can see which variable, why something sometimes exists before you declare it, and how a function remembers the world where it was born.
What you'll learn
- Distinguish global, local and block scope, and predict from where a variable is accessible.
- Explain the hoisting of declared functions and the temporal dead zone (TDZ) of
letandconst. - Create a closure that keeps private state between calls, like a counter.
- Implement a function factory by taking advantage of the fact that each closure remembers its own environment.
Lessons
Scope: global, local and blockWho can see which variable. HoistingHow JavaScript 'hoists' declarations. ClosuresFunctions that remember their environment.Practice this module in the app
DevPath is a hands-on course: you read the theory here; in the app you put it into practice with exercises that really run, offline.
Start free in the app →