JavaScript Closures Tutorial (Explained in depth)

  Рет қаралды 60,237

ColorCode

ColorCode

Күн бұрын

JavaScript Closures Tutorial, FINALLY explained!
Full playlist here: • 20 Things JavaScript D...
Closures are incredibly difficult to explain and understand, and sadly they come up in interviews all the time. Why do we need Closures? And how can you use them to your advantage?
JavaScript Closures from the series "10 Things JS Developers Should Know"
by ColorCode.io, Sina Jazayeri
This is episode 9 in a 10 part series I’m calling 10 things javascript developers should know but probably don’t. In this series, we’re going to cover some of the most fundamental and important parts of JavaScript that most of us don’t actually know, and barely touch. Today, for episode 9, we’re talking about JavaScript Closures, what do they actually mean, why they exist, and how to use them. Episode 9: Closures. Let’s go!
All the code from this series is available here:
github.com/ColorCode/js-10-th...
0:00:00 Intro
0:01:23 What is a Closure?
0:02:14 Theoretical Example: Outer function + Inner function
0:11:14 What makes Closures special
0:11:28 Practical Example: Click handlers
0:17:28 Outro

Пікірлер: 234
@ColorCodeio
@ColorCodeio 2 жыл бұрын
JavaScript closures! 🎉💻
@satk2554
@satk2554 2 жыл бұрын
It's been a month and half, please drop in the finale...!!!
@ColorCodeio
@ColorCodeio 2 жыл бұрын
@@satk2554 Most likely this weekend.
@DevCoder
@DevCoder Жыл бұрын
can you explain Hoisting in js too😊
@ColorCodeio
@ColorCodeio Жыл бұрын
@@DevCoder Good idea
@dansmar_2414
@dansmar_2414 2 жыл бұрын
It's not just a javascript tutorial, but also how to comunicate and express yourself. This series is on my top bookmarks now. Thank you again!
@ColorCodeio
@ColorCodeio Жыл бұрын
You’re welcome! 😀
@thomaswinterburn6680
@thomaswinterburn6680 7 ай бұрын
Excellent video explains it so well, I did some digging and found why it stays in memory. So like quantum entanglement theory, the outer function is entangled with the inner functions so, the JavaScript engine uses garbage collection to clean up memory that is no longer reachable. Because the inner function still has a reference to the outer function's environment, that environment is considered reachable and isn't garbage-collected. This allows the inner function to access variables from the outer function even after it has finished executing.
@nyxthevoyager
@nyxthevoyager 4 ай бұрын
The intro was a couple of seconds, but pretty inspirational. Thank you! I decided to change my career at 28, and everyone looks like they know everything about programming. I am too late for the party. Knowing this little ptsd of yours is supportive of people like me!
@ColorCodeio
@ColorCodeio 4 ай бұрын
You are definitely not too late to the party. You have plenty of time. Keep pushing.
@vladislavamarkova8379
@vladislavamarkova8379 2 жыл бұрын
Another great explanation of a topic which is indeed hard to grasp! Clear, practical, and so nice to watch! Thank you, keep going that way. Wish you all good! : )
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thanks Vladislava!
@rafahathibrahim
@rafahathibrahim Жыл бұрын
First time on your channel and now also my favourite for javascript. Theres so much quality in your work, and that too is for free. Thankyou, you have my utmost respect.
@ColorCodeio
@ColorCodeio Жыл бұрын
Thank you
@fariskanbur5428
@fariskanbur5428 Жыл бұрын
Another excellent explanation :) We are looking forward to the coming of such series about js and similar special topics. Thank you very much for answering many questions on many people's minds.
@ColorCodeio
@ColorCodeio Жыл бұрын
Thanks Faris
@eumm11
@eumm11 6 ай бұрын
these videos are so well done that you barely notice the time passing
@ColorCodeio
@ColorCodeio 5 ай бұрын
😀
@andcap2239
@andcap2239 2 жыл бұрын
What a great channel!!! OMG, this is all i needed to understand some of the difficult stuff into JS. Thks for your content!
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Great to hear!
@jomariiringan8724
@jomariiringan8724 Жыл бұрын
Awesome! This is one of the question from my job interview together with the Higher order function which you explain it much simpler than i imagine. This will also improve my code structure & development performance, Thanks!
@ColorCodeio
@ColorCodeio Жыл бұрын
Glad it was helpful!
@aziham.
@aziham. Жыл бұрын
Wow, Sina! Your last example on closures was exactly what I needed to finally appreciate their usefulness. Previously, when passing a function to an event handler, I always wondered how I could pass something to that function while also passing it to the event handler. I was concerned that it would execute immediately rather than when the event occurred, and that I would only have access to the event object. However, your example has answered all of my questions. Thank you so much, Sina! Your teaching style is phenomenal, and I would love to see you make a video tutorial on JS debouncing. I've watched a lot of videos on the subject, but I think your approach would be particularly helpful.
@ColorCodeio
@ColorCodeio Жыл бұрын
Thanks, that’s a good idea.
@75jkd
@75jkd Жыл бұрын
I am in a full stack program and I think I learned more about closures in this video then the class on them in school. Awesome!
@ColorCodeio
@ColorCodeio Жыл бұрын
Glad I could be helpful. What are you learning in your class?
@thomaswinterburn6680
@thomaswinterburn6680 7 ай бұрын
School for fool @@ColorCodeio
@B-Billy
@B-Billy 2 жыл бұрын
This is first time on your channel, and I am amazed by the the knowledge you put and the video editing & presentation skills are PRO. Perfect!! 🎉🎉
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you
@tyv1383
@tyv1383 10 ай бұрын
I feel like he should have more subscribers, it’s the only closure video I’ve seen so far that goes really in depth with the examples
@arghyadas2836
@arghyadas2836 10 ай бұрын
@@tyv1383 I totally agree. These videos are really well explained. His presentation is also top notch.
@J4RMAMS
@J4RMAMS 9 ай бұрын
You’re great Sina!!! You’re god sent and put out quality content that clarifies JavaScript concepts that are sometime not very digestible for new developers and aspiring ones.
@ColorCodeio
@ColorCodeio 9 ай бұрын
You are so welcome!
@quangtranoannhat2930
@quangtranoannhat2930 2 жыл бұрын
Great video. Thanks for making me have a deeper understanding of Closure
@ColorCodeio
@ColorCodeio 2 жыл бұрын
You're welcome :)
@steffancrowley
@steffancrowley 2 жыл бұрын
Honestly this is the best video on the closures I’ve seen, thanks!
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you
@keronwilliams5392
@keronwilliams5392 2 жыл бұрын
Love this series! Thank you King!
@ColorCodeio
@ColorCodeio 2 жыл бұрын
You’re welcome 🙏🏼
@mlbbfans
@mlbbfans 6 ай бұрын
Really like the way you explain the concepts. How nice would it be if you create a video convering all the fundamentals of JavaScript in one video
@thegohmez6816
@thegohmez6816 Жыл бұрын
Amazing. About halfway through I figured out....I have been using closures this whole time. Another great example is writing a custom hook to fetch in React. Great stuff. You describe things really well.
@ColorCodeio
@ColorCodeio 5 ай бұрын
Awesome 🎉
@apq2589
@apq2589 Жыл бұрын
What a great class you have brought us! I agree with you that this is a very though theme, but you had explained it with in a terrific way! Thank you Sina Qoli! 😃
@ColorCodeio
@ColorCodeio 5 ай бұрын
Thanks!
@snode373
@snode373 2 жыл бұрын
Dude. A real person here. Thank you for everything. I'll always come back here and will bring others with me. Much love ✌🏽
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you. Made my day :)
@ssyedyaseens
@ssyedyaseens 10 ай бұрын
This is incredible! Thanks for this!
@ColorCodeio
@ColorCodeio 10 ай бұрын
My pleasure!
@FameRK
@FameRK 2 жыл бұрын
Well explained. Worth the wait. Thank you.
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thanks dude
@137dylan
@137dylan 2 жыл бұрын
I have been studying JS since early last year, and despite thinking I already had a strong grasp of closures, this video helped bolster my understanding. Molte grazie! It would be great if you released some videos on TypeScript as the trend indicates it will be the standard for FE development (at least) in the coming years.
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thanks! I'll consider TS for future videos.
@santhoshk9285
@santhoshk9285 2 жыл бұрын
great video 🔥 waiting for eps 10
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Will be coming soon
@karthikk6769
@karthikk6769 2 жыл бұрын
You have my respect. Great explanation.
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you 🙏
@Icode2395
@Icode2395 4 ай бұрын
The Last example was insane🔥
@ColorCodeio
@ColorCodeio 4 ай бұрын
🔥
@xViolaine
@xViolaine 3 ай бұрын
Pretty sure it's also directly taken from MDN Webdocs under "Practical Closures"
@hansheinrich700
@hansheinrich700 Жыл бұрын
The click handler is a good real world example! However, I think in this case it would've been great to move your code from the browser console to a code editor. The browser console is great for bugfixing and testing but maybe sonewhat confusing for beginners. Apart from that: great video.
@abelmarkos5753
@abelmarkos5753 2 жыл бұрын
Very nice This tutorial series helped explaining Alot of the most confusing and hard to understand topics in javascript So thank you very very much for that
@ColorCodeio
@ColorCodeio 2 жыл бұрын
That’s awesome! I’m glad
@anejasahil
@anejasahil Жыл бұрын
The best explanation of closures on KZbin i have ever seen
@ColorCodeio
@ColorCodeio Жыл бұрын
👍
@ankitrawat927
@ankitrawat927 Жыл бұрын
Well done Sina !! Thanks for the explanation.
@ColorCodeio
@ColorCodeio Жыл бұрын
🙏
@alexgill1997
@alexgill1997 2 жыл бұрын
Another great video! An ASYNC video would be a blessing!
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Great suggestion!
@mattsmith6828
@mattsmith6828 11 ай бұрын
@10:30 - This all makes sense. I think it's also worth noting the difference between instance variables (object properties) and local variables - which can be created in a function but not in other objects. Inside of this function, "const name = n", the variable "name" is a local variable. The only ways to access this variable are to access it from inside of the function, to use a "getter" function or include it in a "return" expression. On the other hand, inside of a function, instance variables (not listed in this function) are declared using the "this" keyword as an access modifier. Ex - this.age = 21 Instance variables inside of a function are basically the same as a property inside of an object (excluding functions). Instance variables are accessible from outside of a function, but only after creating an INSTANCE of that function, hence the name. Local variables inside of a function are inherently protected because they have block-level scope to that function. Parameters in a function are actually declared and instantiated in the body of the function as local variables. In this example, he's using "human" as a (callable) function, and not as an object. I know this because he's invoking "human" without the "new" keyword, and he also included a "return" expression. It's also a hint that he didn't create any instance variables, using the "this" keyword. I hope this helps someone. I'm still relatively new at this, but I think I'm catching on. Great video!!!
@zackplauche
@zackplauche 26 күн бұрын
Dude your editing among coding videos and explaining concepts is absolutely supreme! How can I be like you?
@shaunlobsinger
@shaunlobsinger 2 жыл бұрын
This was a great video! When I started deving forever ago, I wish someone would have explained it to me like this 😆
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Haha thanks dude
@nikhilchauhan7511
@nikhilchauhan7511 Жыл бұрын
a really good video. you explained closure really well.
@ColorCodeio
@ColorCodeio Жыл бұрын
Thanks!
@Kannada_discover
@Kannada_discover 10 ай бұрын
This is your teaching is pretty good...keeep continue dude
@ColorCodeio
@ColorCodeio 9 ай бұрын
Thanks!
@chucksresume7203
@chucksresume7203 Жыл бұрын
Excellent content and explanation. Subbed.
@ColorCodeio
@ColorCodeio Жыл бұрын
Thanks Chuck.
@mdshoharabpk1126
@mdshoharabpk1126 Жыл бұрын
you are so great and also your explanation is so great. thank you so much.
@ColorCodeio
@ColorCodeio Жыл бұрын
🙏
@user-de4zh8qm4w
@user-de4zh8qm4w 2 ай бұрын
loved the explanation
@eazy2195
@eazy2195 Жыл бұрын
Great example, understood clearly, if you console.log sina for example and click on the functions, you can see, at least in the chrome browser, under scopes it actually says Closure and it shows you the variables that are being saved or remembered from the original function, it even displays the original function name
@EdwinManual
@EdwinManual 2 жыл бұрын
Very underrated channel. Great videos bro. Keep doing it.
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you!
@puchkag.p6459
@puchkag.p6459 5 ай бұрын
You deserve more subs mannn... Keep up the quality Content 😀😀
@ColorCodeio
@ColorCodeio 4 ай бұрын
Thanks
@sumonbarai7218
@sumonbarai7218 Жыл бұрын
you are a great teacher . thanks for every video that's are provide javascript community. watching from Bangladesh 🇧🇩🇧🇩
@ichiroutakashima4503
@ichiroutakashima4503 9 ай бұрын
I know this is a year old video but it is still very helpful. I hate that I'm using closures but I don't know how to explain it. It's like, watching a video in another language without subtitles. Though you can understand it, you can barely speak it. That's how closures to me are.
@ColorCodeio
@ColorCodeio 9 ай бұрын
I hear you
@AhmadAli-wt8zy
@AhmadAli-wt8zy 2 жыл бұрын
You are amazing teacher you deseve more subscribers👍👍
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you. With time subscribers will come 😉
@jatilyadav4000
@jatilyadav4000 Жыл бұрын
New Subscriber... Just loved your content...Want to gain more knowledge from your content... Keep uploading Best of luck Sir.........
@ColorCodeio
@ColorCodeio Жыл бұрын
Welcome aboard!
@essaadi_elmehdi6784
@essaadi_elmehdi6784 2 жыл бұрын
That's great my brother, thank you 🖤🔥
@ColorCodeio
@ColorCodeio 2 жыл бұрын
👍🎉
@JoeBoo532
@JoeBoo532 2 жыл бұрын
Loving how you present your video! I have to ask what them is that being used on your video? :)
@ColorCodeio
@ColorCodeio 2 жыл бұрын
It's just Chrome DevTools console in dark mode.
@toneking972
@toneking972 Жыл бұрын
Great explanation. I would add that variable value is long lived because closure variables are placed into heap memory and not the stack memory.
@raymondogbuehi
@raymondogbuehi Жыл бұрын
What does this mean exactly?
@pranavgpr5888
@pranavgpr5888 2 жыл бұрын
God, really a great video of explanation! Looking forward for more videos like this. Keep rocking 💥⚡
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you!
@oilybrakes
@oilybrakes 4 ай бұрын
Something makes me believe that the better example for closures, would have been a website with an input field, which has to wait 2sec before processing the data, so that we make sure that user is done typing. (Such as how search engines do it, that fetch possible suggestions of what it is that you are typing in) Not sure how to code it, but I remember that when I did, closures was something I had to think about.
@satk2554
@satk2554 2 жыл бұрын
Absolute code-heavy content from this series and the viewers will be gifted with all the valuable information explained in a crystal clear manner. After all, I am calling people `Sina` and `Qoli` in real LOL.....!!! Respect from INDIA.
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Haha that's hilarious. Thanks Sat!
@mihaipascu4975
@mihaipascu4975 Жыл бұрын
Excelent tutorial !!! Thanks !!!
@ColorCodeio
@ColorCodeio Жыл бұрын
👍
@mabutzke
@mabutzke Жыл бұрын
This explanation was great! I went ahead and created this crazy closure example lol. It creates a function on the fly with a combination of function factories: function math() { function calc(x) { return function (y) { return x / y } } return function (n) { const y = calc(n) return function (z) { return y(z) // Function created on the fly } } } const divide = math() const example = divide(6)(3) const example2 = divide(12)(4) console.log(example) // 2 console.log(example2) // 3
@ColorCodeio
@ColorCodeio Жыл бұрын
Push it up to GitHub and send me a link. Very difficult to read it in comments.
@baxilio3518
@baxilio3518 Жыл бұрын
great video, thanks a lot for the effort
@ColorCodeio
@ColorCodeio Жыл бұрын
Glad you liked it!
@user-mw5bm2xh9x
@user-mw5bm2xh9x 6 ай бұрын
thanks for the explanation
@AhmadAli-wt8zy
@AhmadAli-wt8zy 2 жыл бұрын
why this guy don't have subcribers?
@danielbenson2627
@danielbenson2627 10 ай бұрын
TBH, your YT Shorts invited me to your channel, as you were among the few to successfully fit the concept of closures in a minute video 😅😅 Coming to your page for the first time today, i am really glad for KZbin to suggest your page to me Thank you for the Teaching, very attention grabbing and visual... God bless you ❤❤
@ColorCodeio
@ColorCodeio 9 ай бұрын
Thanks for taking the time to write 👍
@jakubfrei3757
@jakubfrei3757 Жыл бұрын
I love Your sense of humour in combination with explaining, thx And sub:)
@ColorCodeio
@ColorCodeio Жыл бұрын
Awesome, thank you!
@beckychan5792
@beckychan5792 5 ай бұрын
Thank you Sina!
@ColorCodeio
@ColorCodeio 5 ай бұрын
You’re welcome
@DevCoder
@DevCoder Жыл бұрын
awesome and clear explain, thank you so much, can you explain Hoisting in js too😊
@ColorCodeio
@ColorCodeio Жыл бұрын
Good one. I'll do an episode on it.
@alfredpithu
@alfredpithu 7 ай бұрын
Man! I am a fan now. Take love from Bangladesh ❤
@ColorCodeio
@ColorCodeio 4 ай бұрын
Hello Bangladesh
@piotrdros430
@piotrdros430 Жыл бұрын
I hope your channel will grow, as I by watching your videos
@ColorCodeio
@ColorCodeio Жыл бұрын
Thank you ♥
@carsugarmodels
@carsugarmodels 8 ай бұрын
Bravo! Very nice explanation
@ColorCodeio
@ColorCodeio 7 ай бұрын
Ty!
@basilvj1227
@basilvj1227 9 ай бұрын
can you explain advanced react hooks like useMemo etc. Btw great presentation
@user-uq3mp6de4n
@user-uq3mp6de4n 7 ай бұрын
I wanted to ask at 15:50 does writing return inside clickhandler would work instead of creating function.
@ColorCodeio
@ColorCodeio 7 ай бұрын
Yes it would
@ClashRoyale-pt9zj
@ClashRoyale-pt9zj 10 ай бұрын
excelent video. Your talking is unique
@ColorCodeio
@ColorCodeio 10 ай бұрын
🙏
@thunderstruckx996
@thunderstruckx996 Жыл бұрын
Amazing quality of video, well spoken and multiple examples. Definitely a like and subscribe from me!
@ColorCodeio
@ColorCodeio Жыл бұрын
Awesome!
@youshouldaknown
@youshouldaknown 9 ай бұрын
closures are variables and functions that are within the components function.
@samanehhg4347
@samanehhg4347 11 ай бұрын
Thanks for your great explanation🙏 can you please have some c++ tutorials too??
@ColorCodeio
@ColorCodeio 11 ай бұрын
Last time I wrote C++ was 20 years ago. Probably not the best person to teach it 😃
@AndrewTSq
@AndrewTSq Жыл бұрын
Lol. I have watched 3 big youtube developers explaining closures , and they made it sound like some global variable. or maybe a class. but now I even understand why I should use it!. big thanks.
@ColorCodeio
@ColorCodeio Жыл бұрын
Awesome! 🤘
@sanvirahmed
@sanvirahmed Жыл бұрын
In your channel, the about section says, 'Coding Tutorials for regular people! 🎉👨🏻‍💻📽 ' but, you are irregular 😃 By the way, I'm a fan of your explanation style. I look forward for your video. 🥰
@MikeJazayeri
@MikeJazayeri 2 жыл бұрын
Awesome video!
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Sank you 🙏
@kirupaagar6674
@kirupaagar6674 Жыл бұрын
What kind of human are u..watched hell lot of videos on this topic..but now am crystal clear
@ColorCodeio
@ColorCodeio Жыл бұрын
Awesome!
@kirupaagar6674
@kirupaagar6674 Жыл бұрын
@@ColorCodeio sir, you have any plan to have complete. JS course?
@ColorCodeio
@ColorCodeio Жыл бұрын
​@@kirupaagar6674 Yes. It was planned to be released earlier this year but it will be closer to the end of the year. Sign up here for early access: www.colorcode.io/js-mastery
@kirupaagar6674
@kirupaagar6674 Жыл бұрын
@@ColorCodeio done signup... Waiting for First day first show
@ghasembaghban.g7887
@ghasembaghban.g7887 8 ай бұрын
GREAT!
@kaltube4817
@kaltube4817 8 ай бұрын
Well Done
@Kourosh_ey
@Kourosh_ey 10 ай бұрын
You are the best! 😍
@ColorCodeio
@ColorCodeio 9 ай бұрын
You too
@yazeezy4425
@yazeezy4425 10 ай бұрын
This channel rocks!
@ColorCodeio
@ColorCodeio 10 ай бұрын
You rock too
@powerpulsar3
@powerpulsar3 2 жыл бұрын
Good explanation 👍👍.
@ColorCodeio
@ColorCodeio 2 жыл бұрын
👍
@k0secha
@k0secha 5 ай бұрын
TI ptsd is real 😭😭😭 thanks Sina 💯💯💯
@ColorCodeio
@ColorCodeio 4 ай бұрын
😳😭
@pharmacistbuilder
@pharmacistbuilder Жыл бұрын
are you able to share another real world example of closures, or perhaps a common use case for closures ?
@khanalhome2988
@khanalhome2988 2 жыл бұрын
Beautiful just Beautiful and Thank you too
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you
@Salah-YT
@Salah-YT 2 жыл бұрын
12:30 painful to type inside the console, ok bro this is what I'm talking about ok bro I'm a beginner and I'm struggling with JS for about a year now so that is why I said better use VScode it will be good for everyone and me :-) so please I Love ur channel ur so clever and explains a very good and funny time I like that so thank u so much bro I was looking for that u say painful :-) thx bro keep it up, please
@user-fp9hl9cf1q
@user-fp9hl9cf1q 2 жыл бұрын
You are the best!
@ColorCodeio
@ColorCodeio 2 жыл бұрын
🙏🏼
@SahilKumar-xz1xs
@SahilKumar-xz1xs Жыл бұрын
Very good tutorial. That click handler example was too good. I used onClick in place of onclick and struggled for half an hour 😪
@TechleadConsulting
@TechleadConsulting 7 ай бұрын
You are the best 🎉🎉🎉🎉
@ColorCodeio
@ColorCodeio 7 ай бұрын
So are you
@youmnaification
@youmnaification Жыл бұрын
Isn't that the inner has to be returned in order to call it a closure. I think what you were showing us was just a lexical scope being accessed by the inner funcs.
@severgun
@severgun Жыл бұрын
Ok closure holds outer values at creation moment. 16:20 Why not to pass size inside function as parameter?
@wiktorchojnacki9746
@wiktorchojnacki9746 Жыл бұрын
You could, but that is unnecessary as the value is already available inside the inner function. Creating another parameter as you suggest would allocate another piece of memory towards holding that value
@JJ-ot3ps
@JJ-ot3ps Жыл бұрын
hey for the second example, I am not sure if i got closure lol, for the first example I got it, so when you return object from the function in that case it is a bunch of methods, and then you later create instances that can still invoke the methods of the human function even though human function is gone. the reason is because once human is called, human function is gone. But somehow the method did not gone? ....
@nermeenaliabdelhakeem422
@nermeenaliabdelhakeem422 7 ай бұрын
Thank you a lot
@ColorCodeio
@ColorCodeio 4 ай бұрын
👍
@canklc5772
@canklc5772 8 күн бұрын
a late discovery for me. thanks bro
@3prohor
@3prohor 3 ай бұрын
Brate, svaka ti se dala i na kolena pala.
@sc657953
@sc657953 Жыл бұрын
I have found the following two situations in websites with closures. I am wondering if you can shed light on why people would do this? First, a function is invoked at return. Like the following (note that the wt function does not return a value): return wt() Second, a variable being set in a return. Like the following: return t.m = e If anyone that sees this can shed light on this it would be greatly appreciated. I'm utterly confused as to why anyone would do those.
@robertoromanramirez4080
@robertoromanramirez4080 Жыл бұрын
sina you're awesome
@ColorCodeio
@ColorCodeio Жыл бұрын
Roberto you’re awesome too!
@ritikarana757
@ritikarana757 2 жыл бұрын
Awesome :)
@ColorCodeio
@ColorCodeio 2 жыл бұрын
Thank you!
@thedevbek
@thedevbek 5 ай бұрын
Thanks for explaining this thang called closure... I love your hair.
@ColorCodeio
@ColorCodeio 4 ай бұрын
Thanks!
@dhaneshmane
@dhaneshmane 10 ай бұрын
perfect
@Pareshbpatel
@Pareshbpatel 11 ай бұрын
An excellent tutorial on JS Closures. Thanks, Sina. {2023-06-19}
@ColorCodeio
@ColorCodeio 11 ай бұрын
👊👍
@abdosameh6391
@abdosameh6391 Жыл бұрын
I love this vidoe 😍😍
@ColorCodeio
@ColorCodeio Жыл бұрын
This video loves you back
Arrow Functions JavaScript Tutorial - What NOT to do!!!
31:48
ColorCode
Рет қаралды 50 М.
Which one will take more 😉
00:27
Polar
Рет қаралды 81 МЛН
Learn JavaScript CLOSURES in 10 minutes! 🔒
10:58
Bro Code
Рет қаралды 10 М.
Async JavaScript & Callback Functions -- Tutorial for Beginners
24:21
How do closures work? (JavaScript Fundamentals, 2023)
9:12
Andrew Burgess
Рет қаралды 6 М.
garbage.collect() / Андрей Роенко (Яндекс)
48:07
Frontend Channel
Рет қаралды 7 М.
Higher Order Functions - JavaScript Tutorial
10:10
ColorCode
Рет қаралды 58 М.
Inheritance in JavaScript - Prototypal Inheritance tutorial
20:06
STOP Using Classes In JavaScript | Prime Reacts
14:02
ThePrimeTime
Рет қаралды 210 М.
Javascript Closure tutorial ( Closures Explained )
12:52
techsith
Рет қаралды 542 М.
Which one will take more 😉
00:27
Polar
Рет қаралды 81 МЛН