The obvious difference:
1. A function declaration must begin with a function, and a functional expression must not be preceded by functions;
2. function declaration must have an identifier (function name), functional expression is optional;
The other difference:
1. The function declaration promotes the identifier (declaration elevation), and the function expression is not promoted;
2. function declarations and function names in named function expressions can be called inside the function itself, except that the named function expression cannot be called outside the function itself (not in the parent scope), but the function declaration can. As follows:
1 varex=functionexample () {2 varA=1;3a++;4 Console.log (a);5 example (); Internal call valid, correct;6 }7 8 example (); Error, where the calling function is invalid; example is not declared here;9EX (); Here the call to ex is valid;Ten One A functionexample () { - varA=1; -a++; the Console.log (a); - example (); //Internal call valid, correct; - } -Example (); The call function here is valid
The difference between a JS function declaration and a function expression