• Sunday , 27 May 2018

Javascript Closures Tutorial – What makes Javascript Weird…and Awesome Pt 3

Code Canyon

What is a closure? In this Javascript Tutorial, we’re going to be learning about closures – our 3rd most misunderstood concept of Javascript.

Watch the full playlist:

Hopefully, we’re going to break it down enough to make it simple to understand for newbies and intermediate coders alike.

Javascript closures are really not that complex of an idea.

The textbook definition of a closure is a function that retains state and scope after it executes. Basically put, when the function’s done, a callback might need to access the variables inside later…so Javascript remembers those variables. That remembering of the variables is called a closure.

Original source

3d Ocean

Related Posts


  1. Kumar Ankit
    July 3, 2017 at 05:49

    You got yourself a new subscriber!!
    BTW i wanted to learn back-end programming which one should I learn PHP or node.JS??

  2. TaWReOn
    July 3, 2017 at 05:49

    So damn good explanation. Thanks, mate.

  3. Wahid Khudayar
    July 3, 2017 at 05:49

    Do you have any complete video for downloading option?

  4. Владислав Ковальский
    July 3, 2017 at 05:49

    where JS))) without jQuery please

  5. Pramesh Bajracharya
    July 3, 2017 at 05:49

    Such an awesome video. Very informative. Thanks a lot. But where is the part for scope and context? I cannot find it. Can somebody give me the link?

  6. Joseph Coulam
    July 3, 2017 at 05:49

    Hi, I'm slowly moving over from AS3 to JS. I'm wondering if (in this example) a were an object or an array, would you have to nullify the object or array before it gets picked up by garbage collection? For example, a = ["val1", "val2"]. (then before closure) a = []. AS3 had an odd tendency to keep certain things in memory – is this the same with JS?

  7. Samuel Montgomery
    July 3, 2017 at 05:49

    wow. i wish jason from codeschool explained it like this. cant believe i still did not know what a closure was. he really explained it in depth though, i wonder why i couldnt comprehend it from him. is this a simple way of explaining it? are there more complicated expressions of closures? whats a good place to read further on closures? thanks man.

  8. Haleem ul Hassan
    July 3, 2017 at 05:49

    Literally the best explanation on the entire internet on closures! Much appreciated guys. Thank you

  9. Lars von der Burg
    July 3, 2017 at 05:49

    I'm amazed by the quality of the content you're putting up here! There's a ton of JS material out there but the fact that this is about the 20th of your videos that I'm watching speaks for itself.
    Just to help fellow learners along, a lot of these JS concepts are super weird when you come from more classical object-oriented languages like Java (as it was the case for me). A really good summary of essential JS concepts with respect to functional programming can be found here: http://jrsinclair.com/articles/2016/gentle-introduction-to-functional-javascript-intro/

  10. Daniel Stephany
    July 3, 2017 at 05:49

    Thanks for posting, this is one of the best explanations of closers that i have come upon. Thumbs up for sure!

  11. Joshua van Meer
    July 3, 2017 at 05:49

    Alrite, finally get it, thanks

  12. Ali Kalkandelen
    July 3, 2017 at 05:49

    Will, Where is the memory that is storing the javascript code and all the closures? Is the browser taking a small memory block out of your computer to store it every time you load the page? Just wanted to know.

  13. Tomm Tomm
    July 3, 2017 at 05:49

    This has always been a mystery to me until you explained in a very clear manner. Now I can "see" what's going on with my code. Thanks.

  14. Younes Keraressi
    July 3, 2017 at 05:49

    thx dude , 4:07 hehehe so funny

  15. KL Tah
    July 3, 2017 at 05:49

    Sorry if I didn't catch it, but just to confirm, the thing that is called the closure here is the variable 'a'. Is that correct? I've seen the word closure used as an adjective instead of a noun before so I'm a bit confused

  16. B
    July 3, 2017 at 05:49

    Good tuto but jQuery is too big and introduces weird syntax, you shouldn't teach vanilla js concepts with it.

  17. Anthony Albertorio
    July 3, 2017 at 05:49

    Best description on closures that I have seen.

  18. nathan hyland
    July 3, 2017 at 05:49

    I wish there were less of these tutorials in JQuery. Vanilla JS is the way to go for learning. Nobody should learn IN JQuery.

  19. jasbcor
    July 3, 2017 at 05:49

    Thanks, that was one of the clearest and least complicated explanations I've seen about closure.

  20. Sawyer McBride
    July 3, 2017 at 05:49

    great tutorial man. by the way, what mac do you have?

  21. theConfusedGuy
    July 3, 2017 at 05:49

    It would be awesome if you can explain how to use IIFE with closures. Lets say if an loop you want to remember and return each looped value instead of the last value. Until this day, I am still confusing about it.
    Btw, I just want to say your tutorials are the best so far. Much better than many large website's vague tutorial

  22. Carl Wicker
    July 3, 2017 at 05:49

    Once again… thank you 😀

  23. manish kumar
    July 3, 2017 at 05:49

    Yours tutorials r awesome (y)
    Is there any list of topics u have covered,, as sometimes its very tough to find ur video tutorial in a sequential manner.

  24. GXB
    July 3, 2017 at 05:49

    how i can make my website public?

  25. Allen Nie
    July 3, 2017 at 05:49

    I was almost wondering where are the rest two videos, then I realize you made this one only a week ago. Thanks for making this series. You can explain things so clearly and so effectively. It's incredibly hard to find a good video like this!

    I think people might want a release schedule for your tutorials 🙂

  26. Andres Rivera
    July 3, 2017 at 05:49

    I agree with Sergey, plus more into the ExecutionContext – Runtime Environment.

  27. DeAndre Johnson
    July 3, 2017 at 05:49

    I really enjoy your tutorials! Waiting for next video in series! Thanks you for this!

  28. Holmes
    July 3, 2017 at 05:49

    Nice videos! Waiting for the next coming 🙂

  29. Nazmul Hossain
    July 3, 2017 at 05:49

    Waiting for next video 🙂

  30. Sergey Romanov
    July 3, 2017 at 05:49

    ALready waiting for the rest. And I think you need to add another one JS Objects. There are many ways to create an object and how and why you can initialize function as an object with "new" state.

  31. Netanel Basal
    July 3, 2017 at 05:49

    which color scheme you use?

  32. J King
    July 3, 2017 at 05:49

    Thanks for the series, this sort of short and quick video style is great!

Leave A Comment

You must be logged in to post a comment.