I have declared my array globally like so:
window.onload = function(){
var test = 'test';
var sel = new Array();
login_check();
};
Everything pretty much is inherited from login_check() function in my engine. The problem is whilst var test is set var sel is not set when i use it in a function.
I use this in my function :
console.log(test); //displays as intended
if(sel.length > 0){ //ERROR Uncaught ReferenceError: sel is not defined
//do something
}
I should mention sel is normally empty at this point. Does JS some how not allow global arrays to be set?
Instead make it truly global:
And in the function:
If still the same problem, it might be due to this, as
window.selis an empty array, it can be considered asnull.Try another method to keep the variable declaration out of the function: