The method of the JS string is reviewed:
1.charCodeAt () returns an integer that represents the Unicode encoding of the specified position string.
Strobj.charcodeat (Index)
Index is the zero-based number that handles the character count. Valid for numbers from 0 to 1.
If there is no string at the specified position, Nan is returned.
The 2.fromCharCode () method returns a string from some Unicode string.
String.fromCharCode ([Code1[,code2 ...]);
Description
Code1,code2 ... is a sequence of Unicode strings to convert to a string. If there are no arguments, the result is an empty string.
For example:
String.fromCharCode (65,66,112);
Result: ABp
3. CharAt () returns the string at the specified index position. Returns an empty string if it is exceeded.
Strobj.charat (Index)
Description
The zero-based index of the character that the index wants. A valid value is a value between 0 and the length of the string minus one.
For example:
var str = "ABC";
Str.charat (1);
Results: B
4.slice () returns a string fragment.
Strobj.slice (Start[,end])
Description
The start subscript strobj The specified portion of the index starting from 0. If start is negative, it is treated as length+start, where length is the string.
End strobj Specifies a partial end index starting from 0. If end is negative, it is treated as length+end, where length is the string.
For example:
012345
var str = "ABCDEF";
Str.slice (2,4);
Result: CD
5. The substring method returns a substring that is located at the specified position in a string object.
Strobj.substring (Start,end)
Description
Start indicates the starting position of the substring starting at 0.
End indicates the ending position of the substring, starting at 0.
The substring method uses the smaller values from start and end as the starting point for the substring. If start or end is Nan or negative, replace it with 0.
For example:
012345
var str = "ABCDEF";
Str.substring (2,4); or str.substring (4,2);
Result: CD
6. The Substr method returns a substring of the specified length starting at the specified position.
Strobj.substr (Start[,length])
Description
Start position of the substring that is required for start. The index of the first character in the string is 0.
Length The number of characters that should be included in the returned substring.
For example:
012345
var str = "ABCDEF";
STR.SUBSTR (2,4);
Results: Cdef
7. The IndexOf method puts the substring position within the string object for the first time. If no substring is found, 1 is returned.
Strobj.indexof (Substr[,startindex])
Description
SUBSTR the substring to find in the string object.
startindex The integer value indicates the index at which to start the lookup within a string object. If omitted, it is searched from the beginning of the string.
For example:
01234567
var str = "ABCDECDF";
Str.indexof ("CD", 1); 1-bit left-to-right lookup 123 ...
Results: 2
8. The LastIndexOf method returns the position of the last occurrence of a string in a string object. If no substring is matched, 1 is returned.
Strobj.lastindexof (Substr[,startindex])
Description
SUBSTR the substring to find within the string object.
startindex The integer value that indicates the start index position within the string object to find. If omitted, the lookup starts at the end of the string.
For example:
01234567
var str = "ABCDECDF";
Str.lastindexof ("CD", 6); Search from right to left by 6 position ... 55W
Results: 5
9. The search method returns the position of the first string that matches the regular expression find content.
Strobj.search (REEXP)
Description
Reexp a regular Expression object that contains the regular expression pattern and the flags that are available.
For example:
var str = "ABCDECDF";
Str.search ("CD"); or Str.search (/cd/i);
Results: 2
10. The Concat method returns a string value that contains the connection of two or more supplied strings.
Str.concat ([string1[,string2 ...])
Description
String1,string2 a String object or literal to concatenate with all other specified strings.
For example:
var str = "ABCDEF";
Str.concat ("ABCDEF", "ABC");
Results: ABCDEFABCDEFABC
11. Splits a string into substrings and returns the result as an array of strings.
Strobj.split ([Separator[,limit]])
Description
Separator a string or regular expression object that identifies whether one or more characters are used when separating a string. If this option is omitted, a single element array containing the entire string is returned.
Limit this value is used to restrict the number of elements in the returned array.
For example:
var str = "AA BB CC DD EE FF";
Alert (Str.split ("", 3));
Results:
Aa,bb,cc
12. The toLowerCase method returns a string in which the letters are converted to lowercase.
For example:
var str = "ABCABC";
Str.tolowercase ();
Results: ABCABC
13. The toUpperCase method returns a string that all letters in the string are converted to uppercase.
For example:
var str = "ABCABC";
Str.touppercase ();
Results: ABCABC;
JS Review---String