viernes, 6 de abril de 2012

Javascript patterns 2 (Singleton)

We continue with the design pattern more commonly used in Javascript.

Singleton design pattern is used to ensure that only one instance of the object is created.

Singleton Pattern


var SingletonObject = {
    Model : "Ferrari",
    Color: "Red",

    ToString: function() {
        return "Model: " + this.Model + ", Color: " + this.Color;
    }
}

No hay comentarios:

Publicar un comentario