Why is this variable not being initalized?
<p>In the <code>&lt;head&gt;</code> of my page, I do this:</p>

<pre><code>&lt;script type="text/javascript" src="js/foo.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
  console.log(foo.bar);
&lt;/script&gt;
</code></pre>

<p>Code of <code>foo.js</code>:</p>

<pre><code>var foo = function()
{
    this.bar = function()
    {
        console.log('here');
    }
}
</code></pre>

<p>Later on in the html document:</p>

<pre><code>&lt;a href="#" onclick="foo.bar();"&gt;Test&lt;/a&gt;
</code></pre>

<p>However if I click that link above, it says function not defined even though foo.js has been included. Also if I do <code>console.log(foo)</code> it only shows 'function()' and <code>console.log(foo.bar)</code> shows undefined. Why is this, why can't I access the function?</p>
