Closures in Javascript

Just because we use certain tools very frequently, doesn’t necessarily mean we understand them as well as we could. Often, we use patterns we know will work, without really understanding why they work. This is certainly the way I use some of the more obscure parts of Javascript.

And so, after finding myself with some free time, I decided to sit down and think more deeply about a topic I generally try not to think too hard about. The topic I chose was the relationship (which previously I merely suspected to exist) between scope, garbage collection and closures in Javascript.

The results of my ruminations are collated in the presentation embedded here. My understanding of this area is now much clearer than it was before. I published the presentation in the hope that other people might find it useful too.

Needless to say, it’s easier to read in full-screen mode.

Bookmark and Share Category: Javascript, Tech

  • J (as the initial)
    Great slide, learned a lot, thanks.
    Seems to have a typo on page 34 and after, "e.childNodes.length[i].onclick" should read "e.childNodes[i].onclick"
    and in this particuliar example, childNodes would return the spans and their inner text, so alerts would display "1", "3" and "5"
  • The Steganography game: too easy!
  • We rule
  • Well done Mark, I don't think we broke the rules, either.
  • Will forward this along to my hacker/coder friends. Thanks David!
  • Cheers Mark.
  • Got to p26 after making a pretty wild visual replacement to the flash on VM and getting ready for sleep. One take away from playing with jQuery, Chrome (and likely other webkit optimized browsers) handle javascript incredibly faster than firefox. The good news, Chrome frame should work for all.

    (this is my poor man's bookmark to pick this up next time)
blog comments powered by Disqus

Back to top