title: Function count calls
body: <p>I'm a beginner with JavaScript so please be patient =)</p>
  
  <p>I am trying to write a function that counts the number of times it is called.  What I have so far is a function with a counter that is incremented explicitly:</p>
  
  <pre><code>var increment = function () {
      var i = 0;
      this.inc = function () {i += 1;};
      this.get = function () {return i;};
  };
  
  var ob = new increment();
  ob.inc();
  ob.inc();
  alert(ob.get());
  </code></pre>
  
  <p>But I'm wondering how to call only <code>ob();</code>, so the function could increment calls made to itself automatically.  Is this possible and if so, how?</p>