[Javascript] Anonymous functions in parameter space

Paul M Foster paulf at quillandmouse.com
Wed Jul 20 12:03:05 CDT 2011


Hopefully, I'll get the terminology right here. If you, please correct
me.

Why is it common practice to write pass anonymouse functions as
parameters to other functions in javascript? Example:

function alfa(function(){ do_some_stuff; }){ do_other_stuff; };

I see this a lot, and it's unbelievably confusing to decode/read. Why is
it done this way? Instead, why not do it this way:

function bravo() { do_some_stuff; };

var charlie = bravo();

function alfa( parm ) { do_other_stuff; };

alfa(bravo);

Any help?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com


More information about the Javascript mailing list