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.