How cainiao learns JavaScript small experiment function quote _ basic knowledge

Source: Internet
Author: User
Because variable B stores the reference of the function, when the function changes, B also changes at any time, regardless of the order in which the function appears. Two times of alert (B), although the location is different, but the content is the same. The Code is as follows:


Function tt ()
{
Alert (11 );
}
Var B = tt;
Var b1 = tt (); // execute the tt () function


For function reference, you can directly assign the function name "tt" to the variable, but it cannot be in the form of function name + brackets "tt ()", because the second method is to directly execute this function.
When a function is called, the variable name and brackets are used, for example, B ().

The Code is as follows:


Function tt ()
{
Alert (11 );
}
Var B = tt;
Alert (B );
Function tt ()
{
Alert (22 );
}
Alert (B );
B ();


Because variable B stores the reference of the function, when the function changes, B also changes at any time, regardless of the order in which the function appears. Two times of alert (B), although the location is different, but the content is the same.
This is just a small experiment. Next we will study the closure problem in js.
Learn how to conquer RIA-JavaScript-based web Client development and the Chinese version of JavaScript authoritative guide.

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.