[JavaScript] Klassenbasierte Vererbung

// https://javascript.info/class-inheritance
// https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Klassen

// ab ES6
class Car {
  constructor(name) {
    this.name = name;
  }

  drive() {
    console.log("Driving: " + this.name);
  }
}

class Audi extends Car {
  quadro() {
    console.log("Quadro: " + this.name);
  }
}

let a = new Audi("A4");
a.drive();
a.quadro();

Kommentare sind geschlossen.