Skip to content

Instantly share code, notes, and snippets.

@csrgxtu
Created September 30, 2017 08:09
Show Gist options
  • Save csrgxtu/6ce940ebd8a5655bf5a7feadce6733ad to your computer and use it in GitHub Desktop.
Save csrgxtu/6ce940ebd8a5655bf5a7feadce6733ad to your computer and use it in GitHub Desktop.
node cb access parent's var
fs = require('fs')
fs.readFile('/etc/hosts', 'utf8', function (err,data) {
if (err) {
return console.log(err);
}
console.log(data);
});
@csrgxtu
Copy link
Author

csrgxtu commented Sep 30, 2017

fs = require('fs')

function cb(err, data) {
  if (err) {
    return console.log(err);
  }
  console.log(data);
}

fs.readFile('/etc/hosts', 'utf8', cb);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment