JavaScript Scope
<!DOCTYPE html> <html> <body> <h2>Function Hoisting</h2> <script> greet(); // "Hello!" - works because the declaration is hoisted function greet() { console.log("Hello!"); } // A function expression is NOT callable before assignment: // sayBye(); // TypeError: sayBye is not a function var sayBye = function () { console.log("Bye!"); }; </script> </body> </html>