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.
Loading...
Related Quiz
- How can you ensure that your project’s dependencies are secure and up-to-date?
- What is the significance of the 'Agent' class in the http module of Node.js?
- In Node.js, how can data be written to a writable stream?
- Which of the following JavaScript properties allows an object to inherit properties from another object?
- When using the rest operator in a function’s parameters, it will collect the remaining arguments into an ______.