JSFiddle - React, Tailwind, and code Playground
JavaScript
var Car = new Class({
initialize: function (make) {
this.make = make;
this.currentSpeed = 25;
},
printCurrentSpeed: function () {
console.log(this.make + ' is going ' + this.currentSpeed + ' mph.');
}
})
var RaceCar = new Class({ //inheritance
Extends: Car,
initialize: function (make, topSpeed) {
this.parent(topSpeed)
this.topSpeed = topSpeed;
},
goFast: function () {
this.currentSpeed = this.topSpeed;
}
})
var stang = new RaceCar('Mustang', 150);
stang.printCurrentSpeed();
stang.goFast();
stang.printCurrentSpeed();