I have been pondering whether the async
keyword is redundant when simply returning a promise for some time now.
Let's take a look at this example:
async function thePromise() {
const v = await Inner();
return v+1;
}
async function wrapper() {
return thePromise();
}
I am questioning if, for the wrapper
function, since it does not wait inside the promise for resolution, the async keyword is unnecessary. Shouldn't we just use:
function wrapper() {
return thePromise();
}
The main downside to this approach is that it hides the fact that we are using promises, but other than that: is there any real distinction between returning a promise from an asynchronous function or a regular function?