I read it in an article that the code below the handlers in a promise is executed first (asynchronously executes code)
let promise = Promise.resolve();
promise.then(() => alert("promise done!"));
alert("code finished"); // this alert shows first
The above code alerts "code finished" first. To tackle this below is the resolution they have provided
Promise.resolve()
.then(() => alert("promise done!"))
.then(() => alert("code finished"));
My question is in real-time issues, we may have 1000 lines of code below these handlers. We can't handle all within then handler. How to synchronously handle this