Ya. I'm surprised that this works. I though variable hoisting in JS would take care of this. Apparently, hoisting in javascript will only bring the variable names to the top of your scope, not the definition of the variable. 
http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html