es6 class
by bhupendra negi
JavaScript
"use strict";
class Vehicles {
constructor(brand, engine) {
this.brand = brand;
this.engine = engine;
}
drive() {
console.log("This is branded car " + this.brand);
}
}
class hatchback extends Vehicles {
constructor(name, brand, engine) {
super(brand,engine);
this.name = name;
}
service() {
console.log("this car " + this.name + "of brand " + this.brand + "works awsome")
}
}
var i10 = new hatchback("i10", "Hyundai", "petrol");
i10.service();
i10.drive();