SHARE
TWEET

Untitled

a guest Apr 21st, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Sync callback
  2. function greetings(callback) {
  3.   callback();
  4. }
  5. greetings(() => { console.log('Hi'); });
  6. moreWork(); // will run after console.log
  7.  
  8. // Async callback
  9. const fs = require('fs');
  10. fs.readFile('/file.md', function callback(err, data) { // fs.readFile is an async method provided by Node
  11.   if (err) throw err;
  12.   console.log(data);
  13. });
  14. moreWork(); // will run before console.log
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top