Seconding Javascript: The Good Parts and Resig’s book Secrets of the Javascript Ninja.
Here are some tips for Javascript:
- Don’t pollute the global namespace (put all functions into objects/closures)
- Take a look at YUI, it’s a huge codebase with only 2 global objects: YAHOO and YAHOO_config
- Use the Module pattern for singletons (http://yuiblog.com/blog/2007/06/12/module-pattern/)
- Make your JS as reusable as possible (jQuery plugins, YUI modules, basic JS objects.) Don’t write tons of global functions.
- Don’t forget to var your variables
- Use JSlint : http://www.jslint.com/
- If you need to save state, it’s probably best to use objects instead of the DOM.