Javascript function in external file is undefined when declared in a certain way
<p>myfunc() runs successfully when called from within the same js file. but it is undefined (Firebug) when called from an HTML page:</p>

<p>JS file:</p>

<pre><code>$(function() {
    myfunc() {
        alert('inside myfunc');
    }
    alert('outside myfunc');
    myfunc(); //this successfully runs myfunc()
});
</code></pre>

<p>HTML:</p>

<pre><code>&lt;script&gt;
$(function() {
    myfunc(); //this doesn't run myfunc(). It's undefined
});
&lt;/script&gt;
</code></pre>

<p>But when I change myfunc() declaration to:</p>

<pre><code>myfunc = function () { ... }
</code></pre>

<p>It's no longer undefined, and runs successfully.</p>

<p>Sorry for this very noob question, but what just happened? Why did it work when I changed the way I declared the function?</p>
