1 Character method
CharAt (): receives a parameter that returns the character at the given position
charCodeAt (): receives a parameter that returns the character encoding of the specified position character
var str = "Hello World"; alert (Str.charat (1)); Ealert (Str.chatcodeat (1)) //101
2 String manipulation methods
concat (): stitching one or more strings together. String.Concat (str)
Slice (start,[stop]): receives one or two parameters, starting position and end position, returning a substring of the manipulated string
substr (start,n): receives two parameters, starting position and number of return characters , returns a substring of the manipulated string
substring (start,[stop]): receives one or two parameters, starting position and end position, returning a substring of the manipulated string
The next three methods behave differently when passed in a negative value, slice () adds the passed negative value to the string length, substr () adds the first negative argument to the string bed, and the second negative argument to 0,substring () converts the negative argument to 0.
var str = "Hello World" alert (Str.slice ( -3)),//rldalert (str.substring ( -3)),//hello Worldalert (Str.substr (-3));// Rldalert (Str.slice (3,-4));//lowalert (Str.substring (3,-4));//helalert (Str.substr (3,-4));/"" (Empty string)
3 String Position method
IndexOf () lastIndexOf () accepts two parameters, the character to search for and the starting position
String.IndexOf (' a ')//a indicates the character to be searched
4 Trim () method
The method creates a copy of the string, removes all whitespace from the predecessor and suffix, and returns the result
5 String Case Conversion method
toLowerCase ()
toLocaleLowerCase ()
toUpperCase ()
toLocaleUpperCase ()
6 Matching methods for strings
Match (): finds a match for one or more regular expressions, returns an array of String.match (regular expressions)
Search (): Replaces a substring that matches a regular expression, returns the first matching index value in a string, if no 1 string.search (regular expression) is returned
Replace (): ' Retrieves a value that matches a regular expression, string.replace (regular expression, replaced character)
JavaScript string interception method