Level 2 · Core Development
Module 10: Scope and JavaScript Behavior
Global, function and block scope
Explain global, function and block scope, predict which variable a name refers to, and keep variables in the smallest scope that needs them.
Lesson 47
Lexical environments
Describe lexical scope and the scope chain, and predict variable lookup by reading where functions are defined, not where they are called.
Lesson 48
Closures
Create closures that remember variables after their outer function returns, use them for private state and function factories, and avoid the loop closure trap.
Lesson 49
Hoisting and the temporal dead zone
Explain hoisting for function declarations, var, let, const and function expressions, and recognise the temporal dead zone.
Lesson 50
Understanding execution contexts
Describe execution contexts and the call stack, read a stack trace, trace nested calls, and explain how this is set for regular and arrow functions.
Module mastery assessment
Eight questions and a practical task covering Lessons 46 to 50: scope, lexical environments, closures, hoisting and the temporal dead zone, and execution contexts.