Under ECMAScript's syntactic grammar for function declarations, we have the Runtime Semantics: Evaluation of function declarations.
It states that a FunctionDeclaration does not return anything (i.e. empty), and does not run any other code. Specifically, no new Declarative Environment Record (DER) is created, no function object is created, and no binding of an identifier to that function object occurs in the DER.
A FunctionExpression, on the other hand, runs InstantiateOrdinaryFunctionExpression, which does the above (binding only happens if it's a named function expression).
If I write function foo() {}
it seems to me that it will be interpreted as a FunctionDeclaration, and thus no binding will be made on any environment record. Which means, when I call the function foo()
I get a ReferenceError (Source)
What am I missing?