Friday, March 16, 2012

Javascript Singleton Pattern

This is just a working example of the idea discussed here. I thought it would help to see the working behavior.
var QuickDialog = function(){
    var privateInit = function(){console.log("init")};
    return{
        init: privateInit
    };
}();

QuickDialog.init();
QuickDialog.privateInit();
This is the firebug output for the above code.

No comments: