Skip to content

Commit 29c4fc6

Browse files
committed
closes #1589
1 parent 2063dbd commit 29c4fc6

File tree

1 file changed

+6
-3
lines changed
  • 1-js/09-classes/03-static-properties-methods

1 file changed

+6
-3
lines changed

1-js/09-classes/03-static-properties-methods/article.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ That is the same as a direct assignment to `Article`:
123123
Article.publisher = "Ilya Kantor";
124124
```
125125

126-
## Inheritance of static methods
126+
## Inheritance of static properties and methods
127127

128-
Static methods are inherited.
128+
Static properties and methods are inherited.
129129

130-
For instance, `Animal.compare` in the code below is inherited and accessible as `Rabbit.compare`:
130+
For instance, `Animal.compare` and `Animal.planet` in the code below are inherited and accessible as `Rabbit.compare` and `Rabbit.planet`:
131131

132132
```js run
133133
class Animal {
134+
static planet = "Earth";
134135

135136
constructor(name, speed) {
136137
this.speed = speed;
@@ -167,6 +168,8 @@ rabbits.sort(Rabbit.compare);
167168
*/!*
168169

169170
rabbits[0].run(); // Black Rabbit runs with speed 5.
171+
172+
alert(Rabbit.planet); // Earth
170173
```
171174

172175
Now when we call `Rabbit.compare`, the inherited `Animal.compare` will be called.

0 commit comments

Comments
 (0)