I was wondering if functions called with the await keyword only run in order if they resolve to promises. If so, how does the interpreter know that these functions are going to resolve to promises and to not run them concurrently?
For example, the following code takes a total of 5 seconds and 'Hello' is logged immediately to the console. All of the await functions seem to run concurrently.
async function test() {
function work() {
console.log("work");
}
await setTimeout(work, 5000);
await setTimeout(work, 1000);
await setTimeout(work, 5000);
await setTimeout(work, 1000);
await console.log("Hello")
}