Skip to content

Commit 05f4502

Browse files
committed
fixes
1 parent 1646a74 commit 05f4502

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

1-js/05-data-types/02-number/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ Ouch! There are more consequences than an incorrect comparison here. Imagine you
205205

206206
But why does this happen?
207207

208-
A number is stored in memory in its binary form, a sequence of ones and zeroes. But fractions like `0.1`, `0.2` that look simple in the decimal numeric system are actually unending fractions in their binary form.
208+
A number is stored in memory in its binary form, a sequence of bits - ones and zeroes. But fractions like `0.1`, `0.2` that look simple in the decimal numeric system are actually unending fractions in their binary form.
209209

210210
In other words, what is `0.1`? It is one divided by ten `1/10`, one-tenth. In decimal numeral system such numbers are easily representable. Compare it to one-third: `1/3`. It becomes an endless fraction `0.33333(3)`.
211211

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ for (let num of range) {
105105

106106
Now `range[Symbol.iterator]()` returns the `range` object itself: it has the necessary `next()` method and remembers the current iteration progress in `this.current`. Shorter? Yes. And sometimes that's fine too.
107107

108-
The downside is that now it's impossible to have two `for..of` loops running over the object simultaneously: they'll share the iteration state, because there's only one iterator -- the object itself. But two parallel for-ofs is a rare thing, doable with some async scenarios.
108+
The downside is that now it's impossible to have two `for..of` loops running over the object simultaneously: they'll share the iteration state, because there's only one iterator -- the object itself. But two parallel for-ofs is a rare thing, even in async scenarios.
109109

110110
```smart header="Infinite iterators"
111111
Infinite iterators are also possible. For instance, the `range` becomes infinite for `range.to = Infinity`. Or we can make an iterable object that generates an infinite sequence of pseudorandom numbers. Also can be useful.
@@ -144,7 +144,7 @@ Normally, internals of iterables are hidden from the external code. There's a `f
144144

145145
But to understand things a little bit deeper let's see how to create an iterator explicitly.
146146

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

149149
```js run
150150
let str = "Hello";
@@ -170,7 +170,9 @@ There are two official terms that look similar, but are very different. Please m
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-
Naturally, these properties can combine. For instance, strings are both iterable (`for..of` works on them) and array-like (they have numeric indexes and `length`).
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.
174+
175+
For instance, strings are both iterable (`for..of` works on them) and array-like (they have numeric indexes and `length`).
174176

175177
But an iterable may be not array-like. And vice versa an array-like may be not iterable.
176178

@@ -191,11 +193,11 @@ for (let item of arrayLike) {}
191193
*/!*
192194
```
193195

194-
What do they have in common? Both iterables and array-likes are usually *not arrays*, they don't have `push`, `pop` etc. That's rather inconvenient if we have such an object and want to work with it as with an array.
196+
Both iterables and array-likes are usually *not arrays*, they don't have `push`, `pop` etc. That's rather inconvenient if we have such an object and want to work with it as with an array. E.g. we would like to work with `range` using array methods. How to achieve that?
195197

196198
## Array.from
197199

198-
There's a universal method [Array.from](mdn:js/Array/from) that brings them together. It takes an iterable or array-like value and makes a "real" `Array` from it. Then we can call array methods on it.
200+
There's a universal method [Array.from](mdn:js/Array/from) that takes an iterable or array-like value and makes a "real" `Array` from it. Then we can call array methods on it.
199201

200202
For instance:
201203

@@ -227,7 +229,7 @@ The full syntax for `Array.from` allows to provide an optional "mapping" functio
227229
Array.from(obj[, mapFn, thisArg])
228230
```
229231

230-
The second argument `mapFn` should be the function to apply to each element before adding to the array, and `thisArg` allows to set `this` for it.
232+
The optional second argument `mapFn` can be a function that will be applied to each element before adding to the array, and `thisArg` allows to set `this` for it.
231233

232234
For instance:
233235

0 commit comments

Comments
 (0)