Skip to content

Commit c5764ca

Browse files
committed
Merge branch 'master' of github.com:javascript-tutorial/en.javascript.info into sync-5e9eca37
2 parents 20bd6db + 5e9eca3 commit c5764ca

File tree

28 files changed

+123
-139
lines changed

28 files changed

+123
-139
lines changed

1-js/04-object-basics/04-object-methods/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ user.hi(); // John (the simple call works)
257257
*/!*
258258
```
259259
260-
On the last line there is a conditinal operator that chooses either `user.hi` or `user.bye`. In this case the result is `user.hi`.
260+
On the last line there is a conditional operator that chooses either `user.hi` or `user.bye`. In this case the result is `user.hi`.
261261
262-
Then the method is immediately called with parentheses `()`. But it doesn't work right!
262+
Then the method is immediately called with parentheses `()`. But it doesn't work correctly!
263263
264264
As you can see, the call results in an error, because the value of `"this"` inside the call becomes `undefined`.
265265

1-js/04-object-basics/05-object-toprimitive/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
What happens when objects are added `obj1 + obj2`, subtracted `obj1 - obj2` or printed using `alert(obj)`?
55

6-
In that case objects are auto-converted to primitives, and then the operation is carried out.
6+
In that case, objects are auto-converted to primitives, and then the operation is carried out.
77

88
In the chapter <info:type-conversions> we've seen the rules for numeric, string and boolean conversions of primitives. But we left a gap for objects. Now, as we know about methods and symbols it becomes possible to fill it.
99

@@ -138,7 +138,7 @@ alert(+user); // valueOf -> 1000
138138
alert(user + 500); // valueOf -> 1500
139139
```
140140

141-
Often we want a single "catch-all" place to handle all primitive conversions. In this case we can implement `toString` only, like this:
141+
Often we want a single "catch-all" place to handle all primitive conversions. In this case, we can implement `toString` only, like this:
142142

143143
```js run
144144
let user = {

1-js/06-advanced-functions/03-closure/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ function f() {
599599
}
600600

601601
let g = f(); // while g is alive
602-
// there corresponding Lexical Environment lives
602+
// their corresponding Lexical Environment lives
603603

604604
g = null; // ...and now the memory is cleaned up
605605
```

1-js/06-advanced-functions/04-var/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ alert(phrase); // Error, phrase is not defined
3131

3232
## "var" has no block scope
3333

34-
`var` variables are either function-wide or global, they are visible through blocks.
34+
Variables, declared with `var`, are either function-wide or global. They are visible through blocks.
3535

3636
For instance:
3737

@@ -45,7 +45,7 @@ alert(test); // true, the variable lives after if
4545
*/!*
4646
```
4747

48-
`var` ignores code blocks, so we've got a global variable `test`.
48+
As `var` ignores code blocks, we've got a global variable `test`.
4949

5050
If we used `let test` instead of `var test`, then the variable would only be visible inside `if`:
5151

1-js/06-advanced-functions/08-settimeout-setinterval/article.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ There are two methods for it:
99

1010
These methods are not a part of JavaScript specification. But most environments have the internal scheduler and provide these methods. In particular, they are supported in all browsers and Node.js.
1111

12-
1312
## setTimeout
1413

1514
The syntax:
@@ -291,9 +290,9 @@ For server-side JavaScript, that limitation does not exist, and there exist othe
291290
- To cancel the execution, we should call `clearInterval/clearTimeout` with the value returned by `setInterval/setTimeout`.
292291
- Nested `setTimeout` calls is a more flexible alternative to `setInterval`. Also they can guarantee the minimal time *between* the executions.
293292
- Zero delay scheduling with `setTimeout(func, 0)` (the same as `setTimeout(func)`) is used to schedule the call "as soon as possible, but after the current code is complete".
294-
- The browsere ensures that for five or more nested call of `setTimeout`, or for zero-delay `setInterval`, the real delay between calls is at least 4ms. That's for historical reasons.
293+
- The browser limits the minimal delay for five or more nested call of `setTimeout` or for `setInterval` (after 5th call) to 4ms. That's for historical reasons.
295294

296-
Please note that all scheduling methods do not *guarantee* the exact delay. We should not rely on that in the scheduled code.
295+
Please note that all scheduling methods do not *guarantee* the exact delay.
297296

298297
For example, the in-browser timer may slow down for a lot of reasons:
299298
- The CPU is overloaded.

1-js/07-object-properties/01-property-descriptors/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ user.name = "Pete"; // Error: Cannot assign to read only property 'name'...
122122

123123
Now no one can change the name of our user, unless they apply their own `defineProperty` to override ours.
124124

125-
```smart header="Errors appear only in use strict"
125+
```smart header="Errors appear only in strict mode"
126126
In the non-strict mode, no errors occur when writing to read-only properties and such. But the operation still won't succeed. Flag-violating actions are just silently ignored in non-strict.
127127
```
128128

1-js/08-prototypes/04-prototype-methods/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ let clone = Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescr
194194
- [Object.getOwnPropertySymbols(obj)](mdn:js/Object/getOwnPropertySymbols) -- returns an array of all own symbolic keys.
195195
- [Object.getOwnPropertyNames(obj)](mdn:js/Object/getOwnPropertyNames) -- returns an array of all own string keys.
196196
- [Reflect.ownKeys(obj)](mdn:js/Reflect/ownKeys) -- returns an array of all own keys.
197-
- [obj.hasOwnProperty(key)](mdn:js/Object/hasOwnProperty): it returns `true` if `obj` has its own (not inherited) keytt named `key`.
197+
- [obj.hasOwnProperty(key)](mdn:js/Object/hasOwnProperty): it returns `true` if `obj` has its own (not inherited) key named `key`.
198198

199199
We also made it clear that `__proto__` is a getter/setter for `[[Prototype]]` and resides in `Object.prototype`, just as other methods.
200200

1-js/09-classes/05-extend-natives/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Even more, we can customize that behavior.
3434

3535
We can add a special static getter `Symbol.species` to the class. If exists, it should return the constructor that JavaScript will use internally to create new entities in `map`, `filter` and so on.
3636

37-
If we'd like built-in methods like `map`, `filter` will return regular arrays, we can return `Array` in `Symbol.species`, like here:
37+
If we'd like built-in methods like `map` or `filter` to return regular arrays, we can return `Array` in `Symbol.species`, like here:
3838

3939
```js run
4040
class PowerArray extends Array {
@@ -79,7 +79,7 @@ So, if `Rabbit extends Animal`, then:
7979

8080
That's thoroughly explained in the chapter [](info:static-properties-methods#statics-and-inheritance).
8181

82-
But built-in classes are an exception. They don't inherit statics `(1)` from each other.
82+
But built-in classes are an exception. They don't inherit statics from each other.
8383

8484
For example, both `Array` and `Date` inherit from `Object`, so their instances have methods from `Object.prototype`. But `Array.[[Prototype]]` does not point to `Object`. So there's `Object.keys()`, but not `Array.keys()` and `Date.keys()`.
8585

1-js/09-classes/06-instanceof/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ alert( arr instanceof Object ); // true
4646

4747
Please note that `arr` also belongs to the `Object` class. That's because `Array` prototypally inherits from `Object`.
4848

49-
The `instanceof` operator examines the prototype chain for the check, but we can set a custom logic the static method `Symbol.hasInstance`.
49+
The `instanceof` operator examines the prototype chain for the check, but we can set a custom logic in the static method `Symbol.hasInstance`.
5050

5151
The algorithm of `obj instanceof Class` works roughly as follows:
5252

1-js/11-async/05-promise-api/article.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Promise.all(requests)
112112
));
113113
```
114114

115-
A bigger example with fetching user information for an array of github users by their names (or we could fetch an array of goods by their ids, the logic is same):
115+
A bigger example with fetching user information for an array of GitHub users by their names (we could fetch an array of goods by their ids, the logic is same):
116116

117117
```js run
118118
let names = ['iliakan', 'remy', 'jeresig'];
@@ -134,7 +134,7 @@ Promise.all(requests)
134134
.then(users => users.forEach(user => alert(user.name)));
135135
```
136136

137-
**If any of the promises is rejected, `Promise.all` immediately rejects with that error.**
137+
**If any of the promises is rejected, the promise returned by `Promise.all` immediately rejects with that error.**
138138

139139
For instance:
140140

@@ -155,10 +155,10 @@ If one promise rejects, `Promise.all` immediately rejects, completely forgetting
155155
156156
For example, if there are multiple `fetch` calls, like in the example above, and one fails, other ones will still continue to execute, but `Promise.all` don't watch them any more. They will probably settle, but the result will be ignored.
157157
158-
`Promise.all` does nothing to cancel them, as there's no concept of "cancellation" in promises. In [another chapter](fetch-abort) we'll cover `AbortController` that aims to help with that, but it's not a part of the Promise API.
158+
`Promise.all` does nothing to cancel them, as there's no concept of "cancellation" in promises. In [another chapter](info:fetch-abort) we'll cover `AbortController` that can help with that, but it's not a part of the Promise API.
159159
```
160160

161-
````smart header="`Promise.all(...)` allows non-promise items in `iterable`"
161+
````smart header="`Promise.all(iterable)` allows non-promise \"regular\" values in `iterable`"
162162
Normally, `Promise.all(...)` accepts an iterable (in most cases an array) of promises. But if any of those objects is not a promise, it's wrapped in `Promise.resolve`.
163163

164164
For instance, here the results are `[1, 2, 3]`:
@@ -173,8 +173,7 @@ Promise.all([
173173
]).then(alert); // 1, 2, 3
174174
```
175175

176-
So we are able to pass non-promise values to `Promise.all` where convenient.
177-
176+
So we are able to pass ready values to `Promise.all` where convenient.
178177
````
179178
180179
## Promise.allSettled
@@ -289,4 +288,4 @@ There are 5 static methods of `Promise` class:
289288
- `value` (if fulfilled) or `reason` (if rejected).
290289
5. `Promise.race(promises)` -- waits for the first promise to settle, and its result/error becomes the outcome.
291290
292-
Of these five, `Promise.all/allSettled` are the most common in practice.
291+
Of these five, `Promise.all` is probably the most common in practice.

0 commit comments

Comments
 (0)