Indentation should be four spaces. Don't use tabs.
Avoid lines over 80 characters.
End all statements with a semicolon.
minimum. Typically the page could start initialization code:
Add useful comments to bits of code that might require explanation.
Don't use comments where you should use proper naming.
Don't use comments where you should use functions.
Variable name should use uppercase, lowercase and numbers. Avoid using special characters.
Variable names should start with a lowercase letter and use camelCase. Don't use underscores.
Use meaningful names that indicate the function of a variable. Naming things is one of the hardest
things in programming.
Take time to figure out the proper names that represent what you're trying to achieve.
Encapsulate your variables, functions and objects in a custom namespace.
Be careful with declaring variables. Forgetting the var keyword creates an implicit global variable.
JSLint complains if you're initializing variables without the var keyword.
Don't use function literals. They clutter up the global namespace. Use the var keyword
to define functions.
When returning from a function, start the returned object on the same line. Otherwise,
prototype-based inheritance. This makes the object model more flexible, but also requires a bit more
An object can be created using the "new" keyword.
When creating an object, always use the "new" keyword.
This has an effect on the meaning of the "this" variable. If you forget the "new" keyword, "this" will be
set to the window, which means everything will end up in the global namespace.
Furthermore, since you don't return anything from the function, the result will be undefined.
To indicate that this is an object that should be instantiated with the "new" keyword, always start the name with an uppercase.
To create methods on the object, add them to the function prototype.
Inner functions don't have access to the object using this. Instead, their "this" points to the window global. To avoid conflicts, use "that".
To avoid confusion, declare all variables before you use them, at the top of the function.
JSLint will check for this.
Avoid using ++ and -- since they can create tricky code that is prone to errors.