Avoiding Stale Closures
Understand when closures capture old values and how to prevent bugs.
What is a Closure
A closure captures variables from its enclosing scope. The values it sees are those at creation time.
Stale Captures
If you create a function that captures a variable, later changes to that variable may not be visible inside.