MCQ Single Best Answer Not Set

QWhat is a closure in JavaScript?

ID: #4876 Javascript Functions MCQ 210 views
Question Info
#4876Q ID
Not SetDifficulty
Javascript Functions MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A A function that is defined inside another function
  • B A function that has access to the outer function's variables
  • C A function that is bound to an object
  • D None of these
Correct Answer: Option B

Explanation

A closure is a function that has access to the outer function's variables even after the outer function has returned.
Closures are created when a function is defined inside another function and the inner function has access to the outer function's variables.
Closures are often used to create private variables and to preserve state in callback functions.

Share This Question

Challenge a friend or share with your study group.