Which of the following is a practical use of closures in JavaScript?

  • Implementing asynchronous operations like AJAX requests.
  • Creating global variables for sharing data across different scripts.
  • Defining functions with no parameters.
  • Handling keyboard events in a web page.
Closures are often used in JavaScript to implement asynchronous operations like AJAX requests, where you want to maintain the context and state of the calling function. The other options are not practical use cases for closures.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *