title: Returning the ID of MyClass in Javascript
body: <p>I have this block of code that will create a new instance of <code>MyClass</code>, I want each instances of this class to have an id. So I have a function that will return cnt, and every time the new object is initialized the id value will increase.</p>
  
  <pre><code>var MyClass = (function () {
      var Constr, cnt = 0;
  
      Constr = function () {};    
      Constr.id = function () {
      return cnt;
      };
  
      Constr.prototype = {
          constructor: Constr, 
          id: Constr.id
      };
      cnt++
      return Constr;
  }());
  
  var x = new MyClass();
  console.log(x.id);
  document.getElementById("1").innerHTML = x.id;
  </code></pre>
  
  <p>The problem is, I obviously want the value of <code>cnt</code> to be returned, but everything I do returns <code>function() { return cnt; }</code></p>
  
  <p>Update, deleted fiddle, posted incorrect one.</p>