JavaScript Interview Question #83

Does an async function always return a Promise?

Promises, Async/Await, Fetch & Modern JavaScript Mid-Level Intermediate

Quick Interview Answer

Yes. Calling an async function always returns a Promise. If the function returns an ordinary value, JavaScript fulfills the returned Promise with that value.

Detailed Explanation

Yes. Calling an async function always returns a Promise. If the function returns an ordinary value, JavaScript fulfills the returned Promise with that value.

If the async function throws an error, its returned Promise is rejected with that error. This behavior makes async functions interoperable with normal Promise chains.

Code Example

async function getNumber() {
    return 10;
}

getNumber().then(value => {
    console.log(value); // 10
});

async function fail() {
    throw new Error("Failed");
}