- Back to Home »
- JavaScript »
- JavaScript Part-11 IIFE ( Immediately invoked function expressions )
Posted by :
Sudhir Chekuri
Saturday, 10 March 2018
IIFE ( Immediately invoked function expression ) is a function that's executed as soon as it's created. It is a self invoking anonymous function. It has no connection with any events or asynchronous execution.
Explanation:
1. ( function( ) {
Syntax:
( function( ) {
// Code goes here
// ...
} )( );
1. ( function( ) {
// Code goes here
// ...
} )( );
All the code inside the function will be converted into an expression.
2. ( function( ) {
// Code goes here
// ...
} )( );
The second pair of parentheses calls the function resulting from the expression.