I have been in the process of learning Javascript to complement ASP.NET. I have a strong background in general programming, and have always been an advocate of disciplined practices and good hygiene to reduce the error count in code.
However, the language that Javascript is seems to make this very difficult. Its dynamic and interpreted nature seem to push error detection to the last point possible in the cycle. For example, syntax errors can get caught as late as the point when the code is actually executed, rather than before it is run as would be the case in a more static language. Similarly the soft type system is a minefield of potential hidden errors. Although you can represent object oriented design patterns in the language, it almost seems like they have made it as hard as possible to do so with little in the way of syntactic support.
This is compounded by the fact that Javascript seems to attract a sloppy mindset, and a lot of newbie programmers who confuse conscision and cleverness with quality (and I am not referring to minimized code, but examples of putatively good programming.) I Feel like I am reading entries in the obfuscated C contest sometimes.
Of course I also recognize that there are a lot of assets to Javascript that makes it powerful and extensible. Some of the fluid functional like techniques in, for example, jquery are very attractive.
I guess my question then is this: how do you write quality javascript? What tools, practices, idioms, debugging and logging libraries and so forth do you incorporate to reduce the bug count in your javascript applications? Are there web sites or discussion groups that focus on bug free javascript rather than cute programming hacks?