JavaScript - where to declare variables and define functions?
<p>Which is better:</p>

<pre><code>var foo = 0,
    fnFoo = function (bar)
    {
        "use strict";
        // Do stuff
    };

$(document).ready(function ()
{
    "use strict";
    fnFoo(foo);
});
</code></pre>

<p>OR</p>

<pre><code>$(document).ready(function ()
{
    "use strict";

    var foo = 0,
        fnFoo = function (bar)
        {
            "use strict";
            // Do stuff
        };

    fnFoo(foo);
});
</code></pre>

<p>The difference is the location of the variable/function declarations. In this case, assume that only the <code>ready</code> event needs to use <code>foo</code> and <code>fnFoo</code>.</p>
