Skip to content

Instantly share code, notes, and snippets.

@adambene
Created March 8, 2018 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adambene/50ef24996891e3beb22e8363dcc09f50 to your computer and use it in GitHub Desktop.
Save adambene/50ef24996891e3beb22e8363dcc09f50 to your computer and use it in GitHub Desktop.
Delays With Callback Hell in JavaScript
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