Javascript Closure Tutorial | Closures Explained
Vložit
- čas přidán 27. 06. 2024
- Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap
In this Javascript Closure Tutorial you will learn the concept of closure through multiple examples. Closures explained in this way may be easier to understand. Closure is often confused with lexical scope which is an important part of closure, but it is not closure itself.
Subscribe ➜ bit.ly/3nGHmNn
JavaScript for Beginners: Full Course (8 hours): • JavaScript Full Course...
Javascript Scope for Beginners: • var let const in Javas...
Javascript Closure Tutorial | Closures Explained
(0:00) Intro
(0:13) Example 1: Lexical Scope is not Closure / Closure Basics
(9:55) Example 2: Closure with an IIFE
(13:46) Example 3: Closure with an IIFE and a parameter
✅ Follow Me:
Twitter: / yesdavidgray
LinkedIn: / davidagray
Blog: yesdavidgray.com
Reddit: / daveoneleven
Was this tutorial about Javascript Closures helpful? If so, please share. Let me know your thoughts in the comments.
#javascript #closure #tutorial - Věda a technologie
Closure is often confused with Lexical Scope. Lexical Scope is an important part of closure, but it is not closure by itself. This tutorial provides several examples that should allow you to distinguish between lexical scope and closure. This tutorial should also allow you to learn how to give examples of closure if you are asked during the interview process. It is important to understand scope when we discuss closure. If you need to learn more about scope, check out my scope tutorial here: czcams.com/video/_E96W6ivHng/video.html
Thank you Dave ❤️
Thank you for another great video Dave!
@@YuRiSsS you're welcome! 🙏
@Abhijit Desaithank you! That's a great request 💯 I like that idea.
Hi!
Supposing you have some secret JavaScript functions that you don't want anyone to know. Also, that code (functions) are very resource consuming and this is why they need to be client side and not server side so you can't write those functions in python or php.
Also, obfuscation of JavaScript is not useful since it can be easily deobfuscated or seen by placing a breakpoint in the debugging tools in the browser.
This been said, could you make, please, a tutorial teaching us the best way to protect your secret JavaScript functions without paying for third party services?
Thank you so much in advance!
Out of all the yt tutorials on closures I've watched today, this one's been by far the best. Clearly explained step-by-step with readable code as illustration. Calm voice, proper English pronunciation and slow pace of speaking matter particularly to beginners like me. Unlike most teacher-coders on yt, you're actually capable of teaching. Thank you, good job, I'm going to watch more of your tutorials.
Glad I could help, and thank you! 🙏💯
Thank you, Dave! An extremely complex concept was explained clearly. Finally, I understood what closure is and how to use it in my code. The IIFE was a cherry on top. Thank you again.
Glad to hear it and you're welcome! 💯
You have a laid back, natural, and clear way of explaining things. Much appreciated!
Thank you for the kind words! 🙏🙏
This is the first video I've come across, so far, that really goes deep into clearly explaining that simply having an inner function and logging its parents' variables isn't a closure but a lexical scope. Brilliant!
Glad it was helpful!
I discovered you today, Dave and I am highly impressed with your teaching style. Unlike many other YT videos that teach all this stuff, I can actually understand you. (So many are hard to follow due to the thick accent of the instructor.) I'm looking forward to delving into other videos you have. Thank you!
I spent the whole day looking up videos to understand closure, and finally I could find the best one. Thank you so much.
Thank you so much for the kind words! 🙏💯
I spent the whole day looking up videos to understand closure. finally i git it so Thank you so much for clearly and simply explaining
You explained closures in a way that even a primary school student will understand. You definitely deserve a sub. Thank You so much, Dave!
You're welcome!
Finally I fully understood closure.... thank you and bless you
Dave grey taught me html and css! Now he's teaching me one of the javascript topics I find hard to understand! I love this guy, he's the best!!
I can't tell you how much I appreciate the pace of your speaking voice when explaining these concepts. So many of these youtube videos, the person is talking insanely fast, and I cannot keep up with all of it.
I'm glad it helps! 💯 If anyone wants it faster, CZcams lets them speed it up 😀
I has started learning web dev from your html videos ...last april .. thanx for teaching us and making begginer understand the relevant topics....
Just learned closure several days ago. This video definitely helped me review the concept. It also helped me clear up the confusion about lexical scope. Thanks Dave!
You're welcome! 💯
I have smashed that like button and I hope that this playlist keeps growing as these concepts really make a difference. Thank you for sharing your knowledge with us
You're welcome! Glad I could help 💯
Thank you very much, Dave. You explained it in a very beautiful way possible. You know I had been struggling from this since long. There wasn't any such explanation on the internet! Thanks a lot.
You're welcome, Umair 🙏
Dave, thank you so much for your tutorials! All of them are very well structured and easy to understand. I really appreciate all the work you do. Thanks again. Awesome channel! 💛
You're welcome!
Thank you for your video! This is the most understandable explanation of closures I've seen and has solidified my understanding of the concept. Really appreciate the emphasis on what "lexical scope" is and how it's an integral part of -- but not the whole story with -- closures. Truly awesome! Thank you, good sir!
Your tutorials are simply the best on CZcams, thanks for your effort you put for creation high quality content for free ! ❤
Thanks man, I've been struggling with this for days! This video finally made me understand closures (it gave me the aha! moment).
I liked the way your video went beyond the cliche closure examples which weren't allowing me to actually understand practical uses for closures.
Subscribed!
Thanks again, John - check out my tutorials on debounce, throttle, and memoize to see closures put to good use, too. 🚀
Best video tutorial on javascript closures on the whole internet.
Period!
Thank you!
I was writing closure example after example without really understanding the reason behind it and this video with credit example finally got the closure idea to click. Thank You.
Glad to hear it helped!
This was Amazing Dave!!
I wish I had stumbled across your video sooner! I've been trying to wrap my brain around closures for so long. Super helpful! You got a new subscriber!
Thank you, Beth!
Thank you Dave, you just got a new subscriber
Thank you so much for clearly and simply explaining this concept!
You're welcome, Stephanie!
well chosen examples demonstring the unique characteristics of closure. Finally undertand it now!
I watched maybe 10 videos on closure. Finally one person can explain it well, Dave Gray! You also crushed on that song white ladder.
Ha! I do share my name with a few others, but I'm glad I could help with closures! 💯🚀
Thanks dude, it's so clear. I will definitely rewatch this over and over again until I am very familiar with the concept.
The majority of videos made by other content educational creators across various websites talk like they're rappers, you sir are different. Things went much clearer after this video and made me realize that the majority of my confusion is because most of my searches were actually lexical scopes and not closures.
I really am indebted to you.
You're welcome!
thank you, Dave! as always, easy to understand, yet consise and to the point.
Glad it was helpful! 🚀
Thanks for all you do, Dave. Your videos are the best. I've watched several videos on closures, but none of them explained it better than you did. I finally understand closures!
Awesome, thank you!
It’s so refreshing to listen,well explained.Thank you Dave
You are very welcome
Probably the best Closures video I have ever watched. Thanks!!
Glad you liked it!
Thank you so muchhhh
The best closure explanation ever
just found out about this series! Loving them
Thank you, Chetan! Glad you like it! 💯
i watched too many closure videos but first time i understand clearly . thank you so much
Glad it helped! 💯
This is by far the best explanation of JS closure. Thank you Dave. I'm glad I came across your channel.
Glad it was helpful!
One of the best video on closure
this man, helps me to understand closure quickly and easily!
Glad to hear it! 🚀
Good job Dave, thank you so much.
You're welcome!
Finally , finally I could wrap my head around this concept. It's so basic and easy.
Glad I could help! 💯
thank you for wonderful examples! I didn't know this was possible
I really found this explanation about lexical scope and closure the best one from CZcams. Thank you.
Glad it was helpful! 💯
Thanks Dave you could help me to understand the most confusing concept in js, after I read a lot of articles and watched a ton of tutorials.
You're welcome! Glad I could help. 💯
Thank you! Finally understood this important concept.
Glad I could help!
Clearest explanation of what closures are I've found. Great stuff.
Glad it was helpful!
this is an underrated tutorial, i had to got to the bottom of the page on the youtube to get this video. these explanations & examples are more than enough to understand what closure is.
Glad it helped!
finally found a video about closures that makes sense. Thanks
Glad it helped!
Finally I understood JS closures!
Subscribed!
Glad to hear that!
You made closure clear to me! Thank you so much!
Glad it helped!
this helped me a lot,thank you
Excellent explanation, thank very much for this video!
Thanks. You re the best explanator :D
Before coming across your video I had already watched three other ones that weren't explanatory enough for me. Thank you so much for this video; I got everything. Thank you.
You're welcome! 💯
Awesome explanation! Subscribed and digging other videos! Thanks man!
Thank you! 💯🚀
Thank you, Dave. I have enjoyed your Closuer explanation.
Thank you! 🙏
Thank you so much. I finally understand closures
Happy to help! 💯
Thanks, Dave! You are really good at explaining! 😊
You're welcome, Joosep!
wow...Great explanation...Thank you, Dave...
Thanks Dave for this video, please continue the advanced js playlist. You explaining hard concepts easy to understand.
You're welcome, Shiva! I do plan to do more 🚀🙏
This was a masterclass on how to explain abstract concepts with easy-to-follow, real-world examples. Thank you. Subbed!
Awesome, thank you!
Best explaination on the web. Great job sir! Thank you!
The best and detailed "Closure" explanation on the internet
Thank you! 🙏🚀
Thank you ! The explanation is extremely clear for beginners.
Glad it was helpful! And you're welcome! 💯
This tutorial is so well structured it simplified the closure concept in a brilliant way!! Thanks a lot
You're welcome! 💯
This is the best tutorial on Closures.
Thank You!
Glad it was helpful!
I "Thumbs Upped" your video. I've been studying JS recently for a few months, and to my surprise everything is getting easier to understand, like I'm on the steeper part of the learning curve. I've been getting a clearer picture of what closures are, but your explanation helped even more to demystify closures to me. You have a very sensible, logically explanatory and intelligent way of explaining closures. I'll be checking out your other videos because I like your teaching style. Who knows, maybe I'll buy you a cup of coffee :).
Thank you for the kind words 🙏💯
Your videos are absolute gems 💎. Keep up the good work.
Thank you! 🙏
Just a quick thought.
I think the "credits =- 1" line should be at the end of the function since we need to check credits' amount first to evaluate the possibility of playing. In the example we should be able to play 3 times and it only allows two plays.
Everything aside, great video and I always find your explanations very helpful!
Thank you for clear examples, I finally understood. I looked at other youtubers and it was confusing.
Glad it was helpful! 💯
thank you so much, this helped tremedously! subbed!
Glad it helped! 💯
This video was an instant subscribe. It was well thought out and clear, and I now understand two concepts much better than ever before. Closure kind of blew my mind. Thank you so much for sharing your knowledge!
Welcome aboard! And glad it was helpful!
Thank you for clarifying IIFE, it's syntax that has been tripping me up and now I understand what it's doing. Excellent demonstrations for closures.
Thank you, Wallace. 🙏
Great! Great! Great! Thank you very much! Very good explanation! Very good examples!
You are welcome!
It was very interesting, thank you so much
Great videos man. Loving your content. Love the axe behind you too, RIP Eddie!
Glad you enjoy it!
Excellent explanation of closure. Thank you!
You're very welcome! 💯
Dave, you need to seriously consider putting together a Javascript course with projects for Udemy. Your explanations are crystal clear. I have found myself doing course after course, stopping, and then trying to find someone else who would be able to explain the concept a bit clearer than the instructor. It wastes a lot of time. I have found myself coming here for the past three or so concepts, and they click straight away. So thank you.
Thank you, Darryl! I do hope to put a premium course together sometime later this year. I am not sure if Udemy is where I will launch it though.
Clear, simple, concise, well spoken and very useful. I followed along with your code in my IDE (Velo) with no difficulty. Thank you.
Great to hear!
Really loved the ball field analogy! At times I’ve struggled to explain the concept of closures to teammates. this will help greatly… thanks for the great content!
Glad it was helpful!
thank you very much for putting effort in making these tutorials !!!
You're welcome!
Great video! Cleared up a lot of confusion.
Great to hear! Thanks for the note 🙏
Not bored at all. Nicely presented. :)
Thank you! 🙏
Awesome, thank you!
You're welcome!
This is the best closure explanation for me... Great work.
Glad it was helpful! 💯🚀
Thank you Mr.Gray 🤍
You're very welcome! 💯
Really helpful! Thank you!
You're welcome!
great explanation!
The best teacher to explain advanced concepts of Javascript. Instant subscription!
Welcome aboard! 💯🚀
I love your explanation so much, thanks from Egypt.
Glad it was helpful! And hello to Egypt! 👋
your last example was lovely , thank you
Glad you liked it!
Thank you so much , for this explanation i was so confused about closure
Glad it was helpful!
This is really great explanation! Thank-you Mr. Dave
You're welcome! 💯🙏
muy bueno y super claro, gracias Dave. ;)
De nada mi amigo!
I finally understood it. Thank you 😊
Glad it helped!
Brilliant explanation IIFE , my friend.Thanks
Glad it was helpful! 💯
Best video about closure so far. You are a very good teacher.
Thank you, Ren! 🙏
Super usefull examples, congratz man!
You're welcome!
People misunderstand js a lot. People like u make it relevant for us js peeps. Keep going!
Thank you!