tags:

views:

98

answers:

4

every time i encounter this word i wonder what it really means. eg an event handler, is that a function?

$('a').click(function(){ ... });

is the click an event. and the handler the anonymous function?

+6  A: 

function is a generic word, if the function it does is handling an event then the function becomes an event handler.

Murali VP
+8  A: 

A function is a language construct. It becomes a handler depending on how you use it. When a function is registered with an event, it's an event handler. There are other examples of roles functions can play: a constructor is called when constructing an object, a callback is a function passed as a parameter to another function to call, and so on.

Ned Batchelder
+1  A: 

Yes, you've understood correctly.

Joe Mabel
+2  A: 

You're right and it usually works like this:

function somefunc(handler) {
  // do some lengthy tasks then notify handler
  handler();
}

somefunc(function(){ alert('test'); });
Mike Gleason jr Couturier