What scope are variables globally defined by "var"?
<p>In Javascript, if I declare variables with var in javascript outside of a function</p>

<pre><code>var foo = 1;
var bar = 2;

function someFunction() {
    ....
}
</code></pre>

<p>are those variables within the scope of the document or the window? Furthermore, why does this matter? I know that if one declares a variable without var, then the variable is global.</p>

<p>Is there a simple way for me to test whether a variable falls within the scope of the document or the window?</p>
