I am running into a strange scope issue with Javascript (see JSFiddle):
var someGlobal = 3;
function someF() {
// undefined issue
alert(someGlobal);
Since you are declaring a local variable with the same name. So it assigns the value to the local variable. Just remove the var from var someGlobal in someF() and it should be fine.
var someGlobal = 3;
function someF() {
// undefined issue
alert(someGlobal);
someGlobal = 5; // <-- orignially var someGlobal = 5
// Displays 5
alert(someGlobal);
}
function someF2() {
// Should display 5 now
alert(someGlobal);
}
someF();
someF2();