From MDN
Asynchronous functions operate in a separate order than the rest of the code via the event loop,
However I don't understand what that means for a simple function that doesn't return anything explicitly and doesn't use await at all. Is it in any way useful to declare a function async in this case? Would it be executed at a later time to allow the page to respond for example while it executes? My test shows it's executed synchronously and doesn't defer at all:
async function foo() {
console.log('Start heavy stuff');
for (let i = 0; i < 90000000; ++i) {
Math.random()
}
console.log('Fnish heavy stuff')
}
foo();
console.log('All done, synchronously');
The logs are shown in the expecterd order, so could there be a use to making this function async in this case? Is this in any way similar to calling this function with a setTimeout(foo, 0)
?