Here are some points which are consider as best practices.
Always use easy to understand and readable names for variable and function names.
x1, xyz, fe2
Below are also bad variable names as they are too long.
Above variables names are too long and should be avoided. Same rules apply for function names. Too long or Too short function names should be avoided.
Avoid use of global variables as much as possible.
Variables used within functions must be declared as local variables.
Local variables must be declared using var keyword otherwise it will be treated as global variables.
It is advisable to use strict mode, it is not allowed to use undeclared variables.
It is a good practice to declare variables before each script or functions definitions.
It is a good practice to initialize variables during declaration.
It will provide cleaner code, single place for initialization and avoid undefined values for variables which can cause unexpected results.
Initializing variables gives more idea about use of variables and its data type.
Use numbers, strings and Boolean values as primitive type values, and not as objects. Objects will slow down execution speed and sometimes provide unexpected results.
var fname=""; var firstName = new String("Kevin"); fname === firstName // returns false as data type of both variable is different.
Also it is not possible to compare two objects.
var firstName = new String("Kevin"); var myName = new String("Kevin"); firstName == myName // returns false as objects cannot be compared.
Numbers can be automatically converted to Strings or NaN.
var address = '1/4, New Building'; // address is string address = 50; // address is now number