1

私はES6についてもっと学びたいと思っており、チュートリアルでこのクラスを見ました。の前にキーワードがgoFast()なくても機能するのはなぜですか? functionこれはクラス内の関数の新しい短縮形ですか、それとも…?

class RaceCar extends Car { //inheritance
  constructor(make, topSpeed) {
    super(make); //call the parent constructor with super
    this.topSpeed = topSpeed;
  }

  goFast() {
    this.currentSpeed = this.topSpeed;
  }
}

let stang = new RaceCar('Mustang', 150);
stang.printCurrentSpeed();
stang.goFast();
stang.printCurrentSpeed();
4

1 に答える 1