Someone recently asked me when an async function in JavaScript "returns". This is an interesting question because while a function like f()
below has a return
statement in it, f()
actually returns much earlier than that. To understand how this works, let's take a look at an example function. Here, a()
and c()
are normal synchronous functions and b()
is another asynchronous function.
async function f() {
a();
await b();
return c();
}