JavaScript IIFEs Explained Simply
An IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined. Variables declared inside the IIFE have private scope.
const greeting = (() => {
const name = "Sam";
return `Hello, ${name}!`;
})();
console.log(greeting); AI panel
Ask AI to clarify the parts you don’t fully understand, or go more in depth with MDN documentation.