# Closure

*noun*

say it: **“KLOH-zher”** **/ˈkloʊʒər/**

A function together with the variables from the place it was created, which it still remembers and can use later.

## What is **Closure** in JavaScript?

**Closure** — An inner function that remembers the variables around it.

```javascript
function createCounter() {
    let count = 0;
    return () => ++count;
}
```

## In a sentence

- “The click counter works because of a **closure**: the inner function still remembers count after the setup function has returned.”
- “The counter function is a **closure**: it still remembers tokens long after makeCounter returned.”
- “The click counter works because of a **closure**: the function it returns still remembers count.”
- “My debounce helper uses a **closure** to keep track of the timer between calls.”

Level: Journeyman · [More JavaScript terms at this level](https://www.ask-codey.com/glossary?category=javascript&level=3)

Updated: November 9, 2026

## In other subjects

- [Closure in Python](https://www.ask-codey.com/glossary/closure)

Source: https://www.ask-codey.com/glossary/closure-javascript
