1. Character method
// the character ' Zhangamie ' of the output index value . charAt (2) // "a"//"a"// output code A's Ascill code is the"Zhangamie". charCodeAt (2) ///string.fromcharcode ($) // ' a '
2. String methods
Concat, slice, substr, substring do not affect the original string
// connect var name = ' Zhang ' ; var newName = Name.concat (' amie ' // zhang console.log (newName ) // zhang amie // intercept string // slice, substr, substring the first parameter is the index of the start position // slice and substr can accept negative numbers (automatically converted to length-/negative numbers/) // slice, substring the second parameter is the end index, not the match to the end // substr The second parameter is the number of captures, not the match to the end
3. String Position method
IndexOf and LastIndexOf, the first argument to match the string, the second parameter is the location to start looking for
// 5
4.trim clear space before and after
' z hangamie '. Trim () //"z hangamie"
5. Match
var name = ' Cat,bat,sat,fat 'name.match (/.at/g) //["Cat", "bat", "sat", "fat "]//8 indexof is not accepted regexp//" ABC,ABC,ABC,ABC "does not affect the meta-string
The string operator of JS