I have been declaring variables I use in multiple functions at the top of the file.
var a;
window.onload = function() {
a = 10;
}
function bar() {
if(a > 5)
//do something
}
This may be a bad example, but the question is does declaring variables at the top of the file harm anything?