Skip to content

Commit 072fa7d

Browse files
committed
minor
1 parent 7df2a19 commit 072fa7d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,14 @@ The short answer is: constructors in inheriting classes must call `super(...)`,
236236

237237
Of course, there's an explanation. Let's get into details, so you'll really understand what's going on.
238238

239-
In JavaScript, there's a distinction between a "constructor function of an inheriting class" and all others. In an inheriting class, the corresponding constructor function is labeled with a special internal property `[[ConstructorKind]]:"derived"`.
239+
In JavaScript, there's a distinction between a "derived constructor" (constructor function of an inheriting class) and other functions. A derived constructor has a special internal property `[[ConstructorKind]]:"derived"`. In other words, the constructor function of a class that "extends" something bears a "special label".
240240

241-
The difference is:
241+
That label affects its behavior with `new`.
242242

243-
- When a normal constructor runs, it creates an empty object and assigns it to `this`.
243+
- When a regular function `F` is executed as `new F`, it creates an empty object and assigns it to `this`.
244244
- But when a derived constructor runs, it doesn't do this. It expects the parent constructor to do this job.
245245

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.
246+
So a derived constructor must call `super` in order to execute its parent (non-derived) constructor, otherwise the object for `this` won't be created. And we'll get an error.
247247

248248
For the `Rabbit` constructor to work, it needs to call `super()` before using `this`, like here:
249249

0 commit comments

Comments
 (0)