Difference of definition of function in javascript/jQuery
<p>version 1:  </p>

<pre><code>function add(){
var a = 2;
...
...
...
}
</code></pre>

<p>version 2:  </p>

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

<p>Where is the main difference of two versions? For version 2, it does not have the function name. If it just simply run the code in the function, why not just remove the <code>$function(){..};</code>. It really makes me confusing because nowadays, many scripts are written in style of version 2. Please help to clarify my confusion. </p>
