What is an IIFE (Immediately Invoked Function Expression) in JavaScript?
a) A function that runs as soon as it is defined
b) A function that runs at the end of the script
c) A function that is called multiple times
d) A function that waits for a user event
Answer:
a) A function that runs as soon as it is defined
Explanation:
An IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs immediately after it is defined. This pattern is often used to create a private scope for variables and prevent them from polluting the global namespace.