One or three common well-known naming conventions:
1, Camel (camel name): The first letter is lowercase , the next word will start with a capital letter. For example: Var mytestvalue=0;
2. Pascal (Pascal's name): The first letter is capitalized , and the next word starts with a capital letter. For example: Var mytestvalue=0;
3, Hungarian Name: attribute + Type + Object description of the order of combination, so that programmers make variables when the type of variables and other properties have a visual understanding. For example:
G_ Global Variables
C_ Constants
S_ Static variables
javascript variable naming type |
variable naming prefixes |
Array arrays |
A |
Boolean Boolean |
B |
Float floating point |
L |
function functions |
F |
Integer (int) integer type |
N |
Object objects |
O |
Regular expression Regular |
R |
String strings |
S |
var g_nmytestvalue=0; Defining Global integer variables
var s_bmytestvalue=0; Defining Static Boolean variables
Second, JS in the call variable conversion
1, turn into a string.
var lnumber=10.89;
var nnumber=10;
Alert (lnumber.tostring ());//Return is 10
Alert (nnumber.tostring ());//return is also 10
When you use ToString () to convert data to a string, the default is decimal, or you can use ToString (2) to convert the number to binary, 88, 166, and binary.
2. The string is converted into a number.
parseint (), parsefloat () are valid only for strings, and Nan is returned for other types.
parseint () Before judging whether a string is a number, it looks at the character at position 0, determines whether it is a valid number, or returns Nan if it is not. no longer carry on. If it is a valid number, look for characters outside of 1 and perform the same test.
For example: "3145acds" uses the parseint () method to return 3145 because the detection stops when a is detected, and "567.98" returns 567 with the parseint () method because the decimal point is not valid for this method.
parseint ("10", 2);//convert two to decimal integer, and of course 86 or 16 parseint ("AF", 16).
If the decimal includes a leading 0, then it is best to use base dozens of, so that you do not get an unexpected octal value.
parseint ("010", 8);
Parsefloat () usage is similar to parseint (), but the first decimal point in this method is valid and the subsequent decimal point is not valid. This means that the number of 78.89.6 obtained by this method is 78.89. And you must use the decimal parameter.
3. Forced conversion
Boolean (value)--Converts to Boolean
Number (value)--converted to number type
String (value)--converted to String type
JavaScript Advanced Programming (i)