var f = function(arg) { if (arg != null) { document.write(arg); document.write("<br/>"); } else if (arg == undefined) { document.write("undefined<br/>"); } else { document.write("<br/>"); } }; //inheritance //base class function Vehicle(vType){ this.vType = vType; Vehicle.prototype.displayType = function(){f(this.vType);}; }; //instance class function Car(color,brand){ this.color = color; this.brand = brand; }; //setting baseclass to protoype property Car.prototype = new Vehicle("Four wheeler"); var v = new Vehicle("None"); v.displayType(); var c = new Car("black","lotus"); c.displayType();f(c instanceof Vehicle);f(c instanceof Car); //abstract class //its kinda abstract because we cant instantiate it via new VehicleAbs() var VehicleAbs = { vType: "None", displayType: function(){f(this.vType);} }; //instance class function Bike(color, brand){ this.color = color; this.brand = brand; this.vType = "Two Wheeler"; }; //setting baseclass to prototype property Bike.prototype = VehicleAbs; var b = new Bike("black", "Ducati"); b.displayType(); //f(b instanceof VehicleAbs); this will throw error f(b instanceof Bike);