In JavaScript, the variables for function declarations and VAR declarations are promoted. But the function declaration is promoted before the variable declared by Var. Even if the function is written in the back.
Look at the following example:
var aa = 221; function AA () {alert (111);} Console.log (AA); 221
This indicates that the function declaration was promoted first. The subsequent var AA declaration overrides the AA function, so the print is------221.
The above statement is in fact the case when the browser resolves.
function AA () { alert (111);} var = 221; console.log (AA);
This adds that the function name of the function declaration is no different from the variable name of the normal object (Advanced Programming third edition). Indicates that the function name can be overridden by a variable.
function AA () { alert (111);} var aa = 221; console.log (aa); // 221
This is the same as the effect of execution.
Analytical:
function AA () { alert (111);} var = 221; console.log (AA);
Also, function is an object that defines properties and methods that can be defined on its body.
The method defined on it is called a class method, or a static method.
belong to this class only. The instance of the class cannot be called.
Example:
function AA () { alert (111function() { alert (' I am static method ');} AA.BB (); // eject "I am static method"
The description function can define a method.
function AA () {alert (111function() { alert (' I am static method ');} var New AA (); This sentence pops up 111, which runs the AA function. A.BB (); // uncaught typeerror:a.bb is not a function (...)
Indicates that an instance of a class in JS cannot call a class method.
function AA () {alert (111function() { alert (' I am static method ');} AA.C={ cc:5}console.log (AA.C); // Object {Cc:5}
Defines a property for a function object.
function promotion and VAR variable hint in JS