 function declarations are moved to the beginning of each function (its scope) - this is known as Hoisting. Having said so, it is a good practice to declare all the vars altogether on the first line, in order to avoid false expectations with a var that got declared late but happened to hold a value before - this is a common problem for programmers coming from languages with block scope.
</p>

<p class="source">
    Source: <a target="_blank" href="http://www.adequatelygood.com/JavaScript-Scoping-and-Hoistin