What is a closure in JavaScript?
A closure is created when a function retains access to variables from its lexical scope even after the outer function has finished executing. The inner function keeps a reference to the required surrounding environment rather than receiving a one-time copy of each value.