JSFiddle - React, Tailwind, and code Playground
JavaScript
function Car() {}
Car.prototype.beep = function() {
console.error(this.constructor.name, ' -> You have to implement it to use')
}
// bus
function Bus() {}
Bus.prototype = Object.create(Car.prototype)
var bus = new Bus()
bus.beep()
// Waggon
function Waggon() {}
Waggon.prototype = Object.create(Car.prototype)
Waggon.prototype.beep = function() {
alert('beep')
}
var waggon = new Waggon()
waggon.beep()