You can read Closures from here.
Example 1: Following example covers the concept of a basic Garbage Collector.
Example 2: Following example covers the concept of Smart Garbage Collector.
10 Uncaught ReferenceError: z is not defined
Here variable z and variable x both are in closure with function b but as in function b, no work is done with z so z is garbage collected while x is not garbage collected. This was the insight relation of garbage collection and closure.