In programming languages, a closure, also lexical closure or function closure, is a technique for implementing lexically scoped name binding in a language with first-class functions.

A closure can be used to associate a function with a set of β€œprivate” variables, which persist over several invocations of the function.