You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/09-classes/02-class-inheritance/article.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ For instance, to find `rabbit.run` method, the engine checks (bottom-up on the p
66
66
2. Its prototype, that is `Rabbit.prototype` (has `hide`, but not `run`).
67
67
3. Its prototype, that is (due to `extends`) `Animal.prototype`, that finally has the `run` method.
68
68
69
-
As we can recall from the chapter <info:native-prototypes>, JavaScript itself uses prototypal inheritance for build-in objects. E.g. `Date.prototype.[[Prototype]]` is `Object.prototype`. That's why dates have access to generic object methods.
69
+
As we can recall from the chapter <info:native-prototypes>, JavaScript itself uses prototypal inheritance for built-in objects. E.g. `Date.prototype.[[Prototype]]` is `Object.prototype`. That's why dates have access to generic object methods.
70
70
71
71
````smart header="Any expression is allowed after `extends`"
72
72
Class syntax allows to specify not just a class, but any expression after `extends`.
Till now, `Rabbit` did not have its own `constructor`.
184
+
Until now, `Rabbit` did not have its own `constructor`.
185
185
186
186
According to the [specification](https://tc39.github.io/ecma262/#sec-runtime-semantics-classdefinitionevaluation), if a class extends another class and has no `constructor`, then the following "empty" `constructor` is generated:
187
187
@@ -245,7 +245,7 @@ The difference is:
245
245
246
246
So if we're making a constructor of our own, then we must call `super`, because otherwise the object for `this` won't be created. And we'll get an error.
247
247
248
-
For `Rabbit` constructor to work, it needs to call `super()` before using `this`, like here:
248
+
For the `Rabbit` constructor to work, it needs to call `super()` before using `this`, like here:
249
249
250
250
```js run
251
251
classAnimal {
@@ -529,4 +529,4 @@ rabbit.eat(); // Error calling super (because there's no [[HomeObject]])
529
529
- So it's not safe to copy a method with `super` from one object to another.
530
530
531
531
Also:
532
-
- Arrow functions don't have own `this` or `super`, so they transparently fit into the surrounding context.
532
+
- Arrow functions don't have their own `this` or `super`, so they transparently fit into the surrounding context.
0 commit comments