How to make a JavaScript singleton with a constructor without using return?
<p>I currently know two ways to construct singletons in JavaScript. First:</p>

<pre><code>var singleton = {
 publicVariable: "I'm public",
 publicMethod: function() {}
};
</code></pre>

<p>It is perfect except that it does not have a constructor where I could run initialization code.</p>

<p>Second:</p>

<pre><code>(function() {

var privateVariable = "I'm private";
var privateFunction = function() {}

return {
 publicVariable: "I'm public",
 publicMethod: function () {}
}

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

<p>The first version does not have private properties nor does it have a constructor, but it is faster and simpler. The second version is more complex, ugly, but has a constructor and private properties.</p>

<p>I'm not in a need for private properties, I just want to have a constructor. Is there something I am missing or are the two approaches above the only ones I've got?</p>
