Immediately invoked function expression

It was popular in JavaScript[1] as a method of supporting modular programming before the introduction of more standardized solutions such as CommonJS and ES modules.

[10]A lack of block scope means that variables defined inside (for example) a for loop will have their definition "hoisted" to the top of the enclosing function.

[12] This is equivalent to the following code: IIFEs are also useful for establishing private methods for accessible functions while still exposing some properties for later use.

Originally known as a "self-executing anonymous function",[14] Ben Alman later introduced the current term IIFE as a more semantically accurate name for the idiom, shortly after its discussion arose on comp.lang.javascript.

[1][15][16] Notably, immediately invoked functions need not be anonymous inherently, and ECMAScript 5's strict mode forbids arguments.callee,[17] rendering the original term a misnomer.