Note that both behave differently - functions defined by function
statement are defined before the code executes.
typeof f; //returns 'undefined'
var f = function() {};
but
typeof f; //returns 'function'
function f() {}
(Have you also noted where I did and where I didn't use semicolon?)
Also, function statements (the second option) are forbidden in blocks. It is not defined how the following should work:
if (false) {
function f(){}
}
thus it's possible that function f
will be, although illogically, declared in some browsers. However, it's permitted to do the following:
var f;
if (some expr) {
f = function() {};
}
Next time better search before asking a question, var functionName = function() {} vs function functionName() {}