NN 4, IE 4
You want to define a function in the form of an expression that you can, for example, pass as a parameter to an object constructor or assign to an object’s method.
You can use an alternate syntax for defining functions without creating an explicitly named function (as shown in Recipe 4.2). Called an anonymous function, this syntax has all the components of a function definition except its identifier. The syntax model is as follows:
varsomeReference
= function( ) {statements go here
};
Statements inside the curly braces are semicolon-delimited JavaScript statements. You can define parameter variables if they’re needed:
varsomeReference
= function(paramVar1
[,...,paramVarN
]) {statements go here
};