A closure is an inner function that has access to the variables and parameters of its outer function, even after the outer function has returned. Closures are a powerful feature of JavaScript that can be used to create private variables and create functions that have persistent memories.
Example:
function outerFunction(x) {
let y = x;
return function innerFunction(z) {
return y + z;
}
}
let myClosure = outerFunction(5);
console.log(myClosure(10)); // 15