design patterns · JavaScript · Programming

Design Patterns in JavaScript

Singleton Pattern //This is a simple singleton with all public members var simpleSingleton = { “func1” : function() {alert(‘func1’);}, “msg” : “hello” }; //This is complex singleton with private and public members var complexSingleton = (function() { var privateVar = ‘private var’; function privateMethod1(){alert(‘privateMethod1’);} return { publicMethod1 : function(){ //from here all public and private… Continue reading Design Patterns in JavaScript