2. What is IIFE?

IIFE stands for Immediately Invoked Function Expression.

It's an expression, where function is declared in parenthesis and invoked in the same line.

It can be useful for one-time calculations assigned immediately to a variable. Allows you to create closed scope, where variables can share names with outer-scope variables.

const x = 20; const y = 30; const result = (() => x + y)(); // IIFE console.info(result); // 50
devFlipCards 2024

Do you accept cookies?

Cookies are small amounts of data saved locally on you device, which helps our website - it saves your settings like theme or language. It helps in adjusting ads and in traffic analysis. By using this site, you consent cookies usage.