Created
April 11, 2019 17:37
-
-
Save PabloRegen/fe9451bcce1fc64e427dfdae42d0a16c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sync callback | |
function greetings(callback) { | |
callback(); | |
} | |
greetings(() => { console.log('Hi'); }); | |
moreWork(); // will run after console.log | |
// Async callback | |
const fs = require('fs'); | |
fs.readFile('/file.md', function callback(err, data) { // fs.readFile is an async method provided by Node | |
if (err) throw err; | |
console.log(data); | |
}); | |
moreWork(); // will run before console.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment