- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript IIFE
JavaScript Functions
JavaScript IIFE
A JavaScript IIFE is a function that runs immediately after it is defined.
IIFE stands for Immediately Invoked Function Expression.
It is written inside brackets and called straight away with a second pair of brackets.
Example
Example
javascript
(function () {
console.log("This runs at once");
})();The function is defined and called on the same line.
It has no name, so nothing else can call it again.
What is an IIFE?
An IIFE is a function expression that calls itself as soon as it is created.
The outer brackets turn the function into an expression, and the final () runs it.
