- Invocation: The final pair of parentheses at the end () immediately invokes the function. This means the code within the function block is executed immediately after its creation.
In this example, the IIFE creates a new scope, encapsulating the insideVariable and preventing it from leaking into the outer scope.
In this example, the IIFE calculates the sum of two numbers and immediately returns the result.
This example demonstrates the module pattern using an IIFE to create a counter with private state.