Skip to content

Commit 2901e0c

Browse files
authored
Merge pull request #2992 from Rnbsov/patch-41
remove extra break lines and add missed
2 parents 79b9b84 + b70d332 commit 2901e0c

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

1-js/09-classes/02-class-inheritance/article.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ Now `Rabbit` has the `stop` method that calls the parent `super.stop()` in the p
160160
As was mentioned in the chapter <info:arrow-functions>, arrow functions do not have `super`.
161161
162162
If accessed, it's taken from the outer function. For instance:
163+
163164
```js
164165
class Rabbit extends Animal {
165166
stop() {
@@ -176,7 +177,6 @@ setTimeout(function() { super.stop() }, 1000);
176177
```
177178
````
178179

179-
180180
## Overriding constructor
181181

182182
With constructors it gets a little bit tricky.
@@ -280,8 +280,6 @@ alert(rabbit.earLength); // 10
280280
*/!*
281281
```
282282

283-
284-
285283
### Overriding class fields: a tricky note
286284

287285
```warn header="Advanced note"
@@ -370,13 +368,12 @@ In our case, `Rabbit` is the derived class. There's no `constructor()` in it. As
370368

371369
So, `new Rabbit()` calls `super()`, thus executing the parent constructor, and (per the rule for derived classes) only after that its class fields are initialized. At the time of the parent constructor execution, there are no `Rabbit` class fields yet, that's why `Animal` fields are used.
372370

373-
This subtle difference between fields and methods is specific to JavaScript
371+
This subtle difference between fields and methods is specific to JavaScript.
374372

375373
Luckily, this behavior only reveals itself if an overridden field is used in the parent constructor. Then it may be difficult to understand what's going on, so we're explaining it here.
376374

377375
If it becomes a problem, one can fix it by using methods or getters/setters instead of fields.
378376

379-
380377
## Super: internals, [[HomeObject]]
381378

382379
```warn header="Advanced information"

0 commit comments

Comments
 (0)