I just discovered that the following code executes without error (Chrome):
console.log(fa);
function fa(){}
I was under the impression that:
function fa(){}
was identical to:
var fa = function(){};
My assumption had led me to believe that my code block above should have resulted in an error due to fa
not having been declared before it was called. The second form however, when used in my code sample above, will produce an error because fa
has not been defined yet when the first line runs.
Is there some documentation or information somewhere that covers the fact that the function
keyword, when used declaratively, is preparsed, thus exposing said function in advance of the actual order of operation of the lines of code in a script?