Reading · 10 min

Scope and closures

You are previewing a free lesson. Enrol to save progress and take quizzes.

A function remembers the variables that were in scope where it was created. That memory is a closure. It is how event handlers keep access to data, and why a counter function can keep its count private.