DEV Community

Discussion on: Asynchronous JavaScript Under 5 Minutes

Collapse
 
kalebealvs profile image
Kalebe Alves

Actually, you don't need to return a promise on the addNumber function. Not explicitly at least.
If you declare it as an async function, its return will automatically be wrapped into a promise resolution. If you throw an exception, it will be the rejection for said function.
To summarize, an async function will run as a microtask, working as a promise.
I think you already knew that, just don't wanna let that go unoticed.

Collapse
 
shimphillip profile image
Phillip Shim

Thanks for sharing this. It's a wonderful insight.