Closures in JavaScript | Inside a loop, inner function and setTimeoout

  Рет қаралды 211,741

techsith

techsith

Күн бұрын

Пікірлер: 490
@kensleylewis
@kensleylewis 4 жыл бұрын
This is the first visual example of showing how let is different from var. Thanks for sharing this!
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad it was helpful!
@ravikumaryazali2529
@ravikumaryazali2529 4 жыл бұрын
I can proudly say that watching your JavaScript videos changed my knowledge level from beginner to medium, I know JS is like an ocean. Waiting on more n more videos from you. Thanking you is not just enough though
@Techsithtube
@Techsithtube 4 жыл бұрын
Great to hear! I will keep putting more such videos.
@mptakable
@mptakable 2 жыл бұрын
Thanks man for explaining a setTimeout inside for a loop with a var. It's priceless 👌🏻
@timfrailey1492
@timfrailey1492 6 жыл бұрын
Have read tons of closure examples and tutorials and I feel like have had a good understanding of them, but no one really broke it down in the way you did with each loop iteration. That is really the key to understanding why things are happening as they are. Great tutorial -- all of your videos are awesome
@Techsithtube
@Techsithtube 6 жыл бұрын
Tim, I am glad that you leaned from it. Thanks for watching
@cooldezign
@cooldezign 2 жыл бұрын
Your explanation is crystal clear !!!
@rick_from_yr
@rick_from_yr 6 жыл бұрын
Seriously, the best tutorial I've ever seen about closures :D
@abhilashvadnala5865
@abhilashvadnala5865 3 жыл бұрын
I felt Akshay Saini's closure video is the best
@zt.5677
@zt.5677 4 жыл бұрын
I saw your Javascript Closure tutorial ( Closures Explained ) from 2015 as well. Both of them are very good. Thank you for keeping both of them.
@flyingbirds4235
@flyingbirds4235 6 жыл бұрын
I started learning JS because of techsith.
@Techsithtube
@Techsithtube 6 жыл бұрын
I am glad you did. Thanks for watching!
@phalguniroy3351
@phalguniroy3351 5 жыл бұрын
@@Techsithtube me too. JavaScript seems very much clear after your videos.
@shivGGG
@shivGGG 4 жыл бұрын
You are amazing, Guru
@achyutrastogi8080
@achyutrastogi8080 5 жыл бұрын
Awesome, it's not the most complete video, but it explains a lot that most closure videos don't. Good job.
@kshitizshah6685
@kshitizshah6685 3 жыл бұрын
He has got guts and confidence , Salute !
@Techsithtube
@Techsithtube 3 жыл бұрын
Kshitiz, thanks for an awesome comment!
@murrayKorir
@murrayKorir 6 жыл бұрын
OmG this man is the man... I was using for loop with multiple queries inside it and several other callbacks, then at the end I had put a condition to check that the loop had finished, then finalize with a last update query..so the loop always ended before even the queries had finished processing what ta ef man!! it drove me crazy for days checked on stack overflow for solutions but those solutions were just too thick to understand so I found techsith, he explains it very well and made it look so easy. Thanks a lot of this. subscribed, liked and shared. The example with setTimeout() was a mind opener I was able to see the entire code universe, everything now made sense. wonderful work.
@Techsithtube
@Techsithtube 6 жыл бұрын
Carlos, I am glad that you finally got it. Please check it out my video on async await, that can be very useful. Thanks for watching!
@scbu92
@scbu92 6 жыл бұрын
I was always confused by the setTimeout with closures. Thank you for finally clearing that up for me!
@Techsithtube
@Techsithtube 6 жыл бұрын
I am glad you got it. Thanks for watching!
@momithachoubey786
@momithachoubey786 4 жыл бұрын
@@Techsithtube hello.... Can u really provide ur JavaScript tutorial to us, full course??? PLEASE...🙏🙏🙏 BTW LEMME TELL U I AM A BIG FAN OF URS... PLEASE PROVIDE ME UR CLASS DETAILS, REALLY WANNA LEARN FROM YOU SIR
@savitrimhatre2636
@savitrimhatre2636 4 жыл бұрын
This is the best tutorial ever I have came acrossed to learn Closure, difference between using var and let . I was really looking out for the explanation to the problem which you explained in the later part of the video. Thank you so much for the best explanation.
@shadymohammed3197
@shadymohammed3197 5 жыл бұрын
Every time I watch this video I'd like to like it again! You're an awesome teacher!
@MrBulciu
@MrBulciu 5 жыл бұрын
Woah, nice tutorial! I just found your channel and it is amazing. I didn't even feel those 16 minutes pass while watching. Thanks for making top notch content!
@Techsithtube
@Techsithtube 5 жыл бұрын
I am glad that you learn something . Thanks for watching!
@prakashbalaji2336
@prakashbalaji2336 4 жыл бұрын
Thanks a lot...man you cleared the my all the doubts about closures
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad to hear that
@bhanupartapsingh3166
@bhanupartapsingh3166 6 жыл бұрын
bro love love love love u ... it took me time to understand closure loop but end of day ... it is deep understanding knowledge and I am beginner so it's so useful for me .... liked shared ...already subscribed
@Techsithtube
@Techsithtube 6 жыл бұрын
I am glad that you got it in the end. Keep learning! Thanks for subscribing!
@henokgebremedhn1802
@henokgebremedhn1802 4 жыл бұрын
Best tutorial about closures by far, Thank you.
@muneerahmad1428
@muneerahmad1428 6 жыл бұрын
i liked it before watching it even before you said to "like it before watching it", as i have watched few JS tutorials on your channel in last few hours ,, cant resist clicking the "Like" button and yeah i am a subscriber now,,, Thank you so much for your efforts, #RespectForYou
@zakiahmed3198
@zakiahmed3198 4 жыл бұрын
your videos are such incredible js tutorial i have ever seen in youtube
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad you like them! Thank for watching!
@Karan60191
@Karan60191 6 жыл бұрын
wow that var and let concept for closures gave me goosebumps, well done Mr. Patel :)
@sagarshekhar6296
@sagarshekhar6296 5 жыл бұрын
I am new to Advanced JS....and I liked this video....Thanks
@Techsithtube
@Techsithtube 5 жыл бұрын
Thanks for a comment Sagar. :)
@xxdreadsaintxx
@xxdreadsaintxx 5 жыл бұрын
Mind blown! Never would have thought to look at it that way
@Techsithtube
@Techsithtube 4 жыл бұрын
:) Thanks for watching Justin.
@ankitapagaria8610
@ankitapagaria8610 4 жыл бұрын
I've seen so many definitions for closures but never really understood it. This video cleared a lot of doubts for me. Thank you!
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad it was helpful!
@coplepk04
@coplepk04 3 жыл бұрын
Great explanation of closures
@priteshm6823
@priteshm6823 4 жыл бұрын
your videos make learning super easy. Thanks man
@suprajakoppisetty8231
@suprajakoppisetty8231 6 жыл бұрын
Awesome, I have been struggling to understand many concepts and your tutorials are life savers! :D
@Techsithtube
@Techsithtube 6 жыл бұрын
I am glad that they helped you . Thanks for watching!
@daliborkozar870
@daliborkozar870 3 жыл бұрын
I advanced in JS and working in react and I just forget things, this is a great refresher
@Techsithtube
@Techsithtube 3 жыл бұрын
I am glad that you think so . Keep on learning!
@cancanjaker1620
@cancanjaker1620 4 жыл бұрын
Very good explanation of closure from a new perspective.
@sahityavemparala2099
@sahityavemparala2099 2 жыл бұрын
excellent closure explanation...
@murugesansubban
@murugesansubban 5 жыл бұрын
You are a good teacher.. I learnt a lot from you.. thanks
@Techsithtube
@Techsithtube 5 жыл бұрын
Thank you for an awesome comment Murugesan.
@ravimane5508
@ravimane5508 3 жыл бұрын
I am following techsith from last 2 years. Please make a tutorial series and add more videos on Javascript.
@aishwersharma8130
@aishwersharma8130 6 жыл бұрын
Thanks.Your effort deserves a bigggg like.
@prasadambaledath7699
@prasadambaledath7699 5 жыл бұрын
Wow , what an explanation about 'Closures' ! clear and precise !! Thanks a lot techsith !
@saurabhjarande5585
@saurabhjarande5585 4 жыл бұрын
Thank you Sir. You explanation and topics r very nice. It actually helps.
@ravindrakumarambati9194
@ravindrakumarambati9194 4 жыл бұрын
I like the way u explained . Thanks
@Techsithtube
@Techsithtube 4 жыл бұрын
Thanks for liking
@upendrakumarpandit5340
@upendrakumarpandit5340 2 жыл бұрын
thanks , you realy keeps your words whatever you said at the begining of lecture.
@diwakarnrp2092
@diwakarnrp2092 6 жыл бұрын
Your explanation is super sir
@himanshusharma3157
@himanshusharma3157 5 жыл бұрын
First half summary: "closure is a function which remembers its dependencies, so that it can be used outside of containing function." pretty simple... Second half summary (after for loop): it was about difference between var and let keywords. good example to explain scopes. but i din't understand how is related to closures. please explain that.
@satlibwanzai111
@satlibwanzai111 4 жыл бұрын
It demonstrates how the results of closure are changed by block-scope and function-scope.
@ExtraordinaryAF
@ExtraordinaryAF 4 жыл бұрын
You are right. He used closure to show the difference between var and let. var uses functional scope, so the variable 'i' in the closure of the set timeout function keeps getting updated (its the way var works). Let uses block scope, so the variable 'i' in the closure of the set timeout function does not get updated.
@theskydeath
@theskydeath 4 жыл бұрын
If you look closely, the settimeout function executes a callback at later point in time. And by later point means when the outer function has been already executed and it's variable, i, is not present in the lexical scope, But even then callback can access, value of i and that's the magic of closure.
@MinecraftN3rd
@MinecraftN3rd 4 жыл бұрын
with the var keyword in the set Timeout function, the function always updates to the new value of i. Each of the setTimeout functions update to the new value of i after the for loop is finished, because the I in the setTimeout has function scope, which means the variable is visible only inside the function. Where as with "Let" a new variable is used for each of the SetTimeout functions, so the I isnt updated to 3 at the end like all the others. Think of the run time of the for loop is much less than the setTimeout function.
@milindkhadse556
@milindkhadse556 3 жыл бұрын
Very helpful tutorial I don't know this differences. Thank you
@AddictedToCode387
@AddictedToCode387 4 жыл бұрын
probably the best video about this theme i have found so far, extra , perfect :)
@yanchuntang7750
@yanchuntang7750 3 жыл бұрын
great, best js tutorial ever seen
@lukehatcher98
@lukehatcher98 4 жыл бұрын
I loved the looping var vs let example
@shohruxdavronbekovich8267
@shohruxdavronbekovich8267 3 жыл бұрын
Great explanation!!! Thank you for your help!!!
@joesmi8638
@joesmi8638 5 жыл бұрын
This is a super good explanation. Thx.
@mmmmmmm8706
@mmmmmmm8706 5 жыл бұрын
That's the best video thumbnail I've seen on KZbin! One of the best on closures too.
@Techsithtube
@Techsithtube 5 жыл бұрын
Thanks you . I put lot of thought in each thumbnail .
@purvasawant6169
@purvasawant6169 6 жыл бұрын
This couldn't be a coincidence that I already liked your video before watching it completely. Time of the video 1:17 seconds, video liked. I wish there was a super like button.
@bharatchirumamilla2528
@bharatchirumamilla2528 4 жыл бұрын
A True Knowledge you share
@avdbzben
@avdbzben 5 жыл бұрын
You were absolutely right... It was very good
@subhashvishwakarma5203
@subhashvishwakarma5203 4 жыл бұрын
Really awesome ....big thanks to you for such videos
@reynandelizo1480
@reynandelizo1480 4 жыл бұрын
I liked your video your teaching is good and also worth it.
@ramdhenudhunia1507
@ramdhenudhunia1507 5 жыл бұрын
Well explained sir, hats off to you
@mysticaltech
@mysticaltech 4 жыл бұрын
A true JS expert! Thank you.
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad it was helpful!
@sujanmahmud9168
@sujanmahmud9168 4 жыл бұрын
Thank you, all of your videos are really good and better descriptive.
@alexbauer1193
@alexbauer1193 2 жыл бұрын
I loved your video. You're doing a great job.
@dorlinogullari
@dorlinogullari 4 жыл бұрын
Inspecting the new function with a console.dir was the key to understanding this. Basically the lexical environment of a function is stored within that function
@dhimanchakraborty5639
@dhimanchakraborty5639 5 жыл бұрын
The best tutorial I have seen ever.
@shourabhkumarraja1371
@shourabhkumarraja1371 3 жыл бұрын
love you sir!!.. you are awesome 🙏
@Techsithtube
@Techsithtube 3 жыл бұрын
Thanks for watching Shourabh!
@kaushalpatel2284
@kaushalpatel2284 2 жыл бұрын
Nice explanation 🙏
@deeproy7292
@deeproy7292 6 жыл бұрын
you blew my mind with that example...thank you!
@LtKeyser
@LtKeyser 4 жыл бұрын
In any of your tutos I learn some great trick. This console.dir thing is sweet. I'm still learning so I only know that much. Still I haven't seen it anywhere else and I've been doing quite a lot of reading and viewing these days. Good for you.
@bhanubaghel3012
@bhanubaghel3012 5 жыл бұрын
every time whenever i see your videos something new is must in your videos what i don't know it's a real tech chennal
@shibnathroy106
@shibnathroy106 6 жыл бұрын
Thank you for making such high-quality content available to us for *free* .
@priyankapardeshi6505
@priyankapardeshi6505 3 жыл бұрын
Good explanation. Thanks
@SumitJaiswalIndore
@SumitJaiswalIndore 4 жыл бұрын
Great explanation by @ techsith . thanks you for save our time.
@rajabhadariprasadvideos1996
@rajabhadariprasadvideos1996 3 жыл бұрын
the video is so useful to me thank you sir
@cmoney1928
@cmoney1928 5 жыл бұрын
Best explanation of this concept I have seen. I always do this but never understood why it worked.
@akshatbhatt4022
@akshatbhatt4022 5 жыл бұрын
I liked before watching the video.
@Techsithtube
@Techsithtube 5 жыл бұрын
Thanks Akshat for watching
@anonymous.youtuber
@anonymous.youtuber 4 жыл бұрын
Finally I understand this. Thank you so much ! 🙏🏻
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad it helped!
@Gwith126
@Gwith126 6 жыл бұрын
Wow, great video and released on my birthday!
@Techsithtube
@Techsithtube 6 жыл бұрын
Happy Belated Birthday! :)
@ruchirai5775
@ruchirai5775 5 жыл бұрын
Techsith- Genius , thanks for this video
@narsingyadav667
@narsingyadav667 6 жыл бұрын
very good teacher, the way you try to explain is awesome
@asitgupta4299
@asitgupta4299 6 жыл бұрын
Please you be in good mood and keep uploading useful tutorial for us..Well explained ..thnks Sir :)
@climbers1376
@climbers1376 6 жыл бұрын
7:03 block function 7:39 closures only show used variables within specified block function (shown via console.dir) 8:13 articulating closure
@Techsithtube
@Techsithtube 6 жыл бұрын
Thanks for the timeline.
@chapriprogrammer7838
@chapriprogrammer7838 2 жыл бұрын
Sir you are great😊
@MultiHeywatsup
@MultiHeywatsup Жыл бұрын
on 12:42, you mentioned we get a brand new 'i'. If thats the case, how does it remember its previous value to increment itself
@j.leonardomora2189
@j.leonardomora2189 4 жыл бұрын
Thank you so very much, always had a bad time with closures
@Techsithtube
@Techsithtube 4 жыл бұрын
Happy to help! Thanks for watching!
@jabezsamson
@jabezsamson 3 жыл бұрын
Your explanation is just out of this world! Thanks, man! You helped me a lot!
@Sleepytj007
@Sleepytj007 4 жыл бұрын
Thank you for the lessons
@emilewamsteker3412
@emilewamsteker3412 6 жыл бұрын
Hey Techsith, Thanks for taking the time do this video. This is a great explanation.
@Techsithtube
@Techsithtube 6 жыл бұрын
I am glad that it helped. Thanks for watching Emile.
@Street_Food_Adventuress
@Street_Food_Adventuress 4 жыл бұрын
You are absolutely right, I get an interview last week with a closure inside a loop question hahaha
@kmylodarkstar2253
@kmylodarkstar2253 4 жыл бұрын
Amazing dude. Really thanks, it's so important to learn by theory, examples and then challenges
@Techsithtube
@Techsithtube 4 жыл бұрын
Glad you think so! Fundamentals would take you far.
@peoples_amazing_life
@peoples_amazing_life 4 жыл бұрын
keep it up, sir. just now I have subscribed to your channel.
@AhmedMohammed-gy7mt
@AhmedMohammed-gy7mt 6 жыл бұрын
What an awesome tutorial I started love JS because of techsith
@Techsithtube
@Techsithtube 6 жыл бұрын
I am glad to have inspired you . Keep learning!
@sanketburde2025
@sanketburde2025 6 жыл бұрын
Very Good explanation..
@sivahari97
@sivahari97 4 жыл бұрын
For loop - Nice example bro...
@ammujosephshajan2460
@ammujosephshajan2460 4 жыл бұрын
Super cool and i really loved it
@vivekpadelkar5624
@vivekpadelkar5624 4 жыл бұрын
great video ...keep working ..............
@Techsithtube
@Techsithtube 4 жыл бұрын
Thank you, I will
@shikharchaudhary6984
@shikharchaudhary6984 5 жыл бұрын
Amazing explanation.
@deejaydev
@deejaydev 5 жыл бұрын
Thanks for the vital info
@Techsithtube
@Techsithtube 5 жыл бұрын
Thanks for watching Danjuma,
@TechAahar
@TechAahar 4 жыл бұрын
Great explanation with clear situations, thank you for sharing with us.
@ramya23041987
@ramya23041987 4 жыл бұрын
Very nice 👍 video.
@vivekvanga3588
@vivekvanga3588 6 жыл бұрын
Well explained sir... Thank you
@sunsneez
@sunsneez 5 жыл бұрын
Love your videos!! They are so helpful. Thank you.
@Techsithtube
@Techsithtube 5 жыл бұрын
thanks for watching Lexi. Keep on learning!
@christianteller661
@christianteller661 4 жыл бұрын
Great examples, thanks for your time!
@VishnuvardanRS
@VishnuvardanRS 6 жыл бұрын
I am really glad, I found your channel!
@Techsithtube
@Techsithtube 6 жыл бұрын
Thanks for watching Vishnuvardan!
@alvaroprietovideos
@alvaroprietovideos 3 жыл бұрын
Good video! Thanks for sharing
@NihilismEnjoyer98
@NihilismEnjoyer98 5 жыл бұрын
m********r makes it sound so easy!!! XD didn't get the immediately invoked function part at the end but, i'll just dig into it. Thanks for great explanation
@Techsithtube
@Techsithtube 5 жыл бұрын
:) Akshay, I am glad that you got some of the concepts. Keep on learning. I also have a video on immediately invoked function expression. do check it out.
@NihilismEnjoyer98
@NihilismEnjoyer98 5 жыл бұрын
@@Techsithtube sure thing. Thanks.
@manendra19
@manendra19 6 жыл бұрын
Great explanation of this problem.
JavaScript Modules ES6 ES2015 Tutorial
15:10
techsith
Рет қаралды 23 М.
Javascript Closure tutorial ( Closures Explained )
12:52
techsith
Рет қаралды 544 М.
Какой я клей? | CLEX #shorts
0:59
CLEX
Рет қаралды 1,9 МЛН
What are KPIs and Metrics? | Data Fundamental for Beginners
5:46
Alex The Analyst
Рет қаралды 2,1 М.
Tricky JavaScript Interview Questions and Answers
16:35
techsith
Рет қаралды 458 М.
Learn Closures In 13 Minutes
13:22
Web Dev Simplified
Рет қаралды 72 М.
Learn JavaScript CLOSURES in 10 minutes! 🔒
10:58
Bro Code
Рет қаралды 26 М.
Tricky JavaScript interview questions and answers
21:01
techsith
Рет қаралды 133 М.
Visually Understanding JavaScript Prototypes
14:58
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 55 М.
Programming with Math | The Lambda Calculus
21:48
Eyesomorphic
Рет қаралды 254 М.
javaScript promises explained tutorial
13:10
techsith
Рет қаралды 553 М.
JavaScript Pro Tips - Code This, NOT That
12:37
Fireship
Рет қаралды 2,5 МЛН