JSFiddle - React, Tailwind, and code Playground

JavaScript

var Model = function() {
  this.name = Math.random();
}

Model.getInstance = function() {
   if (!this.instance) {
     this.instance = new this();
   }
   return this.instance;
}

var model = Model.getInstance();
var model2 = Model.getInstance();
var model3 = Model.getInstance();

alert(model.name);
alert(model2.name);
alert(model3.name);