Global variable not defined from onclick?
<p>I have declared my array globally like so:</p>

<pre><code>window.onload = function(){
   var test = 'test';
   var sel = new Array();
   login_check();
};
</code></pre>

<p>Everything pretty much is inherited from <code>login_check()</code> function in my engine. The problem is whilst <code>var test</code> is set <code>var sel</code> is not set when i use it in a function.</p>

<p>I use this in my function :</p>

<pre><code>console.log(test); //displays as intended
if(sel.length &gt; 0){  //ERROR Uncaught ReferenceError: sel is not defined 
 //do something
}
</code></pre>

<p>I should mention sel is normally empty at this point. Does JS some how not allow global arrays to be set?</p>
