SO - 29383632

by Arun P Johny

JavaScript

var scareMe = (function () {
    var instance;
    return function () {
        if (instance) {
            return instance;
        }
        instance = this;

    }
})();

scareMe.prototype.nothing = true;
var un1 = new scareMe();
console.log('nothing', un1.nothing); //true
scareMe.prototype.everything = true;
var un2 = new scareMe();
console.log(un1 === un2); //true
console.log('everything', un1.everything); //true