JSFiddle - React, Tailwind, and code Playground

by vaheed akhtar

JavaScript

function person(first,last){
  this.firstname = first;
  this.lastname = last;
}



var p1 = new person('vaheed', 'akhtar');
person.prototype.getDetails=function(){
  return this.firstname+', '+ this.lastname;
}
console.log(p1.getDetails())
console.log('---------using classes-------');

class Car{
   constructor(name, price){
    this.name=name;
    this.price=price;
   }
   details(){
   return this.name + ': '+this.price
   }
}
var c = new Car('Audi', 20000000)
console.log(c.details())