I use the following Singleton pattern in JavaScript:
var exampleClass =(function(){
//private
var a ="test";
function PrivateMethod()
{
return a;
}
//public
return{
Test: function() {
alert(PrivateMethod());
}
}
})();
As I read through StackOverflow I see a lot of other implementations of Singleton and I start to doubt if I couldn't make mine better. I hope someone can tell me what's right or wrong about doing it this way.