class

class Car {
  constructor(owner) {
    this.owner = owner;
  }
  soldTo(newOwner) {
    this.owner = newOwner;
  }
}

class ElectricCar extends Car {
    constructor() {
    // Car.call(this. owner);
    super(owner);
    this.power = 0;
  }

  recharge(time) {
    var that = this;

    setTimeout(function () {
      that.power = Math.min((time / 100), 100);
    }, time)
  }
}

var car = new Car('ken nim');
var ec = new ElectricCar('ken nim');

Last updated

Was this helpful?