One, character method
charAt: Returns the character at the specified position.
var str= "ABCDEFG";//undefinedstr[0]//"a" because IE67 does not support this notation Str.charat (0)//"a"
charCodeAt: Returns the Unicode encoding of the character at the specified position.
Second, the string operation method, does not affect the original string, returns the new string
concat: string concatenation--Returns a new string without affecting the original string. More time with "+"
Slice: Extracts a fragment of a string that returns the extracted part. When the argument is negative, the passed negative value is added to the length of the string
substring: Extracts the characters between two specified index numbers in a string. All negative arguments are converted to 0
substr: Extracts the specified number of characters from the starting index number in the string. The negative first argument is prefixed with the length of the string, and the second argument of the negative is converted to 0
var str= "ABCDEFG"//undefinedstr.slice (0,1)//"A" str.substr (0,1)//"A" str//"ABCDEFG" Str.slice ( -3)//"EFG" Str.substring ( -3)//"ABCDEFG" Str.substr ( -3)//"EFG" Str.slice (3,-4)//"Str.slice (0,-4)//" ABC "str.substring (3,-4)/ /"ABC" STR.SUBSTR (3,-4)//""
Trim: Returns a new string after a trailing space has been deleted
trimleft: Remove opening spaces
trimright: Remove trailing spaces
var str= "abc" //undefinedstr//"abc" Str.trim ()//"abc" str//" ABC " Str.trimleft ()//"ABC "
Case conversion:
toLowerCase
Tolocallowercase
toUpperCase
tolocaluppercase: A region-specific approach
Three, the string position method
indexOf: Returns the position of the first occurrence of a specified string value in a string.
lastIndexOf: Returns the position in a string at the specified position from the back to the forward search.
Str.indexof (' B ')//1str.lastindexof (' B ')//1
String Method Summary