title: Call asynchronous function inside for loop
body: <pre><code>var path;
  
  for (var i = 0, c = paths.length; i &lt; c; i++)
  {
      path = paths[i];
  
      fs.lstat(path, function (error, stat)
      {
          console.log(path); // this outputs always the last element
      });
  }
  </code></pre>
  
  <p>How can I access the <code>path</code> variable, that was passed to fs.lstat function?</p>