title: How to call public function from event handler in JavaScript?
body: <p>I have a class in JavaScript called Greeter. Inside my class I have:</p>
  
  <ul>
  <li>a constructor</li>
  <li>a document click event handler</li>
  <li>a public function called <code>a</code></li>
  </ul>
  
  <p>What I want is for my document click event handler to call the public function <code>a</code>. But I get the error: "<em>Uncaught ReferenceError: a is not defined</em>"</p>
  
  <p>This is my code:</p>
  
  <pre><code>var Greeter = (function () {
  
      function Greeter() {
      }
  
      Greeter.prototype.a = function () {
          alert('I am in a');
      };
  
      $(document).on( "click", function() {
          alert('I am in click event handler');
          a(); // &lt;-- Why can't I call the public function a
      });
  
      return Greeter;
  })();
  
  var greeter = new Greeter();
  </code></pre>
  
  <p>Here is a <a href="http://jsfiddle.net/ffwr3g0m/5/" rel="nofollow">demo</a>.</p>