ES6 prototype example

by Anchit Gupta

JavaScript

class Vehicle{
	constructor(vehicleType){
  	this.vehicleType = vehicleType;
  }
  
  blowhorn(){
  	console.log("blow horn!!");
  }
}

class Bus extends Vehicle{
	constructor(make){
  	super("Bus");
  	this.make = make;
  }
  
  accelerator() {    
    console.log('Accelerating Car');
  }
	brake() {    
    console.log('Braking Car');
  }
}

Bus.prototype.noOfWheels = 4;

var myBus = new Bus("Mercedes");