Practical Functional JavaScript: Code Samples

These are the code samples from my Ajax Experience 2008 talk, Practical Functional JavaScript. Click on a line to view (and run) that sample.

I've written out some of what I said about the samples in the first section. Check back later, and I'll update the rest.— Oliver Steele, 2 Oct 2008, Amherst, MA

1. Function Objects

  1. Callbacks
    1. Basic callback
    2. The long syntax
    3. Reprise
    4. Local (nested) function
    5. Pyramid order
    6. Using the function value directly
    7. Anonymous functions
  2. Functions
    1. Function-valued returns
    2. Variable capture
    3. Two different argument lists
    4. Function-valued arguments
    5. Storing functions
    6. Function registries
    7. Unfiltered
    8. Filtering
    9. Filtering with guards

2. Function Construction Tools

  1. Closures
    1. Functions share variables
    2. Invocation create distinct variables
  2. Idioms
    1. Special variables
    2. call and apply
    3. Method call and apply
    4. Stealing a method the wrong way
    5. Using apply to steal a method
    6. Slice
    7. Passing arguments to a function
    8. Copying arguments to pass to a function
    9. Extending Function's prototype

3. Case Studies: Callbacks