title: TypeScript: How do I call a member function from another function?
body: <p>I am trying to call a member function from another member function - and failing. I figured this would be easy to find but after 10 minutes of searching I can't find what's wrong here.</p>
  
  <p>In the following code (and yes I know pausecomp is a big no-no, I'm just trying to test against a possible race condition):</p>
  
  <pre><code>class LayoutWorker {
      /*
       Specific events handlers.
       e is the object sent by the client. See events.layout for object definitions.
       */
      handlers = {
          textadd: function (e) {
              for (var ind=0; ind&lt;10; ind++)
              {
                  console.log("entering textadd = " + e);
                  // Do the work and call the client back if needed. You can pass to the client any object.
                  e.text += " -- Hello back from the worker!";
                  postClientMessage(e);
  
                  this.pausecomp(4000);
              }
          },
  
          urgent: function (e) {
              for (var ind=0; ind&lt;10; ind++)
              {
                  console.log("entering urgent = " + e);
                  // Do the work and call the client back if needed. You can pass to the client any object.
                  e.text += " -- Hello back from the worker!";
                  postClientMessage(e);
  
                  this.pausecomp(1000);
              }
          }
  
      };
  
      handleEvent(e) {
          console.log("entering handleEvent = " + e);
          // Call the specific handler.
          this.handlers[e.id](e);
      }
  
      pausecomp(millis : number) : void
      {
          var date = new Date();
          var curDate = new Date();
          while(curDate - date &lt; millis)
              curDate = new Date();
      }
  }
  </code></pre>
  
  <p>When I run the above I get:
  Uncaught TypeError: Object # has no method 'pausecomp' </p>
  
  <p>What do I have wrong?</p>
  
  <p>thanks - dave</p>