Why declare inside of $(function () { ... })?
<p>The application I am looking at loads an external javascript file which looks like this:</p>

<pre><code>$(function () {

    // Don't allow browser caching of forms
    $.ajaxSetup({ cache: false });

    var dialogs = {};

    var getValidationSummaryErrors = function ($form) {
        // We verify if we created it beforehand
        ...
        ...
        }
        return errorSummary;
    };
</code></pre>

<p>I understand that the file setups up some variables and also declares a function called getValidationSummaryErrors.</p>

<p>What I don't understand is why is this all within </p>

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

<p>What's the purpose of this? Can I not just declare the variable and things inside the flat file without the "$(function () { }" ?</p>
