Closures sound scary, but the idea is simple: a function remembers where it came from.
Direct answer
A closure is a function bundled with the variables around it when it was created. Even after the outer function returns, the inner function can still use those variables. Closures let you keep private state and build function factories.
A counter
function makeCounter() {
let count = 0;
return function () {
count = count + 1;
return count;
};
}
const counter = makeCounter();
console.log(counter()); // 1
console.log(counter()); // 2
count is not accessible from outside, yet the returned function can use it.
Function factory
function multiplier(factor) {
return n => n * factor;
}
const double = multiplier(2);
console.log(double(5)); // 10
Common use cases
- Private variables
- Event handlers that need context
- Partial application and configuration
Where Teyro fits
Teyro's JavaScript for Beginners course turns this into short lessons you can play in a few minutes a day. It has 50 lessons, and you can start free.
The bottom line
Every function you return from another function can be a closure. Practise with counters and factories.



