1. Variable naming (1) Variable names should not be proud of a short coincidence
The variable name on the left is not very clear, the code extensibility is not good, once the code needs to add functionality, it is easy to appear obj1, Obj2, obj3 this very abstract naming method. So start by making the name of the variable really meaningful, and don't make a very short, generic name.
(2) BOOL variable
It is not advisable to start with a Boolean variable like is/do
var true , true , false;
Can be changed into:
var true , true , false;
There are other commonly used names such as Done/found/successs/ok/available/complete and so on, combined with specific contexts
var true , false , true;
2. Assigning a value when declaring a variable
Declaration of three variables as follows
var Registerform, question, calculateresult;
The above is definitely the legal JS syntax, but the use of these three variables will make people more confused, especially in the middle of the second question, the question is what. But when you assign an initial value to the above variable:
var NULL , = "", = 0;
Let the person be enlightened, originally question is a string of questions, and result is a number, and form is an object. This also facilitates the JS interpreter to do some optimization in advance, do not wait until the use of the time to know what these variables are type
Front End (HTML/CSS/JS)-javascript Coding specification