A few short summaries of the parameters of the function as another function in JS

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.