What is an Immediately Invoked Function Expression (IIFE) and what problem did it solve before ES modules?

JavaScript Professional Medium

JavaScript Professional — Medium

What is an Immediately Invoked Function Expression (IIFE) and what problem did it solve before ES modules?

Key points

  • IIFE executes immediately after being defined
  • Prevents global variable pollution
  • Creates a local scope for variables
  • Avoids variable name collisions in shared global namespace

Ready to go further?

Related questions