Created
January 22, 2018 14:22
-
-
Save Jhegs/316cd9d5fe1fea092e19fcce09367bf7 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
"use strict"; | |
function asyncSqrt(value, callback) { | |
console.log('START execution with value =', value); | |
setTimeout(function () { | |
callback(value, value * value); | |
}, 0 | Math.random() * 100); | |
} | |
asyncSqrt(0, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(1, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(2, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(3, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(4, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(5, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(6, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(7, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(8, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
asyncSqrt(9, function (value, result) { | |
console.log('END execution with value =', value, 'and result =', result); | |
console.log('COMPLETED'); | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bro can you make script for login site