News for hackers. Stuff that matters.
Re:Javascript the right way by Androsynth on Tuesday September 11, 2012 @02:32PM (#4507005)
In JS, a singleton is a reference to a module. It is used to ensure you invoke the module only once.

Global variables are irrelevant since your global namespace most likely resembles a tree structure.

edit: you may be right about the command pattern, I've never used something like that. It may just be the example is half-assed though.

Re:Javascript the right way by jarek-foksa on Tuesday September 11, 2012 @02:38PM (#4507036)
There are no modules in JavaScript as well. At least not in ES5.
Re:Javascript the right way by Androsynth on Tuesday September 11, 2012 @02:41PM (#4507056)
Module pattern. It is easily one of Javascripts greatest strengths.
Re:Javascript the right way by spacemanaki on Wednesday September 12, 2012 @11:33AM (#4511113)
It's a very useful hack but I would hardly call it a great strength. As a module system it completely sucks.

It does leverage one of the language's great strengths, lexically-scoped first-class functions, but that doesn't make it a strength on its own.

Re:Javascript the right way by Androsynth on Wednesday September 12, 2012 @03:25PM (#4512585)
Not sure if anyone will ever see this...

It is not a traditional module I will agree. However I see it as a hybrid class/interface/module and in this role, it works very well and allows you a tremendous amount of flexibility due to the dynamicness of js.