class Vehicle {
#engine = 'V6';
static count = 0;
constructor(type) {
this.type = type;
Vehicle.count++;
}
static getCount() {
return this.count;
}
get info() {
return `${this.type} with ${this.#engine}`;
}
}
class Car extends Vehicle {
static count = 0;
constructor(brand) {
super('car');
this.brand = brand;
Car.count++;
}
}
const tesla = new Car('Tesla');
const ford = new Car('Ford');
console.log(Vehicle.getCount());
console.log(Car.getCount());
console.log(tesla.info); Post #2888
3.94K
CHALLENGE
- ❤ 3
- 👍 2
- 🔥 1