Skip to content

Instantly share code, notes, and snippets.

@Jhegs
Created January 22, 2018 14:22
Show Gist options
  • Save Jhegs/316cd9d5fe1fea092e19fcce09367bf7 to your computer and use it in GitHub Desktop.
Save Jhegs/316cd9d5fe1fea092e19fcce09367bf7 to your computer and use it in GitHub Desktop.
CallBack Hell
"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');
});
});
});
});
});
});
});
});
});
});
@seisdr
Copy link

seisdr commented Feb 22, 2020

Bro can you make script for login site

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment