FnName (); function fnname() {...} //Normal, because ' Ascend ' function declaration, function call can be before function declaration
< Span class= "hljs-function" >fnname (); var fnname=function (//error, variable fnname has not saved a reference to the function, the function call must be after the function expression
var fnname= function () { alert ( ' Hello world ');} (); //function expressions are appended with parentheses, and can be called immediately when the JavaScript engine resolves here
< Span class= "Hljs-keyword" >< Span class= "Hljs-params" >function Fnname ( { alert ( ' Hello world ');} (); //will not error, but the JavaScript engine only resolves function declarations, ignoring subsequent parentheses, function declarations are not called
Function ( { console.log ( ' Hello World ' ); } (); //syntax error, although anonymous function is a function expression, but no assignment operation, // So the JavaScript engine takes the function keyword at the beginning as a functional declaration, an error: Requires a name for the functions
JS executes the function immediately, (). The preceding function is an expression and cannot be a function declaration