views:

119

answers:

4

Hello,

I have been using JavaScript and jQuery a lot lately and I think I can do just about anything I want with it by just Googling and reading tutorials... But often I notice that my coding style differs a lot from what's provided by other people, for example I only just recently found out about shorttags for if/else statements. Or I have never used try/catch. But still, my code works and I can do everything, but it's not very "professional" and often not so efficient.

All books about JS or jQ that I've read so far often cover the same topics or introduce methods of doing things. I don't want that, but I want to improve my coding style. Are there any good books or websites out there that I should read?

A: 

Over here are a few javascript coding styles to keep in mind, all performance-centered.

For jQuery-specific stuff, I frequently find myself browsing through the documentation, where you can pick up a lot of new way of doing things. You won't pick up all of it in one go, so browse for something new, play with it for a while, and when you feel you've incorporated it in how you write your everyday code, come back to the docs for more.

David Hedlund
+1  A: 

You could also read some of John Resig's books..

Marko
A: 

The main thing to consider when dealing with JS is that it's based on prototyping and has closures. Don't try to make it look and work like - "traditional" OOP - Ruby/Python/Java/etc. Everything else regarding "coding style" is subjective, just write in uniform style.

fuwaneko
A: 

I think that Doug Crockford has many wise things to say about JavaScript. His book, JavaScript: The Good Parts is worth reading. Here's a link to a video that you can watch on that subject: http://www.youtube.com/watch?v=hQVTIJBZook Go to [his website][2] and click the links for Code Conventions for the JavaScript Programming Language www.crockford.com/javascript/ and check out Code Conventions for the JavaScript Programming Language and The Elements of JavaScript Style Parts One and Two.

Gail Steiger