In a nutshell and very simplified, hoisting works like this:
function), for which a new "scope object" will be created*
varkeyword (or other related keywords), it creates that symbol name on the current scope (with no value/
So after this process, you've got some intermediary representation of your source code, in which scopes are defined and local symbol names are reserved on it. That's how variable names are hoisted to "the top" before any code has actually been executed.