function tt()
{
alert(11) ;
}
var b = tt;
var b1 = tt(); //Execute the tt() function
For a reference to a function, you can directly add the function name "tt" is assigned to a variable, but it cannot be in the form of function name brackets "tt()", because the second method is to directly execute the function.
When calling a function, use the variable name in brackets, such as: b().
function tt()
{
alert (11);
}
var b = tt;
alert(b);
function tt()
alert(b);
b();
Since the variable b stores a reference to the function, when the function changes, b also changes at any time, regardless of the order in which the functions appear. Alert (b) twice, although the location is different, the content is the same.
This is just a small experiment. Let’s study the closure problem in js.
Chinese version of study books "Conquering RIA - Web Client Development Based on JavaScript" and "JavaScript Definitive Guide".