What is a closure?


In Javascript, a closure is created anytime a function is created. When a function is created, it captures the references (memory address) to the variables available in its surrounding environment (its lexical scope). If this outer function returns an inner function, and the inner function uses some of those captured...