Function declarations precedence/overwriting variable declarations? Hoisting? Why?
Snippet 1: var a; // undefined variable named 'a' function a(foo) { // a function named 'a' var foo = "Hello World"; console.log(foo); } console.log(a); // output is: [Function: a], but why not undefined? Snippet 2: function a(foo) { // a function named 'a' var foo = "Hello World"; console.log(foo); } var a; // undefined variable named 'a' console.log(a); // output is: [Function: a], but why not undefined? I could have just shown Snippet 1 to ask this question - however I showed both just for completeness purposes. I have wrote some brief comments in them as well. My question is, in both cases