When you usually use JS to write functions, it is generally customary function fn () {} to declare a function, in reading some excellent plug-ins when you see the var fn = function () {} the creation of such functions, exactly what they What is the difference between using it, today in the spirit of breaking the sand pot to ask the end, well say this fascinating--function statement.
function declaration
Function Sound Example code
function fn () { console.log (' fn function execution: ') ); // Code:}
So we declare a function called FN, and here's a thought, do you think it would be executed to invoke him on top of the function? Or will it be an error?
// before invoking the FN function we declared function fn () { console.log (' fn function execution: ') ); // Code:}
Console output Results:
Yes, at this point the FN function can be called, here to summarize the reasons.
1: The fn function is the result of a variable that is stored by default in a global context variable (can be verified by window. Function name)
2: This is a function declaration that is created during the global context stage and is already available in the code execution phase. Ps:javascript initializes the context (by global → Local) Each time the method is entered.
3: It can affect variable objects
The declaration of a JavaScript function object (@ INCLUDES function declaration and function expression)