May 2010 Meetup Minutes
By Ken Snyder, published 2010-05-07
Ken Snyder presented at the May 6th meeting on “Inheritance, Event Delegation and Named Function Expressions”Named Function Expressions
- Declarations are in the form `function name() {}`. Expressions are part of a code expression such as assignment: `var name = function name() {}`
- Declarations are parsed immediately so the functions can be run before declared; they are parsed even if in closures or conditional statements. Expressions are parsed when encountered.
- Declarations are useless unless named. Expression functions can be unnamed and will show up in stack traces as `?` or `anonymous`; when named, the name is only defined within the function itself (except incorrectly in IE).
Prototypal Inheritance
Event Delegation
- When child content is changed (e.g. via AJAX), the event handlers do not need to be re-attached
- CSS selector engines can be used to call different handlers for different child elements
- There are fewer event handlers