JSFiddle - React, Tailwind, and code Playground

by deepak sisodiya

HTML

Functionally there is no difference between http://jsfiddle.net/deepaksisodiya/FL79H/3/ and this one. but this one helps methods to group together

JavaScript

// The Constructor Pattern in javascript

var alert  = function (str) {
   var st = document.createTextNode(str);
   var p = document.createElement('p');
   p.appendChild(st);
   document.querySelector('body').appendChild(p);
}

function Car( model, year, miles ) {
  this.model = model;
  this.year = year;
  this.miles = miles;
}

Car.prototype = {
    toString: function () {
       return this.model + " has done " + this.miles + " miles";
    }
};

var civic = new Car( "Honda Civic", 2009, 20000 );
var mondeo = new Car( "Ford Mondeo", 2010, 5000 );
 
alert(civic.toString());
alert(mondeo.toString());