~/talk

JavaScript: Getting Closure

Talkat Web Directions Code 2012 · 2012-05-22..05-23· [javascript]
slides:none on file

Explains how immediately invoked function expressions work as a one-time wrapper, showing the exact parentheses trick, passing window and an undefined parameter to avoid older-ES quirks, and why libraries like jQuery, Backbone and CoffeeScript compile into IIFEs. Demonstrates concrete patterns: a module that returns a public API while hiding a private counter, the for-loop handler fix that uses a factory to seal each i value, and the fact that a closure retains original scope enabling private state and an emulated block scope until ES6 let arrives.

AI-written summary · about

  1. 0:00Intro
  2. 0:43Immediately Invoked Function Expressions
  3. 1:05Immediately Invoked
  4. 1:23Function Expressions
  5. 1:59Why is the difference important
  6. 2:24Do you always need parentheses
  7. 3:01Not the only way
  8. 3:11jQuery Sauce
  9. 3:53jQuery Plugins
  10. 4:38CoffeeScript
  11. 4:48nmloop
  12. 5:13Protecting Globals
  13. 5:54If
  14. 6:37One Statement
  15. 7:35Emulate Block Scope
  16. 8:48Copy Script
  17. 9:35Public Functions
  18. 10:08What is a Closure
  19. 11:07Closures are Useful
  20. 11:37Anonymous Functions
  21. 12:14SelfExecuting Anonymous Functions
  22. 12:39Naming Functions
  23. 13:23Wrapping
  24. 14:27Outro
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.