Skip to content

Commit 03cbee3

Browse files
committed
work
1 parent d4c714c commit 03cbee3

File tree

89 files changed

+1579
-1826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1579
-1826
lines changed

1-js/5-data-types/02-string/article.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,11 @@ If you want to learn more about normalization rules and variants -- they are des
667667
- To look for a substring: use `indexOf`, or `includes/startsWith/endsWith` for simple checks.
668668
- To compare strings according to the language, use `localeCompare`, otherwise they are compared by character codes.
669669

670-
There are several other helpful methods in strings, like `str.trim()` that removes ("trims") spaces from the beginning and end of the string, see the [manual](mdn:js/String) for them.
670+
There are several other helpful methods in strings:
671+
672+
- [str.trim()]` -- removes ("trims") spaces from the beginning and end of the string.
673+
- [str.repeat(n)]` -- repeats the string `n` times.
674+
- ...and others, see the [manual](mdn:js/String) for details.
671675

672676
Also strings have methods for doing search/replace with regular expressions. But that topic deserves a separate chapter, so we'll return to that later.
673677

1-js/8-more-functions/6-call-apply-decorators/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ There are two changes:
362362
- Then `(**)` uses `func.apply` to pass both the context and all arguments the wrapper got (no matter how many) to the original function.
363363

364364

365-
## Borrowing a method
365+
## Borrowing a method [#method-borrowing]
366366

367367
Now let's make one more minor improvement in the hashing function:
368368

1-js/9-object-inheritance/01-prototype/article.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,22 @@ Here we can say that "`animal` is the prototype of `rabbit`" or "`rabbit` protot
4545

4646
So if `animal` has a lot of useful properties and methods, then they become automatically available in `rabbit`. Such properties are called "inherited".
4747

48-
Here's an example with an inherited method:
48+
Loops `for..in` also include inherited properties:
49+
50+
```js run
51+
let animal = {
52+
eats: true
53+
};
54+
55+
let rabbit = {
56+
jumps: true,
57+
__proto__: animal
58+
};
59+
60+
for(let prop in rabbit) alert(prop); // jumps, eats
61+
```
62+
63+
If we have a method in `animal`, it can be called on `rabbit`:
4964

5065
```js run
5166
let animal = {
@@ -138,7 +153,6 @@ Since now, `rabbit.walk()` call finds the method immediately in the object, it d
138153

139154
![](proto-animal-rabbit-walk-2.png)
140155

141-
142156
The only exception from that rule are property setters. If there's a setter in the prototype, it is called instead of blind writing a value into the object.
143157

144158
For instance, here `admin.fullName` is an accessor property, with the setter in the prototype:

1-js/9-object-inheritance/02-function-prototype/1-prototype-after-new/solution.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

1-js/9-object-inheritance/02-function-prototype/1-prototype-after-new/task.md

Lines changed: 0 additions & 91 deletions
This file was deleted.

1-js/9-object-inheritance/02-function-prototype/2-default-arguments/solution.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

1-js/9-object-inheritance/02-function-prototype/2-default-arguments/task.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

1-js/9-object-inheritance/02-function-prototype/3-compare-calls/solution.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

1-js/9-object-inheritance/02-function-prototype/3-compare-calls/task.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

1-js/9-object-inheritance/02-function-prototype/4-new-object-same-constructor/solution.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)