Created
March 3, 2017 10:33
-
-
Save warrenca/732f5dc4255e14978e5eabe30187616a to your computer and use it in GitHub Desktop.
Callback hell
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
function process(callback) { | |
var name = "john"; | |
if (name==="john") { | |
callback(null, "My name is john"); | |
} else { | |
callback("I am not john"); | |
} | |
} | |
process(function(error, message) { | |
if (error) { | |
console.error(error); | |
} else { | |
console.log(message); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check out the corresponding Async-Await example -
https://gist.github.com/warrenca/9f11ceef456a3603d42d4c23b359e409 or in babel