Thing is, in Javascript all variables declared inside a sub-block always exist in the full-scope of the function. So declaring it twice as you did will be interpreted as duplicate. (yeah I know, it's weird). See http://code.tutsplus.com/tutorials/javascript-hoisting-explained--net-15092

Best practice is to always declare all variables at the top of functions, because this is what JS does internally.