Why would I do this:
var myfunc = function() { /* code */ };
...
myfunc();
instead of this:
function myfunc() { /* code */ }
...
myfunc();
Are there any benefits of using one over the other? I have seen both examples used in different places.
The only difference as far as I can tell is that the anonymous function cannot call itself recursively while the named function can. There is a third type of construct that combines both of these, i.e. you can have a named function expression: