The second form is called a "named function expression". It gives you several benefits over normal function expressions:
You can find more detailed information here.
Using named function expressions also comes with some disadvantages. For example, doing f = function g() { ... } will actually create two entities -- the functions f and g, which can potentially be confusing. (see comments)  There are also some intricacies with scoping which can potentially cause bugs if you're not careful. You can find more detailed information here.