You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/11-async/08-async-await/article.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ async function f() {
24
24
f().then(alert); // 1
25
25
```
26
26
27
-
...We could explicitly return a promise, that would be the same:
27
+
...We could explicitly return a promise, that would be the same as:
28
28
29
29
```js run
30
30
asyncfunctionf() {
@@ -72,7 +72,7 @@ Let's emphasize: `await` literally makes JavaScript wait until the promise settl
72
72
It's just a more elegant syntax of getting the promise result than `promise.then`, easier to read and write.
73
73
74
74
````warn header="Can't use `await` in regular functions"
75
-
If we try to use `await` in non-async function, that would be a syntax error:
75
+
If we try to use `await` in non-async function, there would be a syntax error:
76
76
77
77
```js run
78
78
functionf() {
@@ -250,7 +250,7 @@ async function f() {
250
250
f();
251
251
```
252
252
253
-
If we don't have `try..catch`, then the promise generated by the call of the async function `f()` becomes rejected. We can append `.catch` to handle it:
253
+
If we don't have `try..catch` and a promise generated by the call of the async function `f()` becomes rejected. We can append `.catch` to handle it:
If we forget to add `.catch` there, then we get an unhandled promise error (and can see it in the console). We can catch such errors using a global event handler as described in the chapter <info:promise-error-handling>.
266
+
If we forget to add `.catch` there, then we get an unhandled promise error (viewable in the console). We can catch such errors using a global event handler as described in the chapter <info:promise-error-handling>.
267
267
268
268
269
269
```smart header="`async/await` and `promise.then/catch`"
0 commit comments