Javascript
I. Features
1. Case-sensitive
2. Weakly typed variable, only with the keyword "var"
3. Note/*....*/
Two. Variables
1. The variable is declared by the keyword var.
2.var can declare multiple variables at the same time. -------var girl= "jsaacom", Age=19,male=false;
3. Variables are not necessarily initialized. ---------var people;
Three. Variable name rules
1. The initial letter must be (letter, underscore, or dollar symbol)
2. The remaining letters can be underscores, dollar characters, any letters or numbers
3. Variable name does not contain keywords
4. Naming habits
Type |
Prefix |
Example |
Array |
A |
Aarray |
Boolean |
B |
Bmale |
Floating point |
F |
FTax |
Function |
Fn |
Fnswap |
Integral type |
I |
Iage |
Object |
O |
Ocar |
Regular |
Re |
Repattern |
String |
S |
Suniversity |
Four. Data type
1.length----Get string length
2.charAt----Gets the character at the specified position
3.substring----intercepts the character, which does not include the character that terminates the position, and the second parameter defaults from the start position to the end of the string.
4.SUBSTR----intercept n lengths from the starting position
5.indexOf----Gets the position of the first occurrence of a character, if there is a second argument s, indicating the first occurrence of this character from S
6.lastindexof-----Ibid, the difference lies in looking forward from behind.
7.PARSEINT----string Conversion integer (parsefloat decimal type)
8.Number-----String Conversion Array (numeric type string into numeric value)
if (IsNaN (nnum)) {alert ("not a numeric type string");} Else {alert ("is a numeric type string");}
Note: Isnan=is not number
Five. Arrays
1. Writing style (3)
var ateam=new Array (12)----
var acolor=new Array (); ----Indeterminate array length
var ateam=[10,20,30];---length is 3
2.toString----converted to a string, separated by "," by default
Alert (Ateam.join ("-"). ToString ());
Note: Separate by other means (underline)
3. String variable group--->split (requires the same connector) such as: Var sstring= "AAA_BBB_CCC"
4. Reverse order---->reverse
5. Sort---->sort (English only)
2015-09-28 Meet JS1