A small summary of the problem of passing functions as parameters of functions in JS
First, the simplest form of the parameterless function, the function name of the direct form function is placed in parentheses, and then in the execution part of the function.
Of course, the call should wear another really well-defined function.
/*
function Test1 (Func)
{
Func ();
}
function Test2 ()
{
Alert ("I am Test2");
}
Test1 (TEST2);
*/
The second, common invocation method with parameters. The only difference from the first is that when you call a parameter function in the EXECUTE statement that defines the main function, you add the parameter
/*
function Test1 (Func)
{
Func (MyData);
}
function Test3 (data)
{
alert (data);
}
Test1 (Test3 ("Zhangran"));
*/
This kind of, I understand for a while to understand, in fact, is also very simple, is the second reference function is not defined as the main function, when the parameters are generated, here is an anonymous function, oh so much
/*
function Test1 (Func)
{
Func ("Hello");
}
Test1 (function (data)
{
alert (data);
});
*/
http://blog.csdn.net/kaituozhe345/article/details/7236454
A few short summaries of the parameters of the function as another function in JS