JSFiddle - React, Tailwind, and code Playground
JavaScript
var timeStart = new Date().getTime();
function log(text) {
var timeNow = new Date().getTime();
var duration = timeNow - timeStart;
$("#log").html($("#log").html() + duration + 'ms - ' + text + "<br />")
}
function resolveAfterSecond(x) {
return new Promise(resolve => {
setTimeout(() => {
resolve(Math.pow(2,x));
}, 100 * x);
});
}
async function asyncCall(x) {
log('start fce' + x);
result = await resolveAfterSecond(1 + x);
log('hodnota fce' + x + ': ' + result);
var result = await resolveAfterSecond(10 - x - x);
log('hodnota fce' + x + ': ' + result);
log('konec fce' + x);
}
asyncCall(1);
asyncCall(2);
asyncCall(3);
asyncCall(4);