One thing that often misleads people learning closures is that they think the environment in the closure must have a copy of all the variables and their values. It doesn’t. In fact, the environment references the live variables being used by your code, so if a value is changed by code outside your closure function, that new value is seen by your closure function when it is evaluated.
- 11. Anonymous Functions, Scope and Closures: Serious functions
- Publisher: O'Reilly Media, Inc.
- Released: March 2014
A warning about closures?