About handling strings and arrays

  In my opinion, most of the front-end processing of data is the processing of strings and arrays, as well as objects. Because I can't remember these methods, I always confuse them, so I summarize them and write them down for easy reference and review.

  First, the processing of strings,

        1. contact --- Concatenate two or more strings together and return a string

      string1.contact(string2)

    2. indexOf --- returns the index (the index of one occurrence of a substring, starting from zero, or -1 if there is no match)

      long string.indexOf(string)

    3. charAt --- Returns the string at the specified position

      long string.charAt(position)

    4. lastIndexOf --- Returns the position of the last occurrence of the substring in the long string, if not, returns -1

      long string.lastIndexOf(string)

    5. match --- Query whether a string matches a regular expression, if not, return null

      string.match(regular expression)

    6. substring --- returns a string of long strings, passing in the start and end positions

      substring (start bit, end bit)

    7. substr --- returns a string, passing in the start bit and length

      substr(start bit, length)

   

 

      

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325024654&siteId=291194637