JSFiddle - React, Tailwind, and code Playground

by bhupendra negi

JavaScript

// test for proto

function Car(name)
{
    this.brand = name;
    this.service = function() { alert("Serivce err !");}
}

// adding function to proto so that fn does not get repeated in each instance of objects

Car.prototype.drive = function() { alert("zoo zoooo !!"); }

var carA = new Car("Maruti");
var carB = new Car("Tata");

carB.drive();
console.log(carA);