1
JavaScriptIntermediate#closures#functions
During compilation declarations are registered before code runs. Function declarations are fully hoisted, var is hoisted and initialised to undefined, while let/const are hoisted but unusable until their declaration line.
greet(); // works
function greet(){ console.log('hi'); }
console.log(x); // undefined
var x = 5;
console.log(y); // ReferenceError
let y = 5;