LearnFrenzy
Sign in Take a free test

Closures · Closures MCQ · Question 8

Closures and memory Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

Which statement about closures and memory is true?

  • A Closures always cause memory leaks
  • B Captured variables are freed as soon as the outer function returns
  • C Variables a closure uses stay in memory as long as the closure itself is reachable Correct
  • D Closures copy all global variables
Correct Answer: Option C

Once nothing refers to the closure (e.g. a listener is removed), its environment can be garbage-collected. Long-lived closures should avoid capturing large unused data.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links