A function can run before its declaration appears in the code. JavaScript makes this possible by registering identifiers when it creates a lexical environment, before executing that environment’s code. section 5.5.3
In global and function environments, registration scans for function declarations without entering other functions’ bodies. It creates a function for each declaration and binds it by name; a later declaration can overwrite an existing binding. Function expressions and arrow functions are not registered this way. Function environments also receive the implicit arguments identifier and formal parameters with their argument values. section 5.5.3
const firstRonin = "Kiyokawa";
check(firstRonin);
function check(ronin) {
assert(ronin === "Kiyokawa", "The ronin was checked! ");
}
See a function called before its declaration; its parameter receives the value passed at the call site. section 5.5.3
