Frontend & browser·JavaScript in the browser
you called the function on line three and it worked, even though it is declared on line forty.
Hoisting
Declarations being processed before any code in their scope runs, so a function declaration is callable above its own definition. `var` is hoisted too but initialised to undefined, which is the source of the classic bug where a variable exists and is empty rather than throwing. `let` and `const` are hoisted without initialisation, which is what produces the temporal dead zone instead.