Тёмный
No video :(

Immediately Invoked Function Expressions IIFE | chai aur  

Chai aur Code
Подписаться 389 тыс.
Просмотров 111 тыс.
50% 1

Visit chaicode.com for all related materials, community help, source code etc.
#javascript #hindi
Sara code yaha milta h
github.com/hit...
Discord pe yaha paaye jaate h:
hitesh.ai/discord
Instagram pe yaha paaye jaate h:
/ hiteshchoudharyofficial

Опубликовано:

 

29 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 183   
@raosadaqat7302
@raosadaqat7302 3 часа назад
Aap ka teaching ka andaz bohot acha laga. Aap ki wajah se JavaScript seekhna asaan aur interesting ho gaya hai. Shukriya!
@unknown72900
@unknown72900 5 месяцев назад
One unique thing that differentiates your Javascript series with rest all is the way you teach us best practices & important points with good examples rather than following the common procedure of just covering the basics which everyone does. Sharing important interview questions too
@tech_channel110
@tech_channel110 Год назад
sir kamal kr ty ho ap bht achay sy or behtareen andaz may samjhaya ap nay big respect big respect for you
@chaiaurcode
@chaiaurcode Год назад
Thanks
@iamakashkumarram
@iamakashkumarram Год назад
Hanji, suntehi mann pura positive energy se bhar jata ha aur coding karneka mann karta ha. Thanks sir for this best JavaScript series.
@Rajatsharma-dd1pf
@Rajatsharma-dd1pf Год назад
Immediately Invoked Function Expressions (IIFE): the secret sauce for encapsulating code and maintaining a clean global scope. In this video, you'll uncover the power of IIFEs and how they can enhance code organization, protect variables, and prevent naming collisions. Whether you're a seasoned developer or just starting out, understanding and utilizing IIFEs will level up your JavaScript skills. Get ready to dive into this transformative concept and supercharge your coding prowess!
@Adnan-td5iq
@Adnan-td5iq 2 месяца назад
AWESOME SIR YOUR WAY OF TEACHING MAKES U TOTALLY DIFFERENT FROM OTHERS .THANKU SO MUCH SIR FOR UPLOADING SUCH A QUALITY CONTENT IN FREE
@ARPITCHOUDHARY1
@ARPITCHOUDHARY1 7 месяцев назад
Never new this is called IIFE, though know this is an another way to call an function.. Thank you sir for such detailed videos.
@afaqkhatri968
@afaqkhatri968 Год назад
Awesome Way of teaching. By far best javaScript content on youtube.
@chaiaurcode
@chaiaurcode Год назад
Thanks a lot
@harsh-alashi
@harsh-alashi Год назад
I took an Udemy Course wherein IIFE was explained for about 30-35 mins but I didn't understood a single word. Here things are much simpler to understand. Thank You Hitesh Sir!
@manishkarki8119
@manishkarki8119 Год назад
lol same
@alanguagee
@alanguagee 17 дней назад
sir you are rocking I missed my js class and i think thats great because I found you and learn more technical with ans than lecture;s without explanation theory. In earlier after py i hate js but after your lecture i m enjoying and writing so many codes in day and committing git too, thank you so much sir btw, current time is 12: 39 CST and I love it at midnight
@tech_channel110
@tech_channel110 Год назад
I am absolutely captivated by the way you masterfully unraveled the intricacies of JavaScript language concepts, infusing each lesson with a sense of wonder and leaving me both spellbound and incredibly grateful.
@sameer07x19
@sameer07x19 4 месяца назад
Ohh bhai 😂
@sameer07x19
@sameer07x19 4 месяца назад
Ohh bhai 😂
@shashankkumarpandey4184
@shashankkumarpandey4184 7 месяцев назад
Best Lecture, understood everything, Thank you sir!
@mr_professor_x
@mr_professor_x 3 месяца назад
Radhe Radhe ❤❤ Thankyou sir for the amazing lecture.
@MuhammadYasir-cl4jp
@MuhammadYasir-cl4jp 9 месяцев назад
Sir your JavaScript playlist is top notch. Explaining the concepts very well and very easily.❤❤❤
@chaiaurcode
@chaiaurcode 9 месяцев назад
Thanks a ton 😊🙏
@tech_channel110
@tech_channel110 Год назад
I am profoundly awestruck and deeply appreciative of my teacher's (sir hitesh chodhary) exceptional ability to delve into the intricate nuances of JavaScript language concepts, elevating my comprehension to remarkable heights and leaving me utterly inspired.
@Nova_The_Beyonder
@Nova_The_Beyonder 11 месяцев назад
Your teaching skills are top notch, Thankyou for this great video.
@chaiaurcode
@chaiaurcode 11 месяцев назад
You are very welcome
@aryantapre
@aryantapre 8 месяцев назад
Unbelievable content! Hats Off to Hitesh Sir 🙏🙏🙏🙏❤❤
@chaiaurcode
@chaiaurcode 8 месяцев назад
Thanks 🙏😊☕️
@ByteNinjas69
@ByteNinjas69 11 месяцев назад
Amazing concepts, I am learning a lot from your channel
@hitendrasingh01
@hitendrasingh01 9 месяцев назад
Full code + notes + Explanatory comment // Avoiding Global Scope Pollution: // Variables declared inside the IIFE are not added to the global scope. This helps in preventing naming conflicts with other scripts and libraries. // Encapsulation: // It allows encapsulation of variables. Variables declared inside the IIFE are not accessible from the outside, providing a level of privacy. // Isolation: // It helps in isolating code. Variables declared inside the IIFE do not interfere with variables in the outer scope, and vice versa. // Module Pattern: // IIFE is often used in creating a module pattern, allowing the creation of private and public methods within the same scope. // Avoiding Hoisting Issues: // By using a function expression, you avoid hoisting issues that can occur with function declarations. // Immediately Invoked Function Expression (IIFE) - Named IIFE (function chai() { console.log(`DB connected`); })(); // Output: DB connected // If two IIFE are used, it's a good practice to end each with a semicolon to avoid potential issues. // Immediately Invoked Function Expression (IIFE) - Unnamed IIFE ( (name) => { console.log(`DB connected ${name}`); } )('Postgres'); // Output: DB connected Postgres // Explanation: // - The first IIFE is named 'chai' and logs "DB connected" immediately when the script runs. // - The second IIFE is unnamed and takes a parameter 'name', followed by the provided name ('Postgres'). // - Both IIFE syntaxes are valid, and the use of parentheses around the function helps to indicate that it's a function expression being invoked immediately. // Note: Ending IIFE with semicolons is especially important when you are combining multiple JavaScript files into one, to prevent unexpected issues due to automatic semicolon insertion.
@akshitbhatt4508
@akshitbhatt4508 8 месяцев назад
thanks
@shoaib57847
@shoaib57847 10 месяцев назад
Hello sir hitesh im shoaib from karachi pakistan im learning javascript from your playlist its a awesome playlist thank you so much for this series
@abdulsaad8791
@abdulsaad8791 9 месяцев назад
Completely get it what's IIFE and most important is why we use it in real world scenario. Love your way of explaning topics.
@mehakkamran3929
@mehakkamran3929 7 месяцев назад
I was sick the whole week , now I'm back again and will complete the whole playlist IA.
@Fantasticares
@Fantasticares 3 дня назад
sir ek he dil h kitni baar jitoge ❤❤
@kripashanker7201
@kripashanker7201 3 дня назад
bade bhaiya dhanyavaad apka
@nidmcreativeart6079
@nidmcreativeart6079 Год назад
Absolutely right sir, these videos makes us confident. Because of this I can say, yes I know js from scratch 😊. Thanks alot sir.... Big appreciation from my side #madhubani, Bihar
@SuryaKarigar
@SuryaKarigar 11 месяцев назад
It's a better practice to use ; after every expression ❤
@mainakdasgupta7130
@mainakdasgupta7130 Месяц назад
Wow i like your teaching style bhaiya!!
@zohaibalishah91
@zohaibalishah91 Месяц назад
Sir border Paar Se Buht Sara Piyar Apke Liye...
@ayush.tiwarios2105
@ayush.tiwarios2105 Месяц назад
00:02 IF Immediately Invoked Function Expression in JavaScript 00:57 Separate scopes are created to avoid pollution from the global scope 01:50 Writing the function with the 'if' statement is easy but it is important to invoke the function immediately. 02:43 Understanding the execution of functions and its impact on global scope pollution. 03:37 Function written in the manner of Ara function causing an error 04:41 Use semicolons to properly end lines of code 05:34 Passing arguments to a function in JavaScript 06:33 Naming conventions in IF statements
@rohitamrutkar7875
@rohitamrutkar7875 10 месяцев назад
First of all thank you sir to giving such a practical content to us please make Interview Base video on reacts and JavaScript 💌🙏
@Vikram_Singh_CS
@Vikram_Singh_CS Год назад
इस awesome content के लिए - धन्यवाद हितेश
@tech_channel110
@tech_channel110 Год назад
In light of your exceptional teaching, could you please point me towards the next enthralling video series that delves into the realm of Next.js ,React and typescript and database etc ? Your insights have been instrumental in shaping my understanding, and I'm genuinely excited to embark on this next phase of learning under your esteemed guidance.
@chaiaurcode
@chaiaurcode Год назад
Check out my English Channel, Hitesh Choudhary. Such topics are covered there
@tusharpandita167
@tusharpandita167 3 месяца назад
A very simple example given below // IIFE // example of named iife function (function HW(){ console.log("Hello world") })(); // example of unamed Iife function (() =>{ console.log("Hello Universe") } )();
@madhurikumari2071
@madhurikumari2071 11 месяцев назад
Such a content full learning .. #"full knowledge wasool "😊 this channel is so resourceful, if anybody wnna deep dive with Mern must go through this series and channel 🎉😊
@chaiaurcode
@chaiaurcode 11 месяцев назад
Thanks a ton
@psyyhill
@psyyhill Год назад
Really learning a lot from you, sir! Thanks for providing us this learning for free! 🙌🏻
@safinkhan6329
@safinkhan6329 4 месяца назад
Thank you so much for this simple explanation❤
@aquibrashid8815
@aquibrashid8815 3 месяца назад
We need IIFE to deal with two things: 1. To prevent any pollution to the global scope from the values inside our function - now, this holds true when working with the oudated var keyword or in instances where you mistakenly declare the functions and variables in the global scope instead of inside the intended function. If you take care of both these things, IIFE’s are not a strict requirement to prevent polluting the global scope. 2. To call a function immediately - there can be instances where we need to immediately invoke a function but there can be other ways as well to immediately invoke the functions other than IIFEs. Overall , IIFEs are a good code practice to prevent any potential pollution problems in cases we are exporting our code to other files and also the code looks clean
@earlymorningcodes6100
@earlymorningcodes6100 7 месяцев назад
Thanks a lot Hitesh for such a wonderful explanation
@fatimaiqra2169
@fatimaiqra2169 3 месяца назад
Thanks, your video is really time-saving!
@hamzasajid7973
@hamzasajid7973 5 месяцев назад
Super duper work Hitesh bhai
@aggsha7580
@aggsha7580 5 дней назад
Thanks A Lot Sir ❤❤
@photosofmine3443
@photosofmine3443 Месяц назад
SUMMARY : 1. IIFE is a function which immediately executes after it's creation . It is wriiten as one parentheses for wrapping the function and other for execution ()(); 2. Variables defined inside an IIFE are not accessible from outside its scope which helps to avoid conflicts with other variables or functions (global scope pollution). Means IIFE keeps variables and functions private in it. 3. IIFE written with function name is named IIFE and not with name are unnamed/anonymous. 4.We can use parameter inside first parentheses. 5. To write two or multiple IIFE one should be end with semicolon ;
@palakjain7745
@palakjain7745 9 месяцев назад
Beautifully Explained
@Whitefield123-f6w
@Whitefield123-f6w Месяц назад
Love the session
@rahultripathi6935
@rahultripathi6935 Год назад
You always more than expectation ❤ I be like itna depth me kon teach h Vo bhi chai ke sath
@babarshabbir2554
@babarshabbir2554 3 месяца назад
"Master IIFEs with this clear, concise tutorial! Ideal for JavaScript learners. #chai" - 9 words.
@codewithsehran
@codewithsehran 4 месяца назад
3:00 That's cooooool 🫨
@dot_programmer
@dot_programmer 7 месяцев назад
I don't know what is IIFE apki backend ki series dekh rha tha abhi tab main socha IIFE dekh lo phr ap ki ye video bhi dhondh li ❤ Great Sir, Kmall ka teaching level hai 🔥🔥
@MohammedismailAkbarAli
@MohammedismailAkbarAli 3 месяца назад
👆🏼 Quetion: Can an IIFE have a return value? No in normal case. But if someone stores it in a valiable it can be keept and reuse it. const result = (function() { return 10; })(); console.log(result); (totally out of curiosity banged my head init this and i found this, thought to share with people)
@jinsishahcs7889
@jinsishahcs7889 2 месяца назад
Great content!
@VikashSingh-hc6zo
@VikashSingh-hc6zo 9 месяцев назад
thank you sir maja a gya great explanation and so intresting
@chaiaurcode
@chaiaurcode 9 месяцев назад
So nice of you 😊
@amit-gminggeek5301
@amit-gminggeek5301 2 месяца назад
Nice explanation ❤
@Hammad-wp8dm
@Hammad-wp8dm Месяц назад
Lub you Sir g . #RU-vid run this comment as IIfe function 😁😁😁. And donot forgot to use ; at the end of IIfe function
@sumanthachark
@sumanthachark 11 месяцев назад
Beautifully explained!
@jrahul42
@jrahul42 29 дней назад
thanks,great one
@PijushKonar
@PijushKonar 7 месяцев назад
IIFEs are used in JavaScript for several reasons: Prevent global pollution: Variables and functions inside stay private, avoiding conflicts with other code. Create modules: Encapsulate code to organize and isolate functionality. Run code immediately: Useful for initialization tasks or ensuring execution on page load. Control `this` behavior: Bind `this` explicitly within the IIFE for specific scenarios. Think of IIFEs as self-contained bubbles for your code, keeping it tidy and organized!
@pranjalgogoigaming-1209
@pranjalgogoigaming-1209 9 месяцев назад
PROVIDING EXTRA KNOWLEGE IS YOUR KEY FEATURE
@word_wide_fukrey
@word_wide_fukrey 10 месяцев назад
Sir, how IIFE and normal function different in case of polluting globle scope, as far as i know, i think normal function are aslo avoid polluting globle scope, so how can we differtiate IIFE and normal function in case of polluting globle scope?
@MonikaKumari-er4de
@MonikaKumari-er4de 5 месяцев назад
Thank you sir❤️
@BitFire007
@BitFire007 5 месяцев назад
"Chai aur Code, you're the mentor every JavaScript learner dreams of. Phenomenal content!"
@asadorakzaipti
@asadorakzaipti 10 месяцев назад
A very well explained , thank you sir
@swarnabbanerjee9102
@swarnabbanerjee9102 6 месяцев назад
Great lecture
@vishwamshah4509
@vishwamshah4509 2 месяца назад
what an explanation bhai!!
@umairkhan5073
@umairkhan5073 Месяц назад
Sir g thusi great ❤
@arshitcc
@arshitcc 5 месяцев назад
Thank You Sir
@priyankagehlot9945
@priyankagehlot9945 2 месяца назад
kaafi majedar tha ye video
@torche6403
@torche6403 7 месяцев назад
Great One!
@mdrehanfarid2134
@mdrehanfarid2134 9 месяцев назад
GREAT PLAYLIST GOING ON ...
@apoorvaraj3894
@apoorvaraj3894 8 месяцев назад
Thank you for that 2nd IIFE.
@neerajdhakad2858
@neerajdhakad2858 4 месяца назад
Thank you
@hrushikeshmarathe5513
@hrushikeshmarathe5513 Год назад
Hi sir thanks for explaining such deep concepts.Waiting for react native episodes.Thanks in advance
@triptibhatnagar27
@triptibhatnagar27 5 месяцев назад
What is global scope pollution here ??
@swarajgaikwad2360
@swarajgaikwad2360 Год назад
@chaiaurcode - If we return some value in IIFE execution then where it will get stored?
@swarajgaikwad2360
@swarajgaikwad2360 Год назад
Or how we can store that return value ?
@manojnegi3502
@manojnegi3502 8 месяцев назад
thank you hitesh
@saudjavaid566
@saudjavaid566 2 месяца назад
yar ap love ho
@krishnavamsi1126
@krishnavamsi1126 3 месяца назад
learnt new things
@sanamukhtar4008
@sanamukhtar4008 3 месяца назад
thank you
@pankajpanday6351
@pankajpanday6351 11 месяцев назад
This is how global scope gets polluted var ex = "nagin"; // assume it is imported from library or written by other developer // some thousand line code if (true) { // we wrote this var ex = "good one"; // it broke the code below by modifying variable above console.log(ex); } // some thousand line code console.log(ex); // some other developer coded this and this is how IIFE prevents it var ex = "nagin"; // assume it is imported from library // some thousand line code (function () { if (true) { // we wrote this var ex = "good one"; // it broke the code below by modifying variable above console.log(ex); } })(); // some thousand line code console.log(ex); // some other developer coded this A normal function can also do the same job but if we don't need that function again, we usually use IIFE.
@Instrumentation010
@Instrumentation010 9 месяцев назад
Interesting topic
@iamkmsyed
@iamkmsyed 6 месяцев назад
Thanks Sir!
@vrajverma3907
@vrajverma3907 Год назад
IIFE function janta tha lkn aaj aur acche se jaana. Thank you so much sir.
@chaiaurcode
@chaiaurcode Год назад
Aur kyu use krna h ye b jaana 😁
@vrajverma3907
@vrajverma3907 Год назад
@@chaiaurcode aap jaise teacher honge toh kya, kyu aur kaise.. Inn teeno ka jawab mil jata hain. Ek request hain sir... NextJS ki bhi series bana dijiye aap
@talhakhan4684
@talhakhan4684 11 месяцев назад
Semicolon after IIFE We can also pass arguments to IIFE Named IIFE are IIFE function with name
@priyalss2910
@priyalss2910 10 месяцев назад
Very nice content sir 💯💯💯💯
@user-tm8sn8dz5j
@user-tm8sn8dz5j 3 месяца назад
thanks sir
@mithleshsingh2784
@mithleshsingh2784 9 месяцев назад
Great sir
@Manishkumar-kp5gr
@Manishkumar-kp5gr 7 месяцев назад
Immediately invoked function expressions😊
@ayush753
@ayush753 Год назад
Sir front-end or back end developer ka future scope keya hai sir 🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔🤔
@su1nta
@su1nta 3 месяца назад
arrow functions with implicit return needs to be terminated with a semicolon too; faced a case where I defined an arrow function with implicit return and then defined an IIFE. but the IIFE didn't got invoked unless I terminated the arrow function. Hope that helps someone.
@SoumiMaity-ux4gv
@SoumiMaity-ux4gv 9 месяцев назад
Thanks sir😊
@usama5619
@usama5619 10 месяцев назад
thank You !
@chaiaurcode
@chaiaurcode 10 месяцев назад
Welcome!
@atvmoviedigest
@atvmoviedigest 5 месяцев назад
Global scope mein kya pollution ho sakte hai , any practical scenario?
@BABABENNETT
@BABABENNETT 4 месяца назад
hitesh sir op
@technoyash2970
@technoyash2970 10 месяцев назад
thanks bhaiya
@ankushladani496
@ankushladani496 Год назад
Waiting for next lecture...❤
@Dev-Phantom
@Dev-Phantom 7 месяцев назад
new to me, cool
@chaiaurcode
@chaiaurcode 7 месяцев назад
😊☕️
@TEJASSADADE
@TEJASSADADE Год назад
great explanation
@user-nw6hb5xy9b
@user-nw6hb5xy9b 11 месяцев назад
thanks for this video sir
@AbhayGupta-ij6ji
@AbhayGupta-ij6ji 3 месяца назад
sir, can't we pass object inside a function when we are dealing with IIFE?
@poojasaid7761
@poojasaid7761 8 месяцев назад
Thanks
@aritraganguly3957
@aritraganguly3957 5 месяцев назад
This was asked in TCS ninja interview