I am running into a strange scope issue with Javascript (see JSFiddle):
var someGlobal = 3;
function someF() {
// undefined issue
alert(someGlobal);
someF creates a new (locally scoped) variable called someGlobal (which masks the global someGlobal) and assigns a value to it. It doesn't touch the global someGlobal (although cannot access it because there is another variable with the same name in scope).
var statements are hoisted, so someGlobal is masked for all of someF (not just after the var statement). The value of the local someGlobal is undefined until a value is assigned to it.
someF2 access the original (untouched) global someGlobal.