This document discusses JavaScript best practices around avoiding global namespace pollution, using closures effectively, and different approaches to object-oriented programming in JavaScript. It presents questions at different skill levels related to these topics, from basics to more advanced concepts. The document emphasizes techniques like revealing module pattern, scope manipulation with call() and apply(), and using intrinsic JavaScript features over pseudo-classical patterns.
2. Rob Robbins
www.robrobbins.info
www.github.com/robrobbins
www.twitter.com/robrobbins
www.jsmag.com (xdisc20)
w's. o's, and b's oh my!
3. Bullets for presenters who ramble:
(re-reads synopsis)
The global namespace. Or not?
Closure? How many are googling now?
OO? Where did your training go?
-- next time --
CS.I? O(n) is not a new text message shorthand!
4. N00b vs Pirate vs Ninja
N00b What is the global? What's in
there already?
Pirate What is a naming collision?
How to best avoid them?
Ninja Explain this form:
(function() {} ())
5. The Global and you
This? Number 1 error
Function soup? Examples EVERYWHERE
Function scope Versus block scope
Callbacks Often point to window, oops
Site hierarchy How do you spell hierarchy?
Namespaces Can we use them?
6. N00b vs Pirate vs Ninja
Noob What is a closure?
Use a var referenced via
Pirate closure
Ninja Create a function that, given
an int, returns a functor which
when called increments or
decrements the original int
7. Now you see it. Now you do.
Revealing module Yahoo, Douglas Crockford
This = that; Handy scope reference
FUNCTOR Best. Word. Ever.
call() and apply() Allow scope manipulation
8. N00b vs Pirate vs Ninja
N00b What is OO?
Pirate Explain JavaScript's
inheritance model
Ninja Implement psuedo-classical,
prototypal, and functional
inheritance