JSFiddle - React, Tailwind, and code Playground
by rodneyrehm
JavaScript
(function(){
var instance;
var counter = 0;
var Something = function() {
// doesn't matter if called w/o new keyword
if (instance) {
return instance;
}
this.counter = counter++;
return instance = this;
};
var a = new Something();
var b = new Something();
var c = new Something();
console.log(a.counter, b.counter, c.counter);
console.log(a === b, a === c);
})()