jargon

Frontend & browser·JavaScript in the browser

the callback still had the variable from the function that created it, long after that function returned.

Closure

A function together with the scope it was defined in, which it keeps alive for as long as the function is reachable. It is the mechanism behind every callback that remembers something, and behind private state without classes. It is also a memory hazard: a closure over a large object or a DOM node keeps that object alive, which is one of the most common shapes of a leak in a long-lived page.

Commonly confused with