The JS interpreter shares your preference of writing all var declarations at the top - in fact, at interpretation time they will be "hoisted" to the top of the scope. In other words:
foo()
var bar = 1;
is actually run as var bar;
foo();
bar = 1;