3 ms·
Also to clarify something, it technically wouldn't be a closure since - A closure is an inner scope that has a references to its outer scope. It happens any t
by fsnarskiy 8y ago
Also to clarify something, it technically wouldn't be a closure since -
A closure is an inner scope that has a references to its outer scope.
It happens any time a function is created (technically, even global). That actually even goes for “IIF(Instantly Invoked Functions)”, since the function is created first (has references to its outer scope) and THEN is called (two separate “events” in js). The call is not part of the function decl/expr and therefore comes next. Between the two there’s a gap and that’s where you’d say there’s a closure. After that call the reference to the function ceases to exist and the garbage collection tears down the function and with that the closure too.