JSFiddle - React, Tailwind, and code Playground

JavaScript

var ClassName;
    
    (function() {
        var instance;
        ClassName = function ClassName() {
            //If private instance variable already initialized return reference
            if(instance) {
                return instance;   
            }
            //If instance does not created save pointer of original reference
            //to private instance variable. 
            instance = this;

            //All constructor initialization will be here
            // i.e.: 
            this.someProperty = 0;
            this.someMethod = function(){
                //Some action here
            };
        };
    }());



    //Extending defined class like Singltone object using new prototype property
    ClassName.prototype.nothing = true;
    var obj_1 = new ClassName();
    //Extending defined class like Singltone object using new prototype property
    ClassName.prototype.everything = true; 
    var obj_2 = new ClassName();

    //Testing does this two object pointing to same instance
    console.log(obj_1 === obj_2); //Result is true, it points to same instance object

    //All prototype properites work
    //no matter when they were defined
    console.log(obj_1.nothing && obj_1.everything 
                && obj_2.nothing && obj_2.everything); //Result true


    //Values of properties which is defined inside of constructor
    console.log(obj_1.someProperty);// output 0
    console.log(obj_2.someProperty);// output 0 
    //Changing property value 
    obj_1.someProperty = 1;

    console.log(obj_1.someProperty);// output 1
    console.log(obj_2.someProperty);// output 1

    console.log(obj_1.constructor === ClassName); //Output true