Created
August 5, 2016 12:16
-
-
Save denizozger/13274a4da749a25445faa862de08b38b to your computer and use it in GitHub Desktop.
Demonstrate why Error()'s are useless when callback queue is used
This file contains hidden or 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
var getValue = function(value, cb) { | |
setTimeout(function err() { | |
throw Error(); | |
}, 0); | |
return cb(null, value); | |
}; | |
var result = getValue(5, (err, a) => { | |
console.log(a); | |
}); | |
process.exit(); | |
// Output :5 | |
var getValue = function(value, cb) { | |
throw Error(); | |
return cb(null, value); | |
}; | |
var result = getValue(5, (err, a) => { | |
console.log(a); | |
}); | |
process.exit(); | |
// throws Error() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment