title: node js pass context to callback
body: <p>I am using node.js. I have this handlers.js file:</p>
  
  <pre><code>exports.Handlers = function(prefix) {
      this.prefix = prefix;
      this.db = new DBInstance();
  };
  
  exports.Handlers.prototype.getItemById = function(id) {
      var item = this.db.getItemById(id, function(error, item) {
          item.name = this.prefix + item.name;
          ...
          ...
      });
  };
  </code></pre>
  
  <p>When I call:</p>
  
  <pre><code>var h = new Handlers();
  h.getItemById(5);
  </code></pre>
  
  <p>I get an error since the context isn't the Handlers and this.prefix doesn't exists. I can fix it using this:</p>
  
  <pre><code>exports.Handlers.prototype.getItemById = function(id) {
      var scope = this;
      var item = this.db.getItemById(id, function(error, item) {
          item.name = scope.prefix + item.name;
          ...
          ...
      });
  };
  </code></pre>
  
  <p>Is there any better way to pass the context to the callback?
  What is the nodejs common way to pass the context to the callback?</p>