Coding conventions are style guidelines for programming. They typically cover: Naming and declaration rules for variables and functions. Rules for the use of white space, indentation, and comments.
JavaScript is a lightweight interpreted programming language. The web browser receives the JavaScript code in its original text form and runs the script from that.
You can use the JavaScript Console from Google Chrome . Go on Chrome and Press the key sequence: CTRL+SHIFT+j for Windows or CMD+OPT+j for Mac. You can write JavaScript on any editor just like Ruby and then paste it to the JS Console.
Not exactly what you're looking for, but (like Doug Crockford's vids) I think everybody who writes/edits/reviews JS should look at Chris Heilmann's slides and videos on maintainable javascript.
In the slides, slide 127, he says don't worry so much about style guides/code standards, reformat all code checked in to VCS.
Also these:
Mozilla JavaScript Tips
JavaScript Style Guide
Another reason why Crockford's JavaScript coding guidelines are a good idea to follow:
This code (below) actually returns undefined because of JavaScript's semicolon injection - which is a damn good reason to get the whole team of developers singing from the same song sheet:
return // injected semicolon, therefore returns 'undefined'
{
javascript : "fantastic"
}; // object constructs anonymously but nothing happens with it.
Bit more about that at Beware of JavaScript semicolon insertion
I never saw a widely acknowledged JavaScript coding standard out there. We did write our own some time ago and I published it on my blog in accordance with my employer.
Keep in mind that some of the guidelines might be a bit outdated.
Google has posted a Javascript guide
You can find some simple but essential coding conventions at the Google Code Wiki.
For very detailed style guides read the Dojo Style Guide. It is going over naming conventions, file conventions, variable usage, code layout, whitespace, and comments.
A bit puzzled that I cannot find on the replies Idiomatic.js and jQuery Core Style Guide. Addy Osmani puts those two on the very top of full list of coding styles for JavaScript in his "JavaScript Style Guides And Beautifiers" article.
I personally prefer jQuery standard, though it doesn't much differ from Idiomatic.js. But whatever standard you choose you will need a validator to check how successful you are following it. I couldn't find any for jQuery or at least Idiomatic, but eventually came up with JS_CodeSniffer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With