Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
async using callback
// Async using call back
var addA = function (a, b, cb) {
setTimeout (() => {
cb(a + b);
}, 0);
};
// How to use it :D
addA(2, 3, (result) => {
console.log(result)
})
// Callback Hell :(
addA(1, 1, (r) => {
addA(r, 1, (r) => {
addA(r, 1, (r) => {
addA(r, 1, (r) => {
addA(r, 3, (r) => {
addA(r, 3, (r) => {
console.log(r)
})
})
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment