The two look very much alike.
Functions declaration: Function Function name () {}
Functional Expressions: Function name (writable and not writable) () {}: Named function expression/anonymous function expression
For a few examples:
function aaa () {}: Functions declaration
var a=function aaa () {}: named function expression
var a = function () {}: an anonymous function expression;
(function aaa () {}): expression
Difference:
1. Function expressions can be directly followed by parentheses, and function declarations do not
function aaa () {alert (1);} () (Error)
var a=function aaa () {alert (1);} () (Run directly)
2. function declaration can be resolved in advance
if (true) {function aaa () {alert (1);}}
else{function aaa () {alert (2);}};
AAA (); The execution result is indeterminate, possibly 1, possibly 2, because the function declaration is pre-parsed and AAA is parsed before the IF
if (true) {var a=function aaa () {alert (1);}}
else{var a= function aaa () {alert (2);}};
A (); The execution result is 1 first executed if statement.
3. The difference between anonymous and named functions
var a=function aaa () {alert (1);}
A (); All browsers support
AAA (), non IE error but put AAA in the function can be. IE will parse it into a () and AAA ();
(function aaa () {alert (1)})
AAA () Non IE error.
function declarations and function expressions