Secrets of the Javascript Ninja

John Resig & Bear Bibeault

Derick Leony (@dleony)

Book content

  1. Preparing for training
    • Intro
    • Debugging & testing
  2. Apprentice traininig
    • Functions! (name, length, closures, scopes, ...)
    • this
    • Prototypes
    • RegExpThreads & timers
  3. Ninja training
    • Code evaluation
    • Decompilation
    • Cross browser strategiesDOM stuff
  4. Master training
    • Events
    • More DOM
    • CSS selector engines

Preparing for training

Ninja stars

JavaScript best practices

Testing frameworks

Our own assert

Apprentice training

Ninja apprentice

Function declaration

var foo = function() {} != function foo() {}

What's this?

It depends on the invocation. Four cases:

Prototype fun

Borrowing methods.

Modern browsers allow accessing HTMLElement.prototype.

More prototype fun

Faking inheritance.

Timers, intervals and events

JavaScript is mono-threaded.

Timeline of timers and events

Ninja training

Ninja training

Evaluating code

Decompiling

Work without with

Attributes and properties

Style properties

Master training

Master training

Events

DOM manipulation

CSS selector engines

ありがとう

Arigato

/