What is a closure in JavaScript?

Instruction: Explain lexical scope and demonstrate a function retaining access to an outer variable.

Context: Practice a concise JavaScript closure answer with a reusable counter example.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

A closure is a function together with access to the surrounding variables where it...

Related Questions