File tree 1 file changed +6
-3
lines changed
1-js/09-classes/03-static-properties-methods
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -123,14 +123,15 @@ That is the same as a direct assignment to `Article`:
123
123
Article .publisher = " Ilya Kantor" ;
124
124
```
125
125
126
- ## Inheritance of static methods
126
+ ## Inheritance of static properties and methods
127
127
128
- Static methods are inherited.
128
+ Static properties and methods are inherited.
129
129
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 ` :
131
131
132
132
``` js run
133
133
class Animal {
134
+ static planet = " Earth" ;
134
135
135
136
constructor (name , speed ) {
136
137
this .speed = speed;
@@ -167,6 +168,8 @@ rabbits.sort(Rabbit.compare);
167
168
*/ ! *
168
169
169
170
rabbits[0 ].run (); // Black Rabbit runs with speed 5.
171
+
172
+ alert (Rabbit .planet ); // Earth
170
173
```
171
174
172
175
Now when we call ` Rabbit.compare ` , the inherited ` Animal.compare ` will be called.
You can’t perform that action at this time.
0 commit comments