Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 373 Bytes

override-keyword.md

File metadata and controls

18 lines (15 loc) · 373 Bytes

The Override keyword is used by a method in a subclass to override a method in a superclass.

class Vehicle {
    startEngine() {
        console.log("Engine started");
    }
}

class Car extends Vehicle {
    override startEngine() {
        console.log("Car engine started with a roar!");
    }
}

const myCar = new Car();
myCar.startEngine();