Skip to content

Immediately Invoked Function Expressions (IIFE)

An IIFE is a function that is executed immediately after its definition. It is often used to create a private scope and avoid polluting the global namespace. It can be written with either function declarations or arrow functions.

(function () {
console.log("IIFE executed");
})();
(() => console.log("Arrow IIFE"))();