JavaScript - self executing functions
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/423228/difference-between-function-and-function">Difference between (function(){})(); and function(){}();</a>  </p>
</blockquote>



<p>Sorry if this is a stupid question.</p>

<p>I am trying to understand a few of the features of JavaScript a little better. In <code>The Definitive JavaScript</code> it says that self-executing functions should have brackets round them like so:</p>

<pre><code>var obj = (function() {
    var value = 0;

    return {
        increment: function(inc) {
            value += typeof inc === "number" ? inc : 1;
        },
        getValue: function() {
            return value;
        }
    }
})();
</code></pre>

<p>but in <code>JavaScript - The Good Parts</code> where this example is taken from, it has the above self-executing function without the brackets round, like so:</p>

<pre><code>var obj = function() {
    var value = 0;

    return {
        increment: function(inc) {
            value += typeof inc === "number" ? inc : 1;
        },
        getValue: function() {
            return value;
        }
    }
}();
</code></pre>

<p>Both of these examples work for me, but I wanted to ask if there were any differences in functionality that I should be aware of. I hope this isn't too trivial. I just wanted to be sure.</p>

<p>Thanks a lot.</p>

<p><strong>Edit:</strong></p>

<p>As Rob W has pointed out, there is another thread on the subject. <a href="http://peter.michaux.ca/articles/an-important-pair-of-parens" rel="nofollow">This is an excellent blog regarding this issue</a> that was linked to from the other post.</p>
