Lesson 05 · JavaScript
JavaScript Foundations: Scope & Closures
Where variables live and who can see them: block scope, the var pitfalls let and const fix, and closures - functions that remember their birth environment.
Prerequisites: JavaScript Foundations: Iterating & Transforming
Learning objectives
By the end of this lesson, you will be able to:
- Predict which declaration a name refers to when scopes nest
- Explain how let and const differ from var inside blocks
- Read and write functions that return other functions
- Use closures for counters, run-once guards and configuration
- Recognize closures hiding in code you already use