What is the simplest/cleanest way to implement singleton pattern in JavaScript?
Isn't this a singleton too?
function Singleton() { var i = 0; var self = this; this.doStuff = function () { i = i + 1; console.log( 'do stuff',i ); }; Singleton = function () { return self }; return this; } s = Singleton(); s.doStuff();