Skip to content

Commit 947afdd

Browse files
authored
Merge pull request #2297 from patrikbego/patch-2
Fixed couple of grammar mistakes.
2 parents 2554d3d + 0b401e6 commit 947afdd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

1-js/05-data-types/06-iterable/article.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Iterables
33

4-
*Iterable* objects is a generalization of arrays. That's a concept that allows us to make any object useable in a `for..of` loop.
4+
*Iterable* objects are a generalization of arrays. That's a concept that allows us to make any object useable in a `for..of` loop.
55

66
Of course, Arrays are iterable. But there are many other built-in objects, that are iterable as well. For instance, strings are also iterable.
77

@@ -26,7 +26,7 @@ let range = {
2626
// for(let num of range) ... num=1,2,3,4,5
2727
```
2828

29-
To make the `range` iterable (and thus let `for..of` work) we need to add a method to the object named `Symbol.iterator` (a special built-in symbol just for that).
29+
To make the `range` object iterable (and thus let `for..of` work) we need to add a method to the object named `Symbol.iterator` (a special built-in symbol just for that).
3030

3131
1. When `for..of` starts, it calls that method once (or errors if not found). The method must return an *iterator* -- an object with the method `next`.
3232
2. Onward, `for..of` works *only with that returned object*.
@@ -140,7 +140,7 @@ for (let char of str) {
140140

141141
## Calling an iterator explicitly
142142

143-
For deeper understanding let's see how to use an iterator explicitly.
143+
For deeper understanding, let's see how to use an iterator explicitly.
144144

145145
We'll iterate over a string in exactly the same way as `for..of`, but with direct calls. This code creates a string iterator and gets values from it "manually":
146146

@@ -165,16 +165,16 @@ That is rarely needed, but gives us more control over the process than `for..of`
165165

166166
## Iterables and array-likes [#array-like]
167167

168-
There are two official terms that look similar, but are very different. Please make sure you understand them well to avoid the confusion.
168+
Two official terms look similar, but are very different. Please make sure you understand them well to avoid the confusion.
169169

170170
- *Iterables* are objects that implement the `Symbol.iterator` method, as described above.
171171
- *Array-likes* are objects that have indexes and `length`, so they look like arrays.
172172

173-
When we use JavaScript for practical tasks in browser or other environments, we may meet objects that are iterables or array-likes, or both.
173+
When we use JavaScript for practical tasks in a browser or any other environment, we may meet objects that are iterables or array-likes, or both.
174174

175175
For instance, strings are both iterable (`for..of` works on them) and array-like (they have numeric indexes and `length`).
176176

177-
But an iterable may be not array-like. And vice versa an array-like may be not iterable.
177+
But an iterable may not be array-like. And vice versa an array-like may not be iterable.
178178

179179
For example, the `range` in the example above is iterable, but not array-like, because it does not have indexed properties and `length`.
180180

@@ -293,7 +293,7 @@ alert( str.slice(1, 3) ); // garbage (two pieces from different surrogate pairs)
293293
Objects that can be used in `for..of` are called *iterable*.
294294

295295
- Technically, iterables must implement the method named `Symbol.iterator`.
296-
- The result of `obj[Symbol.iterator]()` is called an *iterator*. It handles the further iteration process.
296+
- The result of `obj[Symbol.iterator]()` is called an *iterator*. It handles further iteration process.
297297
- An iterator must have the method named `next()` that returns an object `{done: Boolean, value: any}`, here `done:true` denotes the end of the iteration process, otherwise the `value` is the next value.
298298
- The `Symbol.iterator` method is called automatically by `for..of`, but we also can do it directly.
299299
- Built-in iterables like strings or arrays, also implement `Symbol.iterator`.

0 commit comments

Comments
 (0)