Hoisting in JavaScript

JavaScript interpreters makes two passes over code.

In the first pass, the interpreter hoists variables and functions (i.e. moves declarations to the top of the scope).

The instructions in the code are then executed in the second pass.

References