JavaScript Hoisting
Javascript is an interpreted language, it goes line by line executing the code. When declarations are moved to the beginning of the scope, this is known as hoisting.
Get German Mardones’s stories in your inbox
Join Medium for free to get updates from this writer.
In other words, we can call a function and define it further down, because JS will upload the definition of this function to the beginning of the scope.
Finally JS does the following
In the case of Variables, it only applies in the declaration and not in the assignment, leaving the previous example as follows.
if we were to put the “max” declaration at the end of our code and initialize it with “=3” this would throw us an error.









