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/02-promise-basics/article.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -58,7 +58,7 @@ let promise = new Promise(function(resolve, reject) {
58
58
We can see two things by running the code above:
59
59
60
60
1. The executor is called automatically and immediately (by `new Promise`).
61
-
2. The executor receives two arguments: `resolve` and `reject` — these functions are pre-defined by the JavaScript engine. So we don't need to create them. We only should call one of them when ready.
61
+
2. The executor receives two arguments: `resolve` and `reject` — these functions are pre-defined by the JavaScript engine. So we don't need to create them. We should only call one of them when ready.
62
62
63
63
After one second of "processing" the executor calls `resolve("done")` to produce the result. This changes the state of the `promise` object:
64
64
@@ -81,7 +81,7 @@ The call to `reject(...)` moves the promise object to `"rejected"` state:
81
81
82
82
To summarize, the executor should do a job (something that takes time usually) and then call `resolve` or `reject` to change the state of the corresponding promise object.
83
83
84
-
A promise that is either resolved or rejected is called "settled", as opposed to a initially "pending" promise.
84
+
A promise that is either resolved or rejected is called "settled", as opposed to an initially "pending" promise.
85
85
86
86
````smart header="There can be only a single result or an error"
87
87
The executor should call only one `resolve` or one `reject`. Any state change is final.
@@ -263,7 +263,7 @@ It's not exactly an alias of `then(f,f)` though. There are several important dif
263
263
264
264
3. Last, but not least, `.finally(f)` is a more convenient syntax than `.then(f, f)`: no need to duplicate the function `f`.
0 commit comments