Can anyone point me in the direction of some really well written javascript examples. I have been trying to improve my javascript after reading a lot from douglas crockford book etc but i wondered where i could find some live examples of code that is written well?
You could simply analyze the source of jquery. Although quite advanced, it's truly a bastion of quality, well documented code.
EDIT for future readers: as you can see from the comment feedback, the jquery source is not advisable for a beginner to analyze as it has some dirty hacks and is too hard to get in places. Avoid it and use some of the other suggestions instead.
some javascript framework like jQuery are well written and documented. Make sure you're downloading the development package (uncompressed one)
I don't think there is 1 'standard' example, in the end everybody has their own style and approaches. Working in projects it's important to create/use good code guidelines/conventions.
An example article I found describing someones coding conventions based on the Yahoo! User Interface Library might explain what I'm talking about more.
As for right and wrong, there are a lot of ways to do things right. The importance is knowing what is wrong. And use coding conventions to make sure your code is consistent.
Douglas Crockford is your man when it comes to some lean, mean, spanking javascript
His site has quite a few samples
Have a look here: http://javascript.crockford.com/code.html
and here: http://javascript.crockford.com/
You should check out JSLint the JavaScript Quality tool. This is also a Douglas Crockford project.
You can paste in your code and get your verdict (scary), but you can also download the tool. I've integrated it into my test and builds so that all JavaScript is validated against JSLint before building and running unit tests (using Rhino for both). JSLint can be a bit tough on your code(ing style) - you can disable some of the check. I for instance I allow my code to use i++
Crockford does not.
I suggest that you read the other links provided by our fellow stackers so that you understand the workings of JSLint.
This project by legalbox - a scalable js app framework - is written using Crockford's teachings (amongst others). More over it is a pretty interesting project. Check out the code.
Check out this project: Computer Science in JavaScript, by Nicholas C. Zakas