Skip to content

Commit 1c5b757

Browse files
committed
Merge branch 'master' of github.com:javascript-tutorial/en.javascript.info into sync-5b195795
2 parents c6b7abc + 5b19579 commit 1c5b757

File tree

17 files changed

+83
-95
lines changed

17 files changed

+83
-95
lines changed

1-js/02-first-steps/06-type-conversions/article.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Type Conversions
22

3-
Most of the time, operators and functions automatically convert the values given to them to the right type.
3+
Most of the time, operators and functions automatically convert the values given to them to the right type.
44

55
For example, `alert` automatically converts any value to a string to show it. Mathematical operations convert values to numbers.
66

@@ -81,18 +81,7 @@ alert( Number(false) ); // 0
8181

8282
Please note that `null` and `undefined` behave differently here: `null` becomes zero while `undefined` becomes `NaN`.
8383

84-
````smart header="Addition '+' concatenates strings"
85-
Almost all mathematical operations convert values to numbers. A notable exception is addition `+`. If one of the added values is a string, the other one is also converted to a string.
86-
87-
Then, it concatenates (joins) them:
88-
89-
```js run
90-
alert( 1 + '2' ); // '12' (string to the right)
91-
alert( '1' + 2 ); // '12' (string to the left)
92-
```
93-
94-
This only happens when at least one of the arguments is a string. Otherwise, values are converted to numbers.
95-
````
84+
Most mathematical operators also perform such conversion, we'll see that in the next chapter.
9685

9786
## Boolean Conversion
9887

1-js/02-first-steps/06-type-conversions/1-primitive-conversions-questions/solution.md renamed to 1-js/02-first-steps/07-operators/3-primitive-conversions-questions/solution.md

File renamed without changes.

1-js/02-first-steps/06-type-conversions/1-primitive-conversions-questions/task.md renamed to 1-js/02-first-steps/07-operators/3-primitive-conversions-questions/task.md

File renamed without changes.

1-js/02-first-steps/08-comparison/1-comparison-questions/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ null === +"\n0\n" → false
1313
Some of the reasons:
1414

1515
1. Obviously, true.
16-
2. Dictionary comparison, hence false.
16+
2. Dictionary comparison, hence false. `"a"` is smaller than `"p"`.
1717
3. Again, dictionary comparison, first char of `"2"` is greater than the first char of `"1"`.
1818
4. Values `null` and `undefined` equal each other only.
1919
5. Strict equality is strict. Different types from both sides lead to false.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Object.defineProperty(obj, propertyName, descriptor)
6666
: The object and its property to apply the descriptor.
6767

6868
`descriptor`
69-
: Property descriptor to apply.
69+
: Property descriptor object to apply.
7070

7171
If the property exists, `defineProperty` updates its flags. Otherwise, it creates the property with the given value and flags; in that case, if a flag is not supplied, it is assumed `false`.
7272

2-ui/1-document/07-modifying-document/12-sort-table/solution.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ The solution is short, yet may look a bit tricky, so here I provide it with exte
22

33

44
```js
5-
let sortedRows = Array.from(table.rows)
6-
.slice(1)
7-
.sort((rowA, rowB) => rowA.cells[0].innerHTML > rowB.cells[0].innerHTML ? 1 : -1);
5+
let sortedRows = Array.from(table.tBodies[0].rows) // (1)
6+
.sort((rowA, rowB) => rowA.cells[0].innerHTML > rowB.cells[0].innerHTML ? 1 : -1); // (2)
87

9-
table.tBodies[0].append(...sortedRows);
8+
table.tBodies[0].append(...sortedRows); // (3)
109
```
1110

12-
1. Get all `<tr>`, like `table.querySelectorAll('tr')`, then make an array from them, cause we need array methods.
13-
2. The first TR (`table.rows[0]`) is actually a table header, so we take the rest by `.slice(1)`.
14-
3. Then sort them comparing by the content of the first `<td>` (the name field).
15-
4. Now insert nodes in the right order by `.append(...sortedRows)`.
11+
The step-by-step algorthm:
1612

17-
Tables always have an implicit `<tbody>` element, so we need to take it and insert into it: a simple `table.append(...)` would fail.
13+
1. Get all `<tr>`, from `<tbody>`.
14+
2. Then sort them comparing by the content of the first `<td>` (the name field).
15+
3. Now insert nodes in the right order by `.append(...sortedRows)`.
1816

19-
Please note: we don't have to remove them, just "re-insert", they leave the old place automatically.
17+
Please note: we don't have to remove row elements, just "re-insert", they leave the old place automatically.
18+
19+
Also note: even if the table HTML doesn't have `<tbody>`, the DOM structure always has it. So we must insert elements as `table.tBodes[0].append(...)`: a simple `table.append(...)` would fail.

2-ui/1-document/11-coordinates/3-position-at-absolute/solution.view/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
let box = elem.getBoundingClientRect();
2929

3030
return {
31-
top: box.top + pageYOffset,
32-
left: box.left + pageXOffset
31+
top: box.top + window.pageYOffset,
32+
left: box.left + window.pageXOffset
3333
};
3434
}
3535

2-ui/1-document/11-coordinates/4-position-inside-absolute/solution.view/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
let box = elem.getBoundingClientRect();
2727

2828
return {
29-
top: box.top + pageYOffset,
30-
left: box.left + pageXOffset
29+
top: box.top + window.pageYOffset,
30+
left: box.left + window.pageXOffset
3131
};
3232
}
3333

2-ui/1-document/11-coordinates/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ function getCoords(elem) {
215215
let box = elem.getBoundingClientRect();
216216
217217
return {
218-
top: box.top + pageYOffset,
219-
left: box.left + pageXOffset
218+
top: box.top + window.pageYOffset,
219+
left: box.left + window.pageXOffset
220220
};
221221
}
222222
```

2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.view/index.html

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@
2020
<div id="tooltip" hidden>Tooltip</div>
2121

2222
<script>
23-
// for the demo
24-
setTimeout(function() {
25-
new HoverIntent({
26-
elem,
27-
over() {
28-
tooltip.style.left = elem.getBoundingClientRect().left + 5 + 'px';
29-
tooltip.style.top = elem.getBoundingClientRect().bottom + 5 + 'px';
30-
tooltip.hidden = false;
31-
},
32-
out() {
33-
tooltip.hidden = true;
34-
}
35-
});
36-
}, 2000);
23+
new HoverIntent({
24+
elem,
25+
over() {
26+
tooltip.style.left = elem.getBoundingClientRect().left + 5 + 'px';
27+
tooltip.style.top = elem.getBoundingClientRect().bottom + 5 + 'px';
28+
tooltip.hidden = false;
29+
},
30+
out() {
31+
tooltip.hidden = true;
32+
}
33+
});
3734
</script>
3835

3936
</body>

0 commit comments

Comments
 (0)