How can I implement this code to run in correct order (A and B) without change the setTime using only callback?
function a() {
setTimeout(function () {
console.log('a');
},1000);
}
function b() {
console.log('b');
}
function c() {
a();
b();
}
c();
When run the c(), I need to run a() and b() in synchronous order, that's:
- wait a sec;
- run a() function...
- ... and then, run b() function
setTimeoutis always asynchronous.