When I have some code I need to execute more than once I wrap it up in a function so I don\'t have to repeat myself. Sometimes in addition there\'s a need to execute this co
The second function foo
is a function definition expression.
In a function definition expression, you can only call the function with the name within the function itself according to "Javascript the definitive guide":
For function definition expressions, the name is optional: if present, the name refers to the function object only within the body of the function itself.
It can be used in a recursion function definition expression.
For example:
var f = function factorial(n) {
if (n == 0 || n == 1)
return 1;
else
return n * factorial(n-1);
}