Quantcast
Channel: Comments on Promises and Static Values
Viewing all articles
Browse latest Browse all 9

By: Wesley de A Queiroz

$
0
0

I totally agree with Ben C.
All async functions are already wrapped at runtime in a promise.
Their return value is passed to the resolve function and their throw value are passed to reject.
Just reading MdN docs should clarify that.

And in fact your example will throw at parse time bec await is not available on the promise constructor function because it is not an async function, only it’s parent function.

As far as differentiating an async function from a common function every good code editor will provide typing information and will show the return type as a promise.
And the declaration prefix (async) is clear enough to tell that you are dealing with promises.

In the development world we should always avoid to re-do any work that the platform amd/or ecosystem already does for us, this avoid code bloating and ensures a more common communication between people working together on a project.


Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images