Created
October 25, 2019 02:57
-
-
Save clementohNZ/f4c05e74759ea92af9ca102e12b85a7f to your computer and use it in GitHub Desktop.
Revisions
-
clementohNZ created this gist
Oct 25, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ class Car { constructor() { this.distance = 0; } move() { this.distance += 1; console.log(`current distance is: ${this.distance}`); } } class Toyota extends Car { constructor() { super(); } move() { super.move(); } } class Ferrari extends Car { constructor() { super(); } moveVeryQuickly() { this.distance += 5; console.log(`current distance is: ${this.distance}`); } } const cars = [ new Car(), new Toyota(), new Ferrari(), ] cars.forEach(car => { car.move(); }); // current distance is: 1 // current distance is: 1 // current distance is: 1