Sébastien Hiticas

24 bonnes pratiques Javascript pour débutant

22 juin 2009 Laisser un commentaire

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é :

  1. Use === Instead of ==
  2. Eval = Bad
  3. Don’t Use Short-Hand
  4. Utilize JS Lint
  5. Place Scripts at the Bottom of Your Page
  6. Declare Variables Outside of the For Statement
  7. The Fastest Way to Build a String
  8. Reduce Globals
  9. Comment Your Code
  10. Embrace Progressive Enhancement
  11. Don’t Pass a String to “SetInterval” or “SetTimeOut”
  12. Don’t Use the “With” Statement
  13. Use {} Instead of New Object()
  14. Use [] Instead of New Array()
  15. Long List of Variables? Omit the “Var” Keyword and Use Commas Instead
  16. Always, Always Use Semicolons
  17. “For in” Statements
  18. Use Firebug’s “Timer” Feature to Optimize Your Code
  19. Read, Read, Read…
  20. Self-Executing Functions
  21. Raw JavaScript Can Always Be Quicker Than Using a Library
  22. Crockford’s JSON.Parse
  23. Remove “Language”

Bonne lecture !

Laisser un commentaire