24 bonnes pratiques Javascript pour débutant
22 juin 2009 Laisser un commentaire Tweet
Voici un article intéressant et avec des exemples sur les bonnes pratiques en Javascript :
http://net.tutsplus.com/tutorials/javascript-ajax/24-javascript-best-practices-for-beginners/
Le résumé :
- Use === Instead of ==
- Eval = Bad
- Don’t Use Short-Hand
- Utilize JS Lint
- Place Scripts at the Bottom of Your Page
- Declare Variables Outside of the For Statement
- The Fastest Way to Build a String
- Reduce Globals
- Comment Your Code
- Embrace Progressive Enhancement
- Don’t Pass a String to “SetInterval” or “SetTimeOut”
- Don’t Use the “With” Statement
- Use {} Instead of New Object()
- Use [] Instead of New Array()
- Long List of Variables? Omit the “Var” Keyword and Use Commas Instead
- Always, Always Use Semicolons
- “For in” Statements
- Use Firebug’s “Timer” Feature to Optimize Your Code
- Read, Read, Read…
- Self-Executing Functions
- Raw JavaScript Can Always Be Quicker Than Using a Library
- Crockford’s JSON.Parse
- Remove “Language”
Bonne lecture !