IIFE (Immediately Invoked Function Expression)
IIFE (Immediately Invoked Function Expression) — An IIFE is a function that is executed immediately after it is defined. It creates a private scope to avoid polluting the global namespace. IIFEs were commonly used before ES6 modules to create private scopes. The pattern wraps a function in parentheses (making it an expression) followed by `()` to invoke it immediately. They are still useful for creating isolated lexical scopes and the module pattern. This term relates to the Function category of the reference. You will meet iife (immediately invoked function expression) in practice when working with APIs such as Function.prototype.call(), Function.prototype.apply(), Function.prototype.bind(), Function.prototype.toString(). Related terms: Closure, Hoisting, Event Loop, Prototype Chain, Temporal Dead Zone (TDZ), Currying. Understanding iife (immediately invoked function expression) makes the rest of the JavaScript documentation noticeably easier to follow, because the concept recurs across methods, guides, and error messages.