JSFiddle - React, Tailwind, and code Playground

by secretgspot

HTML

<h1>Constructor pattern</h1>

JavaScript

// basic constructor
function Helicopter(model, type, tail) {
    this.model = model;
    this.type = type;
    this.tail = tail;
}

// basic constructor extended with prototype property
Helicopter.prototype.toString = function(){
        return this.model + " type: " + this.type + " tail: " + this.tail; 
    };

// make new objects
var tibaz = new Helicopter("Robinson", "R22", "TI-BAZ");
var tiazz = new Helicopter("Robinson", "R22", "TI-AZZ");

console.log(tiazz.toString());