I'm reading JavaScript Patterns (http://shop.oreilly.com/product/9780596806767.do) and I just read something that surprised me. Stoyan Stefanov (his G+ profile is giving me a 404??) states that the best practice is the Single var pattern.

I had always been under the impression that despite the benefits of fewer lines of code/characters the multi-var pattern is preferred because it prevents accidentally not declaring a variable (and putting it on the global namespace) by adding a semi-colon accidentally and/or refactoring mistakes.

I've done both and I prefer the multi-var pattern simply to prevent myself from making mistakes (isn't that the concept of +Douglas Crockford's "JavaScript: The Good Parts"?)

What are your thoughts? Which pattern do you use the most and do you think it's the best or do you use both and just not really think much of it? Let us know in the comments.

#Question   #blogpost   #JavaScript   #JS   #CodingPatterns   #Oreilly   #patterns  
Shared publiclyView activity