Oct
23
2009
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” }; })();

An article by admin




