Two different ways of instantiation
<p>This is not a "how to" question. I want to discuss two possible ways of instantiation in JavaScript to find pros and cons of each one.</p>

<p>First one:</p>

<pre><code>function Counter() {
  this.counter = 0;
}

Counter.prototype.count = function() {
  this.counter += 1;
  return this.counter;
};

var counter = new Counter();

console.log("Counter: " + counter.count());
</code></pre>

<p>And the second:</p>

<pre><code>var counter = new (function() {
  var counter = 0;
  this.count = function() {
    counter += 1;
    return counter;
  }
})();

console.log("Counter: " + counter.count());
</code></pre>

<p><strong>IMPORTANT NOTE: <code>counter</code> is supposed to be instantiated only once.</strong></p>

<p>The first one looks more structured but the second does not clutter the namespace with unnecessary <code>Counter</code> function.</p>

<p>What do you think? Should I consider these two pieces of code equivalent? Am I missing something?</p>

<hr>

<p>BTW, I use the 2nd way at the moment. The reason I ask this question is that JSHint states that it's a "Weird construction." and proposes to delete <code>new</code> which apparently breaks the code.</p>
