We need a mock Interview from you. What type of questions you will ask in an interview. If possible we will want to the answers in your own way :) This will helps for many people in their IT carrer.
A big use of this is when you want to use async/await everywhere in your code, and then in that case, I can write it as (async function main(arg) { try { let result = await somethingThatReturnsPromise(arg); console.log(result); } catch (e) { console.error(e); } })(someVal) But it is as simple as it gets. ((a) => console.log(a))(10) is a very simple example that I give in interviews. There is a function expression and I'm immediately executing it without assigning it to any binding. Great video!
I understand that the intent of this video is to teach newbies about IIFE, and I appreciate the effort :) . But this just gets some basics wrong and misses the entire point of IIFEs. So for those watching: 1. IIFE is Immediately Invoked Function *Expression* (not Evaluation) 2. IIFE isn't a "style of coding", it's not a personal preference thing. It has very specific use cases (eg- code injection without risking clashes with global namespace) 3. *What is an IIFE?* The explanation of IIFEs is incorrect, the thing inside braces isn't a "callback", it's the opposite. It's an inlined function call. An IIFE is simply an anonymous function definition that is called immediately in place. 4. *Why use IIFEs?* Since this is for beginners, let's just imagine you want to run some code in the browser console in an existing web app. Now suddenly you have restrictions on variable names, because if you call your variable 'x', there might already be a var with that name declared by the original authors of the site. What you want is a lexical scope to shadow the outer declaration of 'x', that's where you use an IIFEE. There are only a couple more use cases where IIFEs make sense. In general it's not a "style of code", and is instead considered a code-smell. 5. *Why are the 'require' imports made at the end?* If you look carefully, you'll quickly understand what's happening is really the 'require' calls are the arguments to the anon function that is being called. You don't need to put them there *at all*, you could just have the parameter list and argument list be empty, and make the calls to 'require' inside the function body. I hope that helped. :)
I hope by seeing the length of this comment everyone can imagine that if I cover what is iife and why we use iife, video would be little more than 30 mins. These titles are probably for future. Right now, just a mini case that it’s an important part, even if it’s not much used as regular.
Some People ask that we have to go with him or not?, MY ANSWER, I Guess this question, doesn't matter, No one else like him, You have a chance, grab it, his courses are wonderful, I really didn't know about programming that much!, He Helped, No One else, he is a star in my life, God sent him for us, Grab it right Now, Question doesn't matter!, GRAB! GRAB! GRAB!
Everytime in Morning when i watch video. It makes my day. More specifically it makes me feel that I'm developer. I make beautiful things for beautiful world. From Gujarat
I really like this video, immediately after covering this topic in a course I came over here to get more clarity on this. Thanks a lot for this video sir.
Opened the youtube, was about to search something and on the left corner saw the thumbnail. that was enough. though i got confused IIFE with LIFE... THANK YOU for the video sir. learned something new........
00:05 Understanding the importance of IIFE in JavaScript interviews 01:43 Understanding IIFE is important for reading and collaborating on others' code 03:19 Understanding the importance of IIFE and its application in coding 04:55 Setting up server using Express in package.json 06:33 IIFE allows for immediate execution of code. 08:15 Creating and utilizing templates in Javascript 10:01 Starting the server and handling errors in JavaScript 11:51 Introduction to IIFE writing code
Hi Hitesh, Big fan of yours!! Just a suggestion since most of the people now watch your videos on phone can you try once shooting the video in 18:9 aspect ratio rather than 16:9 as phone screens are becoming wider and taller
Sir In your javascript course on youtube you mentioned about it as self executing functions Sir please upload these kinds of videos as noone talks about it but you really working hard for us, so we are 💯💯❤🙏🙏
3:35 but it got a click bait with the illusion sir, "Why life appears in JavaScript interviews" 😂😂😂😂 and great video, learned a new thing in life #iife!
@@Oldstoryhouse 💯 sure! Go for it.. if U want to learn JS above beginner's level.. Content quality is as good as his English fluency as well as examples... Btw It's about 10hr course so U won't miss any thing like other 1-2hr crash courses.
Great explanation of the syntax but I don't think the original question was answered! I still don't know what the key aspects about IIFE are that make it such a common JS interview question. Is it just that we may need to know the syntax in case one of our teammates prefers this syntax?
How can we write this in iife👇 const session =require('express-session'); const mongoSessionStore= require('connect-mongodb-session')(session) As connect-mongodb-session require session obj as a input .
Hello sir, Thank you for such a informative video. I need your guidance to start my career in cloud. I just want to communicate with you. How can I start the career in cloud computing? waiting for your prompt response!!!
So what is the advantage of writing the code in this style rather than normally declaring the variables like const express = require('express') and then using them like that? Like why should i use this iife style over the regular style?
We use IIFE when we want some data members of the function to be completely isolated or private in the program, that is the variables don't take any value from outside the iffe function. The second thing is that they get invoked as soon as the program is run that's why called 'immediately invoked...' In case we want some portion of code to get executed as soon as the code runs IFFE comes into rescue!
They're entirely different constructs. Destructuring is merely a way to assign to multiple variables from a single object without having write comma separate declarations (or different 'let' statements). IIFE is a way to execute code as soon as the script is loaded, without polluting the global namespace with variable names.
I watched your video in which you talked about , something when company say they will teach you and give you minimum assured package of sat 5lac then take money from you about 15% of your salary, I remembered you talked about it I wanna watch your views again but I cant find that video can you please help me Thankyou
It's a poor explanation really; I'd advise you to move over to the MDN pages (or javascript .info). There you'll find a much more in-depth explanation.
Hey Hitesh, What do you think about learning Swift iOS development in 2021? Everyone I see and every internship I see only lists react native or flutter as a requirement.. but when I search internationally swift is still super dominant. So what do you say about this?
Accidentally, I read it as "Why life appears in javascript interviews" LOL 😂😂😂
I read the same 🤣🤣🤣
Same here
I too
i read it same...😁😁
Same 😂
Such an illusion of eye..nearly everyone read the title as 'Why life appears in Javascript interviews'😃
My first thought, "Life? What Life?"
We need a mock Interview from you. What type of questions you will ask in an interview. If possible we will want to the answers in your own way :) This will helps for many people in their IT carrer.
A big use of this is when you want to use async/await everywhere in your code, and then in that case, I can write it as
(async function main(arg) {
try {
let result = await somethingThatReturnsPromise(arg);
console.log(result);
} catch (e) {
console.error(e);
}
})(someVal)
But it is as simple as it gets. ((a) => console.log(a))(10) is a very simple example that I give in interviews. There is a function expression and I'm immediately executing it without assigning it to any binding. Great video!
Really after quite a while the intro of LCO is really awesome, this is the best till date!
I understand that the intent of this video is to teach newbies about IIFE, and I appreciate the effort :) . But this just gets some basics wrong and misses the entire point of IIFEs. So for those watching:
1. IIFE is Immediately Invoked Function *Expression* (not Evaluation)
2. IIFE isn't a "style of coding", it's not a personal preference thing. It has very specific use cases (eg- code injection without risking clashes with global namespace)
3. *What is an IIFE?* The explanation of IIFEs is incorrect, the thing inside braces isn't a "callback", it's the opposite. It's an inlined function call. An IIFE is simply an anonymous function definition that is called immediately in place.
4. *Why use IIFEs?* Since this is for beginners, let's just imagine you want to run some code in the browser console in an existing web app. Now suddenly you have restrictions on variable names, because if you call your variable 'x', there might already be a var with that name declared by the original authors of the site. What you want is a lexical scope to shadow the outer declaration of 'x', that's where you use an IIFEE. There are only a couple more use cases where IIFEs make sense. In general it's not a "style of code", and is instead considered a code-smell.
5. *Why are the 'require' imports made at the end?* If you look carefully, you'll quickly understand what's happening is really the 'require' calls are the arguments to the anon function that is being called. You don't need to put them there *at all*, you could just have the parameter list and argument list be empty, and make the calls to 'require' inside the function body.
I hope that helped. :)
I hope by seeing the length of this comment everyone can imagine that if I cover what is iife and why we use iife, video would be little more than 30 mins. These titles are probably for future. Right now, just a mini case that it’s an important part, even if it’s not much used as regular.
This comment really helped, thank you!!!
Some People ask that we have to go with him or not?, MY ANSWER, I Guess this question, doesn't matter, No one else like him, You have a chance, grab it, his courses are wonderful, I really didn't know about programming that much!, He Helped, No One else, he is a star in my life, God sent him for us, Grab it right Now, Question doesn't matter!, GRAB! GRAB! GRAB!
'Why life appears in javascript interviews', that's what I read two times wondering!
3:49 This is one of the best reasons, Why I watch your videos as much I can.
yah yah me also
Everytime in Morning when i watch video. It makes my day.
More specifically it makes me feel that I'm developer. I make beautiful things for beautiful world.
From Gujarat
your teaching style and videos are nice many new things I learn from it..thank you sir
You are opening so many puzzles for us. Thanks for your efforts🙏🏼
Glad you like them!
I really like this video, immediately after covering this topic in a course I came over here to get more clarity on this. Thanks a lot for this video sir.
Thank you hitesh.You are cooking contents very well which tastes simple and digestive.
Opened the youtube, was about to search something and on the left corner saw the thumbnail. that was enough. though i got confused IIFE with LIFE... THANK YOU for the video sir. learned something new........
your communication skill is OP😀😀
00:05 Understanding the importance of IIFE in JavaScript interviews
01:43 Understanding IIFE is important for reading and collaborating on others' code
03:19 Understanding the importance of IIFE and its application in coding
04:55 Setting up server using Express in package.json
06:33 IIFE allows for immediate execution of code.
08:15 Creating and utilizing templates in Javascript
10:01 Starting the server and handling errors in JavaScript
11:51 Introduction to IIFE writing code
Hi Hitesh,
Big fan of yours!!
Just a suggestion since most of the people now watch your videos on phone can you try once shooting the video in 18:9 aspect ratio rather than 16:9 as phone screens are becoming wider and taller
Sir In your javascript course on youtube you mentioned about it as self executing functions
Sir please upload these kinds of videos as noone talks about it but you really working hard for us, so we are 💯💯❤🙏🙏
It was really new .... I even listened thus word for the first time
These videos are the best kind
You have already talked about this in .. new js course ... ♥️
I misread the time has : why life appears in JavaScript interviews😅
Before this video i was watching your video of self executing anonymous function in js that's mind blowing you have already talked little bit about it
3:35 but it got a click bait with the illusion sir, "Why life appears in JavaScript interviews" 😂😂😂😂 and great video, learned a new thing in life #iife!
Hitesh Sir, Content is informative and keep uploading these types of videos.
I came here through Ur JS tutorials playlist after seeing a new video at bottom :D
Same!
So how was that ?? Was it worth to watch
@@Oldstoryhouse 💯 sure! Go for it.. if U want to learn JS above beginner's level..
Content quality is as good as his English fluency as well as examples...
Btw It's about 10hr course so U won't miss any thing like other 1-2hr crash courses.
thank you Hitesh 👍
excited learn these kind of tricks in JS
thanku sir for quality content 🙏❤️
Very informative video ,this one 😊
thank you!
Thank you for making these videos 💓
Is there any extra advantage of following IIFE style
Why life ? 😉 IIFE
Great explanation of the syntax but I don't think the original question was answered! I still don't know what the key aspects about IIFE are that make it such a common JS interview question. Is it just that we may need to know the syntax in case one of our teammates prefers this syntax?
I was not aware of IIFE thanks sir :)
First time hearing IIFE. Like IIFE any other. Give the titles I will Explore.
Thanks
is studying this method only advantage for interview only or is any other advantages
Thanks Sir
You are Akshay Kumar for Programming World ❤
( .... )(
require ("hitesh-sir"),
require ("more such content")
)
Really helpful ❤️
Sir ji compress app size in flutter
Please sir ji
please make videos of aws....
we all are waiting for that
Didn't get the intuition behind the name where is "instant invocation" part of iife
Enjoyed
Hy, Hitesh can you make a video about how does a interviewer search in a candidate
Got 2 notifications,
IIFE concept - Hitesh Choudhary
Family Man Trailer - Amazon Prime Video
Me: *Clicked on IIFE
How can we write this in iife👇
const session
=require('express-session');
const mongoSessionStore=
require('connect-mongodb-session')(session)
As connect-mongodb-session require session obj as a input .
Thanks 👍❤️
Where can we get your mousemat?
Why it is said that Ninja code is tried by all but only doable by some?
Hello sir, Thank you for such a informative video. I need your guidance to start my career in cloud. I just want to communicate with you. How can I start the career in cloud computing? waiting for your prompt response!!!
Hi hitesh your content is great,I have 4 years gap and I learned python and angular, what do u suggest like how to proceed with career
Please make about shopify.
I started to find what's the meaning of appears really!
So what is the advantage of writing the code in this style rather than normally declaring the variables like const express = require('express') and then using them like that? Like why should i use this iife style over the regular style?
We use IIFE when we want some data members of the function to be completely isolated or private in the program, that is the variables don't take any value from outside the iffe function.
The second thing is that they get invoked as soon as the program is run that's why called 'immediately invoked...'
In case we want some portion of code to get executed as soon as the code runs IFFE comes into rescue!
@@kashifahmed_1995 thanks ill make sure to research more about these
@@khushi_jha16 Its on you but rarely it is asked in interviews
Sir Make Video on Google IO 2021
Sir do make this kind of videos
Now I'm overwhelmed what's else do interviewers asks that no one is talking about
Ever going path of learning...
I see this code in a project a week ago.
Interviewer: Tell me about iife.
Me: My life has been great as I came to this city of dreams...
interviewer: hired.
I think now I get why many don't talk about it. It doesn't serve much utility value. It's obviously Little painful to write and read it.
Amazing
3:54 it will get views, because of your magical title
🙌🏻👍🙌🏻
How IIFE is different from destructuring?
They're entirely different constructs. Destructuring is merely a way to assign to multiple variables from a single object without having write comma separate declarations (or different 'let' statements).
IIFE is a way to execute code as soon as the script is loaded, without polluting the global namespace with variable names.
Why are you using body-parser.. It is depreciated
I watched your video in which you talked about , something when company say they will teach you and give you minimum assured package of sat 5lac then take money from you about 15% of your salary, I remembered you talked about it I wanna watch your views again but I cant find that video can you please help me Thankyou
Now you don't require body-parser because now express comes with in built body-parser.
Express provide his own body-parser you don't need body-parser package express. json( )
Bro say slowly I loved script❤😂
Finally you got hair cut😁😁,in this lockdown
Thank you!❤️
Honestly, i just didnt understand when you started to explain what exactly is IFFE ? I am sorry, I didnt understand what is IFFE.
It's a poor explanation really; I'd advise you to move over to the MDN pages (or javascript .info). There you'll find a much more in-depth explanation.
This is not, what is iife video. That’s a separate video in playlist. This video serves the purpose to awareness towards iife.
Thanks for the info which I am probably not going to need in my life 😂😂
when he says I know I am going too fast... .and You are watching it on 2x :)
Hey Hitesh,
What do you think about learning Swift iOS development in 2021?
Everyone I see and every internship I see only lists react native or flutter as a requirement.. but when I search internationally swift is still super dominant.
So what do you say about this?
I have enjoyed video but it's not 100% enjoyable without your vs code theme video, please it's over due than covid19...
first first ❤️❤️❤️
I got to know it's iife not life after reading the comment section. 🤨
i subscribe your video
The word iife is misunderstood as life. As iife I'm hearing it for the 1st time.
4:10
how many of you read iife as life
me too
Support++
I'm not the only person who read iife as life. 😂
That company must be Razorpay
Another JS video. Pls make some videos on something other than JS. 🙄
I completely agree with you. But I guess more number of audience from this channel are for JavaScript content
@@siemen_subbaiah This is bcz he makes content for JS only as he knows JS.
I see you got a nice haircut 💈
Yeep, got it today
Who else read iffe as life😂
1st comment
First
Hi 👋,
First comment
First veiw 😎 is
🥳
ahaaa haircut
1st View