filmov
tv
Immediately Invoked Function Expression (IIFE) | Javascript IIFE Function Expressions Explained

Показать описание
Code :
//Immediately Invoked Function Expression (IIFE)
//It is a javascript function which runs as soon as it is defined
//first closing paranthesis makes an expression
//Last closing paranthesis tells javascript interpreter to call this
//function immediately
(function(){
})();
//Named IIFE
(favMovie = function(movie="Inception"){
})();
favMovie("Interstellar")
//Adv : to avoid declaring variables in global scope and to create
//closures
let b=2
{
let b=3
}
O/P :
Welcome to Azhar Techno Coder Channel
My favorite movie is Inception
My favorite movie is Interstellar
3
2
Next Steps :
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
#IIFE
#ImmediatelyInvokedFunctionExpression
#javascript
//Immediately Invoked Function Expression (IIFE)
//It is a javascript function which runs as soon as it is defined
//first closing paranthesis makes an expression
//Last closing paranthesis tells javascript interpreter to call this
//function immediately
(function(){
})();
//Named IIFE
(favMovie = function(movie="Inception"){
})();
favMovie("Interstellar")
//Adv : to avoid declaring variables in global scope and to create
//closures
let b=2
{
let b=3
}
O/P :
Welcome to Azhar Techno Coder Channel
My favorite movie is Inception
My favorite movie is Interstellar
3
2
Next Steps :
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
#IIFE
#ImmediatelyInvokedFunctionExpression
#javascript