Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding standards for JavaScript

Status
Not open for further replies.

toyt78

Technical User
Joined
Apr 5, 2005
Messages
125
Location
US
Any place that has JavaScript coding standards?
 
Pick a style and stick with it -- that's the rule I use anyway.

- Since JS is case sensitive, I use camel-case for meaningful variable names (ie: thisIsUsingCamelCase)
- I append an underscore to variables if they have local scope to a function (ie: _thisIsMyLocalVariable)
- I put semi-colons at the end of each line (where appropriate).
- I'll use TABs (instead of spaces) for indentation
- I'll try and use long-hand code that is understandable for the next person doing maintenance (rather than condensed/obvuscated code that is less obvious for a non-experienced developer to manage)

These are my own preference... they developed as a result of my experiences within many different organisations... and I consistently use them for all my development. I consider the consistency important... you can adapt to different coding standards (based on your client demands) but you need to be able to adhere to the standard in a consistent manner -- and that, in itself, is a skill you should learn [smile]

Thanks for the opportunity to "wake my brain up" this morning!
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top