PRACTICE / UNDERSTAND / REPEAT

JavaScript: Closures

Practice closures with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

15 questionsAnswers explainedFree · no login
Question 1 of 15
Closures · MCQQuestion link ↗

What does this function return?

let count = 6;
const next = () => ++count;
next();
Choose one answer
Answer & explanation

Answer: 7

The inner function closes over `count` and keeps access to the binding after `makeCounter` returns.