I have a program, which is supposed to execute the first line and wait for two seconds then execute the second, and finally the third.
console.log("Before Execution...");
setTimeout(() => console.log("Between"), 2000);
console.log("After Execution...");
But the output I am getting is something like this:
Before Execution...
After Execution...
Between
I understand that it's because setTimeout()
works asynchronously, but there must be way to do a real synchronous delay.