Consider the following code snippet:
async function f() {
console.log("entering");
for (let i=0;i<=1e9;i++) {}
console.log("quitting");
}
async function g() {
console.log("before");
f();
console.log("after");
}
g();
I would expect the function g() to call f() without waiting for it to finish. Thus, I would expect the output to be
before
entering
after
quitting
However, g() actually waits for f() to finish. Why does this happen, when f() is supposed to be an async function?
awaitwithinf()that would cause it to run asynchronously.asyncjust means that you can useawaitwithin the function.await. Check this out developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…async/awaitmechanism means.