title: Passing scope of a function to the callback function
body: <p>In node let's say I have the following code:-</p>
  
  <pre><code>function readDirectory(callback){
      fs.readdir('./', filterList);
  }
  
  function filterList(err,data){
      //callback is undefined
      if(err) callback(err);
      callback();
  }
  
  readDirectory(function(){
      console.log("Hi");
  }
  </code></pre>
  
  <p>But the following works if I define function inside the <code>readDirectory</code> itself because it's in the same scope:-</p>
  
  <pre><code>function readDirectory(callback){
      fs.readdir('./', function(err,data){
          if(err) callback(err);
          callback();
      });
  }
  
  readDirectory(function(){
      console.log("Hi");
  }
  </code></pre>
  
  <p>So my question is, is there a way to pass the scope of <code>readDirectory</code> to the callback function that's defined outside?</p>