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: ebook/07_iterables-and-looping.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ for (const prop of Object.keys(car)){
59
59
60
60
## The `for in` loop
61
61
62
-
Even though it is not a new ES6 loop, let's look at the `for in` loop to understand what differentiate it compared to the `for of`.
62
+
Even though it is not a new ES6 loop, let's look at the `for in` loop to understand what differentiates it to the `for of` loop.
63
63
64
64
The `for in` loop is a bit different because it will iterate over all the [enumerable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties) of an object in no particular order.
65
65
@@ -103,7 +103,7 @@ for (let i of list) {
103
103
`for in` will return a list of keys whereas the `for of` will return a list of values of the numeric properties of the object being iterated.
104
104
105
105
106
-
Another differences is that we **can** stop a `for of` loop but we can't do the same with a `for in` loop.
106
+
Another difference is that we **can** stop a `for of` loop but we can't do the same with a `for in` loop.
Copy file name to clipboardExpand all lines: ebook/12_classes.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ const person = class Person {
53
53
54
54
Let's start creating our first `Class`.
55
55
56
-
We only need a method called `constructor` (remember to add only one constructor, a `SyntaxError` will be thrown if the class contains more than one constructor methods).
56
+
We only need a method called `constructor` (remember to add only one constructor, a `SyntaxError` will be thrown if the class contains more than one constructor method).
Copy file name to clipboardExpand all lines: ebook/13_promises.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,13 +126,13 @@ myPromise
126
126
127
127
We use `.then()` to grab the value when the promise resolves and `.catch()` when the promise rejects.
128
128
129
-
If you see our error log you can see that it tells us where the error occured, that is because we wrote `reject(Error("this is our error"));` and not simply `reject("this is our error");`.
129
+
Looking at our error log you can see that it tells us where the error occured, that is because we wrote `reject(Error("this is our error"));` and not simply `reject("this is our error");`.
130
130
131
131
132
132
133
133
### Chaining promises
134
134
135
-
We can chain promises one after the other, using what was returned from the previous one as the base for the subsequent one, whether the promise resolved or got rejected.
135
+
We can chain promises one after the other, using what was returned from the previous one as the base for the subsequent one, whether the promise was resolved or rejected.
136
136
137
137
```js
138
138
constmyPromise=newPromise((resolve, reject) => {
@@ -251,7 +251,7 @@ Our values returned together, after 1000ms (the timeout of the *second* promise)
251
251
252
252
If we were to pass an empty iterable then it will return an already resolved promise.
253
253
254
-
If one of the promise was rejected, all of them would asynchronously reject with the value of that rejection, no matter if they resolved.
254
+
If one of the promises was rejected, all of them would asynchronously reject with the value of that rejection, even if they resolved.
// one of the two promise will fail, but `.all` will return only a rejection.
264
+
// one of the two promises will fail, but `.all` will return only a rejection.
265
265
Promise
266
266
.all([promise1, promise2])
267
267
.then(data=> {
@@ -274,7 +274,7 @@ Promise
274
274
// Error: oooops error
275
275
```
276
276
277
-
`Promise.race()` on the other hand returns a promise that resolves or rejects as soon as one of the promises in the iterable resolves or reject, with the value from that promise.
277
+
`Promise.race()` on the other hand returns a promise that resolves or rejects as soon as one of the promises in the iterable resolves or rejects, with the value from that promise.
// Object { value: "I like to eat Banana", done: false }
59
+
// Object { value: "I like to eat Bananas", done: false }
60
60
fruitGenerator.next();
61
-
// Object { value: "I like to eat Apple", done: false }
61
+
// Object { value: "I like to eat Apples", done: false }
62
62
fruitGenerator.next().value;
63
-
// "I like to eat Orange"
63
+
// "I like to eat Oranges"
64
64
```
65
65
66
-
- Our new generator will loop over the array and print one value at a time every time we call `.next()`.
67
-
-if you are only concerned about getting the value, then use `.next().value` and it will not print the status of the generator
66
+
- Our new generator will loop over the array and print one value at a time every time we call `.next()`
67
+
-If you are only concerned about getting the value, then use `.next().value` and it will not print the status of the generator
68
68
69
69
70
70
@@ -113,21 +113,21 @@ myGenerator.throw("ooops");
113
113
// Object { value: undefined, done: true }
114
114
```
115
115
116
-
As you can see when we called `.throw()` the `generator` returned us the error and finished even though we still had one more `yield` to execute.
116
+
As you can see when we called `.throw()` the `generator` returned us the error and finished even though we still had one more `yield` to execute.
117
117
118
118
119
119
120
120
## Combining Generators with Promises
121
121
122
-
As we have previously seen, Promises are very useful for asynchronous programming, and by combining them with generators we can have a very powerful tool at our disposal to avoid problems like the *callback hell*.
122
+
As we have previously seen, Promises are very useful for asynchronous programming, and by combining them with generators we have a very powerful tool at our disposal to avoid problems like the *callback hell*.
123
123
124
-
As we are solely discussing ES6, I won't be talking about async functions as they were introduce in ES2017 but know that the way they work is based on what you will see now.
124
+
As we are solely discussing ES6, I won't be talking about async functions as they were introduced in ES2017, but know that the way they work is based on what you will see now.
125
125
126
126
You can read more about async functions in Chapter 19.
127
127
128
-
Using a Generator in combination with a `Promise` will allow us to write asynchronous code that feels like synchronous.
128
+
Using a Generator in combination with a `Promise` will allow us to write asynchronous code that feels like synchronous code.
129
129
130
-
What we want to do is to wait for a promise to resolve and then pass the resolved value back into our generator in the `.next()` call.
130
+
What we want to do is wait for a promise to resolve and then pass the resolved value back into our generator in the `.next()` call.
0 commit comments