๐
Lexical Environment ยท Scope Chain ยท Memory LifecycleClosure Simulator
Code Editor
Example:
Speed:500ms/step
idle
Console
Console output will appear here.
Key Concepts
env
Lexical Environment
Lexical Environment โ Each function creates an environment object that holds its local variables.
โ
[[Outer]] Reference
Outer Reference โ Every environment has a [[Outer]] pointer to its parent, forming the scope chain.
GC
Memory Lifecycle
Memory Lifecycle โ When a function returns, its environment stays in memory if a closure references it (retained). When no closures reference it, it becomes eligible for garbage collection.
On StackRetainedGC'd
Press โถ Run or Step to begin