Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement