Basically, when JavaScript compiles all of your code, all variable declarations using var are hoisted/lifted to the top of their functional/local scope (if declared inside a function) or to the top of their global scope (if declared outside of a function) regardless of where the actual declaration has been made. This is what we mean by “hoisting”.
Functions declarations are also hoisted, but these go to the very top, so will sit above all of the variable declarations.
However, a key thing to note is that the only thing that gets moved to the top is the variable declarations , not the actual value given to the variable.
All declarations (var, let, const, function, function*, class) are "hoisted" in JavaScript.