If functions in JS are first-class, what allows them to be called before they are defined?
Don't first class functions mean that they behave as variables? Clearly they don't behave exactly like variables though, since this: console.log(foo); var foo = 'bar'; ...doesn't work, whereas this: console.log(foo()); function foo() { return('bar'); } ...does. That said, this: console.log(foo()); var foo = function() { return 'bar'; }; doesn't work, which is more consistent. What gives? Because you don't compare the same thing. In your example - you compare function declaration function foo()... with variable declaration and assignment in var foo = 'bar'; A more correct comparison would be of