string

At the bottom, strings are stored as character arrays

length()

Can be used to get the length of a string

charAt()

Can return a character at a specified position in a string

Gets the specified character based on the index

The output is the same in both ways

charCodeAt()

Gets the Unicode encoding for the character at the specified position

formCharCode()

Retrieves characters based on character encoding

Using String. FormCharCode ()

concat()

You can concatenate two or more strings

indexOf()

This method retrieves whether a string contains a specified content

If the content is contained in the string, the index of its first occurrence is returned

Returns -1 if the specified content is not found

You can specify a second argument that specifies where to start the search

lastIndexOf()

This method is used the same as indexOf()

The difference is that indexOf() is found from front to back

LastIndexOf () finds from back to front

slice()

You can intercept a specified position from a string

Does not affect the original string, instead intercepts the content and returns it

  • The output is the original string

  • The return value should be set

The first parameter is the start unknown index (including the start position)

The second argument is the index of the end position (excluding the end position)

If the second parameter is omitted, all the following parameters are intercepted

You can pass a negative number as an argument, which means reciprocal

substring()

You can also intercept a string similar to slice()

Similarities:

  • The first parameter is the start unknown index (including the start position)
  • The second argument is the index of the end position (excluding the end position)

Difference:

  • This method cannot accept negative values as arguments
  • If a negative value is passed, 0 is used by default
  • The order of arguments is automatically adjusted, and if the second argument is less than the first, positions are automatically switched

substr()

Used to intercept strings

The first parameter is the index of the starting position

The second parameter is the length of the intercept

This parameter can now be used but is deprecated

split

You can split a string into an array

Takes a string as an argument to split the array

Check to see if the type is array

If you pass an empty string as an argument, each character is split into an element in the array

toUpperCase()

Converts a string to uppercase and returns

toLowerCase()

Converts a string to lowercase and returns