Update article.md

Explicitly describe how async functions treat non-promise return values
This commit is contained in:
Oguntoye Opeyemi 2019-01-31 18:30:15 +01:00 committed by GitHub
parent 38e1bb5c52
commit c7753486e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,7 @@ async function f() {
}
```
The word "async" before a function means one simple thing: a function always returns a promise. If the code has `return <non-promise>` in it, then JavaScript automatically wraps it into a resolved promise with that value.
The word "async" before a function means one simple thing: a function always returns a promise. Even If a function actually returns a non-promise value, prepending the function definition with the "async" keyword directs Javascript to automatically wrap that value in a resolved promise.
For instance, the code above returns a resolved promise with the result of `1`, let's test it: