Last active
December 22, 2016 17:49
-
-
Save aramkoukia/3a600a4d90312927420d2b78b4f4764c to your computer and use it in GitHub Desktop.
Inheritance in JavaScript ES6
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 characters
class Car { | |
constructor() { | |
this.logger = console.log; | |
} | |
log() { | |
this.logger(`Hello ${this.name}`); | |
} | |
} | |
class SuvCar extends Car { | |
constructor() { | |
super(); | |
this.name = 'SUV Car Name'; | |
} | |
} | |
// Usage sample | |
const suvCar = new SuvCar(); | |
suvCar.log(); // logs: "Hello SUV Car Name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment