Live data from Hacker News

Javascript the right way

jstherightway.com

41–43 of 43 posts

Re: Javascript the right way

#41
post #16
post #12

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…

Can you give an example of a JavaScript library that is a singleton?

Re: Javascript the right way

#42
post #21

Earlier 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.

Really? I'd see him as quite important to modern JS. Heck, he discovered JSON, that's certainly important, and he helps shape the ECMAScript standards. To ignore him would be foolish.

Re: Javascript the right way

#43

Earlier 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.

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.

Post reply on HN