Javascript Best Practices

A brief summary of Javascript best practices for naming variables, commenting along with few tips to help organize the code that is more important than ever in software development.

The best practices are choosing easy to understand and short names for variables and functions. Minimizing the use of global variables; this includes all data types, objects, and functions because local variables are variables that are accessible to one method/function whereas global variables are accessible everywhere in the program and can be overwritten by other scripts.

Sticking to a strict coding style. Commenting the code as best as possible. Avoid mixing of other technologies. Using shortcut notations to keep the code easier to read. Keeping the code modularized and specialized. Enhancing progressively and avoid creating a lot of JavaScript dependent code. Allowing for configuration and translation and everything that is likely to change in the code should not be scattered throughout the code. Avoid heavy nesting like nesting loops inside loops, instead optimizing loops as they can get terribly slow in JavaScript.