title: Why do I get "TypeError: this.X is not a function" when calling method from another method?
body: <p>The following code generates the error <code>TypeError: this.SetValue is not a function</code>.</p>
  
  <pre><code>class FlightData {
      constructor(app)
      {
          this.app = app;
  
          this.websocket = new WebSocket('ws://'+window.location.hostname+':20225/flight_data');
          this.websocket.addEventListener('message', this.HandleSocketMessage);
      }
  
      SetValue(name, value)
      {
          console.log(name + ": " + value);
      }
  
      HandleSocketMessage(e)
      {
          this.SetValue("name", "value");
      }
  }
  </code></pre>
  
  <p>If I do the following instead, it works. However I am trying to avoid closures (even though the one here is harmless) in my code:</p>
  
  <pre><code>this.websocket.addEventListener('message', e =&gt; {
          this.SetValue("name", "value");
  });
  </code></pre>
  
  <p>Can someone please explain why the code at the top doesn't work and what I need to do to make it work?</p>