Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Last active December 22, 2016 17:49
Show Gist options
  • Save aramkoukia/3a600a4d90312927420d2b78b4f4764c to your computer and use it in GitHub Desktop.
Save aramkoukia/3a600a4d90312927420d2b78b4f4764c to your computer and use it in GitHub Desktop.
Inheritance in JavaScript ES6
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