JS function Reference, function call and callback function

Source: Internet
Author: User

var Function1=function2;

1. The result of calling the Function1 () function is exactly the same as calling Function2 () because two functions refer to the same code, so the function name is also called a function call.

2. The difference between the reference function and the calling function is related to whether the function name is enclosed in parentheses, and the function reference will only appear separately, but the function call must be followed by parentheses, often with an argument attached.

3.window.onload=function () {

Function1 ();

}

At this point function1 () is the callback function, and all other events on the webpage can be joined in the OnLoad event handler. The OnLoad event handler becomes an event initialization function that sets up other events in the Web page, so the OnLoad event not only performs general Web page startup tasks, such as initialization, it also joins other event handler callback functions to the application.

Such as:

//go to page default displayWindow.onload=function() {boundarydesign.clearroom (Context,obj,scale);    Tiledesign.clearfloor (Ctx,obj,scale);    Zone.initroomdata (Obj,minx,miny); //Default Display Menu$ (". Select"). Children (). EQ (0). Trigger ("click"); $(". Select"). Children (). Click (function() {      if($ (". Select"). Children (). EQ (1). Hasclass (". Active") && $ (". Mode_list"). Children (). EQ (3). Hasclass (". Active ")) {        $(". Default-static"). attr ("Disabled", "disabled");    }    }); //Disable right mouse button default menu$ (document). Bind ("ContextMenu",function(e) {return false; })  });

JS function Reference, function call and callback function

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.