« links for 2006-12-04 | Main | Authoring accessible Web content »

How to code anything in JavaScript

This began as a post for the JAG internal wiki. But I wound up looking up a lot of good links, so I thought I'd mirror the post here in order to keep those links handy.

When I want to implement a requirement, such as a business rule or DHTML behavior in JavaScript, sometimes I find that I don't know how to implement that behavior. Sometimes this might be because the requirement is complex, as in the case of DHTML animation. Or the algorithm I am searching for may just be obscure, such as a unique ID generator that uses a closure instead of a global counter.

When I do not immediately know how to implement a requirement, I usually need that information in a hurry. I do not have time to make extensive flow charts, or to research the deep features of JavaScript. What I want is to find someone else who has already implemented something ''similar'' to the requirement. And I want to see their source code.

The fastest way to make this happen is to search the comp.lang.javascript newsgroup. This venerable institution has existed since 1999. Among the group's active members are experts in the field; for example, Douglas Crockford, Peter Paul Koch and Matt Kruse. Its archives and FAQ contain a wealth of information. Here are a few examples:

If the answer I am looking for is not to be found in the archives, then I post that question to the newsgroup. If a question is not easily found in the archives, and if it is not in the FAQ, then it is often a new(ish) problem, and people will be excited and helpful when answering.

Once a question has been answered, that may be the beginning of a dialog with the person who gave the answer. If a question is of particular interest to the community, then it may even result in a longer discussion between several different people. All of this provides excellent opportunities for asking more questions, in a fairly friendly and responsive environment.