title: Getting an undefined "this" when using Classes/Async Await
body: <p>I've just started to experiment with classes and async await. I'm using Node version 8.9.0 (LTS). When I <code>console.log(this)</code>, I get <code>undefined</code> instead of the reference to the object.</p>
  
  <p><strong>subhandler.js</strong></p>
  
  <pre><code>class Handler {
    constructor(props) {
      this.defaultRes = {
        data: successMessage,
        statusCode: 200
      };
    }
  
    async respond(handler, reply, response = this.defaultRes) {
      console.log(this); // why is `this` undefined????
      try {
        await handler;
        return reply(response.data).code(response.statusCode)
      } catch(error) {
        return reply(error);
      }
    }
  }
  
  class SubHandler extends Handler {
    constructor(props) {
      super(props);
      this.something = 'else';
    }
  
    makeRequest(request, reply) {
      console.log(this); // why is `this` undefined!!
      // in this case, doSomeAsyncRequest is a promise
      const handler = doSomeAsyncRequest.make(request.params);
      super.respond(handler, reply, response);
    }
  }
  
  module.exports = new SubHandler;
  </code></pre>
  
  <p><strong>Inside Hapi route</strong></p>
  
  <pre><code>const SubHandler = require('./subhandler');
  
  server.route({
      method: 'GET',
      path: '/',
      handler: SubHandler.makeRequest,
      // handler: function (request, reply) {
      //  reply('Hello!'); //leaving here to show example
      //}
  });
  </code></pre>
  
  <p><strong>Prototype example</strong></p>
  
  <pre><code>function Example() {
    this.a = 'a';
    this.b = 'b';
  }
  
  Example.prototype.fn = function() {
    console.log(this); // this works here
  }
  
  const ex = new Example();
  ex.fn();
  </code></pre>