- use function statement,
- use function expression
The above two have the exactly same result. they will both define a function foo. But I found there are still one difference: scope.
But in function expression is different, the function call statement must be after the function is defined, otherwise the function call will be failed.
When you think a little deeper, the error of function expression make sense, because the function expression means first declare a variable, then assign it with a function object. Why it failed before the function defined is because the variable is not declared and assigned yet.