Oct
23
2009

Best Practices – Javascript

  • 1.use === instead of ==
  • 2. Avoid to use short-hand if(condition) variable = true Consider this : if(condition) { variable = true; }
  • 3. Place scripts at the bottom of your page
  • 4. Declare variables outside of the for statement
  • 5. reduce globals
  • 6. Comment your code.
  • 7. Dont pass a String  to “Setinterval” or “SetTimeOut”
  • 8.Dont use the “with” statement
  • 9.use {} instead of new object()
  • 10. use [] instead of new Array() var a = new Array(); a[0] = “prabu”; a[1  ="Siva"; instead of that , var a= ["prabu","siva"];
  • 11. Always use semi colons
  • 12. Self-executing Functions. ( function do() { return { name : “prabu”, lastname : “kalaiselvam” }; })();

About the Author:

Leave a comment

 

October 2009
M T W T F S S
    Jul »
 1234
567891011
12131415161718
19202122232425
262728293031  
  Domain Name + 1GB Linux India Web Hosting in Rs.349