Here are some of the more commonly used methods of using strings, strings are arrays of characters, and in JavaScript, strings are immutable: You can access text anywhere in a string, but JavaScript does not provide a way to modify the contents of a known string.
Common features:
1 obj.length Length2 3 Obj.trim () remove whitespace4 Obj.trimleft ()5 obj.trimright)6 Obj.charat (n) returns the nth character in a string7 obj.concat (value, ...) Stitching8 Obj.indexof (Substring,start) sub-sequence position9 Obj.lastindexof (Substring,start) sub-sequence positionTen obj.substring (from, to) gets a subsequence from an index One Obj.slice (start, end) Slice A obj.tolowercase () uppercase - obj.touppercase () lowercase - obj.split (delimiter, limit) split the Obj.search (regexp) matches from the beginning, returning the first position where the match was successful (g invalid) - Obj.match (regexp) Global Search, if there is a G in the regular means find all, otherwise only find the first one. - Obj.replace (regexp, replacement) is replaced, and g in the regular replaces all, otherwise only the first match is replaced . - $ number: matches the nth group content; +$&: the current matching content; - $ ': text located to the left of the matched substring; +$: Text on the right side of the matching substring A$$: Direct Volume $ symbol
How to use JavaScript strings