I am trying to make a Singleton class constructor in Javascript.
But I am getting an error. 
Taking Java analogy, what I did was :
var ob1 = (function getSingleton() {
    var privateData;
    if(this.privateData !== null) {
        this.privateData = new getSingleton();
        return this.privateData;
    }
})();
But I am getting the following:
Uncaught RangeError: Maximum call stack size exceeded.
What am I conceptually doing wrong? Or, how can it be made perfect?
