File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
1-js/09-classes/03-static-properties-methods Expand file tree Collapse file tree 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`:
123123Article .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
133133class Animal {
134+ static planet = " Earth" ;
134135
135136 constructor (name , speed ) {
136137 this .speed = speed;
@@ -167,6 +168,8 @@ rabbits.sort(Rabbit.compare);
167168*/ ! *
168169
169170rabbits[0 ].run (); // Black Rabbit runs with speed 5.
171+
172+ alert (Rabbit .planet ); // Earth
170173```
171174
172175Now when we call ` Rabbit.compare ` , the inherited ` Animal.compare ` will be called.
You can’t perform that action at this time.
0 commit comments