JavaScript · Junior · Question 19 of 75

What is a closure?

Explanation

Every JS function remembers the lexical environment where it was created and can read and change its variables even after the outer function finishes. Private data, function factories, memoization and event handlers are built on this.

Further reading

Problem with a question

JavaScript · Junior · question 19

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz