Ad
  • Custom User Avatar

    I guess all of the instances should point to the same location in memory, so probably this solution would make more sense.
    This the Singleton pattern is from "JavaScript Patterns" by Stoyan Stefanov.

    var Singleton = function() {
        var instance;
        Singleton = function() {
            return instance;
        };
        Singleton.prototype = this;
        instance = new Singleton();
        instance.constructor = Singleton;
        instance.test = 1;
        return Singleton;
    };