Beginner JavaScript
Q5 / 100

What is a closure in JavaScript?

Correct! Well done.

Incorrect.

The correct answer is B) A function that remembers and has access to variables from its outer scope even after the outer function has returned

B

Correct Answer

A function that remembers and has access to variables from its outer scope even after the outer function has returned

Explanation

Closures capture variables from enclosing scopes. function counter() { let n=0; return () => n++; } — the inner function closes over n.

Progress
5/100