Differences between these two module patterns
<p>Are there any differences in functionality between these two JavaScript module patterns?</p>

<pre><code>var MODULE = (function() {

    var privvy = "I'm private!";

    return {
        getPublic: function() {
            return "I'm public";
        },      
        getPriv: function() {
            return privvy;
        }       
    };
}());
</code></pre>

<p>and</p>

<pre><code>var MODULE = (function() {

    var privvy = "I'm private!";

    return new function() {
        this.getPublic = function() {
            return "I'm public";
        };
        this.getPriv = function() {
            return privvy;
        };
    };
}());
</code></pre>

<p>I think what is happening is, in the first, an object with two public members is explicitly declared and then returned. One of the members has a function as a value which has a reference to the 'private' variable (i.e. a closure is formed by the immediately-executed function but the getPublic() method still has access to this variable after this function finished execution - I think)</p>

<p>In the second, an object is created by way of an anonymous constructor which assigns two functions to publicly accessible variables and the IEF creates the closure that limits access to the priv variable in the same way.</p>

<p>Do these two variations result in exactly the same object?</p>
