This concept is known as “hoisting”.
However, variables that are hoisted return a value of undefined.
Because of hoisting, all var statements in a function should be placed as near to the top of the function as possible.
This best practice increases the clarity of the code.
In the case of functions, only function declarations are hoisted-but not the function expressions.