Skip to content

Instantly share code, notes, and snippets.

@bepitulaz
Created January 4, 2017 12:54
Show Gist options
  • Save bepitulaz/42d2f5d34939371b7e92da82c9573620 to your computer and use it in GitHub Desktop.
Save bepitulaz/42d2f5d34939371b7e92da82c9573620 to your computer and use it in GitHub Desktop.
Callback vs Promise
const fs = require('fs');
/**
Tiga operasi menghapus file di bawah ini, walaupun disusun berurutan
tetapi belum tentu selesainya berurutan dari operasi 1 sampai operasi 3.
*/
// Operasi 1
fs.unlink('/file-one', function(err) {
console.log('file one is deleted');
});
// Operasi 2
fs.unlink('/file-two', function(err) {
console.log('file two is deleted');
});
// Operasi 3
fs.unlink('/file-three', function(err) {
console.log('file three is deleted');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment