title: How can we access variable from callback function in node.js?
body: <pre><code>var sys = require('sys');
  var exec = require('child_process').exec;
  var cmd = 'whoami';
  var child = exec( cmd,
        function (error, stdout, stderr) 
        {
          var username=stdout.replace('\r\n','');
        }
  );
  
  var username = ?
  </code></pre>
  
  <p>How can I find username outside from exec function ?</p>