Skip to content

Commit b8346a5

Browse files
authored
Merge pull request #2530 from hamirmahal/infra/update-article-in-async-await
improve readability of article in chapter 8, async
2 parents 8e0d226 + 065e31d commit b8346a5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

1-js/11-async/08-async-await/article.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ The function execution "pauses" at the line `(*)` and resumes when the promise s
6969

7070
Let's emphasize: `await` literally suspends the function execution until the promise settles, and then resumes it with the promise result. That doesn't cost any CPU resources, because the JavaScript engine can do other jobs in the meantime: execute other scripts, handle events, etc.
7171

72-
It's just a more elegant syntax of getting the promise result than `promise.then`, easier to read and write.
72+
It's just a more elegant syntax of getting the promise result than `promise.then`. And, it's easier to read and write.
7373

7474
````warn header="Can't use `await` in regular functions"
75-
If we try to use `await` in non-async function, there would be a syntax error:
75+
If we try to use `await` in a non-async function, there would be a syntax error:
7676

7777
```js run
7878
function f() {
@@ -83,7 +83,7 @@ function f() {
8383
}
8484
```
8585

86-
We may get this error if we forget to put `async` before a function. As said, `await` only works inside an `async` function.
86+
We may get this error if we forget to put `async` before a function. As stated earlier, `await` only works inside an `async` function.
8787
````
8888
8989
Let's take the `showAvatar()` example from the chapter <info:promise-chaining> and rewrite it using `async/await`:
@@ -186,7 +186,7 @@ class Waiter {
186186
187187
new Waiter()
188188
.wait()
189-
.then(alert); // 1
189+
.then(alert); // 1 (this is the same as (result => alert(result)))
190190
```
191191
The meaning is the same: it ensures that the returned value is a promise and enables `await`.
192192

0 commit comments

Comments
 (0)