Step by step understanding JavaScript IIFE ( Immediately invoked function expression)
HTML-код
- Опубликовано: 12 дек 2016
- For more such videos visit www.questpond.com
For more such videos subscribe ruclips.net/user/questpondvide...
See our other Step by Step video series below :-
Learn C# Step by Step goo.gl/FNlqn3
Learn Design Pattern Step by Step:- goo.gl/eJdn0m
Learn Angular tutorial step by step tinyurl.com/ycd9j895
Learn MVC Core step by step :- tinyurl.com/y9jt3wkv
Learn Azure Step by Step :- tinyurl.com/y6fmrech
Learn SharePoint Step by Step in 8 hours:- goo.gl/XQKHeP
Python Tutorial for Beginners:- • Python Tutorial for Be...
Learn Data Science in 1 hour :- tinyurl.com/y5o7qbau
Learn Power BI Step by Step:- tinyurl.com/y6thhkxw
Learn MSBI Step by Step in 32 hours:- goo.gl/TTpFZN
Learn SQL Server Step by Step tinyurl.com/ja4zmwu
Learn Tableau step by step :- tinyurl.com/kh6ojyo
In this video we will try to understand why we need JavaScript IIFE ( Immediately invoked function expression).
30 Important C# Interview Questions : ruclips.net/video/BKynEBPqiIM/видео.html
25 Important ASP.NET Interview Questions : ruclips.net/video/pXmMdmJUC0g/видео.html
25 Angular Interview Questions : ruclips.net/video/-jeoyDJDsSM/видео.html
20+ SQL Server Interview Questions : ruclips.net/video/SEdAF8mSKS4/видео.html
5 MSBI Interview Questions : ruclips.net/video/5E815aXAwYQ/видео.html
this is the best explanation on both youtube and the internet about this concept. thanks so much for sharing this knowledge.
Very interesting topic in javascript. Thank you.
Thank you for your teachings and advises.
Very clear video, thanks.
Very well explained - with real example.
I did not understand what polluting the global meant . Now i do ! Thank you
quality video and explanation
I used to wonder what polluting the global variable actually meant, now i understand. Thanks
thank you!!
nice and thanks
GOOD One
thanks
after you wrap the global variable into the anonymous function is it still the global variable?
I can happily say that no one knows the advantage of IIFE functions, just making stories
Hi Shiv, So can't we use anymore iffy variables as a global variables ...? since we are unable to access the global variable (I.e. counter) inside of the function, then any ways to access a variable inside of the iffy block..?
thanks
Satya
Hello Satya sir,
The variables created inside IIFY will not be public he can still access public variables.
Hi Satya, the counter variable inside IIFE can be used via a public return function which can be defined in IIFE and it should return the counter variable. This is possible because of closure.
But doesn't the IIFE just get dumped from memory immediately after execution? So what good is it in this example?
Instead of this complicated code we can just rename top "counter" variable to topCounter for example. It will be much simplier then IIFE.
In projects of huge magnitude the components ( functions) are created by some on else and page by some one else. You never know with lot of global variables you are sitting on a ticking bomb.
It is no more a global variable. Something wrong?
if you are using counter variable inside SomeFun() , then automatically then outer counter variable becomes irrelevant since the function will use its own counter variable so I am not sure if your example justify IIFE
The outer counter variable does not become irrelevant because without the IIFE, counter variable will be a global variable and all the other functions will use it as it is defined in global scope.
@@umeshchauhan3223
var counter = 10;
function oldFunction(){
var counter = 50;
console.log('counter inside oldFunction', counter);
}
oldFunction();
console.log('counter outside oldFunction', counter);
This video no longer make any sense and has not described IIFE. To read about IIFE visit benalman.com/news/2010/11/immediately-invoked-function-expression/
This video no longer make any sense and has not described IIFE.
var counter = 10;
function oldFunction(){
var counter = 50;
console.log('counter inside oldFunction', counter);
// Prints 50
}
oldFunction();
// Prints 10
console.log('counter outside oldFunction', counter);
To read about IIFE visit benalman.com/news/2010/11/immediately-invoked-function-expression/