Novice Learning JavaScript Small Experiment Function Reference _ Basics

Source: Internet
Author: User
Copy Code code as follows:

function TT ()
{
Alert (11);
}
var b = TT;
var B1 = TT (); Perform the TT () function function

For a reference to a function, you can assign the function name "tt" directly to a variable, but not the function name + parenthesis form "tt ()" Because the second is to execute the function directly.
When calling a function, use the variable name + bracket form, such as: B ().
Copy Code code as follows:

function TT ()
{
Alert (11);
}
var b = TT;
alert (b);
function TT ()
{
Alert (22);
}
alert (b);
b ();

Since variable B holds a reference to a function, B changes at any time when the function changes, regardless of the order in which the function appears. Two alert (b), although the location is different, but the content is the same.
This is just a small experiment, the following research in the next JS closure problem.
Learn to use the book "Conquer ria--Web Client development based on JavaScript" and "JavaScript authoritative guide" Chinese version.
Related Article

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.