Skip to content

Instantly share code, notes, and snippets.

@RashidJorvee
Created October 9, 2019 14:38
Show Gist options
  • Save RashidJorvee/5c9e846b9c72e9badc0118b1da4bf008 to your computer and use it in GitHub Desktop.
Save RashidJorvee/5c9e846b9c72e9badc0118b1da4bf008 to your computer and use it in GitHub Desktop.
function third(val, callback){
callback(val*2, false);
}
function second(val, callback){
callback(val*2, false);
}
function first(val, callback){
callback(val*2, false);
}
first (2, function(result1, err) { //calling first function with parameters, val 2 and a callback function.
if(!err) { // if execution of first function is successfull.
second(result1, function(result2, err) { // calling second function, in parameter we are passing the result of first function and a callback
if(!err){ // if execution of second function is successfull.
third(result2, function(result3, err) { // calling third function, in parameter we are passing the result of second function and a callback
if(!err){ // if execution of third function is successfull.
console.log(result3) //printing the result from third function on console.
}
});
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment