A closure is when a function is able to remember and access a lexical scope, even when the function is executed outside the lexical scope.
A closure is a function that stores references to the adjacent state (lexical scope). In other words, a closure allows access to the scope of an outer function from an inner function.
function iniciar() { var nombre = "Mozilla"; // La variable nombre es una variable local creada por iniciar. function mostrarNombre() { // La función mostrarNombre es una función interna, una clausura. alert(nombre); // Usa una variable declarada en la función externa. } mostrarNombre(); } iniciar();