title: How to access this.property of class in prototype method in nodejs
body: <p>Here is what i am trying to do. I am writing an app in nodejs express and trying to divide different parts of apps in separate modules. I have some problem access this variable in middleware functions</p>
  
  <p>Below is my routes module</p>
  
  <pre><code>"use strict";
  function route(params){
    var app = params.app;
    var ApiHelper = require('../library/apiHelper').init(params);
    //get
    app.get('/', Api.index);
    app.get('/check', ApiHelper.validateRequest, Api.check);
  }
  module.exports = route;
  </code></pre>
  
  <p>My ApiHelper class</p>
  
  <pre><code>"use strict";
  function ApiHelper(params){
    this.params = params;
  }
  module.exports.init = function (params){
    return new ApiHelper(params);
  };
  ApiHelper.prototype.validateRequest = function validateRequest(req, res, next){
    console.log(this.params);//this is undefined
  };
  </code></pre>
  
  <p>I am unable to access this.params in validateRequest object of the ApiHelper</p>