Looks more like JS the java way. Singletons make no sense in a language that has global variables and never lets you stop an object from being duplicated. The command pattern makes no sense in a language with first-class functions. I'd steer clear of this resource if you want to write javascript the right way.
Almost every javascript library you use is a singleton, so your second sentence makes no sense. Check the example, it is just the module pattern. If a programmer wants to deviate away from a pattern, the language lock-in won't stop them. Also, the command pattern is a great tool for handling undo/redo on a UI. I think you are being way to dismissive of some good advice. Just because someone is trying to share a bette…
Javascript the right way
41–43 of 43 posts
Re: Javascript the right way
#42Earlier quoted context omitted.
In what sense?
Crockford is as important to modern JS as Lerdorf is to modern PHP. He has a very minimal role in the community, and most of that involves resting on his laurels and being divisive.
Re: Javascript the right way
#43Earlier quoted context omitted.
Module pattern. It is easily one of Javascripts greatest strengths.
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.
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.