Created
March 8, 2018 17:09
-
-
Save adambene/50ef24996891e3beb22e8363dcc09f50 to your computer and use it in GitHub Desktop.
Delays With Callback Hell in JavaScript
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
const delay = (ms, result, cb) => setTimeout(() => cb(result), ms); | |
function delays() { | |
delay(800, "Hello, I'm in a", a => { | |
console.log(a); | |
delay(400, "callback!", b => { | |
console.log(b); | |
}); | |
}); | |
} | |
// call it | |
delays(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment