An "async" function versus a function that returns a "Promise"

Viewed 50

An async function already returns a Promise:

const Area = async (L, B) => L * B;
console.log(await Area(5, 4));
Area(5, 4).then(r => console.log(r));

The above can also be written using a function that returns a Promise:

const pfArea = (L, B) => new Promise(resolve => resolve(L * B));
console.log(await pfArea(5, 4));
pfArea(5, 4).then(r => console.log(r));

What does the second method offer, besides the ability to return an error condition using the reject option?

0 Answers
Related