Javascript best practices

Talking about javascript best practices, it is always a good idea to always use var. By using this keyword, you can keep javascript variables straight.

Another important thing that you need to do is to be feature detect instead of browser detect. Code written for browser versions detection is not ideal.

Using square bracket notation is recommended if you are interested in implementing best practices of javascript.

Stay aaway from use of eval. It is a javascript function, commonly used at the time of running arbitrary code.

It is of utmost importance that you put special emphasis on the correction of reference forms. Keep in mind that all HTML forms need to possess a name attribute.

There is no need of name attribute when it comes to dealing with XHTML documents. Referencing forms with the help of index is not a best way in javascript.

Finally, make sure that you do not use statement ‘with’ in javascript.

Leave a Reply

 
Copyright © 2012 Buzzing Live · All rights reserved ·