Warm so know the new, can for the teacher. The string object looks at the following method.
1:string.charat (Index) method: Returns the character of the string index.
1 ' Hello '. CharAt (1); 2 "E"
2:string.charcodeat (Index) method: Returns the ASCII code for the character of the string index.
1 ' a '. charCodeAt (0); 2 97
The 3:string.indexof method determines the position of a string in another string (numeric type), and if 1 is returned, it indicates a mismatch, and IndexOf begins to match from the string header
1 ' Hello '. indexOf (' e '); 2 1
The 4:string.lastindexof method determines the position of a string in another string (numeric), and if 1 is returned, it does not match, and IndexOf starts at the end of the string.
1 ' Hello '. lastIndexOf (' e '); 2 1 //Because the position returned is actually from the beginning of the number, the individual to raise the two functions are not different
5:string.concat (string,...); String concatenated, the return value is a new string, but the original string does not change
1 var s= ' abc '; 3 s.concat (' eee '); 4 "Abceee" 5 s 6 "ABC"
6:string.replace (' Sub-string 1 ', ' substring 2 '); String substitution, the string 2 is substituted into a substring 1
7:string.tolowercase () Convert the string to lowercase string.touppercase () converts the string to uppercase
' Aaaeee '. toLocaleLowerCase ();//lowercase "aaaeee" ' aaaaa '. toLocaleUpperCase (); Uppercase "AAAAA"
8:string.formcharcode (numeric); This is a static method of the string object, passing in an ASCII code that returns the character corresponding to the code.
1 String.fromCharCode (); 2 "a"
9: String interception method: Subtring () | substr () | Slice ()
SUBSTRING (): Pass in two parameters, the first parameter is the starting position, the last parameter is the end position, and the truncated substring is returned. [does not include the end position of the character]
1 ' Hello World ' substring (2,7); 2 "Llo W"
Substr () Method: Pass in two parameters, the first parameter is the starting position, the last parameter is the number of characters to intercept, return the truncated substring
1 ' Hello World ' substr (2,9); 2 "Llo World"
Slice () method: Pass in two parameters, the first argument is the starting position, the last parameter is the end position, and the truncated substring is returned. [Character not including end position] If the 2nd argument is greater than the first parameter, both the return value is empty.
var C = ' The Three Musketeers '; C.slice (4, 9)//' Three ' C.slice (9, 4)//'
10:string.split (delimiter): Splits the string, the return value is an array;
1 ' A|b|c '. Split (' | ') 2 ["A", "B", "C"]
The above is an introduction to some of the built-in methods of the string built-in object mind map.
A summary of the methods of string-string objects in javascript: